directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r373292 - in /directory/trunks/apacheds: core/src/main/java/org/apache/ldap/server/ core/src/main/java/org/apache/ldap/server/configuration/ standalone/simple/jndi/src/main/java/org/apache/ldap/server/configuration/
Date Sun, 29 Jan 2006 06:39:59 GMT
Author: akarasulu
Date: Sat Jan 28 22:39:52 2006
New Revision: 373292

URL: http://svn.apache.org/viewcvs?rev=373292&view=rev
Log:
Added new configuration option to disable the shutdown hook used to force 
synchronization of the partitions this is in response to DIREVE-330 here:

     https://issues.apache.org/jira/browse/DIREVE-330


Modified:
    directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
    directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
    directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
    directory/trunks/apacheds/standalone/simple/jndi/src/main/java/org/apache/ldap/server/configuration/MutableServerStartupConfiguration.java

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java?rev=373292&r1=373291&r2=373292&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
Sat Jan 28 22:39:52 2006
@@ -104,6 +104,7 @@
     // Constructor
     // ------------------------------------------------------------------------
 
+    
     /**
      * Creates a new instance.
      */
@@ -113,27 +114,10 @@
         {
             throw new NullPointerException( "instanceId" );
         }
-        
         this.instanceId = instanceId;
-        
-        // Register shutdown hook.
-        Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() {
-            public void run()
-            {
-                try
-                {
-                    shutdown();
-                }
-                catch( NamingException e )
-                {
-                    log.warn(
-                            "Failed to shut down the directory service: " +
-                            DefaultDirectoryService.this.instanceId, e );
-                }
-            }
-        }, "ApacheDS Shutdown Hook (" + instanceId + ')' ) );
     }
 
+    
     // ------------------------------------------------------------------------
     // BackendSubsystem Interface Method Implemetations
     // ------------------------------------------------------------------------
@@ -191,6 +175,33 @@
         Hashtable envCopy = ( Hashtable ) env.clone();
 
         StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration(
env );
+
+        if ( cfg.isShutdownHookEnabled() )
+        {
+            Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() {
+                public void run()
+                {
+                    try
+                    {
+                        shutdown();
+                    }
+                    catch( NamingException e )
+                    {
+                        log.warn(
+                                "Failed to shut down the directory service: " +
+                                DefaultDirectoryService.this.instanceId, e );
+                    }
+                }
+            }, "ApacheDS Shutdown Hook (" + instanceId + ')' ) );
+            
+            log.info( "ApacheDS shutdown hook has been registered with the runtime." );
+        }
+        else if ( log.isWarnEnabled() )
+        {
+            log.warn( "ApacheDS shutdown hook has NOT been registered with the runtime."
+ 
+                "  This default setting for standalone operation has been overriden." );
+        }
+
         envCopy.put( Context.PROVIDER_URL, "" );
         
         try

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java?rev=373292&r1=373291&r2=373292&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
Sat Jan 28 22:39:52 2006
@@ -18,15 +18,17 @@
  */
 package org.apache.ldap.server.configuration;
 
+
 import java.io.File;
 import java.util.List;
 import java.util.Set;
 
 import org.apache.ldap.server.DirectoryService;
 
+
 /**
  * A mutable version of {@link StartupConfiguration}.
- *
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -34,64 +36,81 @@
 {
     private static final long serialVersionUID = -987437370955222007L;
 
+
     /**
      * Creates a new instance.
      */
     public MutableStartupConfiguration()
     {
     }
-    
+
+
     /**
-     * Creates a new instance that operates on the {@link DirectoryService}
-     * with the specified ID.
+     * Creates a new instance that operates on the {@link DirectoryService} with
+     * the specified ID.
      */
-    public MutableStartupConfiguration( String instanceId )
+    public MutableStartupConfiguration(String instanceId)
     {
         super( instanceId );
     }
 
-    public void setInstanceId( String instanceId )
+
+    public void setInstanceId(String instanceId)
     {
         super.setInstanceId( instanceId );
     }
 
-    public void setAuthenticatorConfigurations( Set authenticators )
+
+    public void setAuthenticatorConfigurations(Set authenticators)
     {
         super.setAuthenticatorConfigurations( authenticators );
     }
 
-    public void setBootstrapSchemas( Set bootstrapSchemas )
+
+    public void setBootstrapSchemas(Set bootstrapSchemas)
     {
         super.setBootstrapSchemas( bootstrapSchemas );
     }
 
-    public void setContextPartitionConfigurations( Set contextParitionConfigurations )
+
+    public void setContextPartitionConfigurations(Set contextParitionConfigurations)
     {
         super.setContextPartitionConfigurations( contextParitionConfigurations );
     }
 
-    public void setAccessControlEnabled( boolean accessControlEnabled )
+
+    public void setAccessControlEnabled(boolean accessControlEnabled)
     {
         super.setAccessControlEnabled( accessControlEnabled );
     }
 
-    public void setAllowAnonymousAccess( boolean enableAnonymousAccess )
+
+    public void setAllowAnonymousAccess(boolean enableAnonymousAccess)
     {
         super.setAllowAnonymousAccess( enableAnonymousAccess );
     }
 
-    public void setInterceptorConfigurations( List interceptorConfigurations )
+
+    public void setInterceptorConfigurations(List interceptorConfigurations)
     {
         super.setInterceptorConfigurations( interceptorConfigurations );
     }
 
-    public void setTestEntries( List testEntries )
+
+    public void setTestEntries(List testEntries)
     {
         super.setTestEntries( testEntries );
     }
 
-    public void setWorkingDirectory( File workingDirectory )
+
+    public void setWorkingDirectory(File workingDirectory)
     {
         super.setWorkingDirectory( workingDirectory );
+    }
+
+
+    public void setShutdownHookEnabled(boolean shutdownHookEnabled)
+    {
+        super.setShutdownHookEnabled( shutdownHookEnabled );
     }
 }

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=373292&r1=373291&r2=373292&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 28 22:39:52 2006
@@ -54,6 +54,7 @@
     private static final long serialVersionUID = 4826762196566871677L;
 
     private File workingDirectory = new File( "server-work" );
+    private boolean shutdownHookEnabled = true; // allow by default
     private boolean allowAnonymousAccess = true; // allow by default
     private boolean accessControlEnabled = false; // turn off by default
     private Set authenticatorConfigurations; // Set<AuthenticatorConfiguration>
@@ -391,5 +392,17 @@
     public void validate()
     {
         setWorkingDirectory( workingDirectory );
+    }
+
+    
+    protected void setShutdownHookEnabled( boolean shutdownHookEnabled )
+    {
+        this.shutdownHookEnabled = shutdownHookEnabled;
+    }
+    
+    
+    public boolean isShutdownHookEnabled()
+    {
+        return shutdownHookEnabled;
     }
 }

Modified: directory/trunks/apacheds/standalone/simple/jndi/src/main/java/org/apache/ldap/server/configuration/MutableServerStartupConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/simple/jndi/src/main/java/org/apache/ldap/server/configuration/MutableServerStartupConfiguration.java?rev=373292&r1=373291&r2=373292&view=diff
==============================================================================
--- directory/trunks/apacheds/standalone/simple/jndi/src/main/java/org/apache/ldap/server/configuration/MutableServerStartupConfiguration.java
(original)
+++ directory/trunks/apacheds/standalone/simple/jndi/src/main/java/org/apache/ldap/server/configuration/MutableServerStartupConfiguration.java
Sat Jan 28 22:39:52 2006
@@ -140,4 +140,9 @@
     {
         super.setLdapsCertificatePassword( ldapsCertificatePassword );
     }
+    
+    public void setShutdownHookEnabled( boolean shutdownHookEnabled )
+    {
+        super.setShutdownHookEnabled( shutdownHookEnabled );
+    }
 }



Mime
View raw message