001/* 002 * (C) Copyright 2015 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 */ 018 019package org.nuxeo.scim.server.mapper; 020 021import org.nuxeo.runtime.api.Framework; 022import org.nuxeo.usermapper.service.UserMapperService; 023 024/** 025 * factory to get the Mapper implementation 026 * 027 * @author tiry 028 * @since 7.4 029 */ 030public class UserMapperFactory { 031 032 protected static AbstractMapper mapper = null; 033 034 public static synchronized AbstractMapper getMapper(String baseUrl) { 035 036 if (mapper == null) { 037 UserMapperService ums = Framework.getService(UserMapperService.class); 038 if (ums != null && ums.getAvailableMappings().contains(ConfigurableUserMapper.MAPPING_NAME)) { 039 mapper = new ConfigurableUserMapper(baseUrl); 040 } else { 041 mapper = new StaticUserMapper(baseUrl); 042 } 043 } 044 return mapper; 045 } 046 047}