Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1156 - in development/main: magic/core/etc/deliverables/templates magic/spells/example metro/private metro/tools metro/tools/main/src/main/net/dpml/metro transit transit/task/src/main/net/dpml/transit/task util

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1156 - in development/main: magic/core/etc/deliverables/templates magic/spells/example metro/private metro/tools metro/tools/main/src/main/net/dpml/metro transit transit/task/src/main/net/dpml/transit/task util
  • Date: Fri, 10 Dec 2004 18:48:07 +0100

Author: mcconnell
Date: Fri Dec 10 18:48:07 2004
New Revision: 1156

Modified:
development/main/magic/core/etc/deliverables/templates/reactor.xml
development/main/magic/core/etc/deliverables/templates/standard.xml
development/main/magic/spells/example/build.xml
development/main/metro/private/module.xml
development/main/metro/tools/main/src/main/net/dpml/metro/Metro.java
development/main/metro/tools/module.xml
development/main/transit/module.xml
development/main/transit/task/src/main/net/dpml/transit/task/MainTask.java

development/main/transit/task/src/main/net/dpml/transit/task/PluginManager.java

development/main/transit/task/src/main/net/dpml/transit/task/TransitComponentHelper.java
development/main/util/build.xml
development/main/util/module.xml
Log:
This commit is basically dealing with the complexities of Ant's static
management of the ComponentHelper and the rather nasty way that the ant task
deals with creation of a new component helper of sub-projects which
effectivly drops a custom ComponentHelper. Commit also includes some
enhancements to the Metro cli main class to generate version info in the same
format as Transit and the addition of commons-cli javadoc links to the tools
and transit modules.

Modified: development/main/magic/core/etc/deliverables/templates/reactor.xml
==============================================================================
--- development/main/magic/core/etc/deliverables/templates/reactor.xml
(original)
+++ development/main/magic/core/etc/deliverables/templates/reactor.xml Fri
Dec 10 18:48:07 2004
@@ -18,39 +18,37 @@

<project name="reactor"
xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="antlib:net.dpml.magic" >
+ xmlns:x="antlib:net.dpml.magic">

- <import file="setup.xml"/>
-
- <target name="init" depends="setup">
- <x:reactor target="info"/>
+ <target name="init">
+ <x:reactor target="init"/>
</target>

- <target name="clean" depends="setup">
+ <target name="clean">
<x:reactor target="clean"/>
</target>

- <target name="prepare" depends="setup">
+ <target name="prepare">
<x:reactor target="prepare"/>
</target>

- <target name="build" depends="setup">
+ <target name="build">
<x:reactor target="build"/>
</target>

- <target name="package" depends="setup">
+ <target name="package">
<x:reactor target="package"/>
</target>

- <target name="test" depends="setup">
+ <target name="test">
<x:reactor target="test"/>
</target>

- <target name="install" depends="setup">
+ <target name="install">
<x:reactor target="install"/>
</target>

- <target name="default" depends="setup">
+ <target name="default">
<x:reactor/>
</target>


Modified: development/main/magic/core/etc/deliverables/templates/standard.xml
==============================================================================
--- development/main/magic/core/etc/deliverables/templates/standard.xml
(original)
+++ development/main/magic/core/etc/deliverables/templates/standard.xml Fri
Dec 10 18:48:07 2004
@@ -18,11 +18,9 @@

<project name="standard"
xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="antlib:net.dpml.magic" >
+ xmlns:x="antlib:net.dpml.magic">

- <import file="setup.xml"/>
-
- <target name="info" depends="setup">
+ <target name="info">
<x:info/>
</target>


Modified: development/main/magic/spells/example/build.xml
==============================================================================
--- development/main/magic/spells/example/build.xml (original)
+++ development/main/magic/spells/example/build.xml Fri Dec 10 18:48:07
2004
@@ -6,7 +6,7 @@
<transit:init/>
<import file="${dpml.templates}/standard.xml"/>

- <target name="prepare" depends="standard.prepare">
+ <target name="init" depends="standard.init">
<x:filter feature="path" token="MESSAGE"/>
</target>


Modified: development/main/metro/private/module.xml
==============================================================================
--- development/main/metro/private/module.xml (original)
+++ development/main/metro/private/module.xml Fri Dec 10 18:48:07 2004
@@ -18,6 +18,7 @@
<target name="docs" depends="install">
<x:javadoc>
<link href="http://java.sun.com/j2se/1.4/docs/api"/>
+ <link href="http://www.dpml.net/commons-cli/api/1.0"/>
<group title="Activation API">
<package name="net.dpml.activation"/>
<package name="net.dpml.activation.*"/>

Modified: development/main/metro/tools/main/src/main/net/dpml/metro/Metro.java
==============================================================================
--- development/main/metro/tools/main/src/main/net/dpml/metro/Metro.java
(original)
+++ development/main/metro/tools/main/src/main/net/dpml/metro/Metro.java
Fri Dec 10 18:48:07 2004
@@ -368,9 +368,9 @@
private void handleVersionMessage( Plugin descriptor )
{
System.out.println(
- "\nMetro: "
+ "\n Metro: "
+ descriptor.getURI()
- + "\nBuild: " + descriptor.getBuild()
+ + "\n Build: " + descriptor.getBuild()
+ "\n" );
}


Modified: development/main/metro/tools/module.xml
==============================================================================
--- development/main/metro/tools/module.xml (original)
+++ development/main/metro/tools/module.xml Fri Dec 10 18:48:07 2004
@@ -15,6 +15,7 @@
<link href="http://java.sun.com/j2se/1.4/docs/api"/>
<link href="http://www.dpml.net/asf/ant/1.6.2/api"/>
<link href="http://www.dpml.net/junit/junit/3.8.1/api"/>
+ <link href="http://www.dpml.net/commons-cli/api/1.0"/>
</x:javadoc>
</target>


Modified: development/main/transit/module.xml
==============================================================================
--- development/main/transit/module.xml (original)
+++ development/main/transit/module.xml Fri Dec 10 18:48:07 2004
@@ -43,6 +43,7 @@
<x:javadoc overview="overview.html">
<link href="http://java.sun.com/j2se/1.4/docs/api"/>
<link href="http://www.dpml.net/asf/ant/1.6.2/api"/>
+ <link href="http://www.dpml.net/commons-cli/api/1.0"/>
<group title="Transit Main Protocol">
<package name="net.dpml.transit"/>
<package name="net.dpml.transit.adapter"/>

Modified:
development/main/transit/task/src/main/net/dpml/transit/task/MainTask.java
==============================================================================
---
development/main/transit/task/src/main/net/dpml/transit/task/MainTask.java
(original)
+++
development/main/transit/task/src/main/net/dpml/transit/task/MainTask.java
Fri Dec 10 18:48:07 2004
@@ -22,6 +22,7 @@

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ComponentHelper;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;

import net.dpml.transit.Transit;
@@ -113,6 +114,20 @@
// Task
//
------------------------------------------------------------------------

+ public void setProject( Project project )
+ {
+ super.setProject( project );
+ if( !init )
+ {
+ setTaskName( "transit" );
+ setupMonitors();
+ File home = Transit.HOME;
+ log( "home: " + home.getAbsolutePath() );
+ TransitComponentHelper.getComponentHelper( project );
+ init = true;
+ }
+ }
+
/**
* Initialization of the task during which a singleton reference to the
TRANSIT
* sub-system is establish.
@@ -121,12 +136,6 @@
public void init()
throws BuildException
{
- if( !init )
- {
- setTaskName( "transit" );
- setupMonitors();
- init = true;
- }
}

/**
@@ -146,17 +155,26 @@
public void execute() throws BuildException
{
File home = Transit.HOME;
- log( "home: " + home.getAbsolutePath() );
File templates = new File( home, "templates" );
File docs = new File( home, "docs" );
File cache = new File( home, "main" );
- getProject().setNewProperty( "dpml.home", home.toString() );
- getProject().setNewProperty( "dpml.templates", templates.toString()
);
- getProject().setNewProperty( "dpml.docs", docs.toString() );
- getProject().setNewProperty( "dpml.cache", cache.toString() );
-
- setupTransitComponentHelper();
+ updateProperty( "dpml.home", home.getAbsolutePath() );
+ updateProperty( "dpml.templates", templates.getAbsolutePath() );
+ updateProperty( "dpml.docs", docs.getAbsolutePath() );
+ updateProperty( "dpml.cache", cache.getAbsolutePath() );
+ }

+ private void updateProperty( String key, String value )
+ {
+ String v = getProject().getProperty( key );
+ if( null == v )
+ {
+ getProject().setProperty( key, value );
+ }
+ else if( !v.equals( value ) )
+ {
+ getProject().setNewProperty( key, value );
+ }
}

/**
@@ -172,19 +190,5 @@
TRANSIT.getNetworkMonitorRouter().addMonitor(
new NetworkMonitorAdapter( adapter ) );
}
-
- private void setupTransitComponentHelper()
- {
- ComponentHelper current = (ComponentHelper)
getProject().getReference( "ant.ComponentHelper" );
- if( current instanceof TransitComponentHelper )
- {
- return;
- }
- ComponentHelper componentHelper = new TransitComponentHelper();
- componentHelper.setProject( getProject() );
- componentHelper.initDefaultDefinitions();
- getProject().addReference( "ant.ComponentHelper", componentHelper );
- }
-
}


Modified:
development/main/transit/task/src/main/net/dpml/transit/task/PluginManager.java
==============================================================================
---
development/main/transit/task/src/main/net/dpml/transit/task/PluginManager.java
(original)
+++
development/main/transit/task/src/main/net/dpml/transit/task/PluginManager.java
Fri Dec 10 18:48:07 2004
@@ -66,17 +66,14 @@

public void buildFinished( BuildEvent event )
{
- //To change body of implemented methods use File | Settings | File
Templates.
}

public void targetStarted( BuildEvent event )
{
- //To change body of implemented methods use File | Settings | File
Templates.
}

public void targetFinished( BuildEvent event )
{
- //To change body of implemented methods use File | Settings | File
Templates.
}

public void taskStarted( BuildEvent event )
@@ -96,12 +93,6 @@
Project project = event.getProject();

//
- // register the custom ComponentHelper
- //
-
- setupTransitComponentHelper( project );
-
- //
// handle target addition
//

@@ -139,19 +130,6 @@
}
}

- private void setupTransitComponentHelper( Project project )
- {
- ComponentHelper current = (ComponentHelper) project.getReference(
"ant.ComponentHelper" );
- if( ( null != current ) && ( current instanceof
TransitComponentHelper) )
- {
- return;
- }
- ComponentHelper componentHelper = new TransitComponentHelper();
- componentHelper.setProject( project );
- componentHelper.initDefaultDefinitions();
- project.addReference( "ant.ComponentHelper", componentHelper );
- }
-
private ArrayList readPluginNames( Project project, String type )
{
File pluginFile = new File( m_MagicDir, type + ".type" );

Modified:
development/main/transit/task/src/main/net/dpml/transit/task/TransitComponentHelper.java
==============================================================================
---
development/main/transit/task/src/main/net/dpml/transit/task/TransitComponentHelper.java
(original)
+++
development/main/transit/task/src/main/net/dpml/transit/task/TransitComponentHelper.java
Fri Dec 10 18:48:07 2004
@@ -37,6 +37,8 @@
import org.apache.tools.ant.input.DefaultInputHandler;
import org.apache.tools.ant.ComponentHelper;
import org.apache.tools.ant.AntTypeDefinition;
+import org.apache.tools.ant.SubBuildListener;
+import org.apache.tools.ant.BuildEvent;

import org.w3c.dom.Element;

@@ -48,17 +50,23 @@
* @author <a href="mailto:dev@dpmlnet";>Stephen J. McConnell</a>
* @version $Id: Metro.java 916 2004-11-25 12:15:17Z niclas AT apache.org $
*/
-public class TransitComponentHelper extends ComponentHelper
+public class TransitComponentHelper extends ComponentHelper
+ implements SubBuildListener
{
- /**
- * Vector of plugin uris already loaded.
- */
- private Vector m_uris = new Vector();
+ //------------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------------

/**
- * The current project.
+ * Creation of a component helper for the supplied project.
+ *
+ * @param project the project
+ * @return the project component for a specific project
*/
- private Project m_project;
+ public static ComponentHelper getComponentHelper( Project project )
+ {
+ return getComponentHelper( project, false );
+ }

/**
* Creation of a component helper for the supplied project.
@@ -66,16 +74,66 @@
* @param project the project
* @return the project component for a specific project
*/
- public static ComponentHelper getComponentHelper(Project project)
+ public static ComponentHelper getComponentHelper( Project project,
boolean flag )
{
-System.out.println( "#getting project helper for: " + project.getName() );
- ComponentHelper helper = new TransitComponentHelper();
- helper.setProject( project );
+ ComponentHelper current =
+ (ComponentHelper) project.getReference( "ant.ComponentHelper" );
+ if( ( null != current ) && ( current instanceof
TransitComponentHelper) )
+ {
+ return current;
+ }
+ TransitComponentHelper helper = new TransitComponentHelper( project,
current );
+ helper.initDefaultDefinitions();
+ if( flag )
+ {
+ project.log(
+ "\nAssigning Transit component helper to sub-project: "
+ + project.getBaseDir() );
+ }
+ else
+ {
+ project.log( "\nAssigning Transit component helper" );
+ }
project.addReference( "ant.ComponentHelper", helper );
+ project.addBuildListener( helper );
return helper;
}

/**
+ * Vector of plugin uris already loaded.
+ */
+ private static Vector m_uris = new Vector();
+
+
+ //------------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------------
+
+ /**
+ * The current project.
+ */
+ private Project m_project;
+
+ /**
+ * The parent component helper.
+ */
+ private ComponentHelper m_parent;
+
+ //------------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------------
+
+ public TransitComponentHelper( Project project, ComponentHelper parent )
+ {
+ setProject( project );
+ m_parent = parent;
+ }
+
+ //------------------------------------------------------------------------
+ // implementation
+ //------------------------------------------------------------------------
+
+ /**
* Set the current project.
* @param project the current ant project
*/
@@ -87,51 +145,92 @@

/**
* Create an object for a component using a supplied name. The name
- * is the fully qualified component name which allws us to intercept
+ * is the fully qualified component name which allows us to intercept
* specific namespace qualifiers - in this case 'plugin:'. In the event
of
* a plugin namespace we check to see if the plugin for that name is
already
* loaded and it not we proceed with classic transit-based loading of the
* plugin and registration of plugin classes with the component helper.
*
- * @param componentName the name of the component, if
- * the component is in a namespace, the
- * name is prefixed with the namespace uri and ":"
+ * @param name the name of the component, if the component is in a
namespace, the
+ * name is prefixed with the namespace uri and ":"
* @return the class if found or null if not.
*/
public Object createComponent( String name )
{
- checkNamespace( name );
- return super.createComponent( name );
+ int k = name.lastIndexOf( ":" );
+ if( k > 0 )
+ {
+ String urn = name.substring( 0, k );
+ String task = name.substring( k+1 );
+
+ URI uri = convertUrnToURI( urn );
+ if( null == uri )
+ {
+ return super.createComponent( name );
+ }
+ else
+ {
+ if( m_parent != null )
+ {
+ Object object = m_parent.createComponent( name );
+ if( null != object )
+ {
+ return object;
+ }
+ }
+ String alias = installPlugin( uri, urn, task );
+ return super.createComponent( name );
+ }
+ }
+ else
+ {
+ return super.createComponent( name );
+ }
+ }
+
+ /**
+ * Convert a urn to a uri taking into account possible urn alias names.
+ * TODO: turn this inot a parameteizable namespace to artifact map.
+ *
+ * @param urn the urn to convert to a uri
+ */
+ private URI convertUrnToURI( String urn )
+ {
+ if( urn.startsWith( "artifact:meta:" ) )
+ {
+ return convertToURI( urn );
+ }
+ else if( urn.equals( "antlib:net.dpml.magic" ) )
+ {
+ return convertToURI(
"artifact:meta:dpml/magic/dpml-magic-core#SNAPSHOT" );
+ }
+ else
+ {
+ return null;
+ }
}

/**
- * Check is the name stats with 'plugin:' and if load if required. The
- * implementation will retireve the plugin descriptor. If the descriptor
+ * The implementation will retrieve the plugin descriptor. If the
descriptor
* declares a classname then the class will be loaded and assigned under
* name. If the classname is undefined and resource is defined, the
- * implementation will attempt to locate an antlib defintion at the
resource
+ * implementation will attempt to locate an antlib definition at the
resource
* location and will attempt to load all taskdef and typedef entries
declared
* in the antlib.
*
- * @param name the component name
+ * @param uri the plugin uri
+ * @param name the fully qualified component name
*/
- private void checkNamespace( String name )
+ private String installPlugin( URI uri, String urn, String name )
{
- if( !name.startsWith( "plugin:" ) )
+ if( m_uris.contains( uri ) )
{
- return;
+ return uri.toString() + ":" + name;
}

- String urn = name.substring( 0, name.lastIndexOf( ":" ) );
try
{
- String spec = "artifact:meta:" + urn.substring( 7 );
- URI uri = new URI( spec );
-
- if( m_uris.contains( uri ) )
- {
- return;
- }
+ m_project.log( "installing plugin: " + urn );

StandardLoader loader = new StandardLoader();
Plugin descriptor = loader.getPluginDescriptor( uri );
@@ -140,7 +239,7 @@
if( null != descriptor.getClassname() )
{
Class clazz = classloader.loadClass(
descriptor.getClassname() );
- super.addTaskDefinition( name, clazz );
+ super.addTaskDefinition( uri + ":" + name, clazz );
}
else
{
@@ -171,11 +270,13 @@
}

m_uris.add( uri );
+
+ return uri.toString() + ":" + name;
}
catch( Throwable e )
{
final String error =
- "Could not load plugin: " + name;
+ "Could not load plugin: " + uri;
throw new BuildException( error, e );
}
}
@@ -189,5 +290,90 @@
return m_project;
}

+ /**
+ * Return the plugin uri by resolving the string form the beggining of
the name
+ * to the last occurance of ":". The content following the ":" is used by
ant for
+ * the actual task name. We use the string preceeding the name to hold
the
+ * artifact uri.
+ *
+ * @param name the fully qualified task name
+ * @return the plugin uri
+ * @exception BuildException if a convertion error occurs
+ */
+ private URI getURI( String name ) throws BuildException
+ {
+ String urn = name.substring( 0, name.lastIndexOf( ":" ) );
+ if( name.startsWith( "artifact:meta:" ) )
+ {
+ return convertToURI( urn );
+ }
+ else
+ {
+ String spec = "artifact:meta:" + urn.substring( 7 );
+ return convertToURI( spec );
+ }
+ }
+
+ /**
+ * Convert a urn to a url wrapping any errors in a build exception.
+ * @param urn the urn
+ * @return the uri
+ * @exception BuildException if a convertion error occurs
+ */
+ private URI convertToURI( String urn ) throws BuildException
+ {
+ try
+ {
+ return new URI( urn );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to convert the urn ["
+ + urn
+ + "] to a uri.";
+ throw new BuildException( error, e );
+ }
+ }
+
+ public void buildStarted( BuildEvent event )
+ throws BuildException
+ {
+ getComponentHelper( event.getProject(), false );
+ }
+
+ public void subBuildStarted( BuildEvent event )
+ {
+ getComponentHelper( event.getProject(), true );
+ }
+
+ public void subBuildFinished( BuildEvent event )
+ {
+ }
+
+ public void buildFinished( BuildEvent event )
+ {
+ }
+
+ public void targetStarted( BuildEvent event )
+ {
+ }
+
+ public void targetFinished( BuildEvent event )
+ {
+ }
+
+ public void taskStarted( BuildEvent event )
+ {
+ }
+
+ public void taskFinished( BuildEvent event )
+ {
+ }
+
+ public void messageLogged( BuildEvent event )
+ {
+ }
+
}


Modified: development/main/util/build.xml
==============================================================================
--- development/main/util/build.xml (original)
+++ development/main/util/build.xml Fri Dec 10 18:48:07 2004
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>

<project name="dpml-util" default="default" basedir="."
- xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+ xmlns:transit="antlib:net.dpml.transit" >

<transit:init/>
<import file="${dpml.templates}/reactor.xml"/>

+
</project>

Modified: development/main/util/module.xml
==============================================================================
--- development/main/util/module.xml (original)
+++ development/main/util/module.xml Fri Dec 10 18:48:07 2004
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>

-<project name="dpml-util" default="build" basedir="."
- xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+<project name="dpml-util" default="docs" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="antlib:net.dpml.magic" >

<transit:init/>

<import file="${dpml.templates}/standard.xml"/>
- <import file="${dpml.templates}/checkstyle/checkstyle.xml"
optional="true"/>
+ <!--<import file="${dpml.templates}/checkstyle/checkstyle.xml"
optional="true"/>-->

<target name="build" depends="standard.build">
<x:module index="index.xml"/>



  • svn commit: r1156 - in development/main: magic/core/etc/deliverables/templates magic/spells/example metro/private metro/tools metro/tools/main/src/main/net/dpml/metro transit transit/task/src/main/net/dpml/transit/task util, mcconnell, 12/10/2004

Archive powered by MHonArc 2.6.24.

Top of Page