directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r279449 - in /directory/standalone/trunk/osgi/kerberos: ./ src/main/java/org/apache/kerberos/
Date Wed, 07 Sep 2005 22:43:18 GMT
Author: erodriguez
Date: Wed Sep  7 15:43:08 2005
New Revision: 279449

URL: http://svn.apache.org/viewcvs?rev=279449&view=rev
Log:
Rewrote the Kerberos OSGi wrapper to use the declarative Service Binder.

Added:
    directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/metadata.xml
  (with props)
Removed:
    directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosConfiguration.java
Modified:
    directory/standalone/trunk/osgi/kerberos/project.xml
    directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/Activator.java
    directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosConfig.java
    directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServer.java
    directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServerFactory.java

Modified: directory/standalone/trunk/osgi/kerberos/project.xml
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/kerberos/project.xml?rev=279449&r1=279448&r2=279449&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/kerberos/project.xml (original)
+++ directory/standalone/trunk/osgi/kerberos/project.xml Wed Sep  7 15:43:08 2005
@@ -6,7 +6,7 @@
   <currentVersion>0.1.1</currentVersion>
   <properties>
     <osgi.bundle.category>Network Service</osgi.bundle.category>
-    <osgi.import.package>org.apache.ldap.server.configuration,org.osgi.framework,org.apache.mina.registry,org.apache.mina.protocol,org.apache.mina.common,org.osgi.service.cm,org.osgi.util.tracker</osgi.import.package>
+    <osgi.import.package>org.ungoverned.gravity.servicebinder,org.apache.ldap.server.configuration,org.osgi.framework,org.apache.mina.registry,org.apache.mina.protocol,org.apache.mina.common,org.osgi.service.cm</osgi.import.package>
   </properties>
   <package>org.apache.kerberos</package>
   <shortDescription>Apache Kerberos Network Service</shortDescription>
@@ -43,12 +43,6 @@
       <properties>
         <osgi.jar.bundle>true</osgi.jar.bundle>
       </properties>
-    </dependency>
-    <dependency>
-      <!-- required to load Configuration base class -->
-      <groupId>directory</groupId>
-      <artifactId>apacheds-core</artifactId>
-      <version>0.9.2-SNAPSHOT</version>
     </dependency>
   </dependencies>
 </project>

Modified: directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/Activator.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/Activator.java?rev=279449&r1=279448&r2=279449&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/Activator.java
(original)
+++ directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/Activator.java
Wed Sep  7 15:43:08 2005
@@ -17,210 +17,8 @@
 
 package org.apache.kerberos;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Properties;
+import org.ungoverned.gravity.servicebinder.GenericActivator;
 
-import javax.naming.CompoundName;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.naming.ldap.LdapContext;
-import javax.naming.spi.InitialContextFactory;
-
-import org.apache.kerberos.store.JndiPrincipalStoreImpl;
-import org.apache.kerberos.store.PrincipalStore;
-import org.apache.mina.registry.ServiceRegistry;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class implements a simple bundle that starts and stops the Apache Kerberos service.
- */
-public class Activator implements BundleActivator
+public class Activator extends GenericActivator
 {
-    /** the log for this class */
-    private static final Logger log = LoggerFactory.getLogger( Activator.class );
-
-    public static final String FACTORY_PID = "org.apache.kerberos";
-
-    private ServiceRegistry registry;
-    private ServiceTracker tracker;
-
-    private KerberosServerFactory serverFactory = null;
-    private ServiceRegistration registration = null;
-
-    private PrincipalStore principalStore;
-
-    /**
-     * The key of the property specifying where Kerberos users are stored.  If this
-     * property is not set the store defaults to performing a subtree search
-     * from the DN in the {@link Context#PROVIDER_URL}. If it is present a more
-     * efficient search is conducted on the more specific DN.
-     */
-    public static final String KDC_ENTRY_BASEDN_KEY = "kdc.entry.basedn";
-
-    /**
-     * Implements BundleActivator.start().
-     * Logs that this service is starting and starts this service.
-     * @param context the framework context for the bundle.
-     */
-    public void start( BundleContext context ) throws BundleException
-    {
-        log.debug( "Starting Apache Kerberos." );
-
-        tracker = new ServiceTracker( context, ServiceRegistry.class.getName(), null );
-        tracker.open();
-
-        registry = (ServiceRegistry) tracker.getService();
-
-        ServiceReference storeReference = context.getServiceReference( InitialContextFactory.class.getName()
);
-
-        InitialContextFactory factory = (InitialContextFactory) context.getService( storeReference
);
-
-        Hashtable env = new Hashtable( new KerberosConfiguration().toJndiEnvironment() );
-        loadEnvironment( env );
-
-        LdapContext ctx = null;
-
-        try
-        {
-            ctx = (LdapContext) factory.getInitialContext( env );
-        }
-        catch ( NamingException ne )
-        {
-            ne.printStackTrace();
-            throw new BundleException( "Initial context load failed." );
-        }
-
-        Name searchBaseDn = null;
-
-        if ( env.containsKey( KDC_ENTRY_BASEDN_KEY ) )
-        {
-            String baseDn = (String) env.get( KDC_ENTRY_BASEDN_KEY );
-            searchBaseDn = getRelativeName( ctx, baseDn );
-        }
-
-        principalStore = new JndiPrincipalStoreImpl( ctx, searchBaseDn );
-
-        serverFactory = new KerberosServerFactory( registry, principalStore );
-
-        Dictionary parameters = new Hashtable();
-        parameters.put( ConfigurationAdmin.SERVICE_FACTORYPID, FACTORY_PID );
-        registration = context.registerService( ManagedServiceFactory.class.getName(), serverFactory,
parameters );
-
-        ServiceReference adminRef = null;
-        try
-        {
-            ConfigurationAdmin admin = null;
-            Configuration[] configs = null;
-            try
-            {
-                adminRef = context.getServiceReference( ConfigurationAdmin.class.getName()
);
-
-                // Potential start order problem!
-                if ( adminRef != null )
-                {
-                    admin = (ConfigurationAdmin) context.getService( adminRef );
-                    String filter = "(&(service.factoryPid=" + FACTORY_PID + ")" + "(|(service.bundleLocation="
-                            + context.getBundle().getLocation() + ")" + "(service.bundleLocation=NULL)"
-                            + "(!(service.bundleLocation=*))))";
-                    configs = admin.listConfigurations( filter );
-                }
-            }
-            catch ( Exception e )
-            {
-                e.printStackTrace();
-            }
-
-            if ( admin == null || configs == null || configs.length == 0 )
-            {
-                serverFactory.updated( KerberosServerFactory.DEFAULT_PID, KerberosConfig.getDefaultConfig()
);
-            }
-        }
-        catch ( ConfigurationException ce )
-        {
-            ce.printStackTrace();
-        }
-        finally
-        {
-            if ( adminRef != null )
-            {
-                context.ungetService( adminRef );
-            }
-        }
-    }
-
-    /**
-     * Implements BundleActivator.stop().
-     * Logs that this service has stopped.
-     * @param context the framework context for the bundle.
-     */
-    public void stop( BundleContext context )
-    {
-        log.debug( "Stopping Apache Kerberos." );
-
-        principalStore = null;
-
-        registration.unregister();
-        registration = null;
-
-        serverFactory.destroy();
-        serverFactory = null;
-
-        registry = null;
-    }
-
-    private Name getRelativeName( DirContext ctx, String baseDn ) throws BundleException
-    {
-        Properties props = new Properties();
-        props.setProperty( "jndi.syntax.direction", "right_to_left" );
-        props.setProperty( "jndi.syntax.separator", "," );
-
-        Name searchBaseDn = null;
-
-        try
-        {
-            Name ctxRoot = new CompoundName( ctx.getNameInNamespace(), props );
-            searchBaseDn = new CompoundName( baseDn, props );
-
-            if ( !searchBaseDn.startsWith( ctxRoot ) )
-            {
-                throw new BundleException( "Invalid search base for Apache profiles." );
-            }
-
-            for ( int ii = 0; ii < ctxRoot.size(); ii++ )
-            {
-                searchBaseDn.remove( 0 );
-            }
-        }
-        catch ( NamingException e )
-        {
-            throw new BundleException( "Failed to initialize search base for Apache profiles."
);
-        }
-
-        return searchBaseDn;
-    }
-
-    private void loadEnvironment( Hashtable env )
-    {
-        env.put( "java.naming.provider.url", "dc=example,dc=com" );
-        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
-        env.put( "java.naming.security.authentication", "simple" );
-        env.put( "java.naming.security.credentials", "secret" );
-        env.put( "java.naming.factory.initial", "org.apache.ldap.server.jndi.CoreContextFactory"
);
-
-        env.put( "kdc.entry.basedn", "ou=Users,dc=example,dc=com" );
-    }
 }

Modified: directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosConfig.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosConfig.java?rev=279449&r1=279448&r2=279449&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosConfig.java
(original)
+++ directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosConfig.java
Wed Sep  7 15:43:08 2005
@@ -20,27 +20,45 @@
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import org.apache.ldap.server.configuration.Configuration;
+import org.apache.ldap.server.jndi.ContextFactoryService;
+import org.osgi.service.cm.ConfigurationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class KerberosConfig
+public class KerberosConfig extends Configuration
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( KerberosConfig.class );
 
-    private static String SERVICE_PID = "service.pid";
-
-    static String PID = "org.apache.kerberos";
-    static String KERBEROS_PORT_KEY = "kerberos.port";
-    static int KERBEROS_PORT_DEFAULT = 88;
-    static String name = "Apache Kerberos Service";
+    private static final String SERVICE_PID = "service.pid";
+    private static final String PID = "org.apache.kerberos";
+    private static final String KERBEROS_PORT_KEY = "kerberos.port";
+    private static final int KERBEROS_DEFAULT_PORT = 88;
+    private static final String name = "Apache Kerberos Service";
 
     private int port;
 
-    public KerberosConfig( Dictionary configuration )
+    /**
+     * Creates a new instance with default settings.
+     */
+    public KerberosConfig() throws ConfigurationException
+    {
+        this( getDefaultConfig() );
+    }
+
+    /**
+     * Creates a new instance with default settings that operates on the
+     * {@link ContextFactoryService} with the specified ID.
+     */
+    public KerberosConfig( String instanceId ) throws ConfigurationException
     {
-        log.debug( "Got props " + configuration );
+        this( getDefaultConfig() );
+        setInstanceId( instanceId );
+    }
 
+    public KerberosConfig( Dictionary configuration ) throws ConfigurationException
+    {
         if ( configuration == null )
         {
             configuration = getDefaultConfig();
@@ -48,10 +66,13 @@
 
         port = ( (Integer) configuration.get( KERBEROS_PORT_KEY ) ).intValue();
 
-        log.debug( "Kerberos got port " + port );
+        if ( port < 1 || port > 0xFFFF )
+        {
+            throw new ConfigurationException( KERBEROS_PORT_KEY, "invalid value=" + port
);
+        }
     }
 
-    boolean isDifferent( Dictionary config )
+    public boolean isDifferent( Dictionary config )
     {
         if ( port == ( (Integer) config.get( KERBEROS_PORT_KEY ) ).intValue() )
         {
@@ -61,12 +82,12 @@
         return true;
     }
 
-    String getName()
+    public String getName()
     {
         return name;
     }
 
-    int getPort()
+    public int getPort()
     {
         log.debug( "Config returning " + port );
 
@@ -78,7 +99,7 @@
         Dictionary defaults = new Hashtable();
 
         defaults.put( SERVICE_PID, PID );
-        defaults.put( KERBEROS_PORT_KEY, Integer.getInteger( KERBEROS_PORT_KEY, new Integer(
KERBEROS_PORT_DEFAULT ) ) );
+        defaults.put( KERBEROS_PORT_KEY, Integer.getInteger( KERBEROS_PORT_KEY, new Integer(
KERBEROS_DEFAULT_PORT ) ) );
 
         return defaults;
     }

Modified: directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServer.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServer.java?rev=279449&r1=279448&r2=279449&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServer.java
(original)
+++ directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServer.java
Wed Sep  7 15:43:08 2005
@@ -52,11 +52,6 @@
         this.registry = registry;
         this.store = store;
 
-        init();
-    }
-
-    protected void init()
-    {
         port = config.getPort();
         name = config.getName();
 
@@ -64,7 +59,7 @@
         {
             log.debug( name + " starting on " + port );
 
-            provider = new KerberosProtocolProvider( new KdcConfiguration(), store );
+            provider = new KerberosProtocolProvider( new KdcConfiguration(), this.store );
 
             udpService = new Service( name, TransportType.DATAGRAM, port );
             tcpService = new Service( name, TransportType.SOCKET, port );
@@ -76,7 +71,7 @@
         }
         catch ( IOException ioe )
         {
-            ioe.printStackTrace();
+            log.error( ioe.getMessage(), ioe );
         }
     }
 
@@ -95,6 +90,6 @@
         udpService = null;
         tcpService = null;
 
-        log.debug( name + " has stopped listening on " + port );
+        log.debug( name + " has stopped listening on port " + port );
     }
 }

Modified: directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServerFactory.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServerFactory.java?rev=279449&r1=279448&r2=279449&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServerFactory.java
(original)
+++ directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServerFactory.java
Wed Sep  7 15:43:08 2005
@@ -19,47 +19,57 @@
 
 import java.util.Dictionary;
 import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Properties;
 
+import javax.naming.CompoundName;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+import javax.naming.spi.InitialContextFactory;
+
+import org.apache.kerberos.store.JndiPrincipalStoreImpl;
 import org.apache.kerberos.store.PrincipalStore;
 import org.apache.mina.registry.ServiceRegistry;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.ungoverned.gravity.servicebinder.Lifecycle;
 
-public class KerberosServerFactory implements ManagedServiceFactory
+public class KerberosServerFactory implements ManagedServiceFactory, Lifecycle
 {
-    final static String DEFAULT_PID = Activator.FACTORY_PID + ".default";
-
-    private final PrincipalStore store;
-    private final ServiceRegistry registry;
-    private final Map servers = new HashMap();
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( KerberosServerFactory.class
);
 
-    Object updateLock = new Object();
+    private static final String FACTORY_PID = "org.apache.kerberos";
+    private static final String DEFAULT_PID = FACTORY_PID + ".default";
 
-    KerberosServerFactory( ServiceRegistry registry, PrincipalStore store )
-    {
-        this.registry = registry;
-        this.store = store;
-    }
-
-    public void destroy()
-    {
-        Iterator it = servers.keySet().iterator();
-        while ( it.hasNext() )
-        {
-            deleted( (String) it.next() );
-        }
-    }
+    private Map servers = new HashMap();
+    private Object updateLock = new Object();
+    private ServiceRegistry registry;
+    private ConfigurationAdmin cm;
+    private InitialContextFactory factory;
+
+    /**
+     * The key of the property specifying where Kerberos users are stored.  If this
+     * property is not set the store defaults to performing a subtree search
+     * from the DN in the {@link Context#PROVIDER_URL}. If it is present a more
+     * efficient search is conducted on the more specific DN.
+     */
+    public static final String KDC_ENTRY_BASEDN_KEY = "kdc.entry.basedn";
 
     public void updated( String pid, Dictionary config ) throws ConfigurationException
     {
-        int port = ( (Integer) config.get( KerberosConfig.KERBEROS_PORT_KEY ) ).intValue();
+        log.debug( getName() + " updating with " + config );
 
-        if ( port < 1 || port > 0xFFFF )
-        {
-            throw new ConfigurationException( KerberosConfig.KERBEROS_PORT_KEY, "invalid
value=" + port );
-        }
+        KerberosConfig kerberosConfig = new KerberosConfig( config );
 
         synchronized ( updateLock )
         {
@@ -69,33 +79,94 @@
             }
 
             // As soon as we get a "non-default"-config, delete default
-            if ( !DEFAULT_PID.equals( pid ) && ( null != servers.get( DEFAULT_PID
) ) )
+            if ( !pid.equals( DEFAULT_PID ) )
             {
                 deleted( DEFAULT_PID );
             }
 
-            // for a given pid-config, do we have the service?
-            // if not, create it with the config
+            // For a given pid, do we have the service?
             KerberosServer server = (KerberosServer) servers.get( pid );
-            if ( server == null )
+
+            // If we don't have the service, create it with the config.
+            // Or, if we do have the service, re-create it if the config is different.
+            if ( server == null || server.isDifferent( config ) )
             {
-                server = new KerberosServer( new KerberosConfig( config ), registry, store
);
+                deleted( pid );
+                PrincipalStore store = getStore();
+                server = new KerberosServer( kerberosConfig, registry, store );
                 servers.put( pid, server );
             }
-            else
+        }
+    }
+
+    private PrincipalStore getStore() throws ConfigurationException
+    {
+        Hashtable env = new Hashtable( new KerberosConfig().toJndiEnvironment() );
+        loadEnvironment( env );
+
+        LdapContext ctx = null;
+
+        try
+        {
+            ctx = (LdapContext) factory.getInitialContext( env );
+        }
+        catch ( NamingException ne )
+        {
+            log.error( ne.getMessage(), ne );
+            throw new ConfigurationException( (String) env.get( Context.PROVIDER_URL ), "Initial
context load failed." );
+        }
+
+        Name searchBaseDn = null;
+
+        if ( env.containsKey( KDC_ENTRY_BASEDN_KEY ) )
+        {
+            String baseDn = (String) env.get( KDC_ENTRY_BASEDN_KEY );
+            searchBaseDn = getRelativeName( ctx, baseDn );
+        }
+
+        return new JndiPrincipalStoreImpl( ctx, searchBaseDn );
+    }
+
+    private Name getRelativeName( DirContext ctx, String baseDn ) throws ConfigurationException
+    {
+        Properties props = new Properties();
+        props.setProperty( "jndi.syntax.direction", "right_to_left" );
+        props.setProperty( "jndi.syntax.separator", "," );
+
+        Name searchBaseDn = null;
+
+        try
+        {
+            Name ctxRoot = new CompoundName( ctx.getNameInNamespace(), props );
+            searchBaseDn = new CompoundName( baseDn, props );
+
+            if ( !searchBaseDn.startsWith( ctxRoot ) )
+            {
+                throw new ConfigurationException( baseDn, "Invalid search base for Kerberos
principals." );
+            }
+
+            for ( int ii = 0; ii < ctxRoot.size(); ii++ )
             {
-                // we have the service, so ...
-                // for a given config, is the config different?
-                if ( server.isDifferent( config ) )
-                {
-                    // the config for this service is different, so ...
-                    // destroy the listener and recreate it with the new config.
-                    deleted( pid );
-                    server = new KerberosServer( new KerberosConfig( config ), registry,
store );
-                    servers.put( pid, server );
-                }
+                searchBaseDn.remove( 0 );
             }
         }
+        catch ( NamingException e )
+        {
+            throw new ConfigurationException( baseDn, "Failed to initialize search base for
Kerberos principals." );
+        }
+
+        return searchBaseDn;
+    }
+
+    private void loadEnvironment( Hashtable env )
+    {
+        env.put( Context.PROVIDER_URL, "dc=example,dc=com" );
+        env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
+        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+        env.put( Context.SECURITY_CREDENTIALS, "secret" );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
+
+        env.put( KDC_ENTRY_BASEDN_KEY, "ou=Users,dc=example,dc=com" );
     }
 
     public void deleted( String pid )
@@ -111,5 +182,91 @@
     public String getName()
     {
         return "Apache Kerberos Service Factory";
+    }
+
+    /**
+     * All required services have been bound, but our service(s) are not yet
+     * registered.  So, we check the Config Admin service for configs or we
+     * start a server with its default properties.
+     */
+    public void activate()
+    {
+        try
+        {
+            Configuration[] configs = null;
+
+            if ( cm != null )
+            {
+                String filter = "(service.factoryPid=" + FACTORY_PID + ")";
+                configs = cm.listConfigurations( filter );
+
+                log.debug( "filter:         " + filter );
+                log.debug( "configs.length: " + configs.length );
+                log.debug( "configs[ 0 ]:   " + configs[ 0 ] );
+            }
+
+            if ( cm == null || configs == null || configs.length == 0 )
+            {
+                updated( KerberosServerFactory.DEFAULT_PID, KerberosConfig.getDefaultConfig()
);
+            }
+        }
+        catch ( Exception e )
+        {
+            log.error( e.getMessage(), e );
+        }
+        finally
+        {
+            cm = null;
+        }
+    }
+
+    /**
+     * Invalidation has started and our services have been unregistered, but
+     * any required services have not been unbound yet.
+     */
+    public void deactivate()
+    {
+        Iterator it = servers.keySet().iterator();
+
+        while ( it.hasNext() )
+        {
+            deleted( (String) it.next() );
+        }
+    }
+
+    public void setInitialContextFactory( InitialContextFactory factory )
+    {
+        this.factory = factory;
+        log.debug( getName() + " has bound to " + factory );
+    }
+
+    public void unsetInitialContextFactory( InitialContextFactory factory )
+    {
+        this.factory = null;
+        log.debug( getName() + " has unbound from " + factory );
+    }
+
+    public void setServiceRegistry( ServiceRegistry registry )
+    {
+        this.registry = registry;
+        log.debug( getName() + " has bound to " + registry );
+    }
+
+    public void unsetServiceRegistry( ServiceRegistry registry )
+    {
+        this.registry = null;
+        log.debug( getName() + " has unbound from " + registry );
+    }
+
+    public void setConfigurationAdmin( ConfigurationAdmin cm )
+    {
+        this.cm = cm;
+        log.debug( getName() + " has bound to " + cm );
+    }
+
+    public void unsetConfigurationAdmin( ConfigurationAdmin cm )
+    {
+        this.cm = null;
+        log.debug( getName() + " has unbound from " + cm );
     }
 }

Added: directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/metadata.xml
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/metadata.xml?rev=279449&view=auto
==============================================================================
--- directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/metadata.xml
(added)
+++ directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/metadata.xml
Wed Sep  7 15:43:08 2005
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--<!DOCTYPE bundle SYSTEM "metadata.dtd">-->
+<bundle>
+  <component class="org.apache.kerberos.KerberosServerFactory">
+    <provides service="org.osgi.service.cm.ManagedServiceFactory"/>
+    <property name="service.factoryPid" value="org.apache.kerberos" type="string"/>
+    <requires
+        service="org.apache.mina.registry.ServiceRegistry"
+        filter=""
+        cardinality="1..1"
+        policy="static"
+        bind-method="setServiceRegistry"
+        unbind-method="unsetServiceRegistry"
+    />
+    <requires
+        service="org.osgi.service.cm.ConfigurationAdmin"
+        filter=""
+        cardinality="0..n"
+        policy="dynamic"
+        bind-method="setConfigurationAdmin"
+        unbind-method="unsetConfigurationAdmin"
+    />
+    <requires
+        service="javax.naming.spi.InitialContextFactory"
+        filter=""
+        cardinality="1..1"
+        policy="static"
+        bind-method="setInitialContextFactory"
+        unbind-method="unsetInitialContextFactory"
+    />
+  </component>
+</bundle>

Propchange: directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/metadata.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message