Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2973 - in development/main/depot/install: . src/main/net/dpml/depot/install

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2973 - in development/main/depot/install: . src/main/net/dpml/depot/install
  • Date: Mon, 04 Jul 2005 22:05:30 -0400

Author: mcconnell AT dpml.net
Date: Mon Jul 4 22:05:29 2005
New Revision: 2973

Modified:
development/main/depot/install/build.xml

development/main/depot/install/src/main/net/dpml/depot/install/PackageInstaller.java
Log:
Add support for shortcut names for installation of magic and metro.

Modified: development/main/depot/install/build.xml
==============================================================================
--- development/main/depot/install/build.xml (original)
+++ development/main/depot/install/build.xml Mon Jul 4 22:05:29 2005
@@ -6,6 +6,11 @@

<transit:import uri="artifact:template:dpml/magic/standard"/>

+ <target name="init" depends="standard.init">
+ <x:filter token="MAGIC_BUNDLE_URI" key="dpml-magic" feature="uri"
type="zip"/>
+ <x:filter token="METRO_BUNDLE_URI" key="dpml-metro" feature="uri"
type="zip"/>
+ </target>
+
<target name="package" depends="standard.package">
<x:export class="net.dpml.depot.install.PackageInstaller"/>
<property name="link.path"
value="target/deliverables/plugins/${project.name}-LATEST.plugin.link"/>

Modified:
development/main/depot/install/src/main/net/dpml/depot/install/PackageInstaller.java
==============================================================================
---
development/main/depot/install/src/main/net/dpml/depot/install/PackageInstaller.java
(original)
+++
development/main/depot/install/src/main/net/dpml/depot/install/PackageInstaller.java
Mon Jul 4 22:05:29 2005
@@ -16,15 +16,22 @@

package net.dpml.depot.install;

-import java.io.IOException;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URISyntaxException;
import java.rmi.RemoteException;

import net.dpml.depot.profile.DepotProfile;
import net.dpml.depot.profile.ApplicationProfile;

import net.dpml.transit.Transit;
+import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.artifact.ArtifactNotFoundException;
+import net.dpml.transit.artifact.UnsupportedSchemeException;
+import net.dpml.transit.artifact.MissingGroupException;
import net.dpml.transit.model.TransitRegistryModel;
import net.dpml.transit.model.Logger;
import net.dpml.transit.unit.TransitStorageHome;
@@ -39,6 +46,7 @@
// state

//--------------------------------------------------------------------------

+ private final Logger m_logger;
private final TransitRegistryModel m_transit;
private final DepotProfile m_depot;

@@ -61,6 +69,8 @@
super();

m_depot = depot;
+ m_logger = logger;
+
TransitStorageHome home = new TransitStorageHome();
m_transit = new DefaultTransitRegistryModel( logger, home );
}
@@ -77,17 +87,19 @@
processCommand( command );
}
}
- catch( IOException e )
+ catch( HandledException e )
+ {
+ }
+ catch( Exception e )
{
System.out.println( e.toString() );
- m_continue = false;
}
}

System.exit( 0 );
}

- private void processCommand( String command )
+ private void processCommand( String command ) throws Exception
{
if( "exit".equals( command ) )
{
@@ -95,42 +107,122 @@
}
else if( "list".equals( command ) )
{
- System.out.println( "\nListing installed applications:\n" );
- try
- {
- ApplicationProfile[] applications =
m_depot.getApplicationProfiles();
- for( int i=0; i<applications.length; i++ )
- {
- ApplicationProfile profile = applications[i];
- System.out.println( "\t" + profile.getID()
- + "\t" + profile.getCodeBaseURI() );
- }
- }
- catch( Exception e )
- {
- System.out.println( "Internal error while processing
application list." );
- System.out.println( e.toString() );
- }
- System.out.println( "" );
+ processListCommand();
}
- else if( "install".equals( command ) )
+ else if( command.startsWith( "install " ) )
{
- System.out.println( " Implementation pending: " + command );
+ String args = command.substring( "install ".length() );
+ processInstallCommand( args );
}
else if( "help".equals( command ) )
{
System.out.println( "\n Depot Installation Manager (Command
Help)" );
- System.out.println( "\n" );
- System.out.println( HELP );
- System.out.println( "\n Available commands:" );
- System.out.println( "\n exit -- exit the session" );
- System.out.println( " list -- list installed applications" );
- System.out.println( " install [key] [urn] -- install a new
application" );
+ System.out.println( "\n Available commands:\n" );
+ System.out.println( " list -- list installed
applications" );
+ System.out.println( " install magic -- installs the magic
build system" );
+ System.out.println( " install metro -- installs the metro
container" );
+ System.out.println( " install [urn] -- installs an
application" );
+ System.out.println( " exit -- exit the manager" );
System.out.println( "\n" );
}
else
{
- System.out.println( "Invalid command: " + command );
+ System.out.println( " Invalid command: " + command );
+ }
+ }
+
+ private void processListCommand()
+ {
+ System.out.println( "\n Listing installed applications:\n" );
+ try
+ {
+ ApplicationProfile[] applications =
m_depot.getApplicationProfiles();
+ for( int i=0; i<applications.length; i++ )
+ {
+ ApplicationProfile profile = applications[i];
+ System.out.println( "\t" + profile.getID()
+ + "\t" + profile.getCodeBaseURI() );
+ }
+ }
+ catch( Exception e )
+ {
+ final String error = "Internal error while processing
application list.";
+ m_logger.error( error, e );
+ }
+ System.out.println( "" );
+ }
+
+ private void processInstallCommand( String args ) throws Exception
+ {
+ if( "magic".equals( args ) )
+ {
+ processInstallCommand( "@MAGIC_BUNDLE_URI@" );
+ }
+ else if( "metro".equals( args ) )
+ {
+ processInstallCommand( "@METRO_BUNDLE_URI@" );
+ }
+ else
+ {
+ Artifact artifact = resolveArtifact( args );
+ String type = artifact.getType();
+ if( "zip".equals( type ) )
+ {
+ installZipBundle( artifact );
+ }
+ else
+ {
+ final String error =
+ " Artifact type [" + type + "] is not supported at this
time.\n";
+ System.out.println( error );
+ throw new HandledException();
+ }
+ }
+ System.out.println( "" );
+ }
+
+ private Artifact resolveArtifact( String arg ) throws Exception
+ {
+ try
+ {
+ return Artifact.createArtifact( arg );
+ }
+ catch( UnsupportedSchemeException e )
+ {
+ System.out.println( "\n ERROR: " + e.getMessage() + "\n" );
+ throw new HandledException();
+ }
+ catch( MissingGroupException e )
+ {
+ System.out.println( "\n ERROR: " + e.getMessage() + "\n" );
+ throw new HandledException();
+ }
+ catch( URISyntaxException e )
+ {
+ System.out.println( "\n ERROR: " + "Could not convert argument
to a uri." );
+ System.out.println( " " + e.toString() + "\n" );
+ throw new HandledException();
+ }
+ catch( Throwable e )
+ {
+ m_logger.error( "Invalid install argument [" + arg + "]", e );
+ throw new HandledException();
+ }
+ }
+
+ private void installZipBundle( Artifact artifact ) throws Exception
+ {
+ try
+ {
+ URL url = artifact.toURL();
+ System.out.println( "\n loading: " + url );
+ File file = (File) url.getContent( new Class[]{ File.class } );
+ System.out.println( " cached to: " + file );
+ }
+ catch( ArtifactNotFoundException e )
+ {
+ System.out.println( " Artifact not found.\n" );
+ throw new HandledException();
}
}

@@ -146,13 +238,11 @@
return m_INPUT.readLine();
}

- private static final String HELP =
- " This is a minimalist commandline processor that should "
- + "\n eventually handle package installation. Typical "
- + "\n scenarios are the installation of Magic or the "
- + "\n installation of something like the Metro HTTP "
- + "\n facility. This package is also intended to provide "
- + "\n an example of a small Depot plugin suitable for "
- + "\n other CLI based scenarios such as configuration "
- + "\n updates, listing, etc.";
+ private static class HandledException extends Exception
+ {
+ HandledException()
+ {
+ super();
+ }
+ }
}



  • svn commit: r2973 - in development/main/depot/install: . src/main/net/dpml/depot/install, mcconnell, 07/04/2005

Archive powered by MHonArc 2.6.24.

Top of Page