Skip to Content.
Sympa Menu

notify-dpml - r852 - in trunk/main: depot/core/console/src/main/net/dpml/depot metro/station/server/etc/bin/scm/conf

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r852 - in trunk/main: depot/core/console/src/main/net/dpml/depot metro/station/server/etc/bin/scm/conf
  • Date: Wed, 4 Jan 2006 18:14:51 +0100

Author: mcconnell
Date: 2006-01-04 18:14:49 +0100 (Wed, 04 Jan 2006)
New Revision: 852

Modified:
trunk/main/depot/core/console/src/main/net/dpml/depot/Main.java
trunk/main/metro/station/server/etc/bin/scm/conf/wrapper.conf
Log:
Clean-up of the Depot CLI handler.

Modified: trunk/main/depot/core/console/src/main/net/dpml/depot/Main.java
===================================================================
--- trunk/main/depot/core/console/src/main/net/dpml/depot/Main.java
2006-01-04 16:12:36 UTC (rev 851)
+++ trunk/main/depot/core/console/src/main/net/dpml/depot/Main.java
2006-01-04 17:14:49 UTC (rev 852)
@@ -38,6 +38,7 @@
import net.dpml.transit.monitor.RepositoryMonitorAdapter;
import net.dpml.transit.monitor.CacheMonitorAdapter;
import net.dpml.transit.monitor.NetworkMonitorAdapter;
+import net.dpml.transit.util.Enum;
import net.dpml.transit.PID;

/**
@@ -53,102 +54,8 @@

private Object m_plugin;
private boolean m_debug = false;
-
+
/**
- * Static start method used by NT service.
- * @param args command link arguments
- * @exception Exception if a error occurs
- */
- public static void start( final String[] args )
- throws Exception
- {
- System.out.println( "starting station" );
- Main.main( new String[]{"-station", "-server"} );
- }
-
- /**
- * Static stop method used by NT service.
- * @param args command link arguments
- * @exception Exception if a error occurs
- */
- public static void stop( final String[] args )
- throws Exception
- {
- System.out.println( "stopping station" );
- if( null != m_MAIN )
- {
- m_MAIN.exit();
- }
- else
- {
- System.exit( 0 );
- }
- }
-
- /**
- * Create a shutdown hook that will trigger shutdown of the supplied
plugin.
- * @param thread the application thread
- */
- public static void setShutdownHook( final Thread thread )
- {
- //
- // Create a shutdown hook to trigger clean disposal of the
- // controller
- //
-
- Runtime.getRuntime().addShutdownHook(
- new Thread()
- {
- public void run()
- {
- try
- {
- thread.interrupt();
- }
- catch( Throwable e )
- {
- // ignore it
- boolean ignorable = true;
- }
- System.runFinalization();
- }
- }
- );
- }
-
- /**
- * Create a shutdown hook that will trigger shutdown of the supplied
plugin.
- * @param thread the application thread
- */
- private void setInternalShutdownHook( final Logger logger, final Handler
handler )
- {
- //
- // Create a shutdown hook to trigger clean disposal of the
- // handler
- //
-
- Runtime.getRuntime().addShutdownHook(
- new Thread()
- {
- public void run()
- {
- try
- {
- logger.info( "shutdown" );
- handler.destroy();
- }
- catch( Throwable e )
- {
- // ignore it
- boolean ignorable = true;
- }
- System.runFinalization();
- }
- }
- );
- }
-
- /**
* Processes command line options to establish the command handler plugin
to deploy.
* Command parameters recognixed by the console include the following:
* <ul>
@@ -163,7 +70,7 @@
* @exception Exception if a error occurs
*/
public static void main( String[] args )
- throws Exception
+ throws Exception
{
if( null != m_MAIN )
{
@@ -176,7 +83,7 @@
m_MAIN = new Main( args );
}
}
-
+
private Main( String[] arguments )
{
String[] args = arguments;
@@ -195,105 +102,32 @@
}
}

- String option = getSwitch( args );
-
- if( "-reset".equals( option ) )
+ Command command = getCommand( args );
+ if( Command.BUILD.equals( command ) )
{
- int result = handleReset();
- exit( result );
+ handleBuild( args );
}
- else if( "-get".equals( option ) )
+ else if( Command.TRANSIT.equals( command ) )
{
- for( int i=0; i < args.length; i++ )
- {
- String arg = args[i];
- if( arg.equals( "-get" ) )
- {
- if( i + 1 < args.length )
- {
- String path = args[ i + 1 ];
- try
- {
- handleGet( getLogger(), args, path );
- exit();
- }
- catch( Throwable e )
- {
- String message = e.getMessage();
- Throwable cause = e.getCause();
- getLogger().error( message, e );
- exit( -1 );
- }
- }
- else
- {
- final String error =
- "Missing get parameter value.";
- getLogger().error( error );
- exit( -1 );
- }
- }
- }
+ handleTransit( args );
}
- else if( "-setup".equals( option ) )
+ else if( Command.METRO.equals( command ) )
{
- args = CLIHelper.consolidate( args, "-setup" );
- handleSetup( args );
- }
- else if( "-run".equals( option ) )
- {
- args = CLIHelper.consolidate( args, "-run" );
- handleRun( args, tools );
- }
- else if( "-build".equals( option ) )
- {
- args = CLIHelper.consolidate( args, "-build" );
- handleBuild( args );
- }
- else if( "-metro".equals( option ) )
- {
handleMetro( args );
}
- else if( "-server".equals( option ) )
+ else if( Command.STATION.equals( command ) )
{
handleStation( args );
}
- else if( "-station".equals( option ) )
- {
- args = CLIHelper.consolidate( args, "-station" );
- handleStation( args );
- }
- else if( "-transit".equals( option ) )
- {
- args = CLIHelper.consolidate( args, "-transit" );
- handleTransit( args );
- }
else
{
- handleHelp();
- exit();
+ final String error =
+ "Missing application key '" + APPLICATION_KEY + "'.";
+ System.err.println( error );
+ System.exit( 1 );
}
}

- private int handleReset()
- {
- try
- {
- Preferences netDpml = Preferences.userRoot().node( "/net/dpml" );
- clearPreferences( netDpml );
- Preferences rootDpml = Preferences.userRoot().node( "/dpml" );
- clearPreferences( rootDpml );
- return 0;
- }
- catch( Throwable e )
- {
- final String message =
- "Preferences reset error occured.";
- getLogger().warn( message, e );
- return -1;
- }
- }
-
/**
* Exit.
*/
@@ -311,12 +145,12 @@
System.exit( flag );
}

- private void handleSetup( String[] args )
- {
- String name = "setup";
- String spec = "@DEPOT-INSTALL-URI@";
- handlePlugin( name, spec, args );
- }
+ //private void handleSetup( String[] args )
+ //{
+ // String name = "setup";
+ // String spec = "@DEPOT-INSTALL-URI@";
+ // handlePlugin( name, spec, args );
+ //}

private void handleBuild( String[] args )
{
@@ -325,18 +159,18 @@
handlePlugin( name, spec, args, false, true );
}

- private void handleRun( String[] args, boolean tools )
- {
- if( args.length < 1 )
- {
- System.out.println( "Target URI required." );
- System.exit( -1 );
- }
- String name = "run";
- String spec = args[0];
- args = CLIHelper.consolidate( args, spec );
- handlePlugin( name, spec, args, false, tools );
- }
+ //private void handleRun( String[] args, boolean tools )
+ //{
+ // if( args.length < 1 )
+ // {
+ // System.out.println( "Target URI required." );
+ // System.exit( -1 );
+ // }
+ // String name = "run";
+ // String spec = args[0];
+ // args = CLIHelper.consolidate( args, spec );
+ // handlePlugin( name, spec, args, false, tools );
+ //}

private void handleMetro( String[] arguments )
{
@@ -357,8 +191,7 @@
private void handleStation( String[] arguments )
{
String name = "station";
- if( CLIHelper.isOptionPresent( arguments, "-server" )
- || "dpml.server".equals( System.getProperty(
"dpml.depot.application", null ) ) )
+ if( CLIHelper.isOptionPresent( arguments, "-server" ) )
{
String[] args = CLIHelper.consolidate( arguments, "-server" );
args = processSystemProperties( args );
@@ -385,17 +218,7 @@
private void handlePlugin( String name, String spec, String[] args,
boolean wait, boolean tools )
{
System.setSecurityManager( new RMISecurityManager() );
-
- // get setup uri
-
- Preferences prefs = getRootPreferences();
- Preferences handlers = prefs.node( "handlers" );
- Preferences setup = handlers.node( name );
- String path = setup.get( "uri", spec );
-
- // deploy plugin
-
- boolean waitForCompletion = deployHandler( name, path, args, this,
wait, tools );
+ boolean waitForCompletion = deployHandler( name, spec, args, this,
wait, tools );
if( !waitForCompletion )
{
exit();
@@ -418,7 +241,6 @@
}
try
{
- Preferences prefs = getRootPreferences();
TransitModel model = getTransitModel( args );
URI uri = new URI( path );
Transit transit = Transit.getInstance( model );
@@ -427,7 +249,7 @@
m_plugin =
repository.getPlugin(
ClassLoader.getSystemClassLoader(),
- uri, new Object[]{model, args, logger, shutdown, prefs} );
+ uri, new Object[]{model, args, logger, shutdown} );
}
catch( RepositoryException e )
{
@@ -526,6 +348,7 @@
return DefaultTransitModel.getDefaultModel( logger );
}

+ /*
private void handleGet( Logger logger, String[] args, String path )
throws Exception
{
try
@@ -543,22 +366,17 @@
getLogger().error( error, e );
}
}
+ */

- private static void clearPreferences( Preferences prefs ) throws
Exception
- {
- getLogger().info( "Resetting: " + prefs );
- prefs.removeNode();
- }
-
private static URL getCodeSourceLocation()
{
return
Main.class.getProtectionDomain().getCodeSource().getLocation();
}

- private static Preferences getRootPreferences()
- {
- return ROOT_PREFS;
- }
+ //private static Preferences getRootPreferences()
+ //{
+ // return ROOT_PREFS;
+ //}

private static Logger getLogger()
{
@@ -570,55 +388,152 @@
return m_LOGGER;
}

- private static void handleHelp()
- {
- final String message =
- "Help"
- + "\n\nUsage: depot [-help] | [-version] | [-setup] | [-prefs] |
[-get [artifact]] | [-exec [spec]]"
- + "\n\nAvailable command line options:"
- + "\n"
- + "\n -help List command line help."
- + "\n -version List version information."
- + "\n -run [plugin] Load and run the plugin."
- + "\n -build Launch the project builder."
- + "\n -exec [spec] Launch an application using a supplied
specification."
- + "\n -reset Clear Depot and Transit preferences."
- + "\n -station Start the DPML Station process"
- + "\n -debug Enable debug level logging."
- + "\n -D[name]=[value] Set one or more system properties."
- + "\n";
- getLogger().info( message );
- }
+ //private static void handleHelp()
+ //{
+ // final String message =
+ // "Help"
+ // + "\n\nUsage: depot [-help] | [-version] | [-setup] | [-prefs] |
[-get [artifact]] | [-exec [spec]]"
+ // + "\n\nAvailable command line options:"
+ // + "\n"
+ // + "\n -help List command line help."
+ // + "\n -version List version information."
+ // + "\n -run [plugin] Load and run the plugin."
+ // + "\n -build Launch the project builder."
+ // + "\n -exec [spec] Launch an application using a supplied
specification."
+ // + "\n -reset Clear Depot and Transit preferences."
+ // + "\n -station Start the DPML Station process"
+ // + "\n -debug Enable debug level logging."
+ // + "\n -D[name]=[value] Set one or more system properties."
+ // + "\n";
+ // getLogger().info( message );
+ //}

- private static void handleVersion( boolean debug )
- {
- final String message =
- "Version\n"
- + "\n"
- + "\n Process ID: \t" + PROCESS_ID
- + "\n Java Runtime: \t"
- + System.getProperty( "java.runtime.name" ) + " ("
- + System.getProperty( "java.version" ).replace( '_', ' ' ) + ")"
- + "\n Depot Console: \t@DEPOT-CONSOLE-URI@"
- + "\n Exec Handler: \t@DEPOT-EXEC-URI@"
- + "\n Build Handler: \t@DEPOT-BUILD-URI@"
- + "\n Install Handler: \t@DEPOT-INSTALL-URI@"
- + "\n Station Handler: \t@DEPOT-STATION-URI@"
- + "\n Transit Library: \t@TRANSIT-CORE-URI@"
- + "\n";
- getLogger().info( message );
+ //private static void handleVersion( boolean debug )
+ //{
+ // final String message =
+ // "Version\n"
+ // + "\n"
+ // + "\n Process ID: \t" + PROCESS_ID
+ // + "\n Java Runtime: \t"
+ // + System.getProperty( "java.runtime.name" ) + " ("
+ // + System.getProperty( "java.version" ).replace( '_', ' ' ) + ")"
+ // + "\n Depot Console: \t@DEPOT-CONSOLE-URI@"
+ // + "\n Exec Handler: \t@DEPOT-EXEC-URI@"
+ // + "\n Build Handler: \t@DEPOT-BUILD-URI@"
+ // + "\n Install Handler: \t@DEPOT-INSTALL-URI@"
+ // + "\n Station Handler: \t@DEPOT-STATION-URI@"
+ // + "\n Transit Library: \t@TRANSIT-CORE-URI@"
+ // + "\n";
+ // getLogger().info( message );
+ //
+ // if( debug )
+ // {
+ // System.getProperties().list( System.out );
+ // }
+ //}

- if( debug )
+
//--------------------------------------------------------------------------
+ // static utilities for setup of logging manager and root prefs
+
//--------------------------------------------------------------------------
+
+ private String[] processSystemProperties( String[] args )
+ {
+ ArrayList result = new ArrayList();
+ for( int i=0; i < args.length; i++ )
{
- System.getProperties().list( System.out );
+ String arg = args[i];
+ int index = arg.indexOf( "=" );
+ if( index > -1 && arg.startsWith( "-D" ) )
+ {
+ String name = arg.substring( 2, index );
+ String value = arg.substring( index + 1 );
+ System.setProperty( name, value );
+ }
+ else
+ {
+ result.add( arg );
+ }
}
+ return (String[]) result.toArray( new String[0] );
}

-
//--------------------------------------------------------------------------
- // static utilities for setup of logging manager and root prefs
-
//--------------------------------------------------------------------------
+ /**
+ * Setup the monitors.
+ */
+ private static void setupMonitors( Transit instance, Adapter adapter )
throws Exception
+ {
+ instance.getRepositoryMonitorRouter().addMonitor(
+ new RepositoryMonitorAdapter( adapter ) );
+ instance.getCacheMonitorRouter().addMonitor(
+ new CacheMonitorAdapter( adapter ) );
+ instance.getNetworkMonitorRouter().addMonitor(
+ new NetworkMonitorAdapter( adapter ) );
+ }
+
+ /**
+ * Create a shutdown hook that will trigger shutdown of the supplied
plugin.
+ * @param thread the application thread
+ */
+ public static void setShutdownHook( final Thread thread )
+ {
+ //
+ // Create a shutdown hook to trigger clean disposal of the
+ // controller
+ //
+
+ Runtime.getRuntime().addShutdownHook(
+ new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ thread.interrupt();
+ }
+ catch( Throwable e )
+ {
+ // ignore it
+ boolean ignorable = true;
+ }
+ System.runFinalization();
+ }
+ }
+ );
+ }

/**
+ * Create a shutdown hook that will trigger shutdown of the supplied
plugin.
+ * @param thread the application thread
+ */
+ private void setInternalShutdownHook( final Logger logger, final Handler
handler )
+ {
+ //
+ // Create a shutdown hook to trigger clean disposal of the
+ // handler
+ //
+
+ Runtime.getRuntime().addShutdownHook(
+ new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ logger.info( "shutdown" );
+ handler.destroy();
+ }
+ catch( Throwable e )
+ {
+ // ignore it
+ boolean ignorable = true;
+ }
+ System.runFinalization();
+ }
+ }
+ );
+ }
+
+ /**
* DPML build key.
*/
private static final String BUILD_KEY = "dpml.build";
@@ -649,73 +564,24 @@
}

private static Logger m_LOGGER = null;
- private static final Preferences ROOT_PREFS =
- Preferences.userNodeForPackage( Main.class );
+
+ //private static final Preferences ROOT_PREFS =
+ // Preferences.userNodeForPackage( Main.class );

- private String getSwitch( String[] args )
+ private Command getCommand( String[] args )
{
String ref = getApplicationReference( args );
- String app = System.getProperty( "dpml.depot.application", ref );
- if( null != app )
- {
- if( "dpml.metro".equals( app ) )
- {
- return "-metro";
- }
- else if( "dpml.station".equals( app ) )
- {
- return "-station";
- }
- else if( "dpml.server".equals( app ) )
- {
- return "-server";
- }
- else if( "dpml.builder".equals( app ) )
- {
- return "-build";
- }
- else if( "dpml.transit".equals( app ) )
- {
- return "-transit";
- }
- else
- {
- final String error =
- "Application property value not recognized: ["
- + app
- + "].";
- throw new IllegalArgumentException( error );
- }
- }
- if( args.length == 0 )
- {
- return "-help";
- }
- else
- {
- for( int i=0; i<args.length; i++ )
- {
- String arg = args[i];
- if( arg.startsWith( "-" ) && ( arg.length() > 1 ) )
- {
- if( "-run".equals( arg ) || "-build".equals( arg )
- || "-metro".equals( arg ) || "-station".equals( arg )
|| "-setup".equals( arg )
- || "-server".equals( arg ) || "-help".equals( arg ) )
- {
- return arg;
- }
- }
- }
- return args[0];
- }
+ String app = System.getProperty( APPLICATION_KEY, ref );
+ return Command.parse( app );
}

private String getApplicationReference( String[] args )
{
+ String key = "-D" + APPLICATION_KEY + "=";
for( int i=0; i<args.length; i++ )
{
String arg = args[i];
- if( arg.startsWith( "-Ddpml.depot.application=" ) )
+ if( arg.startsWith( key ) )
{
return arg.substring( 25 );
}
@@ -723,38 +589,79 @@
return null;
}

- private String[] processSystemProperties( String[] args )
+ /**
+ * Application selection key.
+ */
+ public static final String APPLICATION_KEY = "dpml.depot.application";
+
+ /**
+ * Application identifier enumeration.
+ */
+ public static final class Command extends Enum
{
- ArrayList result = new ArrayList();
- for( int i=0; i < args.length; i++ )
+ static final long serialVersionUID = 1L;
+
+ /**
+ * Transit command id.
+ */
+ public static final Command TRANSIT = new Command( "dpml.transit" );
+
+ /**
+ * Metro command id.
+ */
+ public static final Command METRO = new Command( "dpml.metro" );
+
+ /**
+ * Station command id.
+ */
+ public static final Command STATION = new Command( "dpml.station" );
+
+ /**
+ * Builder command id.
+ */
+ public static final Command BUILD = new Command( "dpml.builder" );
+
+ /**
+ * Internal constructor.
+ * @param label the enumeration label.
+ * @param index the enumeration index.
+ * @param map the set of constructed enumerations.
+ */
+ private Command( String label )
{
- String arg = args[i];
- int index = arg.indexOf( "=" );
- if( index > -1 && arg.startsWith( "-D" ) )
+ super( label );
+ }
+
+ /**
+ * Create a now mode using a supplied mode name.
+ * @param value the mode name
+ * @return the mode
+ */
+ public static Command parse( String value )
+ {
+ if( value.equalsIgnoreCase( "dpml.metro" ) )
{
- String name = arg.substring( 2, index );
- String value = arg.substring( index + 1 );
- System.setProperty( name, value );
+ return METRO;
}
+ else if( value.equalsIgnoreCase( "dpml.transit" ) )
+ {
+ return TRANSIT;
+ }
+ else if( value.equalsIgnoreCase( "dpml.station" ) )
+ {
+ return STATION;
+ }
+ else if( value.equalsIgnoreCase( "dpml.builder" ) )
+ {
+ return BUILD;
+ }
else
{
- result.add( arg );
+ final String error =
+ "Unrecognized application id [" + value + "]";
+ throw new IllegalArgumentException( error );
}
}
- return (String[]) result.toArray( new String[0] );
}
-
- /**
- * Setup the monitors.
- */
- private static void setupMonitors( Transit instance, Adapter adapter )
throws Exception
- {
- instance.getRepositoryMonitorRouter().addMonitor(
- new RepositoryMonitorAdapter( adapter ) );
- instance.getCacheMonitorRouter().addMonitor(
- new CacheMonitorAdapter( adapter ) );
- instance.getNetworkMonitorRouter().addMonitor(
- new NetworkMonitorAdapter( adapter ) );
- }
}


Modified: trunk/main/metro/station/server/etc/bin/scm/conf/wrapper.conf
===================================================================
--- trunk/main/metro/station/server/etc/bin/scm/conf/wrapper.conf
2006-01-04 16:12:36 UTC (rev 851)
+++ trunk/main/metro/station/server/etc/bin/scm/conf/wrapper.conf
2006-01-04 17:14:49 UTC (rev 852)
@@ -31,7 +31,7 @@
# Java Additional Parameters

wrapper.java.additional.1=-Djava.system.class.loader=net.dpml.transit.SystemClassLoader

wrapper.java.additional.2=-Djava.security.policy=..\..\share\bin\security.policy
-wrapper.java.additional.3=-Ddpml.depot.application=dpml.server
+wrapper.java.additional.3=-Ddpml.depot.application=dpml.station
wrapper.java.additional.4=-Djava.protocol.handler.pkgs=net.dpml.transit

wrapper.java.additional.5=-Djava.rmi.server.RMIClassLoaderSpi=net.dpml.depot.DepotRMIClassLoaderSpi

@@ -43,7 +43,8 @@

# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=net.dpml.depot.Main
-#wrapper.app.parameter.2=-debug
+wrapper.app.parameter.2=-server
+#wrapper.app.parameter.3=-debug

#********************************************************************
# Wrapper Logging Properties




  • r852 - in trunk/main: depot/core/console/src/main/net/dpml/depot metro/station/server/etc/bin/scm/conf, mcconnell at BerliOS, 01/04/2006

Archive powered by MHonArc 2.6.24.

Top of Page