directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r329026 - in /directory/standalone/trunk/osgi: ./ changepw/src/main/java/org/apache/changepw/ dns/src/main/java/org/apache/dns/ kerberos/src/main/java/org/apache/kerberos/ launcher/src/main/java/org/apache/launcher/ ldap/src/main/java/org/a...
Date Fri, 28 Oct 2005 01:30:32 GMT
Author: erodriguez
Date: Thu Oct 27 18:30:18 2005
New Revision: 329026

URL: http://svn.apache.org/viewcvs?rev=329026&view=rev
Log:
Cleaned-up in OSGi bundles:
o  All protocols now using core configuration.
o  All configuration moved to protocol providers, out of OSGi bundles.
o  Common code moved to protocol-common.
o  Updated MINA to 0.8.0.
o  Homogenized syncronization in factories.
o  Removed an unused manifest.mf file.

Removed:
    directory/standalone/trunk/osgi/ntp/manifest.mf
Modified:
    directory/standalone/trunk/osgi/changepw/src/main/java/org/apache/changepw/ChangepwServerFactory.java
    directory/standalone/trunk/osgi/dns/src/main/java/org/apache/dns/DnsServerFactory.java
    directory/standalone/trunk/osgi/kerberos/src/main/java/org/apache/kerberos/KerberosServerFactory.java
    directory/standalone/trunk/osgi/launcher/src/main/java/org/apache/launcher/Launcher.java
    directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapConfig.java
    directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapServerFactory.java
    directory/standalone/trunk/osgi/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java
    directory/standalone/trunk/osgi/project.xml

Modified: directory/standalone/trunk/osgi/changepw/src/main/java/org/apache/changepw/ChangepwServerFactory.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/changepw/src/main/java/org/apache/changepw/ChangepwServerFactory.java?rev=329026&r1=329025&r2=329026&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/changepw/src/main/java/org/apache/changepw/ChangepwServerFactory.java
(original)
+++ directory/standalone/trunk/osgi/changepw/src/main/java/org/apache/changepw/ChangepwServerFactory.java
Thu Oct 27 18:30:18 2005
@@ -17,25 +17,19 @@
 
 package org.apache.changepw;
 
+import java.util.Collections;
 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.apache.protocol.common.MapAdapter;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
@@ -48,30 +42,21 @@
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( ChangepwServerFactory.class
);
 
-    private static final String FACTORY_PID = "org.apache.changepw";
-    private static final String DEFAULT_PID = FACTORY_PID + ".default";
+    private static final String DEFAULT_PID = "org.apache.changepw.default";
 
-    private Map servers = new HashMap();
-    private Object updateLock = new Object();
-    private ServiceRegistry registry;
     private ConfigurationAdmin cm;
+    private ServiceRegistry registry;
     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";
+    private Map servers = Collections.synchronizedMap( new HashMap() );
 
     public void updated( String pid, Dictionary config ) throws ConfigurationException
     {
-        log.debug( getName() + " updating with " + config );
+        log.debug( getName() + " (" + pid + ") updating with " + config );
 
-        ChangepwConfig changepwConfig = new ChangepwConfig( config );
+        ChangePasswordConfiguration changepwConfig = new ChangePasswordConfiguration( new
MapAdapter( config ) );
 
-        synchronized ( updateLock )
+        synchronized ( servers )
         {
             if ( DEFAULT_PID.equals( pid ) && servers.size() > 0 )
             {
@@ -92,88 +77,24 @@
             if ( changepwServer == null || changepwServer.isDifferent( config ) )
             {
                 deleted( pid );
-                PrincipalStore store = getStore();
+                PrincipalStore store = new JndiPrincipalStoreImpl( changepwConfig, factory
);
                 changepwServer = new ChangepwServer( changepwConfig, registry, store );
                 servers.put( pid, changepwServer );
             }
         }
     }
 
-    private PrincipalStore getStore() throws ConfigurationException
-    {
-        Hashtable env = new Hashtable( new ChangepwConfig().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
+    public void deleted( String pid )
     {
-        Properties props = new Properties();
-        props.setProperty( "jndi.syntax.direction", "right_to_left" );
-        props.setProperty( "jndi.syntax.separator", "," );
-
-        Name searchBaseDn = null;
-
-        try
+        synchronized ( servers )
         {
-            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." );
-            }
+            ChangepwServer server = (ChangepwServer) servers.remove( pid );
 
-            for ( int ii = 0; ii < ctxRoot.size(); ii++ )
+            if ( server != null )
             {
-                searchBaseDn.remove( 0 );
+                server.destroy();
             }
         }
-        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.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 )
-    {
-        ChangepwServer server = (ChangepwServer) servers.remove( pid );
-
-        if ( server != null )
-        {
-            server.destroy();
-        }
     }
 
     public String getName()
@@ -183,28 +104,15 @@
 
     /**
      * 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.
+     * registered.  If there is no Config Admin we start a server with 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 )
+            if ( cm == null )
             {
-                updated( ChangepwServerFactory.DEFAULT_PID, ChangepwConfig.getDefaultConfig()
);
+                updated( DEFAULT_PID, new Hashtable( ChangePasswordConfiguration.getDefaultConfig()
) );
             }
         }
         catch ( Exception e )
@@ -223,11 +131,17 @@
      */
     public void deactivate()
     {
-        Iterator it = servers.keySet().iterator();
-
-        while ( it.hasNext() )
+        synchronized ( servers )
         {
-            deleted( (String) it.next() );
+            Iterator it = servers.values().iterator();
+
+            while ( it.hasNext() )
+            {
+                ChangepwServer server = (ChangepwServer) it.next();
+                server.destroy();
+            }
+
+            servers.clear();
         }
     }
 

Modified: directory/standalone/trunk/osgi/dns/src/main/java/org/apache/dns/DnsServerFactory.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/dns/src/main/java/org/apache/dns/DnsServerFactory.java?rev=329026&r1=329025&r2=329026&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/dns/src/main/java/org/apache/dns/DnsServerFactory.java
(original)
+++ directory/standalone/trunk/osgi/dns/src/main/java/org/apache/dns/DnsServerFactory.java
Thu Oct 27 18:30:18 2005
@@ -17,25 +17,19 @@
 
 package org.apache.dns;
 
+import java.util.Collections;
 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.dns.store.JndiRecordStoreImpl;
 import org.apache.dns.store.RecordStore;
 import org.apache.mina.registry.ServiceRegistry;
-import org.osgi.service.cm.Configuration;
+import org.apache.protocol.common.MapAdapter;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
@@ -48,30 +42,21 @@
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( DnsServerFactory.class );
 
-    private static final String FACTORY_PID = "org.apache.dns";
-    private static final String DEFAULT_PID = FACTORY_PID + ".default";
+    private static final String DEFAULT_PID = "org.apache.dns.default";
 
-    private Map servers = new HashMap();
-    private Object updateLock = new Object();
-    private ServiceRegistry registry;
     private ConfigurationAdmin cm;
+    private ServiceRegistry registry;
     private InitialContextFactory factory;
 
-    /**
-     * The key of the property specifying where DNS records 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 DNS_ENTRY_BASEDN_KEY = "dns.entry.basedn";
+    private Map servers = Collections.synchronizedMap( new HashMap() );
 
     public void updated( String pid, Dictionary config ) throws ConfigurationException
     {
-        log.debug( getName() + " updating with " + config );
+        log.debug( getName() + " (" + pid + ") updating with " + config );
 
-        DnsConfig dnsConfig = new DnsConfig( config );
+        DnsConfiguration dnsConfig = new DnsConfiguration( new MapAdapter( config ) );
 
-        synchronized ( updateLock )
+        synchronized ( servers )
         {
             if ( DEFAULT_PID.equals( pid ) && servers.size() > 0 )
             {
@@ -92,87 +77,23 @@
             if ( dnsServer == null || dnsServer.isDifferent( config ) )
             {
                 deleted( pid );
-                RecordStore store = getStore();
+                RecordStore store = new JndiRecordStoreImpl( dnsConfig, factory );
                 dnsServer = new DnsServer( dnsConfig, registry, store );
                 servers.put( pid, dnsServer );
             }
         }
     }
 
-    private RecordStore getStore() throws ConfigurationException
-    {
-        Hashtable env = new Hashtable( new DnsConfig().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( DNS_ENTRY_BASEDN_KEY ) )
-        {
-            String baseDn = (String) env.get( DNS_ENTRY_BASEDN_KEY );
-            searchBaseDn = getRelativeName( ctx, baseDn );
-        }
-
-        return new JndiRecordStoreImpl( ctx, searchBaseDn );
-    }
-
-    private Name getRelativeName( DirContext ctx, String baseDn ) throws ConfigurationException
+    public void deleted( String pid )
     {
-        Properties props = new Properties();
-        props.setProperty( "jndi.syntax.direction", "right_to_left" );
-        props.setProperty( "jndi.syntax.separator", "," );
-
-        Name searchBaseDn = null;
-
-        try
+        synchronized ( servers )
         {
-            Name ctxRoot = new CompoundName( ctx.getNameInNamespace(), props );
-            searchBaseDn = new CompoundName( baseDn, props );
+            DnsServer dnsServer = (DnsServer) servers.remove( pid );
 
-            if ( !searchBaseDn.startsWith( ctxRoot ) )
+            if ( dnsServer != null )
             {
-                throw new ConfigurationException( baseDn, "Invalid search base for Apache
DNS records." );
+                dnsServer.destroy();
             }
-
-            for ( int ii = 0; ii < ctxRoot.size(); ii++ )
-            {
-                searchBaseDn.remove( 0 );
-            }
-        }
-        catch ( NamingException e )
-        {
-            throw new ConfigurationException( baseDn, "Failed to initialize search base for
Apache DNS records." );
-        }
-
-        return searchBaseDn;
-    }
-
-    private void loadEnvironment( Hashtable env )
-    {
-        env.put( Context.PROVIDER_URL, "ou=forward lookup zones,ou=dns,ou=system" );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
-
-        env.put( DNS_ENTRY_BASEDN_KEY, "ou=example.com,ou=forward lookup zones,ou=dns,ou=system"
);
-    }
-
-    public void deleted( String pid )
-    {
-        DnsServer dnsServer = (DnsServer) servers.remove( pid );
-
-        if ( dnsServer != null )
-        {
-            dnsServer.destroy();
         }
     }
 
@@ -183,28 +104,15 @@
 
     /**
      * 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.
+     * registered.  If there is no Config Admin we start a server with 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 )
+            if ( cm == null )
             {
-                updated( DnsServerFactory.DEFAULT_PID, DnsConfig.getDefaultConfig() );
+                updated( DEFAULT_PID, new Hashtable( DnsConfiguration.getDefaultConfig()
) );
             }
         }
         catch ( Exception e )
@@ -223,10 +131,17 @@
      */
     public void deactivate()
     {
-        Iterator it = servers.keySet().iterator();
-        while ( it.hasNext() )
+        synchronized ( servers )
         {
-            deleted( (String) it.next() );
+            Iterator it = servers.values().iterator();
+
+            while ( it.hasNext() )
+            {
+                DnsServer dnsServer = (DnsServer) it.next();
+                dnsServer.destroy();
+            }
+
+            servers.clear();
         }
     }
 

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=329026&r1=329025&r2=329026&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
Thu Oct 27 18:30:18 2005
@@ -17,25 +17,21 @@
 
 package org.apache.kerberos;
 
+import java.util.Collections;
 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.kdc.KdcConfiguration;
+import org.apache.kerberos.kdc.KerberosServer;
 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.apache.protocol.common.MapAdapter;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
@@ -48,30 +44,21 @@
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( KerberosServerFactory.class
);
 
-    private static final String FACTORY_PID = "org.apache.kerberos";
-    private static final String DEFAULT_PID = FACTORY_PID + ".default";
+    private static final String DEFAULT_PID = "org.apache.kerberos.default";
 
-    private Map servers = new HashMap();
-    private Object updateLock = new Object();
-    private ServiceRegistry registry;
     private ConfigurationAdmin cm;
+    private ServiceRegistry registry;
     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";
+    private Map servers = Collections.synchronizedMap( new HashMap() );
 
     public void updated( String pid, Dictionary config ) throws ConfigurationException
     {
-        log.debug( getName() + " updating with " + config );
+        log.debug( getName() + " (" + pid + ") updating with " + config );
 
-        KerberosConfig kerberosConfig = new KerberosConfig( config );
+        KdcConfiguration kerberosConfig = new KdcConfiguration( new MapAdapter( config )
);
 
-        synchronized ( updateLock )
+        synchronized ( servers )
         {
             if ( DEFAULT_PID.equals( pid ) && servers.size() > 0 )
             {
@@ -92,88 +79,24 @@
             if ( server == null || server.isDifferent( config ) )
             {
                 deleted( pid );
-                PrincipalStore store = getStore();
+                PrincipalStore store = new JndiPrincipalStoreImpl( kerberosConfig, factory
);
                 server = new KerberosServer( kerberosConfig, registry, store );
                 servers.put( pid, server );
             }
         }
     }
 
-    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
+    public void deleted( String pid )
     {
-        Properties props = new Properties();
-        props.setProperty( "jndi.syntax.direction", "right_to_left" );
-        props.setProperty( "jndi.syntax.separator", "," );
-
-        Name searchBaseDn = null;
-
-        try
+        synchronized ( servers )
         {
-            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." );
-            }
+            KerberosServer server = (KerberosServer) servers.remove( pid );
 
-            for ( int ii = 0; ii < ctxRoot.size(); ii++ )
+            if ( server != null )
             {
-                searchBaseDn.remove( 0 );
+                server.destroy();
             }
         }
-        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.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 )
-    {
-        KerberosServer server = (KerberosServer) servers.remove( pid );
-
-        if ( server != null )
-        {
-            server.destroy();
-        }
     }
 
     public String getName()
@@ -183,28 +106,15 @@
 
     /**
      * 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.
+     * registered.  If there is no Config Admin we start a server with 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 )
+            if ( cm == null )
             {
-                updated( KerberosServerFactory.DEFAULT_PID, KerberosConfig.getDefaultConfig()
);
+                updated( DEFAULT_PID, new Hashtable( KdcConfiguration.getDefaultConfig()
) );
             }
         }
         catch ( Exception e )
@@ -223,11 +133,17 @@
      */
     public void deactivate()
     {
-        Iterator it = servers.keySet().iterator();
-
-        while ( it.hasNext() )
+        synchronized ( servers )
         {
-            deleted( (String) it.next() );
+            Iterator it = servers.values().iterator();
+
+            while ( it.hasNext() )
+            {
+                KerberosServer server = (KerberosServer) it.next();
+                server.destroy();
+            }
+
+            servers.clear();
         }
     }
 

Modified: directory/standalone/trunk/osgi/launcher/src/main/java/org/apache/launcher/Launcher.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/launcher/src/main/java/org/apache/launcher/Launcher.java?rev=329026&r1=329025&r2=329026&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/launcher/src/main/java/org/apache/launcher/Launcher.java
(original)
+++ directory/standalone/trunk/osgi/launcher/src/main/java/org/apache/launcher/Launcher.java
Thu Oct 27 18:30:18 2005
@@ -30,7 +30,8 @@
 import org.ungoverned.oscar.Oscar;
 
 /**
- * Launcher.
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class Launcher
 {
@@ -38,8 +39,8 @@
     private static final Logger log = LoggerFactory.getLogger( Launcher.class );
 
     /**  Description of the Field */
-    private final static String DFLT_HOME_KEY = "launcher.home";
-    private final static String DFLT_PROFILE = "launcher";
+    private final static String DEFAULT_HOME_KEY = "launcher.home";
+    private final static String DEFAULT_PROFILE = "launcher";
 
     /** Array of launchable program "names", together with classes which contain their main
methods */
     private static String[] launchables = { "app1", "app2", "app3", "app4" };
@@ -60,7 +61,7 @@
             System.err.println( "Fatal error: must specify program to launch" );
         }
 
-        launcherHome = System.getProperty( DFLT_HOME_KEY );
+        launcherHome = System.getProperty( DEFAULT_HOME_KEY );
         if ( launcherHome == null )
         {
             throw new IllegalArgumentException( "launcher.home not set" );
@@ -214,7 +215,7 @@
      */
     private static void launchVtmp( String[] argv ) throws Exception
     {
-        String profile = DFLT_PROFILE;
+        String profile = DEFAULT_PROFILE;
         if ( argv.length > 0 )
         {
             profile = new String( argv[ 0 ] );

Modified: directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapConfig.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapConfig.java?rev=329026&r1=329025&r2=329026&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapConfig.java (original)
+++ directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapConfig.java Thu
Oct 27 18:30:18 2005
@@ -18,29 +18,31 @@
 package org.apache.ldap;
 
 import java.util.Dictionary;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.ldap.server.DirectoryService;
 import org.apache.ldap.server.configuration.Configuration;
-import org.osgi.service.cm.ConfigurationException;
+import org.apache.ldap.server.configuration.ConfigurationException;
 
 public class LdapConfig extends Configuration
 {
-    private static String SERVICE_PID = "service.pid";
-    private static String PID = "org.apache.ldap";
-    private static String LDAP_PORT_KEY = "ldap.port";
-    private static String LDAPS_PORT_KEY = "ldaps.port";
+    public static String LDAP_PORT_KEY = "ldap.port";
+    public static String LDAPS_PORT_KEY = "ldaps.port";
+
     private static int LDAP_PORT_DEFAULT = 389;
     private static int LDAPS_PORT_DEFAULT = 636;
+
+    private static String SERVICE_PID = "service.pid";
+    private static String PID = "org.apache.ldap";
     private static String name = "Apache LDAP Service";
 
-    private int port;
-    private int securePort;
+    private Map configuration = new HashMap();
 
     /**
      * Creates a new instance with default settings.
      */
-    public LdapConfig() throws ConfigurationException
+    public LdapConfig()
     {
         this( getDefaultConfig() );
     }
@@ -49,42 +51,46 @@
      * Creates a new instance with default settings that operates on the
      * {@link DirectoryService} with the specified ID.
      */
-    public LdapConfig( String instanceId ) throws ConfigurationException
+    public LdapConfig( String instanceId )
     {
         this( getDefaultConfig() );
         setInstanceId( instanceId );
     }
 
-    public LdapConfig( Dictionary configuration ) throws ConfigurationException
+    public LdapConfig( Map properties )
     {
-        if ( configuration == null )
+        if ( properties == null )
         {
             configuration = getDefaultConfig();
         }
+        else
+        {
+            configuration.putAll( properties );
+        }
 
-        port = ( (Integer) configuration.get( LDAP_PORT_KEY ) ).intValue();
+        int port = getPort();
 
         if ( port < 1 || port > 0xFFFF )
         {
-            throw new ConfigurationException( LDAP_PORT_KEY, "invalid value=" + port );
+            throw new ConfigurationException( "Invalid value:  " + LDAP_PORT_KEY + "=" +
port );
         }
 
-        securePort = ( (Integer) configuration.get( LDAPS_PORT_KEY ) ).intValue();
+        int securePort = getSecurePort();
 
         if ( securePort < 1 || securePort > 0xFFFF )
         {
-            throw new ConfigurationException( LDAPS_PORT_KEY, "invalid value=" + securePort
);
+            throw new ConfigurationException( "Invalid value:  " + LDAPS_PORT_KEY + "=" +
securePort );
         }
     }
 
     public boolean isDifferent( Dictionary config )
     {
-        if ( port != ( (Integer) config.get( LDAP_PORT_KEY ) ).intValue() )
+        if ( getPort() != ( (Integer) config.get( LDAP_PORT_KEY ) ).intValue() )
         {
             return true;
         }
 
-        if ( securePort != ( (Integer) config.get( LDAPS_PORT_KEY ) ).intValue() )
+        if ( getSecurePort() != ( (Integer) config.get( LDAPS_PORT_KEY ) ).intValue() )
         {
             return true;
         }
@@ -99,22 +105,41 @@
 
     public int getPort()
     {
-        return port;
+        String key = LDAP_PORT_KEY;
+
+        if ( configuration.containsKey( key ) )
+        {
+            return Integer.parseInt( get( key ) );
+        }
+
+        return LDAP_PORT_DEFAULT;
     }
 
     public int getSecurePort()
     {
-        return securePort;
+        String key = LDAPS_PORT_KEY;
+
+        if ( configuration.containsKey( key ) )
+        {
+            return Integer.parseInt( get( key ) );
+        }
+
+        return LDAPS_PORT_DEFAULT;
     }
 
-    public static Dictionary getDefaultConfig()
+    public static Map getDefaultConfig()
     {
-        Dictionary defaults = new Hashtable();
+        Map defaults = new HashMap();
 
         defaults.put( SERVICE_PID, PID );
         defaults.put( LDAP_PORT_KEY, Integer.getInteger( LDAP_PORT_KEY, new Integer( LDAP_PORT_DEFAULT
) ) );
         defaults.put( LDAPS_PORT_KEY, Integer.getInteger( LDAPS_PORT_KEY, new Integer( LDAPS_PORT_DEFAULT
) ) );
 
         return defaults;
+    }
+
+    private String get( String key )
+    {
+        return (String) configuration.get( key );
     }
 }

Modified: directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapServerFactory.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapServerFactory.java?rev=329026&r1=329025&r2=329026&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapServerFactory.java
(original)
+++ directory/standalone/trunk/osgi/ldap/src/main/java/org/apache/ldap/LdapServerFactory.java
Thu Oct 27 18:30:18 2005
@@ -29,7 +29,7 @@
 
 import org.apache.ldap.server.configuration.StartupConfiguration;
 import org.apache.mina.registry.ServiceRegistry;
-import org.osgi.service.cm.Configuration;
+import org.apache.protocol.common.MapAdapter;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
@@ -42,8 +42,7 @@
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( LdapServerFactory.class );
 
-    private static final String FACTORY_PID = "org.apache.ldap";
-    private static final String DEFAULT_PID = FACTORY_PID + ".default";
+    private static final String DEFAULT_PID = "org.apache.ldap.default";
 
     private Map servers = Collections.synchronizedMap( new HashMap() );
     private ServiceRegistry registry;
@@ -55,7 +54,7 @@
     {
         log.debug( getName() + " updating with " + config );
 
-        LdapConfig ldapConfig = new LdapConfig( config );
+        LdapConfig ldapConfig = new LdapConfig( new MapAdapter( config ) );
 
         synchronized ( servers )
         {
@@ -104,8 +103,7 @@
 
     /**
      * 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.
+     * registered.  If there is no Config Admin we start a server with default properties.
      */
     public void activate()
     {
@@ -114,20 +112,9 @@
             env = new Hashtable( new StartupConfiguration().toJndiEnvironment() );
             loadEnvironment( env );
 
-            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 );
-            }
-
-            if ( cm == null || configs == null || configs.length == 0 )
+            if ( cm == null )
             {
-                updated( DEFAULT_PID, LdapConfig.getDefaultConfig() );
+                updated( DEFAULT_PID, new Hashtable( LdapConfig.getDefaultConfig() ) );
             }
         }
         catch ( Exception e )

Modified: directory/standalone/trunk/osgi/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java?rev=329026&r1=329025&r2=329026&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java
(original)
+++ directory/standalone/trunk/osgi/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java
Thu Oct 27 18:30:18 2005
@@ -196,6 +196,8 @@
         Properties props = new Properties();
         props.setProperty( "jndi.syntax.direction", "right_to_left" );
         props.setProperty( "jndi.syntax.separator", "," );
+        props.setProperty( "jndi.syntax.ignorecase", "true" );
+        props.setProperty( "jndi.syntax.trimblanks", "true" );
 
         Name searchBaseDn = null;
 

Modified: directory/standalone/trunk/osgi/project.xml
URL: http://svn.apache.org/viewcvs/directory/standalone/trunk/osgi/project.xml?rev=329026&r1=329025&r2=329026&view=diff
==============================================================================
--- directory/standalone/trunk/osgi/project.xml (original)
+++ directory/standalone/trunk/osgi/project.xml Thu Oct 27 18:30:18 2005
@@ -87,6 +87,14 @@
       <version>0.9.3-SNAPSHOT</version>
     </dependency>
     <dependency>
+      <groupId>directory-shared</groupId>
+      <artifactId>protocol-common</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+      <properties>
+        <osgi.jar.bundle>true</osgi.jar.bundle>
+      </properties>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
@@ -118,7 +126,7 @@
     <dependency>
       <groupId>directory-network</groupId>
       <artifactId>mina</artifactId>
-      <version>0.7.3-SNAPSHOT</version>
+      <version>0.8.0</version>
     </dependency>
     <dependency>
       <groupId>maven</groupId>



Mime
View raw message