akarasulu 2003/11/11 23:48:32
Added: kernel/plugin .cvsignore maven.xml plugin.jelly
plugin.properties project.xml
kernel/plugin/src/java/org/apache/avalon/merlin/tools
MerlinBean.java
kernel/plugin/xdocs goals.xml navigation.xml properties.xml
Log:
Adding for new changes.
Revision Changes Path
1.1 avalon-sandbox/kernel/plugin/.cvsignore
Index: .cvsignore
===================================================================
target
maven.log
velocity.log
snapshot.properties
.classpath
.project
1.1 avalon-sandbox/kernel/plugin/maven.xml
Index: maven.xml
===================================================================
<project default="jar:install" xmlns:maven="jelly:maven" xmlns:j="jelly:core"
xmlns:util="jelly:util" xmlns:ant="jelly:ant">
<preGoal name="jar:jar">
<maven:snapshot project="${pom}"/>
<j:set var="timestamp"
value="${snapshotSignature.substring(pom.artifactId.length)}"/>
<ant:property name="merlin.timestamp" value="${timestamp}"/>
<ant:echo file="${basedir}/snapshot.properties">
build.signature = ${snapshotSignature}
</ant:echo>
</preGoal>
</project>
1.1 avalon-sandbox/kernel/plugin/plugin.jelly
Index: plugin.jelly
===================================================================
<?xml version="1.0"?>
<project xmlns:j="jelly:core"
xmlns:define="jelly:define"
xmlns:util="jelly:util"
xmlns:maven="jelly:maven"
xmlns:ant="jelly:ant"
xmlns:log="jelly:log"
xmlns:merlin="merlin">
<define:taglib uri="merlin">
<define:jellybean
name="kernel"
className="org.apache.avalon.merlin.tools.MerlinBean"
method="doExecute"/>
</define:taglib>
<goal name="merlin:deploy" prereqs="jar:jar"
description="Deployment from ${maven.build.dir}/${maven.final.name}.jar">
<j:set var="merlin.target" value="${merlin.target}"/>
<j:set var="merlin.target" value="${maven.build.dir}/${maven.final.name}.jar"/>
<util:file var="target" name="${merlin.target}"/>
<j:if test="${target.exists()}">
<attainGoal name="merlin:execute"/>
</j:if>
</goal>
<goal name="merlin:simulate" prereqs="test:test"
description="Simulated deployment from ${maven.build.dir}/classes">
<j:set var="merlin.target" value="${maven.build.dir}/classes"/>
<util:file var="target" name="${merlin.target}"/>
<j:if test="${target.exists()}">
<attainGoal name="merlin:execute"/>
</j:if>
</goal>
<goal name="merlin:test" prereqs="test:test"
description="Simulated deployment from ${maven.build.dir}/test-classes">
<j:set var="merlin.target" value="${maven.build.dir}/test-classes"/>
<util:file var="target" name="${merlin.target}"/>
<j:if test="${target.exists()}">
<attainGoal name="merlin:execute"/>
</j:if>
</goal>
<goal name="merlin:execute" prereqs="merlin:prepare-context">
<merlin:kernel
repository="${merlin.repository.local}"
home="${merlin.basedir}"
anchor="${merlin.anchor}"
kernel="${merlin.kernel}"
target="${merlin.target}"
config="${merlin.config}"
debug="${merlin.debug}"
info="${merlin.info}"
wait="${wait}"/>
</goal>
<goal name="merlin:prepare-context">
<ant:property environment="env"/>
<!--
Assign a value to the merlin.anchor.dir variable. If the
value has already been defined this will fail and the prior
defintion will hold.
-->
<j:set var="merlin.anchor.dir" value="${merlin.anchor}"/>
<j:set var="merlin.anchor.dir" value="${basedir}"/>
<util:file var="anchorFile" name="${merlin.anchor.dir}"/>
<j:if test="${anchorFile.exists()}">
<j:set var="merlin.anchor" value="${merlin.anchor.dir}"/>
</j:if>
<!--
Set the repository path.
-->
<j:set var="merlin.repo.local" value="${maven.home.local}"/>
<util:file var="repo" name="${merlin.repo.local}"/>
<j:if test="${repo.exists()}">
<j:set var="merlin.repository.local" value="${merlin.repo.local}/repository"/>
</j:if>
<j:if test="${!repo.exists()}">
<j:set var="merlin.repository.local" value="${user.dir}/.maven/repository"/>
</j:if>
<!--
If a kernel configuration has been declared the use it otherwise
we default to the merlin installation kernel definition.
-->
<j:set var="merlin.kernel" value="${maven.conf.dir}/kernel.xml"/>
<j:set var="merlin.kernel.config" value="${merlin.kernel}"/>
<util:file var="kernelFile" name="${merlin.kernel.config}"/>
<j:if test="${kernelFile.exists()}">
<j:set var="merlin.kernel" value="${merlin.kernel.config}"/>
</j:if>
<!--
Declare the default configuration path which will be overriden
if an merlin.block.config property is set and exists.
-->
<j:set var="merlin.config" value="${maven.conf.dir}/config.xml"/>
<j:set var="merlin.block.config" value="${merlin.config}"/>
<util:file var="configFile" name="${merlin.block.config}"/>
<j:if test="${configFile.exists()}">
<j:set var="merlin.config" value="${merlin.block.config}"/>
</j:if>
<j:if test="${context.getVariable('merlin.debug') == null}">
<j:set var="merlin.debug" value="false"/>
</j:if>
<j:if test="${context.getVariable('merlin.debug') != null}">
<j:if test="${context.getVariable('merlin.debug') == 'true'}">
<j:set var="merlin.debug" value="true"/>
</j:if>
<j:if test="${context.getVariable('merlin.debug') != 'true'}">
<j:set var="merlin.debug" value="false"/>
</j:if>
</j:if>
<j:set var="wait" value="${merlin.kernel.wait}"/>
<j:if test="${wait == null}">
<j:set var="wait" value="1000"/>
</j:if>
</goal>
</project>
1.1 avalon-sandbox/kernel/plugin/plugin.properties
Index: plugin.properties
===================================================================
# ------------------------------------------------------------------
# P L U G I N P R O P E R T I E S
# -------------------------------------------------------------------
# Merlin plugin.
# -------------------------------------------------------------------
#
# The working home directory.
# The default value is ${basedir}/home
#
#merlin.basedir
#
# The relative of absolute directory path that will for the anchor
# for the defintion of relative directory references used in option
# extension directory establishment. The default value is ${basedir}.
#
#merlin.anchor
#
# Relative or absolute directory of the local repository directory.
# The default value is the Maven local repository directory.
#
#merlin.repository.local
#
# Relative or absolute file path to the kernel configuration.
# The default value corresponds to the path ${maven.conf.dir}/kernel.xml.
#
#merlin.kernel
#
# Relative or absolute file path to the target override configuration.
# The default value corresponds to the path ${maven.conf.dir}/config.xml.
#
#merlin.config
#
# Merlin info flag.
#
merlin.info=false
#
# Merlin debug flag.
#
merlin.debug=false
1.1 avalon-sandbox/kernel/plugin/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../../project.xml</extend>
<pomVersion>3</pomVersion>
<id>merlin-plugin</id>
<name>Merlin Plugin</name>
<description>Merlin Plugin for Maven</description>
<shortDescription>Merlin Plugin for Maven</shortDescription>
<package>org.apache.avalon.merlin</package>
<currentVersion>1.1-SNAPSHOT</currentVersion>
<dependencies>
<!-- mx4j dependecies -->
<dependency>
<groupId>mx4j</groupId>
<artifactId>mx4j-jmx</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>mx4j</groupId>
<artifactId>mx4j-tools</artifactId>
<version>1.1.1</version>
</dependency>
<!-- merlin -->
<dependency>
<groupId>merlin</groupId>
<artifactId>merlin-kernel-spi</artifactId>
<version>3.2-dev</version>
</dependency>
<dependency>
<groupId>merlin</groupId>
<artifactId>merlin-kernel-impl</artifactId>
<version>3.2.1-dev</version>
</dependency>
<dependency>
<groupId>avalon-activation</groupId>
<artifactId>avalon-activation-api</artifactId>
<version>1.2-dev</version>
</dependency>
<dependency>
<groupId>avalon-activation</groupId>
<artifactId>avalon-activation-spi</artifactId>
<version>1.2.1-dev</version>
</dependency>
<dependency>
<groupId>avalon-activation</groupId>
<artifactId>avalon-activation-impl</artifactId>
<version>1.2.2-dev</version>
</dependency>
<dependency>
<groupId>avalon-composition</groupId>
<artifactId>avalon-composition-api</artifactId>
<version>1.2-dev</version>
</dependency>
<dependency>
<groupId>avalon-composition</groupId>
<artifactId>avalon-composition-spi</artifactId>
<version>1.2-dev</version>
</dependency>
<dependency>
<groupId>avalon-composition</groupId>
<artifactId>avalon-composition-impl</artifactId>
<version>1.2-dev</version>
</dependency>
<dependency>
<groupId>avalon-extension</groupId>
<artifactId>avalon-extension-spi</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>avalon-extension</groupId>
<artifactId>avalon-extension-impl</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>avalon-meta</groupId>
<artifactId>avalon-meta-api</artifactId>
<version>1.2.1-dev</version>
</dependency>
<dependency>
<groupId>avalon-meta</groupId>
<artifactId>avalon-meta-spi</artifactId>
<version>1.2.1-dev</version>
</dependency>
<dependency>
<groupId>avalon-meta</groupId>
<artifactId>avalon-meta-impl</artifactId>
<version>1.2.1-dev</version>
</dependency>
<dependency>
<groupId>avalon-repository</groupId>
<artifactId>avalon-repository-spi</artifactId>
<version>1.1-dev</version>
</dependency>
<dependency>
<groupId>avalon-repository</groupId>
<artifactId>avalon-repository-impl</artifactId>
<version>1.1-dev</version>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
<version>4.1.5</version>
</dependency>
<!-- excalibur -->
<dependency>
<id>logkit</id>
<version>1.2</version>
</dependency>
<dependency>
<groupId>excalibur-lifecycle</groupId>
<artifactId>excalibur-lifecycle-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<id>excalibur-i18n</id>
<version>1.1</version>
</dependency>
<dependency>
<id>excalibur-thread</id>
<version>1.1.1</version>
</dependency>
<dependency>
<id>excalibur-event</id>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>excalibur</groupId>
<artifactId>excalibur-util-concurrent</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<id>excalibur-configuration</id>
<version>1.1</version>
</dependency>
<!-- other -->
<dependency>
<id>ant</id>
<version>1.5</version>
</dependency>
<dependency>
<id>qdox</id>
<version>1.1</version>
</dependency>
<!-- pre JDK 1.4 dependencies -->
<dependency>
<id>xml-apis</id>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xmlParserAPIs</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<id>xerces</id>
<version>2.4.0</version>
</dependency>
<!-- xdoclet -->
<dependency>
<id>commons-collections</id>
<version>2.1</version>
</dependency>
<dependency>
<id>commons-logging</id>
<version>1.1-dev</version>
</dependency>
<dependency>
<id>log4j</id>
<version>1.2.6</version>
</dependency>
<dependency>
<id>xdoclet</id>
<version>1.2b2</version>
</dependency>
<dependency>
<id>xdoclet+xdoclet-module</id>
<version>1.2b2</version>
</dependency>
<dependency>
<id>xdoclet+xjavadoc</id>
<version>1.2b2</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>${basedir}/src/java</sourceDirectory>
<unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources>
<resource>
<directory>${basedir}/src/plugin-resources</directory>
<targetPath>plugin-resources</targetPath>
</resource>
<resource>
<directory>${basedir}</directory>
<includes>
<include>plugin.jelly</include>
<include>plugin.properties</include>
<include>project.properties</include>
<include>project.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}</directory>
<includes>
<include>snapshot.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
1.1
avalon-sandbox/kernel/plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java
Index: MerlinBean.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.avalon.merlin.tools;
import java.io.File;
import java.net.URL;
import org.apache.avalon.repository.Repository;
import org.apache.avalon.repository.impl.DefaultFileRepository;
import org.apache.avalon.composition.util.ExceptionHelper;
import org.apache.avalon.merlin.kernel.Kernel;
import org.apache.avalon.merlin.kernel.KernelException;
import org.apache.avalon.merlin.kernel.impl.DefaultKernel;
import org.apache.avalon.merlin.kernel.impl.DefaultKernelContext;
/**
* Deploy a set of components using Merlin.
*
* @author [EMAIL PROTECTED]
*/
public class MerlinBean
{
//-----------------------------------------------------
// state
//-----------------------------------------------------
/**
* The merlin system directory.
*/
private File m_system;
/**
* The target jar file, simulated deployment directory or
* block file to be deployed.
*/
private File m_target;
/**
* The local repository directory from which the resource
* repository will be created. Typically this will refer to
* Maven local repository.
*/
private File m_repository;
/**
* The configuration targets file to be used.
*/
private File m_conf;
/**
* The kernel configuration file.
*/
private File m_kernel;
/**
* The directory against which extension directories are resolved
* if extension direcctories are declared in the classloader.
*/
private File m_anchor;
/**
* The local working directory. Typically corresponds to the
* Maven ${badedir} variable.
*/
private File m_home;
/**
* The debug flag.
*/
private String m_debug;
/**
* Execution model flag.
*/
private boolean m_execute = true;
/**
* Info flag.
*/
private boolean m_info = false;
/**
* Shutdown pause.
*/
private int m_wait = 0; // not used
//-----------------------------------------------------
// bean pattern setters
//-----------------------------------------------------
/**
* Set the repository.
* @param repository the repository directory
*/
public void setRepository( File repository )
{
m_repository = repository;
}
/**
* Set the pause between deployment and decommissioning when
* executing in non-server model.
*/
public void setWait( int value ) // not used
{
m_wait = value;
}
public void setConfig( File conf )
{
m_conf = conf;
}
public void setKernel( File kernel )
{
m_kernel = kernel;
}
/**
* Set the target jar file.
* @param target the target jar file to execute
*/
public void setTarget( File target )
{
m_target = target;
}
/**
* Set the working directory.
*/
public void setHome( File home )
{
m_home = home;
}
/**
* Set the debug flag.
*/
public void setDebug( String priority )
{
m_debug = priority;
}
/**
* Set the option jar file extensions directory anchor.
*/
public void setAnchor( File anchor )
{
m_anchor = anchor;
}
/**
* Set the deployment policy.
*/
public void setDeploy( boolean value )
{
m_execute = value;
}
/**
* Set the deployment policy.
*/
public void setInfo( boolean value )
{
m_info = value;
}
//-----------------------------------------------------
// implementation
//-----------------------------------------------------
/**
* Get the target jar file as a URL
* @return the target url
*/
private URL getTarget() throws Exception
{
return m_target.toURL();
}
/**
* Get the repository directory file.
* @return the repository directory
*/
private File getRepositoryDirectory()
{
return m_repository;
}
/**
* Get the configuration source as a URL
* @return the config url
*/
private URL getConfigurationURL() throws Exception
{
if( m_conf != null )
{
if( m_conf.exists() ) return m_conf.toURL();
}
return null;
}
/**
* The intival of time to wait before shutting down the kernel.
*/
public int getWait() // not used
{
return m_wait;
}
/**
* Get the kernel source as a URL or null if not declared.
* @return the kernel url
*/
private URL getKernelURL() throws Exception
{
if( m_kernel != null )
{
if( m_kernel.exists() ) return m_kernel.toURL();
}
return null;
}
/**
* Get the base directory.
* @return the base directory
*/
private File getHomeDirectory()
{
return m_home;
}
/**
* Return the execute mode flag.
* @return the flag
*/
public boolean getExecuteFlag( )
{
return m_execute;
}
/**
* Return the optional extensions anchor directory.
* @return the flag
*/
public File getAnchorDirectory()
{
return m_anchor;
}
/**
* Return the debug flag.
* @return the flag
*/
public boolean getInfoFlag()
{
return m_info;
}
/**
* Return the debug flag.
* @return the flag
*/
public boolean getDebugFlag()
{
return m_debug.equalsIgnoreCase( "true" );
}
/**
* Establish the merlin kernel.
*/
public void doExecute() throws Exception
{
DefaultKernelContext context = null;
try
{
Repository repository = new DefaultFileRepository( m_repository );
context =
new DefaultKernelContext(
repository,
getRepositoryDirectory(),
getAnchorDirectory(),
getHomeDirectory(),
getKernelURL(),
new URL[]{ getTarget() },
getConfigurationURL(),
getExecuteFlag(),
getInfoFlag(),
getDebugFlag()
);
}
catch( Throwable e )
{
final String error =
"Could not establish the kernel context.";
String message = ExceptionHelper.packException( error, e );
System.err.println( message );
throw new KernelException( message, e );
}
Kernel kernel = null;
try
{
kernel = new DefaultKernel( context );
setShutdownHook( kernel );
}
catch( Throwable e )
{
final String error =
"Could not establish the kernel.";
String message = ExceptionHelper.packException( error, e );
System.err.println( message );
throw new KernelException( message, e );
}
try
{
kernel.startup();
}
catch( Throwable e )
{
final String error =
"Kernel startup failure.";
String message = ExceptionHelper.packException( error, e );
System.err.println( message );
throw new KernelException( message, e );
}
}
/**
* Create a shutdown hook that will trigger shutdown of the supplied kernel.
* @param kernel the kernel to be shutdown
*/
private void setShutdownHook( final Kernel kernel )
{
//
// Create a shutdown hook to trigger clean disposal of the
// Merlin kernel
//
Runtime.getRuntime().addShutdownHook(
new Thread()
{
public void run()
{
try
{
kernel.shutdown();
}
catch( Throwable e )
{
// ignore it
}
}
}
);
}
}
1.1 avalon-sandbox/kernel/plugin/xdocs/goals.xml
Index: goals.xml
===================================================================
<?xml version="1.0"?>
<document>
<properties>
<title>Merlin Plug-in Goals</title>
<author email="[EMAIL PROTECTED]">Stephen McConnell</author>
</properties>
<body>
<goals>
<goal>
<name>merlin:meta</name>
<description>
Generates meta info descriptors for service and component types
based on javadoc tags within the java source files. Source files
are scanned for the presence of an @avalon.version tag and if
present, a meta descriptor is generated. If the version tag is
within an interface defintion, a new Service defintion is created
otherwise a Type defintion is created.
Meta info generation process includes:
<ul>
<li>Scan source files for avalon.version tag</li>
<li>Build Type and Service descriptors</li>
<li>Externalize descriptors to serial or xml format</li>
</ul>
</description>
</goal>
</goals>
</body>
</document>
1.1 avalon-sandbox/kernel/plugin/xdocs/navigation.xml
Index: navigation.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project name="Merlin Plugin">
<title>Merlin Plugin</title>
<body>
<links>
<item href="http://jakarta.apache.org/turbine/maven/" name="Maven">
</item>
</links>
<menu name="Overview">
<item href="/goals.html" name="Goals">
</item>
<item href="/properties.html" name="Properties">
</item>
</menu>
</body>
</project>
1.1 avalon-sandbox/kernel/plugin/xdocs/properties.xml
Index: properties.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<properties>
<title>Merlin Plugin Properties</title>
<author email="[EMAIL PROTECTED]">Stephen McConnell</author>
</properties>
<body>
<section name="Merlin Plugin Settings">
<table>
<tr>
<th>Property name</th>
<th>Optional?</th>
<th>Description</th>
</tr>
<tr>
<td>merlin.meta.format</td>
<td>Yes</td>
<td>
<p>Output format specification. Valid values include 'xml' or 'serial'.
The xml value instructs the meta generator to create meta descriptions
in an XML format whereas the 'serial' value generates a serialized
description of the descriptor. Serial format is more efficient. The
XML format is more portable.</p>
</td>
</tr>
<tr>
<td>merlin.meta.force</td>
<td>Yes</td>
<td>
<p>Policy controlling the regeneration of meta descriptors independently
of the descriptor data. This value default to false. </p>
</td>
</tr>
</table>
</section>
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]