notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2834 - development/main/depot/console/src/main/net/dpml/depot
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2834 - development/main/depot/console/src/main/net/dpml/depot
- Date: Mon, 13 Jun 2005 03:46:27 -0400
Author: mcconnell AT dpml.net
Date: Mon Jun 13 03:46:27 2005
New Revision: 2834
Modified:
development/main/depot/console/src/main/net/dpml/depot/Main.java
Log:
Add support for -get (basicaly the same as thetransit command line -get
function).
Modified: development/main/depot/console/src/main/net/dpml/depot/Main.java
==============================================================================
--- development/main/depot/console/src/main/net/dpml/depot/Main.java
(original)
+++ development/main/depot/console/src/main/net/dpml/depot/Main.java Mon
Jun 13 03:46:27 2005
@@ -23,6 +23,8 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URI;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.rmi.Remote;
import java.rmi.ConnectException;
import java.rmi.RemoteException;
@@ -55,7 +57,6 @@
import net.dpml.depot.profile.DepotModel;
import net.dpml.depot.profile.DepotStorage;
-
/**
* CLI hander for the depot package.
*
@@ -144,6 +145,30 @@
}
//
+ // check if get has been requested
+ //
+
+ 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];
+ handleGet( logger, args, path );
+ }
+ else
+ {
+ final String error =
+ "Missing get parameter value.";
+ logger.error( error );
+ }
+ return;
+ }
+ }
+
+ //
// establish the target application profile to run
//
@@ -234,8 +259,7 @@
URI uri = p.getURI();
try
{
- TransitHome home = new TransitStorageUnit();
- TransitModel model = home.create();
+ TransitModel model = loadTransitModel( args, logger );
Transit transit = Transit.getInstance( model );
Logger log = logger.getChildLogger( target );
Repository loader = transit.getRepository();
@@ -360,6 +384,52 @@
}
}
+ private static void handleGet( Logger logger, String[] args, String path
) throws HandledError
+ {
+ TransitModel model = loadTransitModel( args, logger );
+ try
+ {
+ Transit transit = Transit.getInstance( model );
+ URI uri = new URI( path );
+ URL url = new URL( uri.toASCIIString() );
+ File file = (File) url.getContent( new Class[]{ File.class } );
+ getLogger().info( "Cached as: " + file );
+ }
+ catch( URISyntaxException e )
+ {
+ final String error =
+ "Supplied path argument could not be converted to a valid URI."
+ + "\nPath: " + path;
+ getLogger().error( error );
+ throw new HandledError();
+ }
+ catch( MalformedURLException e )
+ {
+ final String error =
+ "Supplied path argument could not be converted to a valid URL."
+ + "\nPath: " + path
+ + "\nCause: " + e.getMessage();
+ getLogger().error( error );
+ throw new HandledError();
+ }
+ catch( IOException e )
+ {
+ final String error =
+ "IOException while attemopting to resolve artifact."
+ + "\nURI: " + path
+ + "\nCause: " + e.getMessage();
+ getLogger().error( error );
+ throw new HandledError();
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected exception while attempting to get artifact.";
+ getLogger().error( error, e );
+ throw new HandledError();
+ }
+ }
+
public static Registry getRegistry( Connection connection )
{
if( null == connection )
@@ -587,12 +657,13 @@
"Depot application deployment."
+ "\n\nUsage: depot [option] [args]"
+ "\n\nAvailable command line options:"
- + "\n\n -debug Enable debug level logging."
+ + "\n\n -debug Enable debug level logging."
+ + "\n -get [artifact] Load the supplied artifact to the cache."
+ "\n -help List command line help."
+ "\n -prefs Start the Depot preferences editor."
+ "\n -profile [name] Launch a named application."
- + "\n -station Start the Depot Station Server activation
system."
+ "\n -reset Clear Depot and Transit prefences."
+ + "\n -station Start the Depot Station Server activation
system."
+ "\n -version List Depot version information.";
logger.info( message );
}
@@ -607,6 +678,24 @@
logger.info( message );
}
+ // TODO: add support for transit configuration profile selection
+
+ private static TransitModel loadTransitModel( String[] args, Logger
logger )
+ {
+ try
+ {
+ TransitHome home = new TransitStorageUnit();
+ return home.create();
+ }
+ catch( ClassCastException e )
+ {
+ final String error =
+ "Unexpected error while attempting to construct the transit
model.";
+ getLogger().error( error, e );
+ throw new HandledError();
+ }
+ }
+
//--------------------------------------------------------------------------
// static utilities for setup of logging manager and root prefs
//--------------------------------------------------------------------------
- svn commit: r2834 - development/main/depot/console/src/main/net/dpml/depot, mcconnell, 06/13/2005
Archive powered by MHonArc 2.6.24.