notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1594 - in development/main/transit: . handler handler/src/main/net/dpml/transit handler/src/main/net/dpml/transit/artifact
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1594 - in development/main/transit: . handler handler/src/main/net/dpml/transit handler/src/main/net/dpml/transit/artifact
- Date: Fri, 28 Jan 2005 05:20:09 +0100
Author: mcconnell
Date: Fri Jan 28 05:20:09 2005
New Revision: 1594
Added:
development/main/transit/handler/src/main/net/dpml/transit/Installer.java
Modified:
development/main/transit/handler/build.properties
development/main/transit/handler/build.xml
development/main/transit/handler/src/main/net/dpml/transit/Main.java
development/main/transit/handler/src/main/net/dpml/transit/Transit.java
development/main/transit/handler/src/main/net/dpml/transit/artifact/CacheHandlerFactory.java
development/main/transit/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
development/main/transit/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
development/main/transit/index.xml
Log:
Update the packaging task to add the default property files and xml files as
resources withing the transit jar file. Add a main class that triggger
standalone execution of transit, and enable default property resultion of
transit and cache properties using the files bundled with the jar. These
changes collectively enable the execution fo Transit in the following modes:
$ java -jar dpml-tanansit-main-WHATEVER.jar // launch transit with a
default installer plugin
$ java -jar dpml-tanansit-main-WHATEVER.jar [some-plugin-artifact-spec]
Modified: development/main/transit/handler/build.properties
==============================================================================
--- development/main/transit/handler/build.properties (original)
+++ development/main/transit/handler/build.properties Fri Jan 28 05:20:09
2005
@@ -8,3 +8,4 @@
junit-filename = junit-3.8.1.jar
+project.jar.main.class=net.dpml.transit.Installer
\ No newline at end of file
Modified: development/main/transit/handler/build.xml
==============================================================================
--- development/main/transit/handler/build.xml (original)
+++ development/main/transit/handler/build.xml Fri Jan 28 05:20:09 2005
@@ -23,6 +23,10 @@
<import file="../../bootstrap.xml"/>
<target name="init" depends="bootstrap.init">
+ <filter token="TRANSIT-CONTROLLER-PLUGIN"
+
value="artifact:plugin:dpml/transit/dpml-transit-plugin#${project.version}"/>
+ <filter token="TRANSIT-INSTALLER-PLUGIN"
+ value="artifact:plugin:osm/util/osm-util-installer#CURRENT"/>
<echo>
#----------------------------------------------------------------------------------
# Transit Protocol Handler
@@ -31,6 +35,21 @@
<mkdir dir="${dpml.home}/transit"/>
</target>
+ <target name="package" depends="build">
+ <mkdir dir="${target.deliverables.jars.dir}"/>
+ <mkdir dir="${basedir}/target/classes/transit"/>
+ <copy todir="${basedir}/target/classes/transit">
+ <fileset dir="${basedir}/target/setup"/>
+ </copy>
+ <jar destfile="${target.deliverables.jars.dir}/${project.filename}"
+ basedir="${target.classes.dir}"
+ includes="**/*.class,**/*.xml,**/*.properties">
+ <manifest>
+ <attribute name="Main-Class" value="${project.jar.main.class}"/>
+ </manifest>
+ </jar>
+ </target>
+
<target name="install" depends="bootstrap.install">
<echo>Installing to: ${user.home}/.ant/lib</echo>
<copy toFile="${user.home}/.ant/lib/${project.antlib}"
Added:
development/main/transit/handler/src/main/net/dpml/transit/Installer.java
==============================================================================
--- (empty file)
+++ development/main/transit/handler/src/main/net/dpml/transit/Installer.java
Fri Jan 28 05:20:09 2005
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.transit;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Hashtable;
+
+import net.dpml.transit.adapter.Adapter;
+import net.dpml.transit.adapter.RepositoryMonitorAdapter;
+import net.dpml.transit.adapter.CacheMonitorAdapter;
+import net.dpml.transit.adapter.NetworkMonitorAdapter;
+import net.dpml.transit.adapter.ConsoleAdapter;
+import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.artifact.CacheHandler;
+import net.dpml.transit.monitors.Monitor;
+import net.dpml.transit.monitors.RepositoryMonitor;
+import net.dpml.transit.monitors.CacheMonitor;
+import net.dpml.transit.monitors.NetworkMonitor;
+import net.dpml.transit.util.Dictionary;
+
+/**
+ * CLI hander for the transit package.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: Main.java 1348 2005-01-03 02:54:01Z mcconnell $
+ */
+public final class Installer
+{
+ /**
+ * Launch transit as a product installer.
+ *
+ * @param args command line argument to be passed to the application
+ * @exception Exception if a deployment error occurs
+ * @see Transit#start
+ */
+ public static void main( final String[] args )
+ throws Exception
+ {
+ String tempPath = System.getProperty( "java.io.tmpdir" );
+ File temp = new File( tempPath );
+ File dpmlTemp = new File( temp, "dpml/install" );
+ File transitTemp = new File( dpmlTemp, "transit" );
+ String boot = "-Xbootstrap=@TRANSIT-CONTROLLER-PLUGIN@";
+ File cache = getCacheLocation( dpmlTemp );
+ transitTemp.mkdirs();
+
+ System.setProperty( "dpml.home", dpmlTemp.getAbsolutePath() );
+ System.setProperty( CacheHandler.CACHE_KEY, cache.getAbsolutePath()
);
+
+ if( args.length == 0 )
+ {
+ String installer = "@TRANSIT-INSTALLER-PLUGIN@";
+ Main.main( new String[]{ boot, "-load", installer } );
+ }
+ else
+ {
+ Main.main( validateArgs( boot, args ) );
+ }
+ }
+
+ private static String[] validateArgs( String boot, String[] args )
+ {
+ boolean ok = false;
+ String[] newArgs = new String[ args.length + 1 ];
+ for( int i=0; i < args.length; i++ )
+ {
+ String arg = args[i];
+ newArgs[i] = arg;
+ if( arg.startsWith( "-Xbootstrap=" ) )
+ {
+ return args;
+ }
+ }
+ newArgs[ args.length ] = boot;
+ return newArgs;
+ }
+
+ /**
+ * If we are running in an environment with an existing installation then
+ * the current cache is returned otherwise a temporary cache is allocated.
+ *
+ * @param base the temporary cache parent directory
+ * @return the working cache directory
+ */
+ private static File getCacheLocation( File base )
+ {
+ File home = getHomeLocation();
+ if( null != home )
+ {
+ return new File( home, "cache" );
+ }
+ else
+ {
+ return new File( base, "cache" );
+ }
+ }
+
+ /**
+ * Return the location of the ${dpml.home} directory. If the environment
+ * variable DPML_HOME is defined that we default to that location
otherwise
+ * if the fallback location ${user.home}/.dpml exists it is returned. If
+ * neither conditions hold, then return null.
+ *
+ * @return the standard home location
+ */
+ private static File getHomeLocation()
+ {
+ String home = Environment.getEnvVariable( Transit.HOME_SYMBOL );
+ if( null != home )
+ {
+ return new File( home );
+ }
+ File user = new File( System.getProperty( "user.home" ) );
+ File standard = new File( user, ".dpml" );
+ if( standard != null )
+ {
+ return standard;
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
+
Modified: development/main/transit/handler/src/main/net/dpml/transit/Main.java
==============================================================================
--- development/main/transit/handler/src/main/net/dpml/transit/Main.java
(original)
+++ development/main/transit/handler/src/main/net/dpml/transit/Main.java
Fri Jan 28 05:20:09 2005
@@ -91,6 +91,7 @@
fis.close();
}
}
+
System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
//
Modified:
development/main/transit/handler/src/main/net/dpml/transit/Transit.java
==============================================================================
--- development/main/transit/handler/src/main/net/dpml/transit/Transit.java
(original)
+++ development/main/transit/handler/src/main/net/dpml/transit/Transit.java
Fri Jan 28 05:20:09 2005
@@ -301,7 +301,7 @@
/**
* Resolve the DPML home directory using assesment of the the ${dpml.home}
- * system propertym, the DPML_HOME environment variable and fallback to
+ * system property, the DPML_HOME environment variable and fallback to
* ${user.home}/.dpml.
* @return the DPML home directory
*/
Modified:
development/main/transit/handler/src/main/net/dpml/transit/artifact/CacheHandlerFactory.java
==============================================================================
---
development/main/transit/handler/src/main/net/dpml/transit/artifact/CacheHandlerFactory.java
(original)
+++
development/main/transit/handler/src/main/net/dpml/transit/artifact/CacheHandlerFactory.java
Fri Jan 28 05:20:09 2005
@@ -24,6 +24,7 @@
import java.net.URL;
import java.util.Properties;
import java.io.IOException;
+import java.io.FileNotFoundException;
import net.dpml.transit.TransitException;
@@ -82,13 +83,12 @@
* @param hosts the set of hosts assigned to the handler
* @return the cache handler
* @exception IOException if an io error occurs
- * @exception TransitException if a trasit system error occurs
+ * @exception TransitException if a transit system error occurs
*/
CacheHandler createCacheHandler( ResourceHost[] hosts )
throws TransitException, IOException
{
- URL url = new URL( m_authorative, TRANSIT_CACHE_PROPERTIES_FILENAME
);
- Properties props = Util.readProps( url );
+ Properties props = getCacheProperties();
String classname =
props.getProperty( CacheHandler.CACHE_CLASS_KEY,
TRANSIT_CACHE_DEFAULT_HANDLER_CLASSNAME );
@@ -113,4 +113,19 @@
throw new TransitException( "Unable to create CacheHandler: " +
classname, e );
}
}
+
+ private Properties getCacheProperties() throws IOException
+ {
+ try
+ {
+ URL url = new URL( m_authorative,
TRANSIT_CACHE_PROPERTIES_FILENAME );
+ return Util.readProps( url );
+ }
+ catch( FileNotFoundException fnfe )
+ {
+ URL url = getClass().getClassLoader().getResource(
+ "transit/authority/" + TRANSIT_CACHE_PROPERTIES_FILENAME );
+ return Util.readProps( url );
+ }
+ }
}
\ No newline at end of file
Modified:
development/main/transit/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
==============================================================================
---
development/main/transit/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
(original)
+++
development/main/transit/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
Fri Jan 28 05:20:09 2005
@@ -248,13 +248,17 @@
}
/**
- * Create the file to the root of the cache directory.
+ * Create the file to the root of the cache directory. If the cache key
is
+ * declared as a system property, the value will take precidence over the
+ * cache configuration properties.
+ *
* @param props the configuration properties
* @return the cache root directory
*/
private File createCacheDirectory( Properties props )
{
- String cache = Util.getProperty( props, CACHE_KEY,
"${user.dir}/.dpml/main" );
+ String fallback = Util.getProperty( props, CACHE_KEY,
"${user.dir}/.dpml/main");
+ String cache = System.getProperty( CACHE_KEY, fallback );
File cachedir = new File( cache );
if( !cachedir.isAbsolute() )
{
Modified:
development/main/transit/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
==============================================================================
---
development/main/transit/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
(original)
+++
development/main/transit/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
Fri Jan 28 05:20:09 2005
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.FileNotFoundException;
import java.net.InetAddress;
import java.net.MalformedURLException;
@@ -217,8 +218,7 @@
m_cacheHandler = handler;
try
{
- URL conf = new URL( authorative, TRANSIT_PROPERTIES_FILENAME );
- Properties props = Util.readProps( conf );
+ Properties props = getTransitProperties( authorative );
setupAuthenticator( props );
}
catch( IOException e )
@@ -227,6 +227,22 @@
}
}
+ private Properties getTransitProperties( URL authorative ) throws
IOException
+ {
+ try
+ {
+ URL conf = new URL( authorative, TRANSIT_PROPERTIES_FILENAME );
+ return Util.readProps( conf );
+ }
+ catch( FileNotFoundException fnfe )
+ {
+ URL url = getClass().getClassLoader().getResource(
+ "transit/authority/" + TRANSIT_PROPERTIES_FILENAME );
+ return Util.readProps( url );
+ }
+ }
+
+
/**
* Return cache handler directory.
*
@@ -515,4 +531,5 @@
RequestIdentifier id = new RequestIdentifier( host, port, protocol,
scheme, prompt );
return id;
}
+
}
Modified: development/main/transit/index.xml
==============================================================================
--- development/main/transit/index.xml (original)
+++ development/main/transit/index.xml Fri Jan 28 05:20:09 2005
@@ -88,6 +88,8 @@
</dependencies>
</project>
+ <!-- tutorials -->
+
<project basedir="tutorials/artifact">
<info>
<group>dpml/tutorial</group>
- svn commit: r1594 - in development/main/transit: . handler handler/src/main/net/dpml/transit handler/src/main/net/dpml/transit/artifact, mcconnell, 01/27/2005
Archive powered by MHonArc 2.6.24.