directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r220146 - /directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
Date Thu, 21 Jul 2005 17:17:54 GMT
Author: akarasulu
Date: Thu Jul 21 10:17:52 2005
New Revision: 220146

URL: http://svn.apache.org/viewcvs?rev=220146&view=rev
Log:
adding logging statements

Modified:
    directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java

Modified: directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java?rev=220146&r1=220145&r2=220146&view=diff
==============================================================================
--- directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
(original)
+++ directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
Thu Jul 21 10:17:52 2005
@@ -44,6 +44,8 @@
 import org.apache.mina.common.TransportType;
 import org.apache.mina.registry.Service;
 import org.apache.mina.registry.ServiceRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 
 /**
@@ -56,10 +58,9 @@
  */
 public class ServerContextFactory extends CoreContextFactory
 {
+    private static Log log = LogFactory.getLog( ServerContextFactory.class.getName() );
     private static Service ldapService;
-
     private static Service kerberosService;
-
     private static ServiceRegistry minaRegistry;
 
 
@@ -75,12 +76,20 @@
             if ( ldapService != null )
             {
                 minaRegistry.unbind( ldapService );
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "Unbind of LDAP Service complete: " + ldapService );
+                }
                 ldapService = null;
             }
 
             if ( kerberosService != null )
             {
                 minaRegistry.unbind( kerberosService );
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "Unbind of KRB5 Service complete: " + kerberosService );
+                }
                 kerberosService = null;
             }
         }
@@ -124,7 +133,6 @@
          * Looks like KdcConfiguration takes properties and we use Hashtable for JNDI
          * so I'm copying over the String based properties into a new Properties obj.
          */
-
         Properties props = new Properties();
         Iterator list = env.keySet().iterator();
         while ( list.hasNext() )
@@ -137,6 +145,7 @@
             }
         }
 
+        // construct the configuration, get the port, create the service, and prepare kdc
objects
         KdcConfiguration config = new KdcConfiguration( props );
         int port = PropertiesUtils.get( env, KdcConfiguration.KERBEROS_PORT_KEY, KdcConfiguration.DEFAULT_KERBEROS_PORT
);
         Service service= new Service( "kerberos", TransportType.DATAGRAM, new InetSocketAddress(
port ) );
@@ -148,10 +157,15 @@
         {
             minaRegistry.bind( service, new KerberosProtocolProvider( config, store ) );
             kerberosService = service;
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "Successful bind of KRB5 Service completed: " + kerberosService
);
+            }
         }
         catch ( IOException e )
         {
-            e.printStackTrace();
+            log.error( "Could not start the kerberos service on port " +
+                    KdcConfiguration.DEFAULT_KERBEROS_PORT, e );
         }
     }
 
@@ -170,6 +184,12 @@
         Hashtable cloned = ( Hashtable ) env.clone();
         String dn = NamespaceTools.inferLdapName( config.getPrimaryRealm() );
         cloned.put( Context.PROVIDER_URL, dn );
+
+        if ( log.isInfoEnabled() )
+        {
+            log.info( "Getting initial context for realm base at " + dn + " for " + config.getPrimaryRealm()
);
+        }
+
         return new InitialLdapContext( cloned, new Control[]{} );
     }
 
@@ -182,23 +202,23 @@
     private void startLdapProtocol( ServerStartupConfiguration cfg, Hashtable env ) throws
NamingException
     {
         int port = cfg.getLdapPort();
-
         Service service = new Service( "ldap", TransportType.SOCKET, new InetSocketAddress(
port ) );
 
         try
         {
             minaRegistry.bind( service, new LdapProtocolProvider( ( Hashtable ) env.clone()
) );
-
             ldapService = service;
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "Successful bind of LDAP Service completed: " + ldapService );
+            }
         }
         catch ( IOException e )
         {
             String msg = "Failed to bind the LDAP protocol service to the service registry:
" + service;
-
             LdapConfigurationException lce = new LdapConfigurationException( msg );
-
             lce.setRootCause( e );
-
+            log.error( msg, e );
             throw lce;
         }
     }



Mime
View raw message