You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/06/09 03:07:19 UTC
cvs commit: avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl DefaultKernelLoader.java
mcconnell 2003/06/08 18:07:19
Modified: merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl
DefaultKernelLoader.java
Log:
Updated so that the shutdown hook is only set when executed in server mode.
Revision Changes Path
1.7 +41 -1 avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelLoader.java
Index: DefaultKernelLoader.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelLoader.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultKernelLoader.java 8 May 2003 03:02:40 -0000 1.6
+++ DefaultKernelLoader.java 9 Jun 2003 01:07:19 -0000 1.7
@@ -66,6 +66,12 @@
* <td>An optional system logging priority (a value of INFO, WARN, ERROR, or DEBUG) to
* be used for internal Merlin execution.</td>
* </tr>
+ * <tr>
+ * <td><code>urn:merlin:kernel.server</code></td>
+ * <td>{@link java.lang.String}</td>
+ * <td>An optional policy declaration with a value of "true" or "false". If false,
+ * the kernel will be shutdown immediately following deployment.</td>
+ * </tr>
* </table>
*
* @param map a map of initialization arguments
@@ -87,6 +93,7 @@
Throwable cause = null;
DefaultLocator context = new DefaultLocator( map );
context.makeReadOnly();
+
DefaultKernel kernel = null;
try
{
@@ -94,7 +101,29 @@
kernel.contextualize( context );
kernel.configure( getKernelConfiguration( profile ) );
kernel.initialize();
- setShutdownHook( kernel );
+
+ if( getServerMode( map ) )
+ {
+ //
+ // only set a shutdown hook if we are in server mode
+ //
+ setShutdownHook( kernel );
+ }
+ else
+ {
+ //
+ // force shutdown of the kernel
+ //
+
+ try
+ {
+ kernel.shutdown();
+ }
+ catch( Throwable e )
+ {
+ // ignore it
+ }
+ }
return kernel;
}
catch( KernelException e )
@@ -112,6 +141,17 @@
System.err.println( message );
throw new KernelException( message, cause );
}
+ }
+
+ private boolean getServerMode( Map map )
+ {
+ String policy = (String) map.get( "urn:merlin:kernel.server" );
+ if( policy == null )
+ {
+ // return the default policy
+ return true;
+ }
+ return policy.equalsIgnoreCase( "true" );
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org