mcconnell 2003/12/08 04:49:59
Modified: kernel/impl/conf merlin.properties
kernel/plugin plugin.jelly
kernel/plugin/src/java/org/apache/avalon/merlin/tools
MerlinBean.java
kernel/unit/src/java/org/apache/avalon/merlin/unit
AbstractMerlinTestCase.java
Log:
Housekeeping.
Revision Changes Path
1.6 +0 -1 avalon-sandbox/kernel/impl/conf/merlin.properties
Index: merlin.properties
===================================================================
RCS file: /home/cvs/avalon-sandbox/kernel/impl/conf/merlin.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- merlin.properties 6 Dec 2003 06:37:43 -0000 1.5
+++ merlin.properties 8 Dec 2003 12:49:59 -0000 1.6
@@ -29,7 +29,6 @@
#
merlin.kernel = file:///${merlin.config}/kernel.xml
-
#----------------------------------------------------------------------
# merlin runtime properties
#----------------------------------------------------------------------
1.4 +8 -2 avalon-sandbox/kernel/plugin/plugin.jelly
Index: plugin.jelly
===================================================================
RCS file: /home/cvs/avalon-sandbox/kernel/plugin/plugin.jelly,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- plugin.jelly 8 Dec 2003 09:16:48 -0000 1.3
+++ plugin.jelly 8 Dec 2003 12:49:59 -0000 1.4
@@ -24,7 +24,7 @@
</j:if>
</goal>
- <goal name="merlin:simulate" prereqs="test:test"
+ <goal name="merlin:simulate" prereqs="java:compile"
description="Simulated deployment from ${maven.build.dir}/classes">
<j:set var="merlin.deployment" value="${maven.build.dir}/classes"/>
<util:file var="target" name="${merlin.deployment}"/>
@@ -43,7 +43,13 @@
</goal>
<goal name="merlin:execute">
- <merlin:kernel deployment="${merlin.deployment}"/>
+ <echo>Target: ${merlin.deployment}</echo>
+ <merlin:kernel
+ hosts="${maven.repo.remote}"
+ deployment="${merlin.deployment}"
+ info="${merlin.info}"
+ debug="${merlin.debug}"
+ />
</goal>
<!--
1.5 +52 -4
avalon-sandbox/kernel/plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java
Index: MerlinBean.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/kernel/plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MerlinBean.java 8 Dec 2003 09:16:48 -0000 1.4
+++ MerlinBean.java 8 Dec 2003 12:49:59 -0000 1.5
@@ -58,6 +58,8 @@
import java.util.Enumeration;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
+import java.util.StringTokenizer;
+import java.util.ArrayList;
import org.apache.avalon.repository.Artifact;
import org.apache.avalon.repository.provider.Builder;
@@ -85,9 +87,11 @@
private String m_deployment;
- //private Factory m_factory;
+ private String[] m_hosts;
- //private Map m_criteria;
+ private String m_debug;
+
+ private String m_info;
//----------------------------------------------------------
// setters
@@ -102,6 +106,33 @@
}
/**
+ * Set the deployment path.
+ */
+ public void setHosts( String path )
+ {
+ if( null != path )
+ {
+ m_hosts = expandHosts( path );
+ }
+ }
+
+ /**
+ * Set the debug policy.
+ */
+ public void setDebug( String policy )
+ {
+ m_debug = policy;
+ }
+
+ /**
+ * Set the info policy.
+ */
+ public void setInfo( String policy )
+ {
+ m_info = policy;
+ }
+
+ /**
* Establish the merlin kernel.
*/
public void doExecute() throws Exception
@@ -114,7 +145,8 @@
InitialContext context =
new DefaultInitialContext(
- getMavenRepositoryDirectory() );
+ getMavenRepositoryDirectory(),
+ m_hosts );
Builder builder = new DefaultBuilder( context, artifact );
Factory factory = builder.getFactory();
@@ -158,7 +190,12 @@
// apply directives assigned to the bean
//
+ criteria.put( "merlin.server", "false" );
criteria.put( "merlin.deployment", m_deployment );
+
+ if( null != m_debug ) criteria.put( "merlin.debug", m_debug );
+ if( null != m_info ) criteria.put( "merlin.info", m_info );
+
}
private Properties getLocalProperties(
@@ -220,6 +257,17 @@
return new File( base );
}
return new File( System.getProperty( "user.dir" ) );
+ }
+
+ private static String[] expandHosts( String arg )
+ {
+ ArrayList list = new ArrayList();
+ StringTokenizer tokenizer = new StringTokenizer( arg, "," );
+ while( tokenizer.hasMoreTokens() )
+ {
+ list.add( tokenizer.nextToken() );
+ }
+ return (String[]) list.toArray( new String[0] );
}
}
1.7 +80 -13
avalon-sandbox/kernel/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java
Index: AbstractMerlinTestCase.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/kernel/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractMerlinTestCase.java 7 Dec 2003 03:17:18 -0000 1.6
+++ AbstractMerlinTestCase.java 8 Dec 2003 12:49:59 -0000 1.7
@@ -134,10 +134,11 @@
Map criteria = factory.createDefaultCriteria();
//
- // set the base directory to the Maven ${basedir}
+ // set the defaults
//
- criteria.put( "merlin.dir", getBaseDirectory() );
+ criteria.put( "merlin.repository", getMavenRepositoryDirectory() );
+ criteria.put( "merlin.context", new File( getBaseDirectory(), "target"
) );
//
// read in any properties declared under the path
@@ -145,8 +146,50 @@
//
applyLocalProperties( criteria );
- m_kernel = factory.create( criteria );
+ //
+ // if the deployment path is undefined then the best we
+ // can do is to assume ${basedir}/target/classes and/or
+ // ${basedir}/target/test-classes contains a BLOCK-INF/block.xml
+ // and from this, derive a merlin.deployment value
+ //
+
+ String[] deployment = (String[]) criteria.get( "merlin.deployment" );
+ if( deployment.length == 0 )
+ {
+ String path = buildDefaultTestPath();
+ if( null != path )
+ {
+ criteria.put( "merlin.deployment", path );
+ }
+ else
+ {
+ final String error =
+ "Cannot locate a deployment objective.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ //
+ // if the ${merlin.override} value is undefined, check for
+ // the existance of an override file in ${basedir}/conf/config.xml
+ // and if it exists assign it as the override parameter
+ //
+
+ if( null == criteria.get( "merlin.override" ) )
+ {
+ String override = buildDefaultOverridePath();
+ if( null != override )
+ {
+ criteria.put( "merlin.override", override );
+ }
+ }
+
+ //
+ // go ahead with the deployment of the kernel
+ //
+
+ m_kernel = factory.create( criteria );
m_shutdown = m_kernel.getClass().getMethod( "shutdown", new Class[0] );
Method method = m_kernel.getClass().getMethod( "getBlock", new Class[0]
);
m_root = method.invoke( m_kernel, new Object[0] );
@@ -187,6 +230,9 @@
protected Object resolve( String path ) throws Exception
{
+ if( null == m_kernel )
+ throw new IllegalStateException( "kernel does not exist" );
+
try
{
Object appliance = m_locate.invoke( m_root, new Object[]{ path } );
@@ -195,15 +241,8 @@
catch( InvocationTargetException ite )
{
Throwable cause = ite.getTargetException();
- if( cause instanceof Exception )
- {
- throw (Exception) cause;
- }
- else
- {
- final String error = ExceptionHelper.packException( cause, true );
- throw new Exception( error );
- }
+ final String error = ExceptionHelper.packException( cause, true );
+ throw new Exception( error );
}
catch( Throwable e )
{
@@ -215,6 +254,34 @@
//----------------------------------------------------------------------
// utilities
//----------------------------------------------------------------------
+
+ private String buildDefaultOverridePath()
+ {
+ File base = getBaseDirectory();
+ File config = new File( base, "conf/config.xml" );
+ if( config.exists() ) return "conf/config.xml";
+ return null;
+ }
+
+ private String buildDefaultTestPath()
+ {
+ File base = getBaseDirectory();
+ File classes = new File( base, "target/classes/BLOCK-INF/block.xml" );
+ File tests = new File( base, "target/test-classes/BLOCK-INF/block.xml" );
+ if( classes.exists() && tests.exists() )
+ {
+ return "target/classes,target/test-classes";
+ }
+ else if( classes.exists() )
+ {
+ return "target/classes";
+ }
+ else if( tests.exists() )
+ {
+ return "target/test-classes";
+ }
+ return null;
+ }
private void applyLocalProperties( Map criteria ) throws IOException
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]