directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r371202 - in /directory/trunks/apacheds: ./ core/src/main/java/org/apache/ldap/server/configuration/ standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/ standalone/simple/main/ standalone/simple/main/src/main/java...
Date Sun, 22 Jan 2006 05:32:13 GMT
Author: akarasulu
Date: Sat Jan 21 21:32:05 2006
New Revision: 371202

URL: http://svn.apache.org/viewcvs?rev=371202&view=rev
Log:
changes ...

 o fixed issue with bad permissions while creating working directory
 o working on getting bootstrapper working
 o fixed some bugs in installation layout
 o added daemon to pom for apacheds so build works right


Added:
    directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/DirectoryServer.java
  (with props)
Modified:
    directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
    directory/trunks/apacheds/pom.xml
    directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/Bootstrapper.java
    directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/InstallationLayout.java
    directory/trunks/apacheds/standalone/simple/main/pom.xml
    directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/ServerMain.java

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java?rev=371202&r1=371201&r2=371202&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
Sat Jan 21 21:32:05 2006
@@ -385,16 +385,6 @@
      */
     protected void setWorkingDirectory( File workingDirectory )
     {
-        workingDirectory.mkdirs();
-        if( !workingDirectory.exists() )
-        {
-            throw new ConfigurationException( "Working directory '" + workingDirectory +
"' doesn't exist." );
-        }
-        if( !workingDirectory.isDirectory() )
-        {
-            throw new ConfigurationException( "Working directory '" + workingDirectory +
"' is not a directory." );
-        }
-
         this.workingDirectory = workingDirectory;
     }
     

Modified: directory/trunks/apacheds/pom.xml
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/pom.xml?rev=371202&r1=371201&r2=371202&view=diff
==============================================================================
--- directory/trunks/apacheds/pom.xml (original)
+++ directory/trunks/apacheds/pom.xml Sat Jan 21 21:32:05 2006
@@ -35,6 +35,7 @@
     <module>protocol-common</module>
     <module>protocols</module>
     <module>standalone/simple</module>
+    <module>standalone/daemon</module>
   </modules>
   <build>
     <plugins>

Modified: directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/Bootstrapper.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/Bootstrapper.java?rev=371202&r1=371201&r2=371202&view=diff
==============================================================================
--- directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/Bootstrapper.java
(original)
+++ directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/Bootstrapper.java
Sat Jan 21 21:32:05 2006
@@ -75,6 +75,17 @@
         this.parentLoader = parentLoader;
         URL[] jars = install.getAllJars();
         this.appLoader = new URLClassLoader( jars, parentLoader );
+        
+        if ( log.isDebugEnabled() )
+        {
+            StringBuffer buf = new StringBuffer();
+            buf.append( "urls in app loader: \n" );
+            for ( int ii = 0; ii < jars.length; ii++ )
+            {
+                buf.append( "\t" ).append( jars[ii] ).append( "\n" );
+            }
+            log.debug( buf.toString() );
+        }
     }
 
 
@@ -83,6 +94,7 @@
         Class clazz = null;
         Method op = null;
         
+        Thread.currentThread().setContextClassLoader( appLoader );
         try
         {
             clazz = appLoader.loadClass( className );
@@ -109,7 +121,7 @@
         }
         catch ( Exception e )
         {
-            log.error( "Could not find initialize(InstallationLayout) method for " + className,
e );
+            log.error( "Could not find init(InstallationLayout) method for " + className,
e );
             System.exit( METHOD_LOOKUP_FAILURE_EXITCODE );
         }
         
@@ -119,7 +131,7 @@
         }
         catch ( Exception e )
         {
-            log.error( "Failed on " + className + ".initialize(InstallationLayout)", e );
+            log.error( "Failed on " + className + ".init(InstallationLayout)", e );
             System.exit( INITIALIZATION_FAILURE_EXITCODE );
         }
     }
@@ -146,7 +158,7 @@
         }
         catch ( Exception e )
         {
-            log.error( "Failed on " + clazz.getName() + ".initialize(InstallationLayout)",
e );
+            log.error( "Failed on " + clazz.getName() + ".start()", e );
             System.exit( START_FAILURE_EXITCODE );
         }
     }
@@ -183,7 +195,7 @@
         }
         catch ( Exception e )
         {
-            log.error( "Could not find initialize(InstallationLayout) method for " + className,
e );
+            log.error( "Could not find stop() method for " + className, e );
             System.exit( METHOD_LOOKUP_FAILURE_EXITCODE );
         }
         
@@ -193,7 +205,7 @@
         }
         catch ( Exception e )
         {
-            log.error( "Failed on " + className + ".stop(stop)", e );
+            log.error( "Failed on " + className + ".stop()", e );
             System.exit( STOP_FAILURE_EXITCODE );
         }
     }
@@ -204,28 +216,57 @@
     
     public void init( String[] args )
     {
-        log.debug( "init(String[]) called" );
+        if ( log.isDebugEnabled() )
+        {
+            StringBuffer buf = new StringBuffer();
+            buf.append( "init(String[]) called with args: \n" );
+            for ( int ii = 0; ii < args.length; ii++ )
+            {
+                buf.append( "\t" ).append( args[ii] ).append( "\n" );
+            }
+            log.debug( buf.toString() );
+        }
 
         if ( install == null )
         {
+            log.debug( "install was null: initializing it using first argument" );
             setInstallationLayout( args[0] );
+            log.debug( "install initialized" );
+        }
+        else
+        {
+            log.debug( "install was not null" );
         }
 
         if ( parentLoader == null )
         {
             log.info( "Trying to get handle on system classloader as the parent" );
             setParentLoader( Thread.currentThread().getContextClassLoader() );
-            log.info( "systemLoader = " + parentLoader );
+            log.info( "parentLoader = " + parentLoader );
         }
         
         callInit( bootstrapProperties.getProperty( BOOTSTRAP_START_CLASS_PROP, null ) );
+        
+        while( true )
+        {
+            try
+            {
+                Thread.sleep( 2000 );
+            }
+            catch ( InterruptedException e )
+            {
+                e.printStackTrace();
+            }
+
+            log.debug( "tick-tock" );
+        }
     }
     
     
     public void stop() throws Exception
     {
         log.debug( "stop() called" );
-        callStop( bootstrapProperties.getProperty( BOOTSTRAP_STOP_CLASS_PROP, null )  );
+//        callStop( bootstrapProperties.getProperty( BOOTSTRAP_STOP_CLASS_PROP, null )  );
     }
 
 
@@ -239,7 +280,7 @@
     {
         log.debug( "start() called" );
         Thread.currentThread().setContextClassLoader( parentLoader );
-        callStart();
+//        callStart();
     }
 
 

Modified: directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/InstallationLayout.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/InstallationLayout.java?rev=371202&r1=371201&r2=371202&view=diff
==============================================================================
--- directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/InstallationLayout.java
(original)
+++ directory/trunks/apacheds/standalone/daemon/src/main/java/org/apache/directory/server/standalone/daemon/InstallationLayout.java
Sat Jan 21 21:32:05 2006
@@ -187,7 +187,7 @@
             if ( ! dirs[ii].canWrite() )
             {
                 throw new IllegalStateException( dirs[ii] + " is write protected from the
current user: " 
-                    + System.getProperty( "java.user" ) );
+                    + System.getProperty( "user.name" ) );
             }
         }
         
@@ -206,7 +206,7 @@
             if ( ! dirs[ii].canRead() )
             {
                 throw new IllegalStateException( files[ii] + " is not readable by the current
user: " 
-                    + System.getProperty( "java.user" ) );
+                    + System.getProperty( "user.name" ) );
             }
         }
     }

Modified: directory/trunks/apacheds/standalone/simple/main/pom.xml
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/simple/main/pom.xml?rev=371202&r1=371201&r2=371202&view=diff
==============================================================================
--- directory/trunks/apacheds/standalone/simple/main/pom.xml (original)
+++ directory/trunks/apacheds/standalone/simple/main/pom.xml Sat Jan 21 21:32:05 2006
@@ -16,6 +16,11 @@
       <version>0.9.4-SNAPSHOT</version>
     </dependency>  
     <dependency>
+      <groupId>org.apache.directory.server.standalone.daemon</groupId>
+      <artifactId>org.apache.directory.server.standalone.daemon</artifactId>
+      <version>0.9.4-SNAPSHOT</version>
+    </dependency>  
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>nlog4j</artifactId>
       <version>1.2.19</version>

Added: directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/DirectoryServer.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/DirectoryServer.java?rev=371202&view=auto
==============================================================================
--- directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/DirectoryServer.java
(added)
+++ directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/DirectoryServer.java
Sat Jan 21 21:32:05 2006
@@ -0,0 +1,87 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.ldap.server;
+
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.directory.InitialDirContext;
+
+import org.apache.directory.server.standalone.daemon.InstallationLayout;
+import org.apache.ldap.server.configuration.MutableServerStartupConfiguration;
+import org.apache.ldap.server.configuration.SyncConfiguration;
+import org.apache.ldap.server.jndi.ServerContextFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+
+/**
+ * DirectoryServer bean used by both the daemon code and by the ServerMain here.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DirectoryServer
+{
+    private static final Logger log = LoggerFactory.getLogger( DirectoryServer.class );
+    private Properties env;
+
+
+    public void init( InstallationLayout install ) throws Exception
+    {
+        long startTime = System.currentTimeMillis();
+        MutableServerStartupConfiguration cfg;
+
+        if ( install != null )
+        {
+            log.info( "server: loading settings from {}", install.getConfigurationFile()
);
+            ApplicationContext factory = null;
+            factory = new FileSystemXmlApplicationContext( install.getConfigurationFile().toURL().toString()
);
+            cfg = ( MutableServerStartupConfiguration ) factory.getBean( "configuration"
);
+            env = ( Properties ) factory.getBean( "environment" );
+        }
+        else
+        {
+            log.info( "server: using default settings ..." );
+            env = new Properties();
+            cfg = new MutableServerStartupConfiguration();
+        }
+
+        env.setProperty( Context.PROVIDER_URL, "ou=system" );
+        env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName()
);
+        cfg.setWorkingDirectory( install.getPartitionsDirectory() );
+        env.putAll( cfg.toJndiEnvironment() );
+        new InitialDirContext( env );
+
+        if (log.isInfoEnabled())
+        {
+            log.info( "server: started in {} milliseconds", ( System.currentTimeMillis()
- startTime ) + "");
+        }
+    }
+    
+    
+    public void synch() throws Exception
+    {
+        env.putAll( new SyncConfiguration().toJndiEnvironment() );
+        new InitialDirContext( env );
+    }
+}

Propchange: directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/DirectoryServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/ServerMain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/ServerMain.java?rev=371202&r1=371201&r2=371202&view=diff
==============================================================================
--- directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/ServerMain.java
(original)
+++ directory/trunks/apacheds/standalone/simple/main/src/main/java/org/apache/ldap/server/ServerMain.java
Sat Jan 21 21:32:05 2006
@@ -17,19 +17,7 @@
 package org.apache.ldap.server;
 
 
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.directory.InitialDirContext;
-
-import org.apache.ldap.server.configuration.MutableServerStartupConfiguration;
-import org.apache.ldap.server.configuration.ServerStartupConfiguration;
-import org.apache.ldap.server.configuration.SyncConfiguration;
-import org.apache.ldap.server.jndi.ServerContextFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
+import org.apache.directory.server.standalone.daemon.InstallationLayout;
 
 
 /**
@@ -41,59 +29,28 @@
  */
 public class ServerMain
 {
-    private static final Logger log = LoggerFactory.getLogger(ServerMain.class);
-    
     /**
-     * Takes a single argument, an optional properties file to load with server
-     * startup settings.
+     * Takes a single argument, the path to the installation home, which contains 
+     * the configuration to load with server startup settings.
      *
      * @param args the arguments
      */
     public static void main( String[] args ) throws Exception
     {
-        long startTime = System.currentTimeMillis();
-        Properties env;
-        ServerStartupConfiguration cfg;
+        DirectoryServer server = new DirectoryServer();
 
         if ( args.length > 0 )
         {
-            log.info( "server: loading settings from {}", args[0] );
-            ApplicationContext factory = new FileSystemXmlApplicationContext( args[0] );
-            cfg = ( ServerStartupConfiguration ) factory.getBean( "configuration" );
-            env = ( Properties ) factory.getBean( "environment" );
+            server.init( new InstallationLayout( args[0] ) );
         }
         else
         {
-            log.info( "server: using default settings ..." );
-            env = new Properties();
-            cfg = new MutableServerStartupConfiguration();
-        }
-
-        env.setProperty( Context.PROVIDER_URL, "ou=system" );
-        env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName()
);
-        env.putAll( cfg.toJndiEnvironment() );
-
-        new InitialDirContext( env );
-
-        if (log.isInfoEnabled())
-        {
-            log.info( "server: started in {} milliseconds",
-                    ( System.currentTimeMillis() - startTime ) + "");
+            server.init( null );
         }
 
         while ( true )
         {
-            try
-            {
-                // this is a big time cludge for now to just play
-                Thread.sleep( 20000 );
-            }
-            catch ( InterruptedException e )
-            {
-            }
-
-            env.putAll( new SyncConfiguration().toJndiEnvironment() );
-            new InitialDirContext( env );
+            server.synch();
         }
     }
 }



Mime
View raw message