directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r368362 - /directory/sandbox/trustin/ldaps/apacheds-server/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
Date Thu, 12 Jan 2006 13:24:45 GMT
Author: trustin
Date: Thu Jan 12 05:23:54 2006
New Revision: 368362

URL: http://svn.apache.org/viewcvs?rev=368362&view=rev
Log:
Used the reflection API in case ApacheDS is not running on JDK 1.5+

Modified:
    directory/sandbox/trustin/ldaps/apacheds-server/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java

Modified: directory/sandbox/trustin/ldaps/apacheds-server/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/ldaps/apacheds-server/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java?rev=368362&r1=368361&r2=368362&view=diff
==============================================================================
--- directory/sandbox/trustin/ldaps/apacheds-server/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
(original)
+++ directory/sandbox/trustin/ldaps/apacheds-server/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
Thu Jan 12 05:23:54 2006
@@ -20,6 +20,7 @@
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.net.InetSocketAddress;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -41,7 +42,6 @@
 import org.apache.ldap.common.exception.LdapNamingException;
 import org.apache.ldap.server.DirectoryService;
 import org.apache.ldap.server.configuration.ServerStartupConfiguration;
-import org.apache.ldap.server.jndi.ssl.support.LdapsInitializer;
 import org.apache.ldap.server.protocol.ExtendedOperationHandler;
 import org.apache.ldap.server.protocol.LdapProtocolProvider;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
@@ -362,9 +362,37 @@
         {
             return;
         }
-        
+
+        // We use the reflection API in case this is not running on JDK 1.5+.
+        IoFilterChainBuilder chain;
+        try
+        {
+            chain = ( IoFilterChainBuilder ) Class.forName(
+                    "org.apache.ldap.server.jndi.ssl.support.LdapsInitializer",
+                    true,
+                    ServerContextFactory.class.getClassLoader() ).getMethod(
+                            "init", new Class[] { ServerStartupConfiguration.class } ).invoke(
+                                    null, new Object[] { cfg } );
+        }
+        catch( InvocationTargetException e )
+        {
+            if( e.getCause() instanceof NamingException )
+            {
+                throw ( NamingException ) e.getCause();
+            }
+            else
+            {
+                throw ( NamingException ) new NamingException(
+                        "Failed to load LDAPS initializer." ).initCause( e.getCause() );
+            }
+        }
+        catch( Exception e )
+        {
+            throw ( NamingException ) new NamingException(
+                    "Failed to load LDAPS initializer." ).initCause( e );
+        }
+
         Service service = new Service( "LDAPS", TransportType.SOCKET, new InetSocketAddress(
cfg.getLdapsPort() ) );
-        IoFilterChainBuilder chain = LdapsInitializer.init( cfg );
         startLDAP0( cfg, env, service, chain );
     }
 



Mime
View raw message