Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1947 - in development/laboratory/plus: . acme acme/src acme/src/main acme/src/main/acme test tools tools/part tools/part/src tools/part/src/main tools/part/src/main/net tools/part/src/main/net/dpml tools/part/src/main/net/dpml/metro tools/part/src/main/net/dpml/metro/tools

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: r1947 - in development/laboratory/plus: . acme acme/src acme/src/main acme/src/main/acme test tools tools/part tools/part/src tools/part/src/main tools/part/src/main/net tools/part/src/main/net/dpml tools/part/src/main/net/dpml/metro tools/part/src/main/net/dpml/metro/tools
  • Date: Fri, 04 Mar 2005 09:45:55 +0100

Author: mcconnell
Date: Fri Mar 4 09:45:55 2005
New Revision: 1947

Added:
development/laboratory/plus/
development/laboratory/plus/acme/
development/laboratory/plus/acme/build.xml
development/laboratory/plus/acme/src/
development/laboratory/plus/acme/src/main/
development/laboratory/plus/acme/src/main/acme/
development/laboratory/plus/acme/src/main/acme/WidgetComponent.java
development/laboratory/plus/acme/src/main/acme/antlib.xml
development/laboratory/plus/build.xml
development/laboratory/plus/index.xml
development/laboratory/plus/test/
development/laboratory/plus/test/build.xml
development/laboratory/plus/tools/
development/laboratory/plus/tools/part/
development/laboratory/plus/tools/part/build.xml
development/laboratory/plus/tools/part/src/
development/laboratory/plus/tools/part/src/main/
development/laboratory/plus/tools/part/src/main/net/
development/laboratory/plus/tools/part/src/main/net/dpml/
development/laboratory/plus/tools/part/src/main/net/dpml/metro/
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/

development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/ComponentTask.java

development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/Part.java

development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/PartTask.java

development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/Parts.java

development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/antlib.xml
Log:
Add the inital content dealing with custom component type handling at the
build file level.

Added: development/laboratory/plus/acme/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/acme/build.xml Fri Mar 4 09:45:55 2005
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="acme-component-builder" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="package" depends="standard.package">
+ <x:export>
+ <antlib resource="acme/antlib.xml"
urn="plugin:acme/acme-component-builder"/>
+ </x:export>
+ </target>
+
+</project>
+

Added: development/laboratory/plus/acme/src/main/acme/WidgetComponent.java
==============================================================================
--- (empty file)
+++ development/laboratory/plus/acme/src/main/acme/WidgetComponent.java Fri
Mar 4 09:45:55 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2005 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 acme;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import net.dpml.metro.tools.Part;
+
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * The DPML component buildtime handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class WidgetComponent extends ProjectComponent implements Part
+{
+ /**
+ * Part preparation.
+ */
+ public void prepare( Part parent ) throws BuildException
+ {
+ log( "initization with parent: " + parent );
+ }
+
+ public String toString()
+ {
+ return "[class:" + getClass().getName()
+ + ":" + System.identityHashCode( Part.class );
+ }
+}

Added: development/laboratory/plus/acme/src/main/acme/antlib.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/acme/src/main/acme/antlib.xml Fri Mar 4
09:45:55 2005
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+
+<antlib>
+ <typedef name="widget" classname="acme.WidgetComponent"/>
+</antlib>
\ No newline at end of file

Added: development/laboratory/plus/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/build.xml Fri Mar 4 09:45:55 2005
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-plus" default="default" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core"
+ xmlns:m="plugin:dpml/metro/dpml-metro-tools">
+
+ <transit:import uri="artifact:template:dpml/magic/reactor"/>
+
+</project>
+

Added: development/laboratory/plus/index.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/index.xml Fri Mar 4 09:45:55 2005
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Copyright 2004 Stephen J McConnell
+ Copyright 2004 Niclas Hedhman
+
+ 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.
+-->
+
+
+<index>
+
+ <import uri="artifact:module:dpml/magic/dpml-magic#SNAPSHOT"/>
+
+ <project basedir="tools/part">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-tools-part</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-transit-tools"/>
+ <include key="ant"/>
+ </dependencies>
+ </project>
+
+ <project basedir="acme">
+ <info>
+ <group>acme</group>
+ <name>acme-component-builder</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-tools-part"/>
+ </dependencies>
+ </project>
+
+ <project basedir="test">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-tools-part-test</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-tools-part"/>
+ <include key="acme-component-builder"/>
+ </dependencies>
+ </project>
+
+</index>

Added: development/laboratory/plus/test/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/test/build.xml Fri Mar 4 09:45:55 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-tools-part-test" default="test" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core"
+ xmlns:m="plugin:dpml/metro/dpml-metro-tools">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:property name="acme.uri" feature="plugin"
key="acme-component-builder"/>
+ <x:property name="metro.tools" feature="plugin" key="dpml-tools-part"/>
+ <transit:plugin uri="${metro.tools}"/>
+ </target>
+
+ <target name="test" depends="standard.test">
+ <m:component>
+ <parts>
+ <part/>
+ <widget xmlns="${acme.uri}"/>
+ </parts>
+ </m:component>
+ </target>
+
+</project>
+

Added: development/laboratory/plus/tools/part/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/tools/part/build.xml Fri Mar 4 09:45:55
2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-tools-part" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core"
+ xmlns:m="plugin:dpml/metro/dpml-metro-tools">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="package" depends="standard.package">
+ <x:export>
+ <antlib resource="net/dpml/metro/tools/antlib.xml"
urn="plugin:dpml/metro/dpml-metro-tools"/>
+ </x:export>
+ </target>
+
+</project>
+

Added:
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/ComponentTask.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/ComponentTask.java
Fri Mar 4 09:45:55 2005
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2005 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.metro.tools;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * The DPML component buildtime handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ComponentTask extends PartTask
+{
+ private Parts m_parts;
+
+ /**
+ * Load the resource and assign the locally cached file path to the
supplied property name.
+ * @exception BuildException if an error occurs during resource resolution
+ */
+ public void execute() throws BuildException
+ {
+ log( "executing: " + this );
+ prepare( this );
+ }
+
+ /**
+ * Task initialization.
+ */
+ public void prepare( Part parent ) throws BuildException
+ {
+ log( "initization with parent: " + parent );
+ Part[] parts = m_parts.getParts();
+ for( int i=0; i<parts.length; i++ )
+ {
+ Part part = parts[i];
+ part.prepare( this );
+ }
+ }
+
+ public Parts createParts()
+ {
+ if( null == m_parts )
+ {
+ m_parts = new Parts( this );
+ }
+ return m_parts;
+ }
+
+}

Added:
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/Part.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/Part.java
Fri Mar 4 09:45:55 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2005 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.metro.tools;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * The task does something but I'm not sure what just yet.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Part
+{
+ public void setProject( Project project );
+
+ /**
+ * Request the part to execute the preparation phase.
+ */
+ void prepare( Part parent );
+
+
+}

Added:
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/PartTask.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/PartTask.java
Fri Mar 4 09:45:55 2005
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2005 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.metro.tools;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * The task does something but I'm not sure what just yet.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class PartTask extends Task implements Part
+{
+ private Part m_parent;
+
+ /**
+ * Request the part to execute the preparation phase.
+ */
+ public void prepare( Part parent )
+ {
+ m_parent = parent;
+ setTaskName( "part" );
+ log( "parent: " + m_parent );
+ }
+
+ /**
+ * Task initialization.
+ */
+ public void init() throws BuildException
+ {
+ super.init();
+ }
+
+ /**
+ * Load the resource and assign the locally cached file path to the
supplied property name.
+ * @exception BuildException if an error occurs during resource resolution
+ */
+ public void execute() throws BuildException
+ {
+ log( "executing: " + this );
+ }
+}

Added:
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/Parts.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/Parts.java
Fri Mar 4 09:45:55 2005
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2005 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.metro.tools;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.DynamicElementNS;
+import org.apache.tools.ant.taskdefs.Sequential;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Location;
+
+/**
+ * The task is a container of parts.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class Parts extends ProjectComponent implements DynamicElementNS
+{
+ private List m_parts = new LinkedList();
+ private Task m_owner;
+
+ public Parts( Task owner )
+ {
+ m_owner = owner;
+ }
+
+ /**
+ * Operation used to construct a custom part type directive.
+ * @param uri the part handler uri
+ * @param name the element name
+ * @param qualified the qualified name
+ */
+ public Object createDynamicElement( String uri, String name, String
qualified )
+ {
+ String path = getProject().replaceProperties( uri );
+ return loadPartHandler( path, name );
+ }
+
+ private Part loadPartHandler( String uri, String name ) throws
BuildException
+ {
+ String urn = uri + ":" + name;
+
+ Object part = null;
+ String target = m_owner.getOwningTarget().getName();
+ Location location = m_owner.getLocation();
+ ClassLoader context = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(
Parts.class.getClassLoader() );
+ part = getProject().createDataType( urn );
+ return (Part) part;
+ }
+ catch( ClassCastException e )
+ {
+ final String error =
+ "The custom part handler ["
+ + part.getClass().getName()
+ + "] established by the uri ["
+ + urn
+ + "] declared by the element <"
+ + name
+ + "> under the task <"
+ + m_owner.getTaskName()
+ + "><parts> within the target <"
+ + target
+ + "> does not implement the net.dpml.metro.tools.Part
interface.";
+ throw new BuildException( error, e, location );
+ }
+ catch( BuildException e )
+ {
+ final String error =
+ "Unable to load the plugin from the uri ["
+ + urn
+ + "] to handle the custom part type declared by the element <"
+ + name
+ + "> within <"
+ + m_owner.getTaskName()
+ + "><parts> under the target <"
+ + target
+ + ">.";
+ throw new BuildException( error, e, location );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected exception while attempting to load the custom part
handler with the uri ["
+ + urn
+ + "] declared by the element <"
+ + name
+ + "> within <"
+ + m_owner.getTaskName()
+ + "><parts> under the target <"
+ + target
+ + ">.";
+ throw new BuildException( error, e, location );
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( context );
+ }
+ }
+
+ /**
+ * Add a standard part to the container.
+ * @param the part to add
+ */
+ public void addPart( PartTask part )
+ {
+ m_parts.add( part );
+ System.out.println( "adding part: " + part );
+ part.setProject( getProject() );
+ part.init();
+ }
+
+ /**
+ * Return the set of parts contained within this container.
+ * @return the contained parts
+ */
+ public Part[] getParts()
+ {
+ return (Part[]) m_parts.toArray( new Part[0] );
+ }
+
+}

Added:
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/antlib.xml
==============================================================================
--- (empty file)
+++
development/laboratory/plus/tools/part/src/main/net/dpml/metro/tools/antlib.xml
Fri Mar 4 09:45:55 2005
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+
+<antlib>
+ <typedef name="part" classname="net.dpml.metro.tools.PartTask"/>
+ <taskdef name="component" classname="net.dpml.metro.tools.ComponentTask"/>
+</antlib>
\ No newline at end of file



  • svn commit: r1947 - in development/laboratory/plus: . acme acme/src acme/src/main acme/src/main/acme test tools tools/part tools/part/src tools/part/src/main tools/part/src/main/net tools/part/src/main/net/dpml tools/part/src/main/net/dpml/metro tools/part/src/main/net/dpml/metro/tools, mcconnell, 03/04/2005

Archive powered by MHonArc 2.6.24.

Top of Page