001/*
002 * (C) Copyright 2012 Nuxeo SA (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 *     Anahide Tchertchian
016 */
017
018package org.nuxeo.ecm.directory.ldap.registry;
019
020import org.apache.commons.logging.Log;
021import org.apache.commons.logging.LogFactory;
022import org.nuxeo.ecm.directory.ldap.LDAPServerDescriptor;
023import org.nuxeo.runtime.model.SimpleContributionRegistry;
024
025/**
026 * Registry for LDAP servers
027 *
028 * @since 5.6
029 */
030public class LDAPServerRegistry extends SimpleContributionRegistry<LDAPServerDescriptor> {
031
032    public static final Log log = LogFactory.getLog(LDAPServerRegistry.class);
033
034    @Override
035    public String getContributionId(LDAPServerDescriptor contrib) {
036        return contrib.getName();
037    }
038
039    @Override
040    public void contributionUpdated(String id, LDAPServerDescriptor contrib, LDAPServerDescriptor newOrigContrib) {
041        super.contributionUpdated(id, contrib, newOrigContrib);
042        log.info("server registered: " + contrib.getName());
043    }
044
045    @Override
046    public void contributionRemoved(String id, LDAPServerDescriptor origContrib) {
047        super.contributionRemoved(id, origContrib);
048        log.info("server unregistered: " + origContrib.getName());
049    }
050
051    // API
052
053    public LDAPServerDescriptor getServer(String name) {
054        return getCurrentContribution(name);
055    }
056
057}