Skip to Content.
Sympa Menu

notify-dpml - r1125 - in trunk/main: depot/library/common/src/main/net/dpml/library depot/library/common/src/main/net/dpml/library/impl depot/library/common/src/main/net/dpml/library/info depot/library/common/src/main/net/dpml/library/model depot/library/common/src/main/net/dpml/library/util depot/library/common/src/test/net/dpml/library/impl depot/library/common/src/test/net/dpml/library/info depot/tools/builder/etc/deliverables/plugins depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks metro metro/builder metro/builder/etc metro/builder/etc/main metro/builder/etc/main/net metro/builder/etc/main/net/dpml metro/builder/etc/main/net/dpml/metro metro/builder/src metro/builder/src/main metro/builder/src/main/net metro/builder/src/main/net/dpml metro/builder/src/main/net/dpml/metro metro/builder/src/main/net/dpml/metro/builder metro/model/src/main/net/dpml/metro/data metro/model/src/test/net/dpml/metro/data/test metro/runtime/src/mai! n/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools planet/http planet/http/server planet/http/server/etc planet/http/server/etc/plugin transit/console/src/main/net/dpml/transit/console transit/core transit/core/etc/prefs transit/core/etc/prefs/xmls transit/core/src/main/net/dpml/lang transit/core/src/main/net/dpml/transit transit/core/src/main/net/dpml/transit/artifact transit/core/src/main/net/dpml/transit/info transit/core/src/main/net/dpml/transit/util transit/core/src/test/net/dpml transit/core/src/test/net/dpml/lang transit/core/src/test/net/dpml/lang/test transit/core/src/test/net/dpml/transit transit/core/src/test/net/dpml/transit/info transit/tools/src/main/net/dpml/transit transit/tools/src/main/net/dpml/transit/tools

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1125 - in trunk/main: depot/library/common/src/main/net/dpml/library depot/library/common/src/main/net/dpml/library/impl depot/library/common/src/main/net/dpml/library/info depot/library/common/src/main/net/dpml/library/model depot/library/common/src/main/net/dpml/library/util depot/library/common/src/test/net/dpml/library/impl depot/library/common/src/test/net/dpml/library/info depot/tools/builder/etc/deliverables/plugins depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks metro metro/builder metro/builder/etc metro/builder/etc/main metro/builder/etc/main/net metro/builder/etc/main/net/dpml metro/builder/etc/main/net/dpml/metro metro/builder/src metro/builder/src/main metro/builder/src/main/net metro/builder/src/main/net/dpml metro/builder/src/main/net/dpml/metro metro/builder/src/main/net/dpml/metro/builder metro/model/src/main/net/dpml/metro/data metro/model/src/test/net/dpml/metro/data/test metro/runtime/src/mai! n/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools planet/http planet/http/server planet/http/server/etc planet/http/server/etc/plugin transit/console/src/main/net/dpml/transit/console transit/core transit/core/etc/prefs transit/core/etc/prefs/xmls transit/core/src/main/net/dpml/lang transit/core/src/main/net/dpml/transit transit/core/src/main/net/dpml/transit/artifact transit/core/src/main/net/dpml/transit/info transit/core/src/main/net/dpml/transit/util transit/core/src/test/net/dpml transit/core/src/test/net/dpml/lang transit/core/src/test/net/dpml/lang/test transit/core/src/test/net/dpml/transit transit/core/src/test/net/dpml/transit/info transit/tools/src/main/net/dpml/transit transit/tools/src/main/net/dpml/transit/tools
  • Date: Wed, 22 Feb 2006 20:37:00 +0100

Author: mcconnell
Date: 2006-02-22 20:36:10 +0100 (Wed, 22 Feb 2006)
New Revision: 1125

Added:
trunk/main/depot/library/common/src/main/net/dpml/library/util/

trunk/main/depot/library/common/src/main/net/dpml/library/util/DefaultPluginFactory.java

trunk/main/depot/library/common/src/main/net/dpml/library/util/PluginFactory.java
trunk/main/depot/library/common/src/main/net/dpml/library/util/package.html
trunk/main/metro/builder/
trunk/main/metro/builder/etc/
trunk/main/metro/builder/etc/main/
trunk/main/metro/builder/etc/main/net/
trunk/main/metro/builder/etc/main/net/dpml/
trunk/main/metro/builder/etc/main/net/dpml/metro/
trunk/main/metro/builder/etc/main/net/dpml/metro/component_1_0.dtd
trunk/main/metro/builder/src/
trunk/main/metro/builder/src/main/
trunk/main/metro/builder/src/main/net/
trunk/main/metro/builder/src/main/net/dpml/
trunk/main/metro/builder/src/main/net/dpml/metro/
trunk/main/metro/builder/src/main/net/dpml/metro/builder/

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginHelper.java
trunk/main/planet/http/server/etc/
trunk/main/planet/http/server/etc/plugin/
trunk/main/planet/http/server/etc/plugin/definition.xml
trunk/main/transit/core/etc/prefs/xmls/
trunk/main/transit/core/etc/prefs/xmls/standard.xml
trunk/main/transit/core/src/main/net/dpml/lang/Category.java
trunk/main/transit/core/src/main/net/dpml/lang/CategoryBeanInfo.java
trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
trunk/main/transit/core/src/main/net/dpml/lang/DTD.java
trunk/main/transit/core/src/main/net/dpml/lang/DTDResolver.java
trunk/main/transit/core/src/main/net/dpml/lang/DefaultClasspath.java
trunk/main/transit/core/src/main/net/dpml/lang/DefaultPlugin.java
trunk/main/transit/core/src/main/net/dpml/lang/DefaultPluginHelper.java
trunk/main/transit/core/src/main/net/dpml/lang/DefaultStrategy.java
trunk/main/transit/core/src/main/net/dpml/lang/Handler.java
trunk/main/transit/core/src/main/net/dpml/lang/Plugin.java
trunk/main/transit/core/src/main/net/dpml/lang/PluginBuilder.java
trunk/main/transit/core/src/main/net/dpml/lang/PluginHelper.java
trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
trunk/main/transit/core/src/main/net/dpml/lang/Version.java
trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java
trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
trunk/main/transit/core/src/test/net/dpml/lang/
trunk/main/transit/core/src/test/net/dpml/lang/test/
trunk/main/transit/core/src/test/net/dpml/lang/test/PluginTestCase.java
Removed:

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PluginExportTask.java
trunk/main/transit/core/src/main/net/dpml/lang/info/
trunk/main/transit/core/src/main/net/dpml/transit/Category.java
trunk/main/transit/core/src/main/net/dpml/transit/CategoryBeanInfo.java
trunk/main/transit/core/src/main/net/dpml/transit/Plugin.java
trunk/main/transit/core/src/main/net/dpml/transit/PropertiesPlugin.java

trunk/main/transit/core/src/main/net/dpml/transit/info/CacheDirectiveBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/info/CodeBaseDirectiveBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/info/ContentDirectiveBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirectiveBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/info/LayoutDirectiveBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/info/ProxyDirectiveBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/info/TransitDirectiveBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferences.java

trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesBeanInfo.java

trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesFactory.java

trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java

trunk/main/transit/tools/src/main/net/dpml/transit/tools/PreferencesTask.java
Modified:

trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultDictionary.java

trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultModule.java

trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java

trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java

trunk/main/depot/library/common/src/main/net/dpml/library/info/DependencyDirective.java

trunk/main/depot/library/common/src/main/net/dpml/library/info/IncludeDirective.java

trunk/main/depot/library/common/src/main/net/dpml/library/model/Dictionary.java

trunk/main/depot/library/common/src/main/net/dpml/library/model/Resource.java

trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultLibraryTestCase.java

trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java

trunk/main/depot/library/common/src/test/net/dpml/library/info/IncludeDirectiveTestCase.java
trunk/main/depot/tools/builder/etc/deliverables/plugins/project.plugin

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/antlib.xml
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
trunk/main/metro/module.xml

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/CompositionClassLoader.java

trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
trunk/main/planet/http/module.xml

trunk/main/transit/console/src/main/net/dpml/transit/console/TransitConsoleHandler.java
trunk/main/transit/core/build.xml
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java
trunk/main/transit/core/src/main/net/dpml/transit/Repository.java
trunk/main/transit/core/src/main/net/dpml/transit/StandardClassLoader.java
trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
trunk/main/transit/core/src/main/net/dpml/transit/SystemClassLoader.java

trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirective.java
trunk/main/transit/core/src/main/net/dpml/transit/util/ElementHelper.java

trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
trunk/main/transit/tools/src/main/net/dpml/transit/antlib.xml

trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java

trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
Log:
move the plugin and transit data models to DTD-based XML definitions


Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultDictionary.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultDictionary.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultDictionary.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -85,6 +85,15 @@
}

/**
+ * Return the local property names associated with the dictionary.
+ * @return the array of local property names
+ */
+ public String[] getLocalPropertyNames()
+ {
+ return getLocalPropertyNames( m_directive.getProperties() );
+ }
+
+ /**
* Return a property value.
* @param key the property key
* @return the property value

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultModule.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultModule.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultModule.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -37,7 +37,7 @@
import net.dpml.library.model.ResourceNotFoundException;
import net.dpml.library.model.ModuleNotFoundException;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;


/**

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -42,7 +42,7 @@
import net.dpml.library.info.Scope;

import net.dpml.transit.Artifact;
-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* Implementation of a resource.

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -41,7 +41,7 @@
import net.dpml.library.info.Scope;

import net.dpml.transit.util.ElementHelper;
-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

import org.w3c.dom.Element;


Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/info/DependencyDirective.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/info/DependencyDirective.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/info/DependencyDirective.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -22,7 +22,7 @@
import java.util.Properties;
import java.util.ArrayList;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* The ModuleDirective class describes a module data-structure.

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/info/IncludeDirective.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/info/IncludeDirective.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/info/IncludeDirective.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -25,7 +25,7 @@
import java.beans.Encoder;
import java.util.Properties;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;
import net.dpml.lang.Enum;

/**

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/model/Dictionary.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/model/Dictionary.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/model/Dictionary.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -33,6 +33,12 @@
String[] getPropertyNames();

/**
+ * Return the local property names associated with the dictionary.
+ * @return the array of local property names
+ */
+ String[] getLocalPropertyNames();
+
+ /**
* Return a property value.
* @param key the property key
* @return the property value

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/model/Resource.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/model/Resource.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/model/Resource.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -24,7 +24,7 @@
import net.dpml.library.info.ResourceDirective.Classifier;

import net.dpml.transit.Artifact;
-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* The Resource interface describes infomation about a published resource.

Added:
trunk/main/depot/library/common/src/main/net/dpml/library/util/DefaultPluginFactory.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/util/DefaultPluginFactory.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/util/DefaultPluginFactory.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2006 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.library.util;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Properties;
+import java.util.ArrayList;
+import java.io.IOException;
+import java.io.File;
+
+import net.dpml.library.model.Type;
+import net.dpml.library.model.Resource;
+
+import net.dpml.lang.Plugin;
+import net.dpml.lang.DefaultPlugin;
+import net.dpml.lang.Strategy;
+import net.dpml.lang.Category;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.DefaultClasspath;
+import net.dpml.lang.DefaultStrategy;
+
+import net.dpml.transit.Artifact;
+
+/**
+ * Interface implemented by plugins that provide plugin building
functionality.
+ * Implementations that load plugin factoryies must supply the target
Resource
+ * as a plugin constructor argument. Factory implementation shall construct
+ * plugin defintions using the supplied resource as the reference for the
+ * classpath dependencies. Suppliementary properties may be aquired using
+ * the Type returned from the Resource.getType( "plugin" ) operation.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DefaultPluginFactory implements PluginFactory
+{
+ /**
+ * Constant artifact type for a plugin.
+ */
+ public static final String TYPE = "plugin";
+
+ /**
+ * Property key used to identify the plugin title.
+ */
+ public static final String PLUGIN_TITLE_KEY = "project.plugin.title";
+
+ /**
+ * Property key used to identify the plugin description.
+ */
+ public static final String PLUGIN_DESCRIPTION_KEY =
"project.plugin.description";
+
+ /**
+ * Property key used to identify a custom plugin handler classname.
+ */
+ public static final String PLUGIN_HANDLER_KEY = "project.plugin.handler";
+
+ /**
+ * Default runtime plugin handler classname.
+ */
+ public static final String STANDARD_PLUGIN_HANDLER =
"net.dpml.transit.StandardHandler";
+
+ /**
+ * Build the plugin definition.
+ * @exception exception if a build related error occurs
+ */
+ public Plugin build( File dir, Resource resource ) throws Exception
+ {
+ URI uri = getPluginURI( resource );
+ String title = getTitle( resource );
+ String description = getDescription( resource );
+ Strategy strategy = getStrategy( dir, resource );
+ Classpath classpath = getClasspath( resource );
+ return new DefaultPlugin(
+ title, description, uri, strategy, classpath );
+ }
+
+ protected URI getPluginURI( Resource resource ) throws Exception
+ {
+ Artifact artifact = resource.getArtifact( TYPE );
+ return artifact.toURI();
+ }
+
+ protected String getTitle( Resource resource )
+ {
+ Type type = resource.getType( TYPE );
+ return type.getProperty( PLUGIN_TITLE_KEY );
+ }
+
+ protected String getDescription( Resource resource )
+ {
+ Type type = resource.getType( TYPE );
+ return type.getProperty( PLUGIN_DESCRIPTION_KEY );
+ }
+
+ protected Classpath getClasspath( Resource resource ) throws IOException
+ {
+ URI[] sysUris = getURIs( resource, Category.SYSTEM );
+ URI[] publicUris = getURIs( resource, Category.PUBLIC );
+ URI[] protectedUris = getURIs( resource, Category.PROTECTED );
+ URI[] privateUris = getURIs( resource, Category.PRIVATE, true );
+ return new DefaultClasspath( sysUris, publicUris, protectedUris,
privateUris );
+ }
+
+ protected Strategy getStrategy( File dir, Resource resource )
+ {
+ Type type = resource.getType( TYPE );
+ Properties properties = getProperties( type );
+ String handler = type.getProperty(
+ PLUGIN_HANDLER_KEY,
+ STANDARD_PLUGIN_HANDLER );
+ return new DefaultStrategy( handler, properties );
+ }
+
+ private URI[] getURIs( Resource resource, Category category ) throws
IOException
+ {
+ return getURIs( resource, category, false );
+ }
+
+ private URI[] getURIs( Resource resource, Category category, boolean
self ) throws IOException
+ {
+ Resource[] resources = resource.getClasspathProviders( category );
+ ArrayList list = new ArrayList();
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource r = resources[i];
+ addURI( list, r );
+ }
+ if( self )
+ {
+ addURI( list, resource );
+ }
+ URI[] uris = (URI[]) list.toArray( new URI[0] );
+ return uris;
+ }
+
+ private void addURI( List list, Resource resource ) throws IOException
+ {
+ if( resource.isa( "jar" ) )
+ {
+ try
+ {
+ Artifact artifact = resource.getArtifact( "jar" );
+ URI uri = artifact.toURI();
+ list.add( uri );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while attempting to resolve resource.";
+ IOException ioe = new IOException( error );
+ ioe.initCause( e );
+ throw ioe;
+ }
+ }
+ }
+
+ private Properties getProperties( Type type )
+ {
+ Properties properties = new Properties();
+ String[] keys = type.getLocalPropertyNames();
+ for( int i=0; i<keys.length; i++ )
+ {
+ String key = keys[i];
+ if( !PLUGIN_HANDLER_KEY.equals( key ) )
+ {
+ String value = type.getProperty( key );
+ properties.setProperty( key, value );
+ }
+ }
+ return properties;
+ }
+}

Added:
trunk/main/depot/library/common/src/main/net/dpml/library/util/PluginFactory.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/util/PluginFactory.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/util/PluginFactory.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 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.library.util;
+
+import java.io.File;
+
+import net.dpml.lang.Plugin;
+
+import net.dpml.library.model.Resource;
+
+/**
+ * Interface implemented by plugins that provide plugin building
functionality.
+ * Implementations that load plugin factoryies must supply the target
Resource
+ * as a plugin constructor argument. Factory implementation shall construct
+ * plugin defintions using the supplied resource as the reference for the
+ * classpath dependencies. Suppliementary properties may be aquired using
+ * the Type returned from the Resource.getType( "plugin" ) operation.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface PluginFactory
+{
+ /**
+ * Build the plugin definition.
+ * @exception exception if a build related error occurs
+ */
+ Plugin build( File basedir, Resource resource ) throws Exception;
+}

Added:
trunk/main/depot/library/common/src/main/net/dpml/library/util/package.html
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/util/package.html
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/util/package.html
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,8 @@
+
+<body>
+
+<p>
+Utility classes related to plugin factories.
+</p>
+
+</body>

Modified:
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultLibraryTestCase.java
===================================================================
---
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultLibraryTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultLibraryTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -168,6 +168,15 @@
}

/**
+ * Return the type local property names.
+ * @return the names
+ */
+ public String[] getLocalPropertyNames()
+ {
+ return new String[0];
+ }
+
+ /**
* Return a named property value.
* @param key the property key (ignored)
* @return the value (allays returns null in mock)

Modified:
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java
===================================================================
---
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -25,7 +25,7 @@
import net.dpml.library.info.Scope;

import net.dpml.transit.Artifact;
-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* Testing the DefaultResource implementation.

Modified:
trunk/main/depot/library/common/src/test/net/dpml/library/info/IncludeDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/common/src/test/net/dpml/library/info/IncludeDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/library/common/src/test/net/dpml/library/info/IncludeDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -18,7 +18,7 @@

package net.dpml.library.info;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* The IncludeDirective class describes a the inclusion of a typed value.

Modified:
trunk/main/depot/tools/builder/etc/deliverables/plugins/project.plugin
===================================================================
--- trunk/main/depot/tools/builder/etc/deliverables/plugins/project.plugin
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/depot/tools/builder/etc/deliverables/plugins/project.plugin
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,41 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE plugin PUBLIC "-//DPML/Plugin DTD Version 1.0//EN"
"http://www.dpml.net/dtds/plugin_1_0.dtd"; >

-#
-# Specification classifier.
-#
-dpml.plugin.meta.namespace = net.dpml
-dpml.plugin.meta.version = 1.0
+<plugin version="1.0.0">
+ <strategy class="net.dpml.transit.StandardHandler">
+ <property name="project.plugin.class" value="@PLUGIN-CLASS@"/>
+ </strategy>
+ <classpath>
+ <system>
+ <uri>artifact:jar:ant/ant-launcher#@ANT-VERSION@</uri>
+ <uri>artifact:jar:ant/ant#@ANT-VERSION@</uri>
+ <uri>artifact:jar:junit/junit#@JUNIT-VERSION@</uri>
+ <uri>artifact:jar:ant/ant-junit#@ANT-VERSION@</uri>
+ <uri>artifact:jar:ant/ant-xslp#@ANT-VERSION@</uri>
+ <uri>artifact:jar:ant/ant-trax#@ANT-VERSION@</uri>
+ </system>
+ <private>
+
<uri>artifact:jar:dpml/transit/dpml-transit-main#@PROJECT-VERSION@</uri>
+
<uri>artifact:jar:dpml/transit/dpml-transit-tools#@PROJECT-VERSION@</uri>
+ <uri>artifact:jar:dpml/depot/dpml-library-main#@PROJECT-VERSION@</uri>
+
<uri>artifact:jar:@PROJECT-GROUP@/@PROJECT-NAME@#@PROJECT-VERSION@</uri>
+ </private>
+ </classpath>
+</plugin>

-#
-# Artifact descriptor.
-#
-dpml.artifact.group = @PROJECT-GROUP@
-dpml.artifact.name = @PROJECT-NAME@
-dpml.artifact.version = @PROJECT-VERSION@
-dpml.artifact.signature = 00000000.000000
-
-#
-# Type.
-#
-dpml.plugin.class = @PLUGIN-CLASS@
-
-#
-# System dependencies.
-#
-dpml.artifact.dependency.sys.0 = artifact:jar:ant/ant-launcher#@ANT-VERSION@
-dpml.artifact.dependency.sys.1 = artifact:jar:ant/ant#@ANT-VERSION@
-dpml.artifact.dependency.sys.2 = artifact:jar:junit/junit#@JUNIT-VERSION@
-dpml.artifact.dependency.sys.3 = artifact:jar:ant/ant-junit#@ANT-VERSION@
-dpml.artifact.dependency.sys.4 = artifact:jar:ant/ant-xslp#@ANT-VERSION@
-dpml.artifact.dependency.sys.5 = artifact:jar:ant/ant-trax#@ANT-VERSION@
-
-#
-# Private.
-#
-dpml.artifact.dependency.0 =
artifact:jar:dpml/transit/dpml-transit-main#@PROJECT-VERSION@
-dpml.artifact.dependency.1 =
artifact:jar:dpml/transit/dpml-transit-tools#@PROJECT-VERSION@
-dpml.artifact.dependency.2 =
artifact:jar:dpml/depot/dpml-library-main#@PROJECT-VERSION@
-dpml.artifact.dependency.3 =
artifact:jar:@PROJECT-GROUP@/@PROJECT-NAME@#@PROJECT-VERSION@
-
-#
-# EOF.
-#

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -77,14 +77,18 @@
else if( "package".equals( name ) )
{
Project project = event.getProject();
- final JarTask task = new JarTask();
- task.setProject( project );
- task.setTaskName( "jar" );
- task.setSrc( new File( project.getProperty(
"project.target.classes.main.dir" ) ) );
- final File jar = getJarFile( project );
- task.setDest( jar );
- task.init();
- task.execute();
+ File jarSrcDir = new File( project.getProperty(
"project.target.classes.main.dir" ) );
+ if( jarSrcDir.exists() )
+ {
+ final JarTask task = new JarTask();
+ task.setProject( project );
+ task.setTaskName( "jar" );
+ task.setSrc( jarSrcDir );
+ final File jar = getJarFile( project );
+ task.setDest( jar );
+ task.init();
+ task.execute();
+ }
}
else if( "test".equals( name ) )
{
@@ -95,7 +99,10 @@
{
final File jar = getJarFile( project );
Path testCompilePath = context.getPath( Scope.TEST );
- testCompilePath.createPathElement().setLocation( jar );
+ if( jar.exists() )
+ {
+ testCompilePath.createPathElement().setLocation( jar );
+ }
final File dest = new File( project.getProperty(
"project.target.classes.test.dir" ) );
try
{

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -18,11 +18,28 @@

package net.dpml.tools.process;

-import net.dpml.tools.tasks.PluginExportTask;
+import java.io.File;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;

+import net.dpml.lang.Plugin;
+import net.dpml.transit.Transit;
+
+import net.dpml.library.info.Scope;
+import net.dpml.library.model.Resource;
+import net.dpml.library.model.Type;
+import net.dpml.library.util.PluginFactory;
+import net.dpml.library.util.DefaultPluginFactory;
+
+import net.dpml.tools.tasks.GenericTask;
+import net.dpml.tools.model.Context;
+
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildException;

/**
* Execute all plugins relative to the current build phase.
@@ -33,7 +50,7 @@
public class PluginProcess extends AbstractBuildListener
{
/**
- * Signals that a target is starting.
+ * Signals that a target is finished.
*
* @param event An event with any relevant extra information.
* Must not be <code>null</code>.
@@ -46,12 +63,113 @@
String name = target.getName();
if( "build".equals( name ) )
{
- Project project = event.getProject();
- final PluginExportTask task = new PluginExportTask();
- task.setProject( project );
- task.setTaskName( "export" );
- task.init();
- task.execute();
+ try
+ {
+ Project project = event.getProject();
+ final Context context = getContext( project );
+ Resource resource = context.getResource();
+ final String path = context.getLayoutPath( TYPE );
+ final File targetDir = context.getTargetDirectory();
+
+ PluginFactory factory = getPluginFactory( resource );
+ Plugin plugin = factory.build( targetDir, resource );
+
+ // extenalize the plugin to XML
+
+ final File deliverables =
context.getTargetDeliverablesDirectory();
+ final File plugins = new File( deliverables, "plugins" );
+ final File file = new File( plugins, path );
+ plugins.mkdirs();
+ file.createNewFile();
+ final OutputStream output = new FileOutputStream( file );
+
+ try
+ {
+ plugin.write( output );
+ }
+ finally
+ {
+ try
+ {
+ output.close();
+ }
+ catch( IOException e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ // md5 and asc
+
+ GenericTask task = new GenericTask();
+ task.setProject( project );
+ task.setTaskName( "plugin" );
+ task.init();
+ task.checksum( file );
+ task.asc( file );
+
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "An error occured during the creation of the plugin
descriptor.";
+ throw new BuildException( error, e );
+ }
}
}
+
+ private PluginFactory getPluginFactory( Resource resource ) throws
Exception
+ {
+ Type type = resource.getType( TYPE );
+ String spec = type.getProperty( "project.plugin.factory" );
+ if( null == spec )
+ {
+ return new DefaultPluginFactory();
+ }
+ else
+ {
+ URI uri = new URI( spec );
+ ClassLoader classloader = Resource.class.getClassLoader();
+ Object[] args = new Object[0];
+ Object instance =
+ Transit.getInstance().getRepository().getPlugin( classloader,
uri, args );
+ if( instance instanceof PluginFactory )
+ {
+ return (PluginFactory) instance;
+ }
+ else
+ {
+ final String error =
+ "Artifact ["
+ + spec
+ + "] assigned as the plugin factory established an
instance of ["
+ + instance.getClass().getName()
+ + "] which is assignable to the "
+ + PluginFactory.class.getName()
+ + " interface.";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ }
+
+ /**
+ * Get the project definition.
+ * @param project the project
+ * @return the build context
+ */
+ protected Context getContext( Project project )
+ {
+ Context context = (Context) project.getReference( "project.context"
);
+ if( null == context )
+ {
+ final String error =
+ "Missing project context reference.";
+ throw new BuildException( error );
+ }
+ context.getPath( Scope.TEST ); // triggers path initialization
+ return context;
+ }
+
+ private static final String TYPE = "plugin";
+
}

Deleted:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PluginExportTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PluginExportTask.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PluginExportTask.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,541 +0,0 @@
-/*
- * Copyright 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.tools.tasks;
-
-import java.io.File;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.Writer;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import net.dpml.library.info.Scope;
-import net.dpml.library.model.Resource;
-
-import net.dpml.tools.model.Context;
-
-import net.dpml.transit.Artifact;
-import net.dpml.transit.Category;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildException;
-
-/**
- * Generates an module as an exportable artifact.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PluginExportTask extends GenericTask
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- /**
- * The constant namespace key.
- */
- public static final String NAMESPACE = "net.dpml";
-
- /**
- * The constant version key.
- */
- public static final String VERSION = "1.0";
-
- /**
- * The constant plugin class key.
- */
- public static final String CLASS_KEY = "dpml.plugin.class";
-
- /**
- * The constant plugin export key.
- */
- public static final String EXPORT_KEY = "dpml.plugin.export";
-
- /**
- * The constant resource key.
- */
- public static final String RESOURCE_KEY = "dpml.plugin.resource";
-
- /**
- * The constant urn key.
- */
- public static final String URN_KEY = "dpml.plugin.urn";
-
- /**
- * The constant group key.
- */
- public static final String ARTIFACT_GROUP = "dpml.artifact.group";
-
- /**
- * The constant name key.
- */
- public static final String ARTIFACT_NAME = "dpml.artifact.name";
-
- /**
- * The constant artifact version key.
- */
- public static final String ARTIFACT_VERSION = "dpml.artifact.version";
-
- /**
- * The constant artifact signature key.
- */
- public static final String ARTIFACT_SIGNATURE =
"dpml.artifact.signature";
-
- /**
- * The constant artifact api dependency key.
- */
- public static final String ARTIFACT_SYSTEM =
"dpml.artifact.dependency.sys";
-
- /**
- * The constant artifact api dependency key.
- */
- public static final String ARTIFACT_PUBLIC =
"dpml.artifact.dependency.api";
-
- /**
- * The constant artifact spi dependency key.
- */
- public static final String ARTIFACT_PROTECTED =
"dpml.artifact.dependency.spi";
-
- /**
- * The constant artifact impl dependency key.
- */
- public static final String ARTIFACT_PRIVATE = "dpml.artifact.dependency";
-
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private String m_class;
- private Antlib m_antlib;
-
- //
------------------------------------------------------------------------
- // implementation
- //
------------------------------------------------------------------------
-
- /**
- * Task initialization.
- */
- public void init()
- {
- if( !isInitialized() )
- {
- super.init();
- getContext().getPath( Scope.TEST );
- }
- }
-
- /**
- * Set the plugin classname.
- * @param type the classname
- */
- public void setClass( String type )
- {
- m_class = type;
- }
-
- /**
- * Construct a new antlib defintion.
- * @return the antlib definition
- */
- public Antlib createAntlib()
- {
- if( null == m_antlib )
- {
- m_antlib = new Antlib();
- return m_antlib;
- }
- else
- {
- final String error =
- "Multiple antlib elements not allowed.";
- throw new BuildException( error );
- }
- }
-
- /**
- * Task execution.
- */
- public void execute()
- {
- Project project = getProject();
- if( ( null == getClassname() ) && ( null == getAntlib() ) )
- {
- final String error =
- "Either the class attribute or nested antlib element must be
declared.";
- log( "Plugin creation failure. " );
- throw new BuildException( error );
- }
-
- final Context context = getContext();
- final String path = context.getLayoutPath( "plugin" );
- final File deliverables = context.getTargetDeliverablesDirectory();
- final File plugins = new File( deliverables, "plugins" );
- final File plugin = new File( plugins, path );
- writePluginFile( plugin );
- }
-
- private String getClassname()
- {
- if( null != m_class )
- {
- return m_class;
- }
- else
- {
- return getResource().getType( "plugin" ).getProperty(
"project.plugin.class", null );
- }
- }
-
- private Antlib getAntlib()
- {
- if( null != m_antlib )
- {
- return m_antlib;
- }
- else
- {
- String res = getResource().getType( "plugin" ).getProperty(
"project.plugin.resource", null );
- String urn = getResource().getType( "plugin" ).getProperty(
"project.plugin.urn", null );
- if( ( null != res ) && ( null != urn ) )
- {
- Antlib antlib = new Antlib();
- antlib.setResource( res );
- antlib.setUrn( urn );
- m_antlib = antlib;
- return antlib;
- }
- else
- {
- return null;
- }
- }
- }
-
- private void writePluginFile( final File file )
- {
- //if( file.exists() && ( getDefinition().getLastModified() <
file.lastModified() ) )
- //{
- // log( "Plugin directive is up-to-date.", Project.MSG_VERBOSE );
- // return;
- //}
- //else
-
- if( !file.exists() )
- {
- log( "Creating plugin directive" );
- }
- else
- {
- log( "Updating plugin directive" );
- }
-
- try
- {
- mkDir( file.getParentFile() );
- file.createNewFile();
- final OutputStream output = new FileOutputStream( file );
- try
- {
- writePluginDescriptor( output, file );
- }
- finally
- {
- closeStream( output );
- }
- checksum( file );
- asc( file );
- }
- catch( Throwable e )
- {
- throw new BuildException( e );
- }
- }
-
- private void writePluginDescriptor( final OutputStream output, final
File file )
- throws Exception
- {
- final Writer writer = new OutputStreamWriter( output );
- writeHeader( writer );
- writeDescriptor( writer, file );
- writeProperties( writer );
- writeClasspath( writer );
- writeTail( writer );
- writer.flush();
- }
-
- /**
- * Write the properties header.
- * @param writer the writer
- * @throws IOException if unable to write xml
- */
- private void writeHeader( final Writer writer )
- throws IOException
- {
- writer.write( "\n#" );
- writer.write( "\n# Specification classifier." );
- writer.write( "\n#" );
- writer.write( "\ndpml.plugin.meta.namespace = " + NAMESPACE );
- writer.write( "\ndpml.plugin.meta.version = " + VERSION );
- }
-
- /**
- * Write the artifact descriptor.
- * @param writer the writer
- * @throws IOException if unable to write xml
- */
- private void writeDescriptor(
- final Writer writer, final File file )
- throws IOException
- {
- writer.write( "\n" );
- writer.write( "\n#" );
- writer.write( "\n# Artifact descriptor." );
- writer.write( "\n#" );
- writer.write( "\n" + ARTIFACT_GROUP + " = " +
getResource().getParent().getResourcePath() );
- writer.write( "\n" + ARTIFACT_NAME + " = " +
getResource().getName() );
- writer.write( "\n" + ARTIFACT_VERSION + " = " +
getResource().getVersion() );
- writer.write( "\n" + ARTIFACT_SIGNATURE + " = " + getSignature( file
) );
- }
-
-
- private String getSignature( final File file )
- {
- if( !file.exists() )
- {
- final String error =
- "Cannot create artifact descriptor due to missing resource: "
- + file;
- throw new BuildException( error );
- }
- final Date created = new Date( file.lastModified() );
- return getSignature( created );
- }
-
- private void writeClasspath( final Writer writer )
- throws Exception
- {
- Resource[] systemResources = getResource().getClasspathProviders(
Category.SYSTEM );
- if( systemResources.length > 0 )
- {
- final String label = "System dependencies.";
- final String lead = ARTIFACT_SYSTEM;
- writeRefs( writer, systemResources, lead, label );
- }
-
- Resource[] apiResources = getResource().getClasspathProviders(
Category.PUBLIC );
- if( apiResources.length > 0 )
- {
- final String label = "Public.";
- final String lead = ARTIFACT_PUBLIC;
- writeRefs( writer, apiResources, lead, label );
- }
-
- Resource[] spiResources = getResource().getClasspathProviders(
Category.PROTECTED );
- if( spiResources.length > 0 )
- {
- final String label = "Protected.";
- final String lead = ARTIFACT_PROTECTED;
- writeRefs( writer, spiResources, lead, label );
- }
-
- Resource[] implResources = getResource().getClasspathProviders(
Category.PRIVATE );
- Resource[] resources = new Resource[ implResources.length + 1 ];
- for( int i=0; i<implResources.length; i++ )
- {
- resources[i] = implResources[i];
- }
- resources[ implResources.length ] = getResource();
- final String label = "Private.";
- final String lead = ARTIFACT_PRIVATE;
- writeRefs( writer, resources, lead, label );
- }
-
- private int writeRefs(
- final Writer writer, final Resource[] refs, final String lead, String
label )
- throws IOException
- {
- writer.write( "\n" );
- writer.write( "\n#" );
- writer.write( "\n# " + label );
- writer.write( "\n#" );
- for( int i=0; i < refs.length; i++ )
- {
- final Resource resource = refs[i];
- writeResource( writer, resource, lead, i );
- }
- return refs.length;
- }
-
- private void writeResource(
- final Writer writer, final Resource resource, final String lead, int i
)
- throws IOException
- {
- writer.write( "\n" );
- writer.write( lead );
- writer.write( "." + i );
- writer.write( " = " );
- if( resource.isa( "jar" ) )
- {
- try
- {
- Artifact artifact = resource.getArtifact( "jar" );
- String uri = artifact.toURI().toString();
- writer.write( uri );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while attempting to write resource.";
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
- }
- }
- else
- {
- if( resource.getTypes().length == 1 )
- {
- String type = resource.getTypes()[0].getName();
- try
- {
- Artifact artifact = resource.getArtifact( type );
- String uri = artifact.toURI().toString();
- writer.write( uri );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while attempting to write resource."
- + "\nResource: " + resource;
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
- }
- }
- else
- {
- final String error =
- "Ambiguity in resource selection - the resource ["
- + resource
- + "] declares multiple types.";
- throw new IOException( error );
-
- }
- }
- }
-
- /**
- * Write the factory class.
- * @param writer the writer
- * @throws IOException if unable to write xml
- */
- private void writeProperties( final Writer writer )
- throws IOException
- {
- String classname = getClassname();
- if( classname != null )
- {
- writer.write( "\n" );
- writer.write( "\n#" );
- writer.write( "\n# Type." );
- writer.write( "\n#" );
- writer.write( "\n" + CLASS_KEY + " = " + classname );
- }
-
- if( m_antlib != null )
- {
- writer.write( "\n" );
- writer.write( "\n#" );
- writer.write( "\n# Antlib." );
- writer.write( "\n#" );
- writer.write( "\n" + RESOURCE_KEY + " = " + m_antlib.getPath() );
- writer.write( "\n" + URN_KEY + " = " + m_antlib.getURN() );
- }
-
- final String export = getProject().getProperty( EXPORT_KEY );
- if( null != export )
- {
- writer.write( "\n" );
- writer.write( "\n#" );
- writer.write( "\n# Export." );
- writer.write( "\n#" );
- writer.write( "\n" + EXPORT_KEY + " = " + export );
- }
- }
-
- /**
- * Write the tail.
- * @param writer the writer
- * @throws IOException if unable to write xml
- */
- private void writeTail( final Writer writer )
- throws IOException
- {
- writer.write( "\n" );
- writer.write( "\n#" );
- writer.write( "\n# EOF." );
- writer.write( "\n#" );
- writer.write( "\n" );
- }
-
- private void closeStream( final OutputStream output )
- {
- if( null != output )
- {
- try
- {
- output.close();
- }
- catch( IOException e )
- {
- log( e.toString() );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // static utils
- //
------------------------------------------------------------------------
-
- private static final String TYPE_ID = "plugin";
-
- /**
- * Return the UTC YYMMDD.HHMMSSS signature of a date.
- * @param date the date
- * @return the UTC date-stamp signature
- */
- public static String getSignature( final Date date )
- {
- final SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd.HHmmss"
);
- sdf.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
- return sdf.format( date );
- }
-
- /**
- * Creation of a new AntLib instance.
- */
- public static class Antlib extends
net.dpml.transit.tools.PluginTask.Antlib
- {
- }
-
-}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/antlib.xml
===================================================================
--- trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/antlib.xml
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/antlib.xml
2006-02-22 19:36:10 UTC (rev 1125)
@@ -5,7 +5,7 @@
<taskdef name="install" classname="net.dpml.tools.tasks.InstallTask"/>
<!--<taskdef name="javac"
classname="net.dpml.tools.tasks.JavacTask"/>-->
<taskdef name="jar" classname="net.dpml.tools.tasks.JarTask"/>
- <taskdef name="export"
classname="net.dpml.tools.tasks.PluginExportTask"/>
+ <!--<taskdef name="export"
classname="net.dpml.tools.tasks.PluginExportTask"/>-->
<taskdef name="junit"
classname="net.dpml.tools.tasks.JUnitTestTask"/>
<taskdef name="property"
classname="net.dpml.tools.tasks.PropertyTask"/>
<taskdef name="filter" classname="net.dpml.tools.tasks.FilterTask"/>


Property changes on: trunk/main/metro/builder
___________________________________________________________________
Name: svn:ignore
+ target


Added: trunk/main/metro/builder/etc/main/net/dpml/metro/component_1_0.dtd
===================================================================
--- trunk/main/metro/builder/etc/main/net/dpml/metro/component_1_0.dtd
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/metro/builder/etc/main/net/dpml/metro/component_1_0.dtd
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,60 @@
+<!--
+Copyright 2006 Stephen McConnell, DPML
+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.
+-->
+
+<!--
+The plugin element is the document root, it defines an instantiation
strategy and
+classloader chain.
+
+ title Plugin title.
+ description Description of the plugin.
+ strategy The plugin instantiation strategy - the strategy element
may
+ contain an arbitary number of property elements.
+ classpath the classpath presented in terms of system, public,
protected
+ and private categories. Each category may contain an
arbirary
+ number of uri elements.
+-->
+
+<!ELEMENT plugin ( title?, description?, strategy, classpath ) >
+<!ATTLIST plugin version CDATA #REQUIRED xmlns CDATA #IMPLIED >
+
+<!ELEMENT strategy ( categories?, context?, parts? ) >
+<!ATTLIST strategy type CDATA #REQUIRED >
+<!ATTLIST strategy lifestyle ( singleton | thread | transient ) "thread" >
+
+<!ELEMENT categories EMPTY >
+
+<!ELEMENT context ( entry* ) >
+<!ATTLIST context class CDATA #IMPLIED >
+
+<!ELEMENT entry ( value* ) >
+<!ATTLIST entry key CDATA #REQUIRED value CDATA #IMPLIED >
+
+<!ELEMENT parts ( component* ) >
+<!ELEMENT component ( categories?, context?, parts? ) >
+<!ATTLIST component key CDATA #REQUIRED >
+<!ATTLIST component type CDATA #REQUIRED >
+<!ATTLIST component lifestyle ( singleton | thread | transient ) "thread" >
+
+<!ELEMENT title (#PCDATA) >
+<!ELEMENT description (#PCDATA) >
+<!ELEMENT classpath ( system?, public?, protected?, private? ) >
+<!ELEMENT system ( uri* ) >
+<!ELEMENT public ( uri* ) >
+<!ELEMENT protected ( uri* ) >
+<!ELEMENT private ( uri* ) >
+<!ELEMENT uri (#PCDATA) >
+

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2006 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.builder;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Properties;
+import java.util.ArrayList;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import net.dpml.library.model.Type;
+import net.dpml.library.model.Resource;
+
+import net.dpml.lang.Plugin;
+import net.dpml.lang.DefaultPlugin;
+import net.dpml.lang.Strategy;
+import net.dpml.lang.Category;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.DefaultClasspath;
+import net.dpml.lang.DefaultPlugin;
+import net.dpml.lang.Version;
+
+import net.dpml.transit.Artifact;
+
+/**
+ * Interface implemented by plugins that provide plugin building
functionality.
+ * Implementations that load plugin factoryies must supply the target
Resource
+ * as a plugin constructor argument. Factory implementation shall construct
+ * plugin defintions using the supplied resource as the reference for the
+ * classpath dependencies. Suppliementary properties may be aquired using
+ * the Type returned from the Resource.getType( "plugin" ) operation.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ComponentPlugin extends DefaultPlugin
+{
+ private static final String NAMESPACE =
+ "link:plugin:dpml/metro/dpml-metro-builder";
+
+ private static final Version VERSION = new Version( 1, 0, 0 );
+
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+
+ private static final String NAME = "plugin";
+
+ private static final String PUBLIC_ID =
+ "-//DPML//DTD Component Plugin Version 1.0//EN";
+
+ private static final String SYSTEM_ID =
+ "http://www.dpml.net/dtds/component_1_0.dtd";;
+
+ private static final String RESOURCE =
+ "net/dpml/lang/component_1_0.dtd";
+
+ private static final String DOCTYPE =
+ "\n<!DOCTYPE "
+ + NAME
+ + " PUBLIC \""
+ + PUBLIC_ID
+ + "\" \""
+ + SYSTEM_ID
+ + "\" >";
+
+ /**
+ * Creation of a new plugin definition.
+ * @param title short title
+ * @param description textual description
+ * @param uri the uri from which the plugin was resolved
+ * @param strategy the plugin instantiation strategy definition
+ * @param classpath the classpath definition
+ */
+ public ComponentPlugin(
+ String title, String description, URI uri, Strategy strategy,
Classpath classpath )
+ {
+ super( title, description, uri, strategy, classpath );
+ }
+
+ /**
+ * Write an XML representation of the plugin to the output stream.
+ * @param output the output stream
+ * @exception Exception if an error ocucrs during externalization
+ */
+ public void write( OutputStream output ) throws Exception
+ {
+ final Writer writer = new OutputStreamWriter( output );
+ writer.write( XML_HEADER );
+ writer.write( DOCTYPE );
+ writeHeader( writer, NAME, NAMESPACE, VERSION );
+ writeTitle( writer, getTitle() );
+ writeDescription( writer, getDescription() );
+ writeStrategy( writer, getStrategy() );
+ writeClasspath( writer, getClasspath() );
+ writeFooter( writer, NAME );
+ writer.write( "\n" );
+ writer.flush();
+ writer.close();
+ }
+
+ protected void writeStrategy( Writer writer, Strategy strategy ) throws
Exception
+ {
+ //
+ // TODO: cast strategy to a ComponentStragety and fill in details
+ //
+
+ String handler = strategy.getHandlerClassname();
+ Properties properties = strategy.getProperties();
+ String[] keys = (String[]) properties.keySet().toArray( new
String[0] );
+ writer.write( "\n <strategy class=\"" + handler + "\">" );
+ for( int i=0; i<keys.length; i++ )
+ {
+ String key = keys[i];
+ String value = properties.getProperty( key );
+ writer.write(
+ "\n <property name=\""
+ + key
+ + "\" value=\""
+ + value
+ + "\"/>" );
+ }
+ writer.write( "\n </strategy>" );
+ }
+}

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2006 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.builder;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Properties;
+import java.util.ArrayList;
+import java.io.IOException;
+import java.io.File;
+
+import net.dpml.library.model.Type;
+import net.dpml.library.model.Resource;
+
+import net.dpml.lang.Plugin;
+import net.dpml.lang.DefaultPlugin;
+import net.dpml.lang.Strategy;
+import net.dpml.lang.Category;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.DefaultClasspath;
+
+import net.dpml.transit.Artifact;
+
+import net.dpml.library.util.DefaultPluginFactory;
+
+/**
+ * Interface implemented by plugins that provide plugin building
functionality.
+ * Implementations that load plugin factoryies must supply the target
Resource
+ * as a plugin constructor argument. Factory implementation shall construct
+ * plugin defintions using the supplied resource as the reference for the
+ * classpath dependencies. Suppliementary properties may be aquired using
+ * the Type returned from the Resource.getType( "plugin" ) operation.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ComponentPluginFactory extends DefaultPluginFactory
+{
+ /**
+ * Build the plugin definition.
+ * @exception exception if a build related error occurs
+ */
+ public Plugin build( File dir, Resource resource ) throws Exception
+ {
+ URI uri = getPluginURI( resource );
+ String title = getTitle( resource );
+ String description = getDescription( resource );
+ Strategy strategy = getStrategy( dir, resource );
+ Classpath classpath = getClasspath( resource );
+ return new ComponentPlugin(
+ title, description, uri, strategy, classpath );
+ }
+
+ protected Strategy getStrategy( File dir, Resource resource )
+ {
+ Type type = resource.getType( "plugin" );
+ String source = type.getProperty( "project.plugin.srcfile",
"plugin/definition.xml" );
+ File src = new File( dir, source );
+ if( src.exists() )
+ {
+ System.out.println( "## WE HAVE A DEFINITION: " + src );
+ return super.getStrategy( dir, resource );
+ }
+ else
+ {
+ System.out.println( "## NO DEFINITION: " + src );
+ return super.getStrategy( dir, resource );
+ }
+ }
+}

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginHelper.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginHelper.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginHelper.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2006 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.builder;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import net.dpml.library.util.PluginFactory;
+import net.dpml.library.model.Resource;
+
+import net.dpml.lang.DefaultPluginHelper;
+import net.dpml.lang.Version;
+import net.dpml.lang.Plugin;
+
+import net.dpml.transit.util.ElementHelper;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+
+/**
+ * Utility class supporting the reading and writing of standard plugins
definitions.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ComponentPluginHelper extends DefaultPluginHelper implements
PluginFactory
+{
+ private static final PluginFactory FACTORY = new
ComponentPluginFactory();
+
+
//------------------------------------------------------------------------------
+ // PluginFactory
+
//------------------------------------------------------------------------------
+
+ /**
+ * Build the plugin definition.
+ * @exception exception if a build related error occurs
+ */
+ public Plugin build( File dir, Resource resource ) throws Exception
+ {
+ return FACTORY.build( dir, resource );
+ }
+
+
//------------------------------------------------------------------------------
+ // PluginHelper
+
//------------------------------------------------------------------------------
+
+ public Plugin resolve( URI uri, Element element ) throws Exception
+ {
+ return super.resolve( uri, element );
+ }
+}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -21,7 +21,7 @@
import java.io.Serializable;
import java.net.URI;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* Description of classpath.

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -23,7 +23,7 @@
import net.dpml.metro.data.ClassLoaderDirective;
import net.dpml.metro.data.ClasspathDirective;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* ClassLoaderDirectiveTestCase.

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -22,7 +22,7 @@

import net.dpml.metro.data.ClasspathDirective;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* ClasspathDirectiveTestCase.

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -38,7 +38,7 @@

import net.dpml.part.ActivationPolicy;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* ComponentDirectiveTestCase

Modified: trunk/main/metro/module.xml
===================================================================
--- trunk/main/metro/module.xml 2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/metro/module.xml 2006-02-22 19:36:10 UTC (rev 1125)
@@ -94,6 +94,20 @@
<include ref="dpml/util/dpml-configuration-impl"/>
</dependencies>
</project>
+
+ <project name="dpml-metro-builder" basedir="builder">
+ <types>
+ <type id="jar"/>
+ <type id="plugin" alias="true">
+ <property name="project.plugin.class"
+ value="net.dpml.metro.builder.ComponentPluginHelper"/>
+ </type>
+ </types>
+ <dependencies>
+ <include key="dpml-metro-model"/>
+ <include ref="dpml/depot/dpml-library-main"/>
+ </dependencies>
+ </project>

<project name="dpml-metro-runtime" basedir="runtime">
<types>

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -53,7 +53,7 @@
import net.dpml.part.Model;
import net.dpml.part.ServiceNotFoundException;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;
import net.dpml.transit.Value;

import net.dpml.lang.UnknownKeyException;

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/CompositionClassLoader.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/CompositionClassLoader.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/CompositionClassLoader.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -27,7 +27,7 @@
import net.dpml.transit.Artifact;
import net.dpml.transit.UnsupportedSchemeException;
import net.dpml.transit.StandardClassLoader;
-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

/**
* A named classloader.

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -32,7 +32,7 @@

import net.dpml.part.Controller;

-import net.dpml.transit.Category;
+import net.dpml.lang.Category;

import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;

Modified: trunk/main/planet/http/module.xml
===================================================================
--- trunk/main/planet/http/module.xml 2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/planet/http/module.xml 2006-02-22 19:36:10 UTC (rev 1125)
@@ -39,6 +39,9 @@
<project name="dpml-http-server" basedir="server">
<types>
<type id="part" alias="true"/>
+ <type id="plugin">
+ <property name="project.plugin.factory"
value="link:plugin:dpml/metro/dpml-metro-builder"/>
+ </type>
</types>
<dependencies scope="BUILD">
<include key="dpml-http-app"/>

Added: trunk/main/planet/http/server/etc/plugin/definition.xml
===================================================================
--- trunk/main/planet/http/server/etc/plugin/definition.xml 2006-02-22
19:26:50 UTC (rev 1124)
+++ trunk/main/planet/http/server/etc/plugin/definition.xml 2006-02-22
19:36:10 UTC (rev 1125)
@@ -0,0 +1,77 @@
+ <component xmlns="metro" type="net.dpml.http.Server"
lifestyle="singleton">
+ <parts>
+ <!--
+ Add a select channel connector to 8080.
+ -->
+ <component key="plain" type="net.dpml.http.SelectChannelConnector">
+ <context>
+ <entry key="port" value="8080"/>
+ <entry key="maxIdleTime" value="50000"/>
+ <entry key="acceptors" value="10"/>
+ </context>
+ </component>
+ <!--
+ Add a SSL connector to 8443.
+ -->
+ <component key="ssl" type="net.dpml.http.SslSocketConnector">
+ <context>
+ <entry key="port" value="8443"/>
+ <entry key="maxIdleTime" value="30000"/>
+ <entry key="keystore"
value="local:keystore:dpml/planet/http/jetty"/>
+ <entry key="password"
value="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/>
+ <entry key="keyPassword" value="OBF:1u2u1wml1z7s1z7a1wnl1u2g"/>
+ </context>
+ </component>
+ <!--
+ Add a user realm.
+ -->
+ <component key="realm" type="net.dpml.http.HashUserRealm">
+ <context>
+ <entry key="name" value="Test Realm"/>
+ <entry key="URI"
value="local:properties:dpml/planet/http/realm"/>
+ </context>
+ </component>
+ <!--
+ Add a web application.
+ -->
+ <component key="webapp" type="net.dpml.http.WebAppContextHandler">
+ <context>
+ <entry key="contextPath" value="/"/>
+ <entry key="war"
value="link:war:dpml/planet/http/dpml-http-app"/>
+ </context>
+ </component>
+ <!--
+ Creation of a HTTP server configured to present static content in
+ the ${dpml.share}/docs directory.
+ -->
+ <component key="context" type="net.dpml.http.ResourceContextHandler">
+ <context>
+ <entry key="resourceBase" value="$${dpml.share}/docs"/>
+ <entry key="contextPath" value="/docs"/>
+ </context>
+ </component>
+ <!--
+ Add an experimental servlet context.
+ (Need to add context cloassloader configuration but this requires
+ per-component threads - currently limited to classes declared within
+ the part classloader).
+ -->
+ <component key="servlets" type="net.dpml.http.ServletContextHandler">
+ <context>
+ <entry key="resourceBase" value="$${dpml.data}"/>
+ <entry key="contextPath" value="/data"/>
+ <entry key="servletHolders">
+ <value class="net.dpml.http.ServletHolder">
+ <value value="data"/>
+ <value value="org.mortbay.jetty.servlet.DefaultServlet"/>
+ </value>
+ </entry>
+ </context>
+ <configuration>
+ <mappings>
+ <map path="/" servlet="data"/>
+ </mappings>
+ </configuration>
+ </component>
+ </parts>
+ </component>

Modified:
trunk/main/transit/console/src/main/net/dpml/transit/console/TransitConsoleHandler.java
===================================================================
---
trunk/main/transit/console/src/main/net/dpml/transit/console/TransitConsoleHandler.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/console/src/main/net/dpml/transit/console/TransitConsoleHandler.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -50,8 +50,10 @@
import net.dpml.cli.validation.URLValidator;
import net.dpml.cli.validation.NumberValidator;

+import net.dpml.transit.Artifact;
import net.dpml.transit.Logger;
import net.dpml.transit.Transit;
+import net.dpml.transit.TransitBuilder;
import net.dpml.transit.RepositoryException;
import net.dpml.transit.DefaultTransitModel;
import net.dpml.transit.info.TransitDirective;
@@ -777,16 +779,13 @@
URI store = DefaultTransitModel.DEFAULT_PROFILE_URI;
URI uri = (URI) m_line.getValue( PROFILE_URI_OPTION, store );
System.out.println( "Saving to: " + uri );
- ClassLoader current =
Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(
TransitDirective.class.getClassLoader() );
- XMLEncoder encoder = null;
+ OutputStream output = null;
try
{
- URL url = uri.toURL();
- OutputStream output = url.openConnection().getOutputStream();
- BufferedOutputStream buffer = new BufferedOutputStream(
output );
- encoder = new XMLEncoder( buffer );
- encoder.writeObject( directive );
+ URL url = buildURL( uri );
+ output = url.openConnection().getOutputStream();
+ TransitBuilder builder = new TransitBuilder();
+ builder.write( directive, output );
}
catch( Exception e )
{
@@ -797,11 +796,17 @@
}
finally
{
- if( null != encoder )
+ if( null != output )
{
- encoder.close();
+ try
+ {
+ output.close();
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
}
- Thread.currentThread().setContextClassLoader( current );
}
}
}
@@ -834,10 +839,9 @@
URI uri = (URI) line.getValue( PROFILE_URI_OPTION, null );
try
{
- URL url = uri.toURL();
- InputStream input = url.openStream();
- XMLDecoder decoder = new XMLDecoder( new
BufferedInputStream( input ) );
- return (TransitDirective) decoder.readObject();
+ URL url = buildURL( uri );
+ TransitBuilder builder = new TransitBuilder();
+ return builder.load( url );
}
catch( FileNotFoundException e )
{
@@ -859,14 +863,14 @@
else
{
File prefs = Transit.DPML_PREFS;
- File config = new File( prefs, "dpml/transit/xmls/config.xml" );
+ File config = new File( prefs, "dpml/transit/xmls/standard.xml"
);
if( config.exists() )
{
try
{
- FileInputStream input = new FileInputStream( config );
- XMLDecoder decoder = new XMLDecoder( new
BufferedInputStream( input ) );
- return (TransitDirective) decoder.readObject();
+ URL url = config.toURL();
+ TransitBuilder builder = new TransitBuilder();
+ return builder.load( url );
}
catch( Exception e )
{
@@ -888,6 +892,19 @@
}
}

+ private URL buildURL( URI uri ) throws IOException
+ {
+ if( Artifact.isRecognized( uri ) )
+ {
+ return Artifact.createArtifact( uri ).toURL();
+ }
+ else
+ {
+ return uri.toURL();
+ }
+
+ }
+
private boolean getEnabledFlag( CommandLine line, HostDirective host )
{
if( line.hasOption( DISABLED_OPTION ) )

Modified: trunk/main/transit/core/build.xml
===================================================================
--- trunk/main/transit/core/build.xml 2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/build.xml 2006-02-22 19:36:10 UTC (rev 1125)
@@ -76,6 +76,15 @@
<checksum fileext=".md5"
file="${target.deliverables.jars.dir}/${project.filename}"/>
<delete file="${target.deliverables.jars.dir}/${project.filename}.asc"/>
<antcall target="execute.jar.asc"/>
+ <echo>
+#----------------------------------------------------------------------------------
+# Updating Transit Prefs. ${dpml.prefs}/dpml/transit
+#----------------------------------------------------------------------------------
+ </echo>
+ <mkdir dir="${dpml.prefs}/dpml/transit"/>
+ <copy preservelastmodified="true" toDir="${dpml.prefs}/dpml/transit">
+ <fileset dir="${basedir}/target/prefs"/>
+ </copy>
</target>

<target name="install" depends="bootstrap.install">
@@ -104,15 +113,6 @@
<copy preservelastmodified="true" overwrite="true"
tofile="${user.home}/.ant/lib/${short.filename}"
file="${target.deliverables.jars.dir}/${long.filename}"/>
- <echo>
-#----------------------------------------------------------------------------------
-# Updating Transit Prefs. ${dpml.prefs}/dpml/transit
-#----------------------------------------------------------------------------------
- </echo>
- <mkdir dir="${dpml.prefs}/dpml/transit"/>
- <copy preservelastmodified="true" toDir="${dpml.prefs}/dpml/transit">
- <fileset dir="${basedir}/target/prefs"/>
- </copy>
</target>

</project>

Added: trunk/main/transit/core/etc/prefs/xmls/standard.xml
===================================================================
--- trunk/main/transit/core/etc/prefs/xmls/standard.xml 2006-02-22 19:26:50
UTC (rev 1124)
+++ trunk/main/transit/core/etc/prefs/xmls/standard.xml 2006-02-22 19:36:10
UTC (rev 1125)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE transit PUBLIC "-//DPML//DTD Transit Configuration Version
1.0//EN" "http://www.dpml.net/dtds/transit_1_0.dtd"; >
+
+<transit cache="${dpml.data}/cache" layout="classic">
+
+ <local path="file:${dpml.share}/local" layout="modern"/>
+
+ <hosts>
+ <host id="dpml" priority="40" url="http://repository.dpml.net/classic";
layout="classic"/>
+ <host id="ibiblio" priority="70" url="http://www.ibiblio.org/maven";
layout="classic"/>
+ <host id="m2" priority="100" url="http://www.ibiblio.org/maven2";
layout="modern"/>
+ <host id="apache" priority="140"
url="http://www.apache.org/dist/java-repository"; layout="classic"/>
+ </hosts>
+
+</transit>

Copied: trunk/main/transit/core/src/main/net/dpml/lang/Category.java (from
rev 1121, trunk/main/transit/core/src/main/net/dpml/transit/Category.java)
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Category.java
2006-02-19 05:59:18 UTC (rev 1121)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Category.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,117 @@
+/*
+ * Copyright 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.lang;
+
+/**
+ * Classoader category enumeration.
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class Category extends ValuedEnum
+{
+ static final long serialVersionUID = 1L;
+
+ /**
+ * System category.
+ */
+ public static final Category SYSTEM = new Category( "system", 0 );
+
+ /**
+ * API category.
+ */
+ public static final Category PUBLIC = new Category( "public", 1 );
+
+ /**
+ * SPI category.
+ */
+ public static final Category PROTECTED = new Category( "protected", 2 );
+
+ /**
+ * Implementation category.
+ */
+ public static final Category PRIVATE = new Category( "private", 3 );
+
+ /**
+ * Array of scope enumeration values.
+ */
+ private static final Category[] ENUM_VALUES =
+ new Category[]{SYSTEM, PUBLIC, PROTECTED, PRIVATE};
+
+ /**
+ * Returns an array of activation enum values.
+ * @return the activation policies array
+ */
+ public static Category[] values()
+ {
+ return ENUM_VALUES;
+ }
+
+ /**
+ * Internal constructor.
+ * @param label the enumeration label.
+ * @param index the enumeration index.
+ * @param map the set of constructed enumerations.
+ */
+ private Category( String label, int index )
+ {
+ super( label, index );
+ }
+
+ /**
+ * Return a string representation of the category.
+ * @return the category name in uppercase
+ */
+ public String toString()
+ {
+ return getName().toUpperCase();
+ }
+
+ /**
+ * Create a category by parsing the supplied name.
+ * @param value the category name
+ * @return the corresponding category
+ * @exception IllegalArgumentException if the value is not recognized
+ */
+ public static Category parse( String value ) throws
IllegalArgumentException
+ {
+ if( value.equalsIgnoreCase( "system" ) )
+ {
+ return SYSTEM;
+ }
+ else if( value.equalsIgnoreCase( "public" ) )
+ {
+ return PUBLIC;
+ }
+ else if( value.equalsIgnoreCase( "protected" ) )
+ {
+ return PROTECTED;
+ }
+ else if( value.equalsIgnoreCase( "private" ) )
+ {
+ return PRIVATE;
+ }
+ else
+ {
+ final String error =
+ "Unrecognized category argument [" + value + "]";
+ throw new IllegalArgumentException( error );
+ }
+ }
+}
+

Copied: trunk/main/transit/core/src/main/net/dpml/lang/CategoryBeanInfo.java
(from rev 1121,
trunk/main/transit/core/src/main/net/dpml/transit/CategoryBeanInfo.java)
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/CategoryBeanInfo.java
2006-02-19 05:59:18 UTC (rev 1121)
+++ trunk/main/transit/core/src/main/net/dpml/lang/CategoryBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 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.lang;
+
+import java.beans.Expression;
+import java.beans.BeanDescriptor;
+import java.beans.DefaultPersistenceDelegate;
+import java.beans.SimpleBeanInfo;
+import java.beans.Encoder;
+
+/**
+ * Bean info for state encoding of the Lifestyle policy enumeration.
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class CategoryBeanInfo extends SimpleBeanInfo
+{
+ private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
+
+ /**
+ * Creation of a bean descriptor.
+ * @return the bean descriptor
+ */
+ public BeanDescriptor getBeanDescriptor()
+ {
+ return BEAN_DESCRIPTOR;
+ }
+
+ private static BeanDescriptor setupBeanDescriptor()
+ {
+ BeanDescriptor descriptor = new BeanDescriptor( Category.class );
+ descriptor.setValue(
+ "persistenceDelegate",
+ new ScopePersistenceDelegate() );
+ return descriptor;
+ }
+
+ /**
+ * Persistence delegate.
+ */
+ private static class ScopePersistenceDelegate extends
DefaultPersistenceDelegate
+ {
+ /**
+ * Instantiate an expression.
+ * @param old the old value
+ * @param encoder the encoder
+ * @return the expression
+ */
+ public Expression instantiate( Object old, Encoder encoder )
+ {
+ Category category = (Category) old;
+ return new Expression( category, Category.class, "parse", new
Object[]{category.getName()} );
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.net.URI;
+
+/**
+ * Interface implements by classpath definitions.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Classpath
+{
+ /**
+ * Return the classloader dependencies relative to a supplied classloader
category.
+ *
+ * @param category the classloader category
+ * @return an array of uris defining the classloader classpath for the
supplied category
+ */
+ URI[] getDependencies( Category category );
+
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/DTD.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/DTD.java 2006-02-22
19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/DTD.java 2006-02-22
19:36:10 UTC (rev 1125)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.net.URI;
+
+/**
+ * DTD reference.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DTD
+{
+ /**
+ * Public identifier.
+ */
+ private final String m_public;
+
+ /**
+ * The system identifier.
+ */
+ private final String m_system;
+
+ /**
+ * Local resource.
+ */
+ private final String m_resource;
+
+ /**
+ * Factory uri.
+ */
+ private final URI m_factory;
+
+ public DTD( final String publicId, final String systemId, final String
resource, URI factory )
+ {
+ m_public = publicId;
+ m_system = systemId;
+ m_resource = resource;
+ m_factory = factory;
+ }
+
+ public String getPublicId()
+ {
+ return m_public;
+ }
+
+ public String getSystemId()
+ {
+ return m_system;
+ }
+
+ public String getResource()
+ {
+ return m_resource;
+ }
+
+ public URI getFactory()
+ {
+ return m_factory;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/DTDResolver.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/DTDResolver.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/DTDResolver.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2004-2006 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.lang;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * A Class to help to resolve Entitys for items such as DTDs or
+ * Schemas.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DTDResolver implements EntityResolver
+{
+ /**
+ * The list of DTDs that can be resolved by this class.
+ */
+ private final DTD[] m_dtds;
+
+ /**
+ * The ClassLoader to use when loading resources for DTDs.
+ */
+ private final ClassLoader m_classLoader;
+
+ /**
+ * Construct a resolver using specified DTDInfos where resources are
loaded
+ * from specified ClassLoader.
+ */
+ public DTDResolver( final DTD[] dtds, final ClassLoader classLoader )
+ {
+ m_dtds = dtds;
+ m_classLoader = classLoader;
+ }
+
+ /**
+ * Resolve an entity in the XML file.
+ * Called by parser to resolve DTDs.
+ */
+ public InputSource resolveEntity( final String publicId, final String
systemId )
+ throws IOException, SAXException
+ {
+ for( int i=0; i<m_dtds.length; i++ )
+ {
+ final DTD info = m_dtds[i];
+
+ if( ( publicId != null && publicId.equals( info.getPublicId() )
)
+ || ( systemId != null && systemId.equals( info.getSystemId()
) ) )
+ {
+ final ClassLoader classLoader = getClassLoader();
+ final InputStream inputStream =
+ classLoader.getResourceAsStream( info.getResource() );
+ return new InputSource( inputStream );
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return CLassLoader to load resource from.
+ * If a ClassLoader is specified in the constructor use that,
+ * else use ContextClassLoader unless that is null in which case
+ * use the current classes ClassLoader.
+ */
+ private ClassLoader getClassLoader()
+ {
+ ClassLoader classLoader = m_classLoader;
+ if( null == classLoader )
+ {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ if( null == classLoader )
+ {
+ classLoader = getClass().getClassLoader();
+ }
+ return classLoader;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/DefaultClasspath.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/DefaultClasspath.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/DefaultClasspath.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.net.URI;
+import java.io.OutputStream;
+import java.util.Arrays;
+
+/**
+ * A Plugin class contains immutable data about a plugin based on a
descriptor resolved
+ * from a 'plugin' artifact.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DefaultClasspath implements Classpath
+{
+ private final URI[] m_system;
+ private final URI[] m_public;
+ private final URI[] m_protected;
+ private final URI[] m_private;
+
+ /**
+ * Creation of a new classpath definition.
+ * @param systemUris an array of uris representing the system classpath
extensions
+ * @param publicUris an array of uris representing the public classpath
entries
+ * @param protectedUris an array of uris representing protected classpath
entries
+ * @param privateUris an array of uris representing private classpath
entries
+ */
+ public DefaultClasspath(
+ URI[] systemUris, URI[] publicUris, URI[] protectedUris, URI[]
privateUris )
+ {
+ if( null == systemUris )
+ {
+ m_system = EMPTY_URIS;
+ }
+ else
+ {
+ m_system = systemUris;
+ }
+
+ if( null == publicUris )
+ {
+ m_public = EMPTY_URIS;
+ }
+ else
+ {
+ m_public = publicUris;
+ }
+
+ if( null == protectedUris )
+ {
+ m_protected = EMPTY_URIS;
+ }
+ else
+ {
+ m_protected = protectedUris;
+ }
+
+ if( null == privateUris )
+ {
+ m_private = EMPTY_URIS;
+ }
+ else
+ {
+ m_private = privateUris;
+ }
+ }
+
+ /**
+ * Return the classloader dependencies relative to a supplied classloader
category.
+ *
+ * @param category the classloader category
+ * @return an array of uris defining the classloader classpath for the
supplied category
+ */
+ public URI[] getDependencies( final Category category )
+ {
+ if( Category.SYSTEM.equals( category ) )
+ {
+ return m_system;
+ }
+ else if( Category.PUBLIC.equals( category ) )
+ {
+ return m_public;
+ }
+ else if( Category.PROTECTED.equals( category ) )
+ {
+ return m_protected;
+ }
+ else if( Category.PRIVATE.equals( category ) )
+ {
+ return m_private;
+ }
+ else
+ {
+ final String error =
+ "Category not recognized."
+ + "\nCategory: " + category;
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ /**
+ * Compare this object with another for equality.
+ * @param other the other object
+ * @return TRUE if equal else FALSE
+ */
+ public boolean equals( Object other )
+ {
+ if( other instanceof Classpath )
+ {
+ Classpath classpath = (Classpath) other;
+ if( !Arrays.equals( m_system, classpath.getDependencies(
Category.SYSTEM ) ) )
+ {
+ return false;
+ }
+ if( !Arrays.equals( m_public, classpath.getDependencies(
Category.PUBLIC ) ) )
+ {
+ return false;
+ }
+ if( !Arrays.equals( m_protected, classpath.getDependencies(
Category.PROTECTED ) ) )
+ {
+ return false;
+ }
+ else
+ {
+ return Arrays.equals( m_private, classpath.getDependencies(
Category.PRIVATE ) );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return the hashcode for the plugin definition.
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ int hash = hashArray( m_system );
+ hash ^= hashArray( m_public );
+ hash ^= hashArray( m_protected );
+ hash ^= hashArray( m_private );
+ return hash;
+ }
+
+ /**
+ * Utility to hash an array.
+ * @param array the array
+ * @return the hash value
+ */
+ protected int hashArray( Object[] array )
+ {
+ if( null == array )
+ {
+ return 0;
+ }
+ int hash = 0;
+ for( int i=0; i<array.length; i++ )
+ {
+ Object object = array[i];
+ hash ^= object.hashCode();
+ }
+ return hash;
+ }
+
+ private static final URI[] EMPTY_URIS = new URI[0];
+
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/DefaultPlugin.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/DefaultPlugin.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/DefaultPlugin.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,315 @@
+/*
+ * Copyright 2004-2005 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.
+ */
+
+package net.dpml.lang;
+
+import java.net.URI;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * A Plugin class contains immutable data about a plugin based on a
descriptor resolved
+ * from a 'plugin' artifact.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DefaultPlugin implements Plugin
+{
+ /**
+ * The plugin builder version value that will be used when reading and
writing
+ * plugin defintions.
+ */
+ public static final Version VERSION = new Version( 1, 0, 0 );
+
+ public static final String XML_HEADER =
+ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+
+ public static final String STANDARD_NAME = "plugin";
+
+ public static final String STANDARD_PUBLIC_ID =
+ "-//DPML//DTD Standard Plugin Version 1.0//EN";
+
+ public static final String STANDARD_SYSTEM_ID =
+ "http://www.dpml.net/dtds/plugin_1_0.dtd";;
+
+ public static final String STANDARD_RESOURCE =
+ "net/dpml/lang/plugin_1_0.dtd";
+
+ private static final String PLUGIN_DOCTYPE =
+ "\n<!DOCTYPE "
+ + STANDARD_NAME
+ + " PUBLIC \""
+ + STANDARD_PUBLIC_ID
+ + "\" \""
+ + STANDARD_SYSTEM_ID
+ + "\" >";
+
+ private final String m_title;
+ private final String m_description;
+ private final URI m_uri;
+ private final Strategy m_strategy;
+ private final Classpath m_classpath;
+
+ /**
+ * Creation of a new plugin definition.
+ * @param title short title
+ * @param description textual description
+ * @param uri the uri from which the plugin was resolved
+ * @param strategy the plugin instantiation strategy definition
+ * @param classpath the classpath defintion
+ */
+ public DefaultPlugin(
+ String title, String description, URI uri, Strategy strategy,
Classpath classpath )
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ if( null == strategy )
+ {
+ throw new NullPointerException( "strategy" );
+ }
+ if( null == classpath )
+ {
+ throw new NullPointerException( "classpath" );
+ }
+ m_uri = uri;
+ m_strategy = strategy;
+ m_title = title;
+ m_description = description;
+ m_classpath = classpath;
+ }
+
+ /**
+ * Return the plugin title.
+ * @return the plugin title
+ */
+ public String getTitle()
+ {
+ return m_title;
+ }
+
+ /**
+ * Return the plugin description.
+ * @return the plugin description
+ */
+ public String getDescription()
+ {
+ return m_description;
+ }
+
+ /**
+ * Return the plugin version.
+ * @return the plugin version identifier
+ */
+ public Version getVersion()
+ {
+ return VERSION;
+ }
+
+ /**
+ * Return the uri to the plugin descriptor.
+ * @return the plugin uri
+ */
+ public URI getURI()
+ {
+ return m_uri;
+ }
+
+ /**
+ * Return the plugin strategy.
+ * @return the plugin strategy
+ */
+ public Strategy getStrategy()
+ {
+ return m_strategy;
+ }
+
+ /**
+ * Return the classpath definition.
+ */
+ public Classpath getClasspath()
+ {
+ return m_classpath;
+ }
+
+ /**
+ * Write an XML representation of the plugin to the output stream.
+ * @param output the output stream
+ * @exception Exception if an error ocucrs during externalization
+ */
+ public void write( OutputStream output ) throws Exception
+ {
+ final Writer writer = new OutputStreamWriter( output );
+ writer.write( XML_HEADER );
+ writer.write( PLUGIN_DOCTYPE );
+ writeHeader( writer, "plugin", null, VERSION );
+ writeTitle( writer, getTitle() );
+ writeDescription( writer, getDescription() );
+ writeStrategy( writer, getStrategy() );
+ writeClasspath( writer, getClasspath() );
+ writeFooter( writer, "plugin" );
+ writer.write( "\n" );
+ writer.flush();
+ writer.close();
+ }
+
+ protected void writeHeader( Writer writer, String root, String
namespace, Version version ) throws IOException
+ {
+ if( null == namespace )
+ {
+ writer.write( "\n\n<" + root + " version=\"" + version + "\">" );
+ }
+ else
+ {
+ writer.write( "\n\n<" + root + " xmlns=\"" + namespace + "\"
version=\"" + version + "\">" );
+ }
+ }
+
+ protected void writeFooter( Writer writer, String root ) throws
IOException
+ {
+ writer.write( "\n</" + root + ">" );
+ }
+
+ protected void writeTitle( Writer writer, String title ) throws
IOException
+ {
+ if( null != title )
+ {
+ writer.write(
+ "\n <title>"
+ + title
+ + "</title>" );
+ }
+ }
+
+ protected void writeDescription( Writer writer, String description )
throws IOException
+ {
+ if( null != description )
+ {
+ writer.write(
+ "\n <description>"
+ + description
+ + "</description>" );
+ }
+ }
+
+ protected void writeStrategy( Writer writer, Strategy strategy ) throws
Exception
+ {
+ String handler = strategy.getHandlerClassname();
+ Properties properties = strategy.getProperties();
+ String[] keys = (String[]) properties.keySet().toArray( new
String[0] );
+ writer.write( "\n <strategy class=\"" + handler + "\">" );
+ for( int i=0; i<keys.length; i++ )
+ {
+ String key = keys[i];
+ String value = properties.getProperty( key );
+ writer.write(
+ "\n <property name=\""
+ + key
+ + "\" value=\""
+ + value
+ + "\"/>" );
+ }
+ writer.write( "\n </strategy>" );
+ }
+
+ protected void writeClasspath( Writer writer, Classpath classpath )
throws Exception
+ {
+ writer.write( "\n <classpath>" );
+ URI[] sysUris = classpath.getDependencies( Category.SYSTEM );
+ if( sysUris.length > 0 )
+ {
+ writer.write( "\n <system>" );
+ for( int i=0; i<sysUris.length; i++ )
+ {
+ URI uri = sysUris[i];
+ writer.write( "\n <uri>" + uri + "</uri>" );
+ }
+ writer.write( "\n </system>" );
+ }
+ URI[] publicUris = classpath.getDependencies( Category.PUBLIC );
+ if( publicUris.length > 0 )
+ {
+ writer.write( "\n <public>" );
+ for( int i=0; i<publicUris.length; i++ )
+ {
+ URI uri = publicUris[i];
+ writer.write( "\n <uri>" + uri + "</uri>" );
+ }
+ writer.write( "\n </public>" );
+ }
+ URI[] protectedUris = classpath.getDependencies( Category.PROTECTED
);
+ if( protectedUris.length > 0 )
+ {
+ writer.write( "\n <protected>" );
+ for( int i=0; i<protectedUris.length; i++ )
+ {
+ URI uri = protectedUris[i];
+ writer.write( "\n <uri>" + uri + "</uri>" );
+ }
+ writer.write( "\n </protected>" );
+ }
+ URI[] privateUris = classpath.getDependencies( Category.PRIVATE );
+ if( privateUris.length > 0 )
+ {
+ writer.write( "\n <private>" );
+ for( int i=0; i<privateUris.length; i++ )
+ {
+ URI uri = privateUris[i];
+ writer.write( "\n <uri>" + uri + "</uri>" );
+ }
+ writer.write( "\n </private>" );
+ }
+ writer.write( "\n </classpath>" );
+ }
+
+ /**
+ * Compare this object with another for equality.
+ * @param other the other object
+ * @return TRUE if equal else FALSE
+ */
+ public boolean equals( Object other )
+ {
+ if( other instanceof DefaultPlugin )
+ {
+ DefaultPlugin plugin = (DefaultPlugin) other;
+ return m_uri.equals( plugin.getURI() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return the hashcode for the plugin definition.
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ return m_uri.hashCode();
+ }
+
+ private static final URI[] EMPTY_URIS = new URI[0];
+
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/DefaultPluginHelper.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/DefaultPluginHelper.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/DefaultPluginHelper.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import net.dpml.transit.util.ElementHelper;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+
+/**
+ * Utility class supporting the reading and writing of standard plugins
definitions.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DefaultPluginHelper implements PluginHelper
+{
+ private static final Version VERSION = new Version( 1, 0, 0 );
+
+ public Plugin resolve( URI uri, Element element ) throws Exception
+ {
+ final Element root = element;
+ String name = root.getTagName();
+ if( !"plugin".equals( name ) )
+ {
+ final String error =
+ "Invalid root element name ["
+ + name
+ + "].";
+ throw new IOException( error );
+ }
+
+ String versionSpec = ElementHelper.getAttribute( root, "version" );
+ Version version = Version.getVersion( versionSpec );
+ if( isRecognized( version ) )
+ {
+ String title = getTitle( ElementHelper.getChild( root, "title" )
);
+ String description = getDescription( ElementHelper.getChild(
root, "description" ) );
+ Element strategyElement = ElementHelper.getChild( root,
"strategy" );
+ Strategy strategy = buildStrategy( strategyElement );
+ Element classpathElement = ElementHelper.getChild( root,
"classpath" );
+ Classpath classpath = getClasspath( classpathElement );
+ return new DefaultPlugin( title, description, uri, strategy,
classpath );
+ }
+ else
+ {
+ final String error =
+ "Incompatible plugin version ["
+ + version
+ + "].";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ protected Classpath getClasspath( Element element ) throws Exception
+ {
+ URI[] sys = buildURIs( element, "system" );
+ URI[] pub = buildURIs( element, "public" );
+ URI[] prot = buildURIs( element, "protected" );
+ URI[] priv = buildURIs( element, "private" );
+ return new DefaultClasspath( sys, pub, prot, priv );
+ }
+
+ protected String getTitle( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ return ElementHelper.getValue( element );
+ }
+ }
+
+ protected String getDescription( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ return ElementHelper.getValue( element );
+ }
+ }
+
+ protected Strategy buildStrategy( Element strategy )
+ {
+ if( null == strategy )
+ {
+ final String error =
+ "Required strategy element is not present in plugin
descriptor.";
+ throw new IllegalStateException( error );
+ }
+
+ String classname = ElementHelper.getAttribute( strategy, "class" );
+ if( null == classname )
+ {
+ final String error =
+ "Required plugin runtime handler 'class' attribute is not
present in the plugin strategy descriptor.";
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ Properties properties = new Properties();
+ Element[] elements = ElementHelper.getChildren( strategy,
"property" );
+ for( int i=0; i<elements.length; i++ )
+ {
+ Element element = elements[i];
+ String name = ElementHelper.getAttribute( element, "name" );
+ String value = ElementHelper.getAttribute( element, "value"
);
+ properties.setProperty( name, value );
+ }
+ return new DefaultStrategy( classname, properties );
+ }
+ }
+
+ private URI[] buildURIs( Element classpath, String key ) throws Exception
+ {
+ Element category = ElementHelper.getChild( classpath, key );
+ if( null == category )
+ {
+ return null;
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( category, "uri"
);
+ URI[] uris = new URI[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ String value = ElementHelper.getValue( child );
+ uris[i] = new URI( value );
+ }
+ return uris;
+ }
+ }
+
+ private boolean isRecognized( Version version )
+ {
+ return VERSION.complies( version );
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/DefaultStrategy.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/DefaultStrategy.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/DefaultStrategy.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2004-2006 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.lang;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * Plugin strategy.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DefaultStrategy implements Strategy
+{
+ private final String m_handler;
+ private final Properties m_properties;
+
+ /**
+ * Creation of a new strategy definition.
+ * @param handler the plugin handler classname
+ * @param properties the handler supplimentary properties
+ */
+ public DefaultStrategy( final String handler, final Properties
properties )
+ {
+ if( null == handler )
+ {
+ throw new NullPointerException( "handler" );
+ }
+ m_handler = handler;
+ if( null == properties )
+ {
+ m_properties = new Properties();
+ }
+ else
+ {
+ m_properties = properties;
+ }
+ }
+
+ /**
+ * Return the classname of the custom plugin instantiation handler.
+ * @return the handler classname
+ */
+ public String getHandlerClassname()
+ {
+ return m_handler;
+ }
+
+ /**
+ * Return the the properties to be supplied to the handler.
+ * @return the custom properties
+ */
+ public Properties getProperties()
+ {
+ return m_properties;
+ }
+
+ /**
+ * Test this object for equality with the supplied object.
+ * @param other the other object
+ * @return true if the objects are equal
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof Strategy )
+ {
+ Strategy strategy = (Strategy) other;
+ if( !m_handler.equals( strategy.getHandlerClassname() ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_properties.equals( strategy.getProperties() );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_handler.hashCode();
+ hash ^= m_properties.hashCode();
+ return hash;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/Handler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Handler.java 2006-02-22
19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Handler.java 2006-02-22
19:36:10 UTC (rev 1125)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.util.Properties;
+
+/**
+ * Interface implemented by plugin handlers.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Handler
+{
+ /**
+ * Instantiate the plugin.
+ *
+ * @param classloader the classloader
+ * @param properties plugin strategy properties
+ * @param args commandline arguments
+ * @return the instance
+ * @exception Exception if an error occurs
+ */
+ Object getPlugin(
+ ClassLoader classloader, Properties properties, Object[] args )
throws Exception;
+
+ /**
+ * Get a plugin class.
+ *
+ * @param classloader the plugin classloader
+ * @param properties the supplimentary properties
+ * @return the plugin class
+ * @exception Exception if an error occurs
+ */
+ Class getPluginClass( ClassLoader classloader, Properties properties )
throws Exception;
+}

Copied: trunk/main/transit/core/src/main/net/dpml/lang/Plugin.java (from rev
1119, trunk/main/transit/core/src/main/net/dpml/transit/Plugin.java)
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Plugin.java
2006-02-18 04:46:34 UTC (rev 1119)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Plugin.java 2006-02-22
19:36:10 UTC (rev 1125)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.net.URI;
+import java.io.OutputStream;
+
+/**
+ * A Plugin class contains immutable data about a plugin based on a
descriptor resolved
+ * from a 'plugin' artifact.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Plugin
+{
+ /**
+ * Return the plugin title.
+ * @return the plugin title
+ */
+ String getTitle();
+
+ /**
+ * Return the plugin description.
+ * @return the plugin description
+ */
+ String getDescription();
+
+ /**
+ * Return the plugin version.
+ * @return the plugin version identifier
+ */
+ Version getVersion();
+
+ /**
+ * Return the uri used to establish the plugin.
+ * @return the plugin uri
+ */
+ URI getURI();
+
+ /**
+ * Return the plugin strategy.
+ * @return the plugin strategy
+ */
+ Strategy getStrategy();
+
+ /**
+ * Return the classpath definition.
+ * @return the classpath
+ */
+ Classpath getClasspath();
+
+ /**
+ * Write an XML representation of the plugin to the output stream.
+ * @param output the output stream
+ * @exception Exception if an error ocucrs during externalization
+ */
+ void write( OutputStream output ) throws Exception;
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/PluginBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/PluginBuilder.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/PluginBuilder.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.util.ElementHelper;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+
+/**
+ * Utility class supporting the reading and writing of standard plugins
definitions.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PluginBuilder
+{
+ private static final DTD[] DTDS = new DTD[]
+ {
+ new DTD(
+ DefaultPlugin.STANDARD_PUBLIC_ID,
+ DefaultPlugin.STANDARD_SYSTEM_ID,
+ DefaultPlugin.STANDARD_RESOURCE, null )
+ };
+
+ private static final DTDResolver DTD_RESOLVER =
+ new DTDResolver( DTDS, PluginBuilder.class.getClassLoader() );
+
+ private static final ErrorHandler ERROR_HANDLER =
+ new InternalErrorHandler();
+
+ /**
+ * Construct a plugin from a supplied uri.
+ * @param url the plugin url
+ * @return the plugin
+ * @exception Exception if an error occurs during plugin loading
+ */
+ public Plugin load( final URL url ) throws Exception
+ {
+ URLConnection connection = url.openConnection();
+ InputStream input = connection.getInputStream();
+
+ final DocumentBuilderFactory factory =
+ DocumentBuilderFactory.newInstance();
+ factory.setValidating( true );
+ factory.setNamespaceAware( true );
+ factory.setExpandEntityReferences( true );
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver( DTD_RESOLVER );
+ builder.setErrorHandler( ERROR_HANDLER );
+
+ final Document document = builder.parse( input );
+ final DocumentType docType = document.getDoctype();
+ final Element root = document.getDocumentElement();
+ String namespace = root.getNamespaceURI();
+ final PluginHelper helper = getPluginHelper( namespace );
+ URI uri = new URI( url.toString() );
+ return helper.resolve( uri, root );
+ }
+
+ private PluginHelper getPluginHelper( String namespace ) throws Exception
+ {
+ if( null == namespace )
+ {
+ return new DefaultPluginHelper();
+ }
+ else
+ {
+ URI uri = new URI( namespace );
+ ClassLoader classloader = Plugin.class.getClassLoader();
+ Object[] args = new Object[0];
+ Object instance =
+ Transit.getInstance().getRepository().getPlugin( classloader,
uri, args );
+ if( instance instanceof PluginHelper )
+ {
+ return (PluginHelper) instance;
+ }
+ else
+ {
+ final String error =
+ "Namespace artifact argument ["
+ + namespace
+ + "] assigned as the plugin helper established an instance
of ["
+ + instance.getClass().getName()
+ + "] which is not assignable to the "
+ + PluginHelper.class.getName()
+ + " interface.";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ }
+
+ private static final class InternalErrorHandler implements ErrorHandler
+ {
+ public void error( SAXParseException e ) throws SAXException
+ {
+ System.out.println( "ERROR: " + e.getMessage() );
+ }
+ public void fatalError( SAXParseException e ) throws SAXException
+ {
+ System.out.println( "FATAL: " + e.getMessage() );
+ }
+ public void warning( SAXParseException e ) throws SAXException
+ {
+ System.out.println( "WARN: " + e.getMessage() );
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/PluginHelper.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/PluginHelper.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/PluginHelper.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006 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.lang;
+
+import java.net.URI;
+import org.w3c.dom.Element;
+
+/**
+ * Interface implemented by plugins that resolve plugins from XML files.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface PluginHelper
+{
+ /**
+ * Construct a plugin using a supplied element and uri.
+ *
+ * @param uri the uri identifying the plugin
+ * @param element the root element definining the plugin
+ * @exception Exception if an error occurs
+ */
+ Plugin resolve( URI uri, Element element ) throws Exception;
+
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004-2006 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.lang;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * Plugin strategy interface definition.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Strategy extends Serializable
+{
+ /**
+ * Return the classname of the custom plugin instantiation handler.
+ * @return the handler classname
+ */
+ String getHandlerClassname();
+
+ /**
+ * Return the the properties to be supplied to the handler.
+ * @return the custom properties
+ */
+ Properties getProperties();
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/Version.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Version.java 2006-02-22
19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Version.java 2006-02-22
19:36:10 UTC (rev 1125)
@@ -0,0 +1,339 @@
+/*
+ * Copyright 2004-2006 Stephen J. McConnell.
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * 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.lang;
+
+import java.io.Serializable;
+
+import java.util.StringTokenizer;
+
+/**
+ * This class is used to hold version information.
+ * <p />
+ *
+ * The version number is made up of three dot-separated fields:
+ * <p />
+ * &quot;<b>major.minor.micro</b>&quot;
+ * <p />
+ * The <b>major</b>, <b>minor</b> and <b>micro</b> fields are
+ * <i>integer</i> numbers represented in decimal notation and have the
+ * following meaning:
+ * <ul>
+ *
+ * <p /><li><b>major</b> - When the major version changes (in ex. from
+ * &quot;1.5.12&quot; to &quot;2.0.0&quot;), then backward compatibility
+ * with previous releases is not granted.</li><p />
+ *
+ * <p /><li><b>minor</b> - When the minor version changes (in ex. from
+ * &quot;1.5.12&quot; to &quot;1.6.0&quot;), then backward compatibility
+ * with previous releases is granted, but something changed in the
+ * implementation of the Component. (ie it methods could have been
added)</li><p />
+ *
+ * <p /><li><b>micro</b> - When the micro version changes (in ex.
+ * from &quot;1.5.12&quot; to &quot;1.5.13&quot;), then the the changes are
+ * small forward compatible bug fixes or documentation modifications etc.
+ * </li>
+ * </ul>
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class Version implements Comparable, Serializable
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ private int m_major;
+ private int m_minor;
+ private int m_micro;
+
+ /**
+ * Parse a version out of a string.
+ * The version string format is <major>.<minor>.<micro> where
+ * both minor and micro are optional.
+ *
+ * @param version The input version string
+ * @return the new Version object
+ * @throws NumberFormatException if an error occurs
+ * @throws IllegalArgumentException if an error occurs
+ * @throws NullPointerException if the version argument is
<code>null</code>.
+ * @since 4.1
+ */
+ public static Version getVersion( final String version )
+ throws NumberFormatException, IllegalArgumentException,
NullPointerException
+ {
+ if( version == null )
+ {
+ throw new NullPointerException( "version" );
+ }
+
+ final StringTokenizer tokenizer = new StringTokenizer( version, "."
);
+ final String[] levels = new String[ tokenizer.countTokens() ];
+ for( int i = 0; i < levels.length; i++ )
+ {
+ levels[ i ] = tokenizer.nextToken();
+ }
+
+ int major = -1;
+ if( 0 < levels.length )
+ {
+ major = Integer.parseInt( levels[ 0 ] );
+ }
+
+ int minor = 0;
+ if( 1 < levels.length )
+ {
+ minor = Integer.parseInt( levels[ 1 ] );
+ }
+
+ int micro = 0;
+ if( 2 < levels.length )
+ {
+ micro = Integer.parseInt( levels[ 2 ] );
+ }
+
+ return new Version( major, minor, micro );
+ }
+
+ /**
+ * Create a new instance of a <code>Version</code> object with the
+ * specified version numbers.
+ *
+ * @param major This <code>Version</code> major number.
+ * @param minor This <code>Version</code> minor number.
+ * @param micro This <code>Version</code> micro number.
+ */
+ public Version( final int major, final int minor, final int micro )
+ {
+ m_major = major;
+ m_minor = minor;
+ m_micro = micro;
+ }
+
+ /**
+ * Retrieve major component of version.
+ *
+ * @return the major component of version
+ * @since 4.1
+ */
+ public int getMajor()
+ {
+ return m_major;
+ }
+
+ /**
+ * Retrieve minor component of version.
+ *
+ * @return the minor component of version
+ * @since 4.1
+ */
+ public int getMinor()
+ {
+ return m_minor;
+ }
+
+ /**
+ * Retrieve micro component of version.
+ *
+ * @return the micro component of version.
+ * @since 4.1
+ */
+ public int getMicro()
+ {
+ return m_micro;
+ }
+
+ /**
+ * Check this <code>Version</code> against another for equality.
+ * <p />
+ * If this <code>Version</code> is compatible with the specified one,
then
+ * <b>true</b> is returned, otherwise <b>false</b>.
+ *
+ * @param other The other <code>Version</code> object to be compared
with this
+ * for equality.
+ * @return <b>true</b> if this <code>Version</code> is compatible with
the specified one
+ * @since 4.1
+ */
+ public boolean equals( final Version other )
+ {
+ if( other == null )
+ {
+ return false;
+ }
+ boolean isEqual = ( getMajor() == other.getMajor() );
+ if( isEqual )
+ {
+ isEqual = ( getMinor() == other.getMinor() );
+ }
+ if( isEqual )
+ {
+ isEqual = ( getMicro() == other.getMicro() );
+ }
+ return isEqual;
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this
<code>Version</code>.
+ * Returns <b>true</b> if the other object is an instance of
<code>Version</code>
+ * and has the same major, minor, and micro components.
+ *
+ * @param other an <code>Object</code> value
+ * @return <b>true</b> if the other object is equal to this
<code>Version</code>
+ */
+ public boolean equals( final Object other )
+ {
+ boolean isEqual = false;
+ if( other instanceof Version )
+ {
+ isEqual = equals( (Version) other );
+ }
+ return isEqual;
+ }
+
+ /**
+ * Add a hashing function to ensure the Version object is
+ * treated as expected in hashmaps and sets. NOTE: any
+ * time the equals() is overridden, hashCode() should also
+ * be overridden.
+ *
+ * @return the hashCode
+ */
+ public int hashCode()
+ {
+ int hash = 61486123 * getMajor();
+ hash = hash + 1273621 * getMinor();
+ hash = hash + 8912738 * getMicro();
+ return hash;
+ }
+
+ /**
+ * Check this <code>Version</code> against another for compliancy
+ * (compatibility).
+ * <p />
+ * If this <code>Version</code> is compatible with the specified one,
then
+ * <b>true</b> is returned, otherwise <b>false</b>. Be careful when using
+ * this method since, in example, version 1.3.7 is compliant to version
+ * 1.3.6, while the opposite is not.
+ * <p />
+ * The following example displays the expected behaviour and results of
version.
+ * <pre>
+ * final Version v1 = new Version( 1, 3, 6 );
+ * final Version v2 = new Version( 1, 3, 7 );
+ * final Version v3 = new Version( 1, 4, 0 );
+ * final Version v4 = new Version( 2, 0, 1 );
+ *
+ * assert( v1.complies( v1 ) );
+ * assert( ! v1.complies( v2 ) );
+ * assert( v2.complies( v1 ) );
+ * assert( ! v1.complies( v3 ) );
+ * assert( v3.complies( v1 ) );
+ * assert( ! v1.complies( v4 ) );
+ * assert( ! v4.complies( v1 ) );
+ * </pre>
+ *
+ * @param other The other <code>Version</code> object to be compared
with this
+ * for compliancy (compatibility).
+ * @return <b>true</b> if this <code>Version</code> is compatible with
the specified one
+ */
+ public boolean complies( final Version other )
+ {
+ if( other == null )
+ {
+ return false;
+ }
+ if( other.m_major == -1 )
+ {
+ return true;
+ }
+ if( m_major != other.m_major )
+ {
+ return false;
+ }
+ else if( m_minor < other.m_minor )
+ {
+ //If of major version but lower minor version then incompatible
+ return false;
+ }
+ else
+ {
+ //If same major version, same minor version but lower micro level
+ //then incompatible
+ return !( m_minor == other.m_minor && m_micro < other.m_micro );
+ }
+ }
+
+ /**
+ * Overload toString to report version correctly.
+ *
+ * @return the dot seperated version string
+ */
+ public String toString()
+ {
+ return m_major + "." + m_minor + "." + m_micro;
+ }
+
+ /**
+ * Compare two versions together according to the
+ * {@link Comparable} interface.
+ * @param o the other object
+ * @return number indicating relative value (-1, 0, 1)
+ * @throws NullPointerException if the argument is null.
+ */
+ public int compareTo( Object o )
+ throws NullPointerException
+ {
+ if( o == null )
+ {
+ throw new NullPointerException ( "o" );
+ }
+
+ Version other = (Version) o;
+
+ if( getMajor() < other.getMajor() )
+ {
+ return -1;
+ }
+
+ if( getMajor() > other.getMajor() )
+ {
+ return 1;
+ }
+
+ if( getMinor() < other.getMinor() )
+ {
+ return -1;
+ }
+
+ if( getMinor() > other.getMinor() )
+ {
+ return 1;
+ }
+
+ if( getMicro() < other.getMicro() )
+ {
+ return -1;
+ }
+
+ if( getMicro() > other.getMicro() )
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/Category.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Category.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Category.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,119 +0,0 @@
-/*
- * Copyright 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.transit;
-
-import net.dpml.lang.ValuedEnum;
-
-/**
- * Classoader category enumeration.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class Category extends ValuedEnum
-{
- static final long serialVersionUID = 1L;
-
- /**
- * System category.
- */
- public static final Category SYSTEM = new Category( "system", 0 );
-
- /**
- * API category.
- */
- public static final Category PUBLIC = new Category( "public", 1 );
-
- /**
- * SPI category.
- */
- public static final Category PROTECTED = new Category( "protected", 2 );
-
- /**
- * Implementation category.
- */
- public static final Category PRIVATE = new Category( "private", 3 );
-
- /**
- * Array of scope enumeration values.
- */
- private static final Category[] ENUM_VALUES =
- new Category[]{SYSTEM, PUBLIC, PROTECTED, PRIVATE};
-
- /**
- * Returns an array of activation enum values.
- * @return the activation policies array
- */
- public static Category[] values()
- {
- return ENUM_VALUES;
- }
-
- /**
- * Internal constructor.
- * @param label the enumeration label.
- * @param index the enumeration index.
- * @param map the set of constructed enumerations.
- */
- private Category( String label, int index )
- {
- super( label, index );
- }
-
- /**
- * Return a string representation of the category.
- * @return the category name in uppercase
- */
- public String toString()
- {
- return getName().toUpperCase();
- }
-
- /**
- * Create a category by parsing the supplied name.
- * @param value the category name
- * @return the corresponding category
- * @exception IllegalArgumentException if the value is not recognized
- */
- public static Category parse( String value ) throws
IllegalArgumentException
- {
- if( value.equalsIgnoreCase( "system" ) )
- {
- return SYSTEM;
- }
- else if( value.equalsIgnoreCase( "public" ) )
- {
- return PUBLIC;
- }
- else if( value.equalsIgnoreCase( "protected" ) )
- {
- return PROTECTED;
- }
- else if( value.equalsIgnoreCase( "private" ) )
- {
- return PRIVATE;
- }
- else
- {
- final String error =
- "Unrecognized category argument [" + value + "]";
- throw new IllegalArgumentException( error );
- }
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/CategoryBeanInfo.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/CategoryBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/CategoryBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,71 +0,0 @@
-/*
- * Copyright 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.transit;
-
-import java.beans.Expression;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.SimpleBeanInfo;
-import java.beans.Encoder;
-
-/**
- * Bean info for state encoding of the Lifestyle policy enumeration.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class CategoryBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( Category.class );
- descriptor.setValue(
- "persistenceDelegate",
- new ScopePersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate.
- */
- private static class ScopePersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Instantiate an expression.
- * @param old the old value
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- Category category = (Category) old;
- return new Expression( category, Category.class, "parse", new
Object[]{category.getName()} );
- }
- }
-}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -57,7 +57,7 @@
/**
* Default configuration url path.
*/
- public static final String DEFAULT_PROFILE_PATH =
"local:xml:dpml/transit/config";
+ public static final String DEFAULT_PROFILE_PATH =
"local:xml:dpml/transit/standard";

/**
* Default configuration url path.
@@ -118,21 +118,20 @@
String path = System.getProperty( PROFILE_KEY );
if( null != path )
{
- URL url = new URL( path );
- InputStream input = url.openStream();
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream(
input ) );
- TransitDirective directive = (TransitDirective)
decoder.readObject();
+ URL url = Artifact.createArtifact( path ).toURL();
+ TransitBuilder builder = new TransitBuilder();
+ TransitDirective directive = builder.load( url );
return new DefaultTransitModel( logger, directive );
}
else
{
File prefs = Transit.DPML_PREFS;
- File config = new File( prefs, "dpml/transit/xmls/config.xml" );
+ File config = new File( prefs, "dpml/transit/xmls/standard.xml"
);
if( config.exists() )
{
- FileInputStream input = new FileInputStream( config );
- XMLDecoder decoder = new XMLDecoder( new
BufferedInputStream( input ) );
- TransitDirective directive = (TransitDirective)
decoder.readObject();
+ URL url = config.toURL();
+ TransitBuilder builder = new TransitBuilder();
+ TransitDirective directive = builder.load( url );
return new DefaultTransitModel( logger, directive );
}
else
@@ -400,7 +399,7 @@
{
try
{
- return new URI( path );
+ return Artifact.createArtifact( path ).toURI();
}
catch( Exception e )
{

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/Plugin.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Plugin.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Plugin.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,94 +0,0 @@
-/*
- * Copyright 2004-2005 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.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-
-/**
- * A Plugin class contains immutable data about a plugin based on a
descriptor resolved
- * from a 'plugin' artifact.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Plugin
-{
- /**
- * Return the uri to the plugin descriptor.
- * @return the plugin uri
- */
- URI getURI();
-
- /**
- * Return the plugin data specification namespace value.
- * @return the namespace
- */
- String getSpecificationNamespace();
-
- /**
- * Return the plugin data version
- * @return the version
- */
- String getSpecificationVersion();
-
- /**
- * Return the classname.
- * @return the classname
- */
- String getClassname();
-
- /**
- * Return the factory interface.
- * @return the interface classname
- */
- String getInterface();
-
- /**
- * Return the implementation dependencies
- *
- * @param key NATIVE, SYSTEM, PRIVATE, PROTECTED or PUBLIC constants.
- *
- * @return the uris matching the key
- */
- URI[] getDependencies( Category key );
-
- /**
- * Return the aggregated set of dependency uris.
- *
- * @return the dependency artifacts
- */
- URI[] getDependencies();
-
-
//==========================================================================
- // supplimentary data for antlib handling
-
//==========================================================================
-
- /**
- * Return the antlib resource path.
- * @return the path
- */
- String getResource();
-
- /**
- * Return the antlib urn
- * @return the urn
- */
- String getURN();
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/PropertiesPlugin.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/PropertiesPlugin.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/PropertiesPlugin.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,456 +0,0 @@
-/*
- * Copyright 2004-2005 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.
- */
-
-package net.dpml.transit;
-
-import java.io.Serializable;
-
-import java.net.URI;
-
-import java.util.ArrayList;
-import java.util.Properties;
-
-/**
- * An implementation of a plugin descriptor based the original properties
- * external format.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class PropertiesPlugin
- implements Plugin, Serializable
-{
- static final long serialVersionUID = 1L;
-
- //-----------------------------------------------------------
- // static
- //-----------------------------------------------------------
-
- /**
- * key to designate the namespace of the plugin descriptor.
- */
- static final String PP_NAMESPACE_KEY = "dpml.plugin.meta.namespace";
-
- /**
- * key to designate the version of the plugin descriptor.
- */
- static final String PP_META_VERSION_KEY = "dpml.plugin.meta.version";
-
- /**
- * key to designate an api entry.
- */
- static final String PP_SYS_KEY = "dpml.artifact.dependency.sys";
-
- /**
- * key to designate an api entry.
- */
- static final String PP_API_KEY = "dpml.artifact.dependency.api";
-
- /**
- * key to designate an spi entry.
- */
- static final String PP_SPI_KEY = "dpml.artifact.dependency.spi";
-
- /**
- * key to designate an impl entry.
- */
- static final String PP_IMP_KEY = "dpml.artifact.dependency";
-
- /**
- * key to designate the plugin classname.
- */
- static final String PP_FACTORY_KEY = "dpml.plugin.class";
-
- /**
- * key to designate a service export.
- */
- static final String PP_EXPORT_KEY = "dpml.artifact.export"; // <-- check
me
-
- /**
- * key to designate the artifact group.
- */
- static final String PP_GROUP_KEY = "dpml.artifact.group";
-
- /**
- * key to designate the artifact name.
- */
- static final String PP_NAME_KEY = "dpml.artifact.name";
-
- /**
- * key to designate the artifact version.
- */
- static final String PP_VERSION_KEY = "dpml.artifact.version";
-
- /**
- * key to designate the artifact a resource path.
- */
- static final String PP_RESOURCE_KEY = "dpml.plugin.resource";
-
- /**
- * key to designate the artifact urn.
- */
- static final String PP_URN_KEY = "dpml.plugin.urn";
-
- //-----------------------------------------------------------
- // immutable state
- //-----------------------------------------------------------
-
- /**
- * The specification namespace identifier.
- */
- private final String m_specificationNamespace;
-
- /**
- * The specification namespace version.
- */
- private final String m_specificationVersion;
-
- /**
- * The set of uris representing the api.
- */
- private final URI[] m_sys;
-
- /**
- * The set of uris representing the api.
- */
- private final URI[] m_api;
-
- /**
- * The set of uris representing the spi.
- */
- private final URI[] m_spi;
-
- /**
- * The set of uris representing the implementation.
- */
- private final URI[] m_imp;
-
- /**
- * Plugin group.
- */
- private final String m_group;
-
- /**
- * Plugin name.
- */
- private final String m_name;
-
- /**
- * Plugin version.
- */
- private final String m_version;
-
- /**
- * Plugin plugin uri.
- */
- private final URI m_uri;
-
- /**
- * Plugin plugin classname.
- */
- private final String m_factory;
-
- /**
- * Plugin plugin service.
- */
- private final String m_interface;
-
- /**
- * Plugin plugin resource path.
- */
- private final String m_resource;
-
- /**
- * Plugin plugin urn.
- */
- private final String m_urn;
-
- //-----------------------------------------------------------
- // constructor
- //-----------------------------------------------------------
-
- /**
- * Creates a new PropertiesPlugin.
- *
- * @param attributes the plugin descriptor attributes
- * @exception NullArgumentException if the supplied attributes are null
- * @exception RepositoryException if an error occurs reading the
properties
- */
- PropertiesPlugin( final Properties attributes )
- throws RepositoryException, NullArgumentException
- {
- if( null == attributes )
- {
- throw new NullArgumentException( "attributes" );
- }
-
- m_specificationNamespace = attributes.getProperty( PP_NAMESPACE_KEY
);
- if( null == m_specificationNamespace )
- {
- final String error = "Missing attribute: " + PP_NAMESPACE_KEY;
- throw new RepositoryException( error );
- }
-
- m_specificationVersion = attributes.getProperty( PP_META_VERSION_KEY
);
- if( null == m_specificationVersion )
- {
- final String error = "Missing attribute: " + PP_META_VERSION_KEY;
- throw new RepositoryException( error );
- }
-
- m_group = attributes.getProperty( PP_GROUP_KEY, "" );
- m_name = attributes.getProperty( PP_NAME_KEY, "" );
- m_version = attributes.getProperty( PP_VERSION_KEY, "" );
-
- m_uri = Artifact.createArtifact( m_group, m_name, m_version,
"plugin" ).toURI();
-
- m_sys = buildDependents( attributes, PP_SYS_KEY );
- m_api = buildDependents( attributes, PP_API_KEY );
- m_spi = buildDependents( attributes, PP_SPI_KEY );
- m_imp = buildDependents( attributes, PP_IMP_KEY );
-
- m_factory = attributes.getProperty( PP_FACTORY_KEY );
- m_interface = attributes.getProperty( PP_EXPORT_KEY );
- m_resource = attributes.getProperty( PP_RESOURCE_KEY );
- m_urn = attributes.getProperty( PP_URN_KEY );
-
- if( ( m_factory == null ) && ( m_resource == null ) )
- {
- final String error =
- "Unable to resolve either the plugin attribute ["
- + PP_FACTORY_KEY
- + "] or ["
- + PP_RESOURCE_KEY
- + "].";
- throw new RepositoryException( error );
- }
- if( ( m_resource != null ) && ( m_urn == null ) )
- {
- attributes.list( System.out );
- final String error =
- "Unable to resolve the plugin attribute ["
- + PP_URN_KEY
- + "].";
- throw new RepositoryException( error );
- }
- }
-
- //-----------------------------------------------------------
- // public
- //-----------------------------------------------------------
-
- /**
- * Return the uri referencing the desriptor.
- * @return the uri
- */
- public URI getURI()
- {
- return m_uri;
- }
-
- /**
- * Return the plugin specification value.
- * @return the namespace of the specification
- */
- public String getSpecificationNamespace()
- {
- return m_specificationNamespace;
- }
-
- /**
- * Return the plugin specification version
- * @return the version
- */
- public String getSpecificationVersion()
- {
- return m_specificationVersion;
- }
-
- /**
- * Test is the supplied object is equal to this object.
- * @param other the object to compare this object with
- * @return true if the objects are equivalent
- */
- public boolean equals( Object other )
- {
- boolean isEqual = other instanceof Plugin;
- if ( isEqual )
- {
- Plugin plugin = (Plugin) other;
- isEqual = isEqual && m_specificationNamespace.equals(
plugin.getSpecificationNamespace() );
- isEqual = isEqual && m_specificationVersion.equals(
plugin.getSpecificationVersion() );
- }
- return isEqual;
- }
-
- /**
- * Return the hashcode for the object.
- * @return the hashcode value
- */
- public int hashCode()
- {
- int hash = m_specificationNamespace.hashCode();
- hash ^= m_specificationVersion.hashCode();
- hash ^= m_group.hashCode();
- hash ^= m_version.hashCode();
- return hash;
- }
-
- /**
- * Return the factory classname.
- * @return the classname
- */
- public String getClassname()
- {
- return m_factory;
- }
-
- /**
- * Return the factory interface.
- * @return the interface classname
- */
- public String getInterface()
- {
- return m_interface;
- }
-
- /**
- * Return the resource path.
- * @return the resource path
- */
- public String getResource()
- {
- return m_resource;
- }
-
- /**
- * Return the antlib urn
- * @return the urn
- */
- public String getURN()
- {
- return m_urn;
- }
-
- /**
- * Return the implementation dependencies
- * @param key one of classloader group identifiers (api, spi, impl)
- * @return the set of URIs
- */
- public URI[] getDependencies( Category key )
- {
- if( key == Category.SYSTEM )
- {
- return m_sys;
- }
- else if( key == Category.PUBLIC )
- {
- return m_api;
- }
- else if( key == Category.PROTECTED )
- {
- return m_spi;
- }
- else if( key == Category.PRIVATE )
- {
- return m_imp;
- }
- else
- {
- final String error =
- "Invalid dependency key: " + key;
- throw new IllegalArgumentException( error );
- }
- }
-
- /**
- * Return all dependencies
- * @return the set of URIs
- */
- public URI[] getDependencies()
- {
- int j = m_sys.length + m_api.length + m_spi.length + m_imp.length;
- URI[] all = new URI[ j ];
- int q = 0;
- for( int i=0; i < m_sys.length; i++ )
- {
- all[q] = m_sys[i];
- q++;
- }
- for( int i=0; i < m_api.length; i++ )
- {
- all[q] = m_api[i];
- q++;
- }
- for( int i=0; i < m_spi.length; i++ )
- {
- all[q] = m_spi[i];
- q++;
- }
- for( int i=0; i < m_imp.length; i++ )
- {
- all[q] = m_imp[i];
- q++;
- }
- return all;
- }
-
- /**
- * Return a stringified representation of the instance.
- * @return the string representation
- */
- public String toString()
- {
- return "[plugin: " + getSpecificationNamespace()
- + "::" + getSpecificationVersion() + "]";
- }
-
- //-----------------------------------------------------------
- // private
- //-----------------------------------------------------------
-
- /**
- * Return the set of dependencies relative to a supplied category.
- * @param attributes the properties source
- * @param key the category key
- * @return the set of uris matching the category
- */
- private URI[] buildDependents( Properties attributes, final String key )
- {
- ArrayList result = new ArrayList();
- int counter = 0;
- while( true )
- {
- String lookup = key + "." + counter;
- counter++;
- final String spec = attributes.getProperty( lookup );
- if( spec == null )
- {
- break;
- }
- URI uri = URI.create( spec );
- Artifact.createArtifact( uri ); // validate spec
- result.add( uri );
- }
- URI[] dependencies = new URI[ result.size() ];
- result.toArray( dependencies );
- return dependencies;
- }
-
-}

Modified: trunk/main/transit/core/src/main/net/dpml/transit/Repository.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Repository.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Repository.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -24,6 +24,8 @@

import java.net.URI;

+import net.dpml.lang.Plugin;
+
/**
* A service that provides support for the establishment of classloaders and
plugin
* instances based on plugin descriptor describing a classloader chain.

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/StandardClassLoader.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/StandardClassLoader.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/StandardClassLoader.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -22,6 +22,8 @@
import java.net.URI;
import java.net.URLClassLoader;

+import net.dpml.lang.Category;
+
/**
* A named classloader.
*

Added: trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,439 @@
+/*
+ * Copyright 2004-2005 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.
+ */
+
+package net.dpml.transit;
+
+import java.io.IOException;
+import java.beans.Expression;
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+import net.dpml.lang.Handler;
+
+/**
+ * Default plugin instantiation handler.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class StandardHandler implements Handler
+{
+ /**
+ * Instantiate the plugin.
+ *
+ * @param classloader the classloader
+ * @param properties plugin strategy properties
+ * @param args commandline arguments
+ * @return the instance
+ * @exception Exception if an error occurs
+ */
+ public Object getPlugin( ClassLoader classloader, Properties properties,
Object[] args )
+ throws Exception
+ {
+ Class clazz = getPluginClass( classloader, properties );
+ return instantiate( clazz, args );
+ }
+
+ /**
+ * Get a plugin class.
+ *
+ * @param classloader the plugin classloader
+ * @param properties the supplimentary properties
+ * @return the plugin class
+ * @exception Exception if an error occurs
+ */
+ public Class getPluginClass( ClassLoader classloader, Properties
properties )
+ throws Exception
+ {
+ if( null == classloader )
+ {
+ throw new NullArgumentException( "classloader" );
+ }
+ if( null == properties )
+ {
+ throw new NullArgumentException( "properties" );
+ }
+
+ String target = properties.getProperty( "project.plugin.class" );
+ if( null == target )
+ {
+ final String error =
+ "Missing 'project.plugin.class' property.";
+ throw new RepositoryException( error );
+ }
+ else
+ {
+ return loadPluginClass( classloader, target );
+ }
+ }
+
+ /**
+ * Instantiate an instance of a class using the supplied arguments.
+ * @param clazz the target class
+ * @param args the commandline arguments
+ * @return the instantiated instance
+ * @exception RepositoryException if an unexpected error occurs
+ * @exception InvocationTargetException if the plugin instance raises an
exception
+ * during instantiation
+ */
+ public Object instantiate( Class clazz, Object[] args ) throws
RepositoryException, InvocationTargetException
+ {
+ if( null == clazz )
+ {
+ throw new NullArgumentException( "clazz" );
+ }
+ if( null == args )
+ {
+ throw new NullArgumentException( "args" );
+ }
+ for( int i=0; i < args.length; i++ )
+ {
+ Object p = args[i];
+ if( null == p )
+ {
+ final String error =
+ "User supplied instantiation argument at position ["
+ + i
+ + "] for the class ["
+ + clazz.getName()
+ + "] is a null value.";
+ throw new NullArgumentException( error );
+ }
+ }
+
+ if( clazz.getConstructors().length == 1 )
+ {
+ Constructor constructor = getSingleConstructor( clazz );
+ return instantiate( constructor, args );
+ }
+ else
+ {
+ try
+ {
+ Expression expression = new Expression( clazz, "new", args );
+ return expression.getValue();
+ }
+ catch( InvocationTargetException e )
+ {
+ throw e;
+ }
+ catch( RepositoryException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Class instantiation error [" + clazz.getName() + "]";
+ throw new RepositoryException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Instantiate an instance of a class using the supplied constructor and
arguments.
+ * @param constructor the target constructor
+ * @param args the commandline arguments
+ * @return the instantiated instance
+ * @exception RepositoryException if an unexpected error occurs
+ * @exception InvocationTargetException if the plugin instance raises an
exception
+ * during instantiation
+ */
+ public Object instantiate( Constructor constructor, Object[] args )
+ throws RepositoryException, InvocationTargetException
+ {
+ Object[] arguments = populate( constructor, args );
+ return newInstance( constructor, arguments );
+ }
+
+ /**
+ * Create a factory using a supplied class and command line arguments.
+ *
+ * @param clazz the the factory class
+ * @param args the command line args
+ * @return the plugin instance
+ * @exception IOException if a plugin creation error occurs
+ * @exception InvocationTargetException if a plugin constructor
invocation error occurs
+ * @exception NullArgumentException if the class or args argument is null
+ */
+ private Object createPlugin( Class clazz, Object[] args )
+ throws IOException, NullArgumentException, InvocationTargetException
+ {
+ if( null == clazz )
+ {
+ throw new NullArgumentException( "clazz" );
+ }
+ if( null == args )
+ {
+ throw new NullArgumentException( "args" );
+ }
+ return instantiate( clazz, args );
+ }
+
+ private Object[] populate( Constructor constructor, Object[] args )
throws RepositoryException
+ {
+ if( null == constructor )
+ {
+ throw new NullArgumentException( "constructor" );
+ }
+ if( null == args )
+ {
+ throw new NullArgumentException( "args" );
+ }
+
+ Class[] classes = constructor.getParameterTypes();
+ Object[] arguments = new Object[ classes.length ];
+ ArrayList list = new ArrayList();
+ for( int i=0; i < args.length; i++ )
+ {
+ list.add( args[i] );
+ }
+
+ //
+ // sweep though the construct arguments one by one and
+ // see if we can assign a value based on the supplied args
+ //
+
+ for( int i=0; i < classes.length; i++ )
+ {
+ Class clazz = classes[i];
+ Iterator iterator = list.iterator();
+ while( iterator.hasNext() )
+ {
+ Object object = iterator.next();
+ Class c = object.getClass();
+ if( isAssignableFrom( clazz, c ) )
+ {
+ arguments[i] = object;
+ list.remove( object );
+ break;
+ }
+ }
+ }
+
+ //
+ // if any arguments are unresolved then check if the argument type
+ // is something we can implicity establish
+ //
+
+ for( int i=0; i < arguments.length; i++ )
+ {
+ if( null == arguments[i] )
+ {
+ Class c = classes[i];
+ if( c.isArray() )
+ {
+ arguments[i] = getEmptyArrayInstance( c );
+ }
+ else
+ {
+ final String error =
+ "Unable to resolve a value for a constructor
parameter."
+ + "\nConstructor class: " +
constructor.getDeclaringClass().getName()
+ + "\nParameter class: " + c.getName()
+ + "\nParameter position: " + ( i + 1 );
+ throw new RepositoryException( error );
+ }
+ }
+ }
+ return arguments;
+ }
+
+ private boolean isAssignableFrom( Class clazz, Class c )
+ {
+ if( clazz.isPrimitive() )
+ {
+ if( Integer.TYPE == clazz )
+ {
+ return Integer.class.isAssignableFrom( c );
+ }
+ else if( Boolean.TYPE == clazz )
+ {
+ return Boolean.class.isAssignableFrom( c );
+ }
+ else if( Byte.TYPE == clazz )
+ {
+ return Byte.class.isAssignableFrom( c );
+ }
+ else if( Short.TYPE == clazz )
+ {
+ return Short.class.isAssignableFrom( c );
+ }
+ else if( Long.TYPE == clazz )
+ {
+ return Long.class.isAssignableFrom( c );
+ }
+ else if( Float.TYPE == clazz )
+ {
+ return Float.class.isAssignableFrom( c );
+ }
+ else if( Double.TYPE == clazz )
+ {
+ return Double.class.isAssignableFrom( c );
+ }
+ else
+ {
+ final String error =
+ "Primitive type ["
+ + c.getName()
+ + "] not supported.";
+ throw new RuntimeException( error );
+ }
+ }
+ else
+ {
+ return clazz.isAssignableFrom( c );
+ }
+ }
+
+ private Object newInstance( Constructor constructor, Object[] arguments )
+ throws RepositoryException, InvocationTargetException
+ {
+ try
+ {
+ Object instance = constructor.newInstance( arguments );
+ //getMonitor().pluginInstantiated( instance );
+ return instance;
+ }
+ catch( InvocationTargetException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Cannot create an instance of ["
+ + constructor.getDeclaringClass().getName()
+ + "] due to an instantiation failure.";
+ throw new RepositoryException( error, e );
+ }
+ }
+
+ private Constructor getSingleConstructor( Class clazz ) throws
RepositoryException
+ {
+ if( null == clazz )
+ {
+ throw new NullArgumentException( "clazz" );
+ }
+ Constructor[] constructors = clazz.getConstructors();
+ if( constructors.length < 1 )
+ {
+ final String error =
+ "Target class ["
+ + clazz.getName()
+ + "] does not declare a public constructor.";
+ throw new RepositoryException( error );
+ }
+ else if( constructors.length > 1 )
+ {
+ final String error =
+ "Target class ["
+ + clazz.getName()
+ + "] declares multiple public constructors.";
+ throw new RepositoryException( error );
+ }
+ else
+ {
+ return constructors[0];
+ }
+ }
+
+ /**
+ * Constructs an empty array instance.
+ * @param clazz the array class
+ * @return the empty array instance
+ * @exception RepositoryException if an error occurs
+ */
+ private Object[] getEmptyArrayInstance( Class clazz ) throws
RepositoryException
+ {
+ try
+ {
+ return (Object[]) Array.newInstance( clazz.getComponentType(), 0
);
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to construct an empty array
for the class: "
+ + clazz.getName();
+ throw new RepositoryException( error, e );
+ }
+ }
+
+ /**
+ * Load a factory class using a supplied classloader and factory
classname.
+ * @param classloader the classloader to load the class from
+ * @param classname the plugin classname
+ * @return the factory class
+ * @exception RepositoryException if a factory class loading error occurs
+ * @exception NullArgumentException if the supplied classloader or
classname is null
+ */
+ protected Class loadPluginClass( ClassLoader classloader, String
classname )
+ throws RepositoryException, NullArgumentException
+ {
+ if( null == classloader )
+ {
+ throw new NullArgumentException( "classloader" );
+ }
+ if( null == classname )
+ {
+ throw new NullArgumentException( "classname" );
+ }
+
+ try
+ {
+ return classloader.loadClass( classname );
+ }
+ catch( ClassNotFoundException e )
+ {
+ StringBuffer buffer = new StringBuffer();
+ packClassLoader( buffer, classloader );
+ final String error =
+ "Plugin class not found."
+ + "Class: " + classname
+ + "\n"
+ + buffer.toString();
+ throw new RepositoryException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to load class: ["
+ + classname
+ + "].";
+ throw new RepositoryException( error, e );
+ }
+ }
+
+ private void packClassLoader( StringBuffer buffer, ClassLoader
classloader )
+ {
+ if( classloader instanceof StandardClassLoader )
+ {
+ StandardClassLoader loader = (StandardClassLoader) classloader;
+ buffer.append( loader.toString( true ) );
+ }
+ else
+ {
+ buffer.append( "Classloader: " + classloader.toString() );
+ }
+ }
+}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -27,15 +27,22 @@
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URL;
+import java.net.URLConnection;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;

import net.dpml.transit.artifact.ArtifactNotFoundException;
-import net.dpml.transit.artifact.Handler;
import net.dpml.transit.monitor.RepositoryMonitorRouter;

+import net.dpml.lang.Plugin;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.Category;
+import net.dpml.lang.Strategy;
+import net.dpml.lang.PluginBuilder;
+import net.dpml.lang.Handler;
+
/**
* Utility class supporting downloading of resources based on
* artifact references.
@@ -163,34 +170,16 @@
{
throw new NullArgumentException( "parent" );
}
+
try
{
getLogger().debug( "loading plugin: " + uri );
Plugin descriptor = getPluginDescriptor( uri );
ClassLoader classloader = createClassLoader( parent, descriptor
);
- String classname = descriptor.getClassname();
- if( null == classname )
- {
- final String error =
- "Supplied plugin descriptor ["
- + uri
- + "] does not declare a main class.";
- throw new IOException( error );
- }
-
- try
- {
- Class clazz = loadPluginClass( classloader, classname );
- getLogger().debug( "established plugin class: " +
clazz.getName() );
- return createPlugin( clazz, args );
- }
- catch( ClassNotFoundException e )
- {
- final String error =
- "Class: " + classname
- + "\nURI: " + uri;
- throw new PluginClassNotFoundException( error );
- }
+ Strategy strategy = descriptor.getStrategy();
+ Handler handler = getHandler( classloader, strategy );
+ Properties properties = strategy.getProperties();
+ return handler.getPlugin( classloader, properties, args );
}
catch( RepositoryException re )
{
@@ -208,6 +197,27 @@
}
}

+ private Handler getHandler( ClassLoader classloader, Strategy strategy )
throws Exception
+ {
+ String classname = strategy.getHandlerClassname();
+ Class clazz = classloader.loadClass( classname );
+ Object handler = clazz.newInstance();
+ if( handler instanceof Handler )
+ {
+ return (Handler) handler;
+ }
+ else
+ {
+ final String error =
+ "Plugin handler classname ["
+ + classname
+ + "] does not implement the "
+ + Handler.class.getName()
+ + " interface.";
+ throw new IllegalStateException( error );
+ }
+ }
+
//---------------------------------------------------------------------
// implementation
//---------------------------------------------------------------------
@@ -237,12 +247,10 @@
try
{
ClassLoader classloader = createClassLoader( parent, descriptor
);
- String classname = descriptor.getClassname();
- if( null == classname )
- {
- throw new IllegalArgumentException( "No classname in
descriptor: " + descriptor.getURI() );
- }
- return loadPluginClass( classloader, classname );
+ Strategy strategy = descriptor.getStrategy();
+ Handler handler = getHandler( classloader, strategy );
+ Properties properties = strategy.getProperties();
+ return handler.getPluginClass( classloader, properties );
}
catch( ClassNotFoundException e )
{
@@ -255,8 +263,8 @@
catch( Throwable e )
{
final String error =
- "Failed to load plugin class.\nClass:"
- + descriptor.getClassname();
+ "Failed to load plugin.\nURI:"
+ + descriptor.getURI();
throw new RepositoryException( error, e );
}
}
@@ -277,12 +285,28 @@
throw new NullArgumentException( "uri" );
}

+ try
+ {
+ PluginBuilder builder = new PluginBuilder();
+ URL url = getURL( uri );
+ return builder.load( url );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve a plugin descriptor for ["
+ + uri
+ + "].";
+ throw new RepositoryException( error, e );
+ }
+
+ /*
Artifact artifact = getArtifact( uri );

if( !"plugin".equals( artifact.getType() ) )
{
final String error =
- "Supplied artifact [" + artifact + "] is not of a 'plugin'
type.";
+ "Supplied artifact [" + artifact + "] is not a 'plugin' type.";
throw new RepositoryException( error );
}
try
@@ -298,8 +322,21 @@
+ "].";
throw new RepositoryException( error, ce );
}
+ */
}

+ private URL getURL( URI uri ) throws IOException
+ {
+ if( Artifact.isRecognized( uri ) )
+ {
+ return Artifact.createArtifact( uri ).toURL();
+ }
+ else
+ {
+ return uri.toURL();
+ }
+ }
+
/**
* Create a factory using a supplied class and command line arguments.
*
@@ -596,22 +633,23 @@

URI plugin = descriptor.getURI();

- URI[] systemArtifacts = descriptor.getDependencies( Category.SYSTEM
);
+ Classpath classpath = descriptor.getClasspath();
+ URI[] systemArtifacts = classpath.getDependencies( Category.SYSTEM );
URL[] sysUrls = getURLs( systemArtifacts );
if( sysUrls.length > 0 )
{
updateSystemClassLoader( plugin, sysUrls );
}

- URI[] apiArtifacts = descriptor.getDependencies( Category.PUBLIC );
+ URI[] apiArtifacts = classpath.getDependencies( Category.PUBLIC );
URL[] apis = getURLs( apiArtifacts );
ClassLoader api = buildClassLoader( plugin, Category.PUBLIC, base,
apis );

- URI[] spiArtifacts = descriptor.getDependencies( Category.PROTECTED
);
+ URI[] spiArtifacts = classpath.getDependencies( Category.PROTECTED );
URL[] spis = getURLs( spiArtifacts );
ClassLoader spi = buildClassLoader( plugin, Category.PROTECTED, api,
spis );

- URI[] impArtifacts = descriptor.getDependencies( Category.PRIVATE );
+ URI[] impArtifacts = classpath.getDependencies( Category.PRIVATE );
URL[] imps = getURLs( impArtifacts );
ClassLoader classloader = buildClassLoader( plugin,
Category.PRIVATE, spi, imps );

@@ -653,7 +691,15 @@
URL[] urls = new URL[ uris.length ];
for( int i=0; i < urls.length; i++ )
{
- urls[i] = new URL( null, uris[i].toString(), new Handler() );
+ URI uri = uris[i];
+ if( Artifact.isRecognized( uri ) )
+ {
+ urls[i] = Artifact.toURL( uri );
+ }
+ else
+ {
+ urls[i] = uri.toURL();
+ }
}
return urls;
}
@@ -783,12 +829,13 @@
{
throw new NullArgumentException( "artifact" );
}
-
+
try
{
URL url = artifact.toURL();
Properties props = new Properties();
- InputStream input = url.openConnection().getInputStream();
+ URLConnection connection = url.openConnection();
+ InputStream input = connection.getInputStream();
props.load( input );
return props;
}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/SystemClassLoader.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/SystemClassLoader.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/SystemClassLoader.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -24,6 +24,8 @@
import java.util.List;
import java.util.Arrays;

+import net.dpml.lang.Category;
+
/**
* The SystemClassLoader is a URLClassLoader that supports late binding of
* URLs. This class may be configured as the system classloader when
loading plugins

Added: trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,461 @@
+/*
+ * Copyright 2006 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.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import net.dpml.transit.util.ElementHelper;
+import net.dpml.transit.info.TransitDirective;
+import net.dpml.transit.info.CacheDirective;
+import net.dpml.transit.info.HostDirective;
+import net.dpml.transit.info.ProxyDirective;
+
+import net.dpml.lang.DTD;
+import net.dpml.lang.DTDResolver;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+
+/**
+ * Utility class supporting the reading of Transit XML configurations.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class TransitBuilder
+{
+ public static final String XML_HEADER =
+ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+
+ public static final String NAME = "transit";
+
+ public static final String PUBLIC_ID =
+ "-//DPML//DTD Transit Configuration Version 1.0//EN";
+
+ public static final String SYSTEM_ID =
+ "http://www.dpml.net/dtds/transit_1_0.dtd";;
+
+ public static final String RESOURCE =
+ "net/dpml/transit/transit_1_0.dtd";
+
+
+ private static final String DOCTYPE =
+ "\n<!DOCTYPE "
+ + NAME
+ + " PUBLIC \""
+ + PUBLIC_ID
+ + "\" \""
+ + SYSTEM_ID
+ + "\" >";
+
+
+ private static final DTD[] DTDS = new DTD[]
+ {
+ new DTD(
+ PUBLIC_ID,
+ SYSTEM_ID,
+ RESOURCE, null )
+ };
+
+ private static final DTDResolver DTD_RESOLVER =
+ new DTDResolver( DTDS, TransitBuilder.class.getClassLoader() );
+
+ private static final ErrorHandler ERROR_HANDLER =
+ new InternalErrorHandler();
+
+ /**
+ * Construct a transit configuration from a supplied uri.
+ * @param url the configuration url
+ * @return the configuration
+ * @exception Exception if an error occurs during configuration loading
+ */
+ public TransitDirective load( final URL url ) throws Exception
+ {
+ URLConnection connection = url.openConnection();
+ InputStream input = connection.getInputStream();
+
+ final DocumentBuilderFactory factory =
+ DocumentBuilderFactory.newInstance();
+ factory.setValidating( true );
+ factory.setNamespaceAware( true );
+ factory.setExpandEntityReferences( true );
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver( DTD_RESOLVER );
+ builder.setErrorHandler( ERROR_HANDLER );
+
+ final Document document = builder.parse( input );
+ //final DocumentType docType = document.getDoctype();
+ // TODO check doctype name and version
+ final Element root = document.getDocumentElement();
+ return build( root );
+ }
+
+ public void write( TransitDirective directive, OutputStream output )
throws IOException
+ {
+ final Writer writer = new OutputStreamWriter( output );
+ try
+ {
+ writer.write( XML_HEADER );
+ writer.write( DOCTYPE );
+
+ CacheDirective cache = directive.getCacheDirective();
+ String cachePath = cache.getCache();
+ String cacheLayout = cache.getCacheLayout();
+ writeHeader( writer, cachePath, cacheLayout );
+
+ ProxyDirective proxy = directive.getProxyDirective();
+ writeProxy( writer, proxy );
+
+ String localPath = cache.getLocal();
+ String localLayout = cache.getLocalLayout();
+ writeLocal( writer, localPath, localLayout );
+
+ HostDirective[] hosts = cache.getHostDirectives();
+ writeHosts( writer, hosts );
+
+ writeFooter( writer );
+ writer.write( "\n" );
+ }
+ finally
+ {
+ writer.flush();
+ writer.close();
+ }
+ }
+
+ private void writeProxy( Writer writer, ProxyDirective proxy ) throws
IOException
+ {
+ if( null != proxy )
+ {
+ String host = proxy.getHost();
+ String username = proxy.getUsername();
+ String password = getPassword( proxy.getPassword() );
+ String[] excludes = proxy.getExcludes();
+
+ boolean credentials = ( ( null != username ) || ( null !=
password ) );
+
+ if( excludes.length == 0 && ( !credentials ) )
+ {
+ writer.write(
+ "\n <proxy host=\"" + host + "\"/>" );
+ }
+ else
+ {
+ writer.write( "\n <proxy host=\"" + host + "\">" );
+ if( credentials )
+ {
+ writer.write( "\n <credentials" );
+ if( null != username )
+ {
+ writer.write( " username=\"" + username + "\"" );
+ }
+ if( null != password )
+ {
+ writer.write( " password=\"" + password + "\"" );
+ }
+ writer.write( "/>" );
+ }
+ if( excludes.length > 0 )
+ {
+ writer.write( "\n <excludes>" );
+ for( int i=0; i<excludes.length; i++ )
+ {
+ String exclude = excludes[i];
+ writer.write( "\n <exclude>" + exclude +
"</exclude>" );
+ }
+ writer.write( "\n </excludes>" );
+ }
+
+ writer.write( "\n </proxy>" );
+ }
+ }
+ }
+
+ private void writeLocal( Writer writer, String path, String layout )
throws IOException
+ {
+ writer.write( "\n <local path=\"" + path + "\" layout=\"" + layout
+ "\"/>" );
+ }
+
+ private void writeHosts( Writer writer, HostDirective[] hosts ) throws
IOException
+ {
+ writer.write( "\n <hosts>" );
+ for( int i=0; i<hosts.length; i++ )
+ {
+ HostDirective host = hosts[i];
+ writeHost( writer, host );
+ }
+ writer.write( "\n </hosts>" );
+ }
+
+ private void writeHost( Writer writer, HostDirective host ) throws
IOException
+ {
+ String id = host.getID();
+ int priority = host.getPriority();
+ String url = host.getHost();
+ boolean enabled = host.getEnabled();
+ boolean trusted = host.getTrusted();
+ String layout = host.getLayout();
+ String index = host.getIndex();
+ String scheme = host.getScheme();
+ String prompt = host.getPrompt();
+ String username = host.getUsername();
+ String password = getPassword( host.getPassword() );
+ boolean credentials = ( ( null != username ) || ( null != password )
);
+
+ writer.write( "\n <host id=\"" + id + "\" priority=\"" + priority
+ "\" url=\"" + url + "\"" );
+ if( !enabled )
+ {
+ writer.write( " enabled=\"false\"" );
+ }
+ if( trusted )
+ {
+ writer.write( " trusted=\"true\"" );
+ }
+ if( null != layout )
+ {
+ writer.write( " layout=\"" + layout + "\"" );
+ }
+ if( null != index )
+ {
+ writer.write( " index=\"" + index + "\"" );
+ }
+ if( ( null != scheme ) && !scheme.equals( "" ) )
+ {
+ writer.write( " scheme=\"" + scheme + "\"" );
+ }
+ if( ( null != prompt ) && !prompt.equals( "" ) )
+ {
+ writer.write( " prompt=\"" + prompt + "\"" );
+ }
+ if( credentials )
+ {
+ writer.write( "\n <credentials" );
+ if( null != username )
+ {
+ writer.write( " username=\"" + username + "\"" );
+ }
+ if( null != password )
+ {
+ writer.write( " password=\"" + password + "\"" );
+ }
+ writer.write( "/>" );
+ writer.write( "\n </host>" );
+ }
+ else
+ {
+ writer.write( "/>" );
+ }
+ }
+
+ private String getPassword( char[] password )
+ {
+ if( null == password )
+ {
+ return null;
+ }
+ else
+ {
+ return new String( password );
+ }
+ }
+
+ //-------------------------------------------------------------
+ // internals supporting XML to directive
+ //-------------------------------------------------------------
+
+ private TransitDirective build( Element root ) throws IOException
+ {
+ String name = root.getTagName();
+ if( !NAME.equals( name ) )
+ {
+ final String error =
+ "Invalid root element name ["
+ + name
+ + "].";
+ throw new IOException( error );
+ }
+
+ String cachePath = ElementHelper.getAttribute( root, "cache" );
+ String cacheLayout = ElementHelper.getAttribute( root, "layout" );
+
+ Element localElement = ElementHelper.getChild( root, "local" );
+ String localPath = ElementHelper.getAttribute( localElement, "path"
);
+ String localLayout = ElementHelper.getAttribute( localElement,
"layout" );
+
+ Element proxyElement = ElementHelper.getChild( root, "proxy" );
+ ProxyDirective proxy = buildProxyDirective( proxyElement );
+
+ Element hostsElement = ElementHelper.getChild( root, "hosts" );
+ HostDirective[] hosts = buildHosts( hostsElement );
+
+ // layouts TBD
+ // handlers TBD
+
+ CacheDirective cache =
+ new CacheDirective(
+ cachePath, cacheLayout, localPath, localLayout,
+ CacheDirective.EMPTY_LAYOUTS, hosts,
CacheDirective.EMPTY_CONTENT );
+ return new TransitDirective( proxy, cache );
+ }
+
+ private ProxyDirective buildProxyDirective( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ String host = ElementHelper.getAttribute( element, "host" );
+ Element credentialsElement = ElementHelper.getChild( element,
"credentials" );
+ String username = getUsername( credentialsElement );
+ char[] password = getPassword( credentialsElement );
+ String[] excludes = buildProxyExcludes( element );
+ return new ProxyDirective( host, excludes, username, password );
+ }
+ }
+
+ private String[] buildProxyExcludes( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ Element[] elements = ElementHelper.getChildren( element,
"exclude" );
+ String[] excludes = new String[ elements.length ];
+ for( int i=0; i<excludes.length; i++ )
+ {
+ Element elem = elements[i];
+ excludes[i] = ElementHelper.getValue( elem );
+ }
+ return excludes;
+ }
+ }
+
+ private HostDirective[] buildHosts( Element element )
+ {
+ Element[] elements = ElementHelper.getChildren( element, "host" );
+ HostDirective[] hosts = new HostDirective[ elements.length ];
+ for( int i=0; i<hosts.length; i++ )
+ {
+ Element elem = elements[i];
+ String id = ElementHelper.getAttribute( elem, "id" );
+ int priority = Integer.parseInt( ElementHelper.getAttribute(
elem, "priority" ) );
+ String url = ElementHelper.getAttribute( elem, "url" );
+ String layout = ElementHelper.getAttribute( elem, "layout" );
+ boolean enabled = ElementHelper.getBooleanAttribute( elem,
"enabled" );
+ boolean trusted = ElementHelper.getBooleanAttribute( elem,
"trusted" );
+ String index = ElementHelper.getAttribute( elem, "index" );
+ String scheme = ElementHelper.getAttribute( elem, "scheme" );
+ String prompt = ElementHelper.getAttribute( elem, "prompt" );
+ Element credentialsElement = ElementHelper.getChild( elem,
"credentials" );
+ String username = getUsername( credentialsElement );
+ char[] password = getPassword( credentialsElement );
+ hosts[i] =
+ new HostDirective(
+ id, priority, url, index, username, password, enabled,
trusted,
+ layout, scheme, prompt );
+ }
+ return hosts;
+ }
+
+ private String getUsername( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ return ElementHelper.getAttribute( element, "username" );
+ }
+ }
+
+ private char[] getPassword( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ String password = ElementHelper.getAttribute( element,
"password" );
+ if( null == password )
+ {
+ return null;
+ }
+ else
+ {
+ return password.toCharArray();
+ }
+ }
+ }
+
+ //-------------------------------------------------------------
+ // internals supporting directive to XML
+ //-------------------------------------------------------------
+
+ private void writeHeader( Writer writer, String cache, String layout )
throws IOException
+ {
+ writer.write( "\n\n<" + NAME + " cache=\"" + cache + "\" layout=\""
+ layout + "\">" );
+ }
+
+ private void writeFooter( Writer writer ) throws IOException
+ {
+ writer.write( "\n</" + NAME + ">" );
+ }
+
+ //-------------------------------------------------------------
+ // utilities
+ //-------------------------------------------------------------
+
+ private static final class InternalErrorHandler implements ErrorHandler
+ {
+ public void error( SAXParseException e ) throws SAXException
+ {
+ System.out.println( "ERROR: " + e.getMessage() );
+ }
+ public void fatalError( SAXParseException e ) throws SAXException
+ {
+ System.out.println( "FATAL: " + e.getMessage() );
+ }
+ public void warning( SAXParseException e ) throws SAXException
+ {
+ System.out.println( "WARN: " + e.getMessage() );
+ }
+ }
+}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -34,7 +34,7 @@
import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;
import net.dpml.transit.Repository;
-import net.dpml.transit.Plugin;
+import net.dpml.lang.Plugin;
import net.dpml.transit.SecuredTransitContext;
import net.dpml.transit.ContentRegistry;
import net.dpml.transit.CacheHandler;

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/CacheDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/CacheDirectiveBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/CacheDirectiveBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,53 +0,0 @@
-/*
- * Copyright 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.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the LayoutHandlerDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class CacheDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( CacheDirective.class
);
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{
- "cache", "cacheLayout", "local", "localLayout",
- "layoutDirectives", "hostDirectives", "contentDirectives"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/CodeBaseDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/CodeBaseDirectiveBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/CodeBaseDirectiveBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,51 +0,0 @@
-/*
- * Copyright 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.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CodeBaseDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class CodeBaseDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
CodeBaseDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{"codeBaseURISpec", "valueDirectives"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/ContentDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/ContentDirectiveBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/ContentDirectiveBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,51 +0,0 @@
-/*
- * Copyright 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.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ContentHandlerDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ContentDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ContentDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{"ID", "title", "CodeBaseURISpec",
"valueDirectives"} ) );
- return descriptor;
- }
-}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirective.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirective.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirective.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -214,6 +214,10 @@
{
return false;
}
+ else if( m_priority != directive.m_priority )
+ {
+ return false;
+ }
else if( m_trusted != directive.m_trusted )
{
return false;
@@ -277,7 +281,7 @@
*/
public int hashCode()
{
- int hash = 0;
+ int hash = m_priority;
hash ^= hashValue( m_id );
hash ^= hashValue( new Boolean( m_trusted ) );
hash ^= hashValue( new Boolean( m_enabled ) );

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirectiveBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/HostDirectiveBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,53 +0,0 @@
-/*
- * Copyright 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.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CodeBaseDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class HostDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( HostDirective.class
);
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{
- "ID", "priority", "host", "index", "username", "password",
- "enabled", "trusted", "layout", "scheme", "prompt"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/LayoutDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/LayoutDirectiveBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/LayoutDirectiveBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,51 +0,0 @@
-/*
- * Copyright 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.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the LayoutHandlerDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class LayoutDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
LayoutDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{"ID", "title", "CodeBaseURISpec",
"valueDirectives"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/ProxyDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/ProxyDirectiveBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/ProxyDirectiveBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,51 +0,0 @@
-/*
- * Copyright 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.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CodeBaseDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ProxyDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( ProxyDirective.class
);
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{"host", "excludes", "username", "password"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/TransitDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/TransitDirectiveBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/TransitDirectiveBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,53 +0,0 @@
-/*
- * Copyright 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.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the LayoutHandlerDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class TransitDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
TransitDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{
- "proxyDirective",
- "cacheDirective"} ) );
- return descriptor;
- }
-}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/util/ElementHelper.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/util/ElementHelper.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/main/net/dpml/transit/util/ElementHelper.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Properties;

+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
@@ -88,8 +89,22 @@
DocumentBuilderFactory.newInstance();
factory.setValidating( false );
factory.setNamespaceAware( false );
- final Document document =
- factory.newDocumentBuilder().parse( input );
+ factory.setExpandEntityReferences( false );
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ return getRootElement( builder, input );
+ }
+
+ /**
+ * Return the root element of the supplied input stream.
+ * @param builder the document builder
+ * @param input the input stream containing a XML definition
+ * @return the root element
+ * @exception Exception if an error occurs
+ */
+ public static Element getRootElement( final DocumentBuilder builder,
final InputStream input )
+ throws Exception
+ {
+ final Document document = builder.parse( input );
return document.getDocumentElement();
}


Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferences.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferences.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferences.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,191 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.util;
-
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.prefs.AbstractPreferences;
-import java.util.prefs.BackingStoreException;
-
-/**
- * An implementation of Preferences based on java.util.Properties suitable
- * for scenarios where the persistent lifetime is limited to the lifetype
- * of the JVM.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class LocalPreferences extends AbstractPreferences
-{
- private final Properties m_properties;
- private Hashtable m_table = new Hashtable();
- private final boolean m_system;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Constructs a new local user preferences object.
- * @param parent the parent node
- * @param name the preferences node name
- */
- public LocalPreferences( LocalPreferences parent, String name )
- {
- this( parent, name, false );
- }
-
- /**
- * Constructs a new local preferences object.
- * @param parent the parent node
- * @param name the preferences node name
- * @param system TRUE if this is a system preference tree
- */
- public LocalPreferences( LocalPreferences parent, String name, boolean
system )
- {
- super( parent, name );
- m_properties = new Properties();
- m_system = system;
- }
-
- //
------------------------------------------------------------------------
- // LocalPreferences
- //
------------------------------------------------------------------------
-
- /**
- * Return true if this is a user node else false.
- * @return the user node status
- */
- public boolean isUserNode()
- {
- return !m_system;
- }
-
- /**
- * Set an attribute value.
- * @param key the attribute key
- * @param value the attribute value
- */
- protected void putSpi( String key, String value )
- {
- getProperties().setProperty( key, value );
- }
-
- /**
- * Get an attribute value.
- * @param key the attribute key
- * @return the attribute value
- */
- protected String getSpi( String key )
- {
- return getProperties().getProperty( key );
- }
-
- /**
- * Remove an attribute.
- * @param key the attribute key
- */
- protected void removeSpi( String key )
- {
- getProperties().remove( key );
- }
-
- /**
- * Remove the preferences node.
- * @exception BackingStoreException if a backing store exception occurs
- */
- protected void removeNodeSpi() throws BackingStoreException
- {
- LocalPreferences parent = (LocalPreferences) parent();
- if( null != parent )
- {
- parent.removeNode( name() );
- }
- }
-
- /**
- * Return the set of attribute keys in this preferences node.
- * @return the array of attribute names
- * @exception BackingStoreException if a backing store exception occurs
- */
- protected String[] keysSpi() throws BackingStoreException
- {
- return (String[]) m_properties.keySet().toArray( new String[0] );
- }
-
- /**
- * Return an array of child node names.
- * @return the array of child node names
- * @exception BackingStoreException if a backing store exception occurs
- */
- protected String[] childrenNamesSpi() throws BackingStoreException
- {
- return (String[]) m_table.keySet().toArray( new String[0] );
- }
-
- /**
- * Return a named child node.
- * @param name the the child node name
- * @return the the child node
- */
- protected AbstractPreferences childSpi( String name )
- {
- synchronized( m_table )
- {
- LocalPreferences prefs = (LocalPreferences) m_table.get( name );
- if( null != prefs )
- {
- return prefs;
- }
- else
- {
- LocalPreferences p = new LocalPreferences( this, name,
m_system );
- m_table.put( name, p );
- return p;
- }
- }
- }
-
- /**
- * Synchronize changes.
- * @exception BackingStoreException if a backing store exception occurs
- */
- protected void syncSpi() throws BackingStoreException
- {
- }
-
- /**
- * Flush changes.
- * @exception BackingStoreException if a backing store exception occurs
- */
- protected void flushSpi() throws BackingStoreException
- {
- }
-
- void removeNode( String name )
- {
- synchronized( m_table )
- {
- m_table.remove( name );
- }
- }
-
- private Properties getProperties()
- {
- return m_properties;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesBeanInfo.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesBeanInfo.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,146 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.util;
-
-import java.beans.Encoder;
-import java.beans.Expression;
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.PropertyDescriptor;
-import java.util.prefs.Preferences;
-import java.util.prefs.BackingStoreException;
-
-/**
- * An implementation of Preferences based on java.util.Properties suitable
- * for scenarios where the persistent lifetime is limited to the lifetype
- * of the JVM.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class LocalPreferencesBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Return the property descriptors.
- * @return the property descriptors
- */
- public PropertyDescriptor[] getPropertyDescriptors()
- {
- return new PropertyDescriptor[0];
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
LocalPreferences.class );
- descriptor.setValue(
- "persistenceDelegate",
- new LocalPreferencesPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate.
- */
- private static class LocalPreferencesPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Instantiate an expression.
- * @param old the old value
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- if( null == old )
- {
- return null;
- }
-
- try
- {
- Preferences prefs = (Preferences) old;
- Object[] args = new Object[ 4 ];
- args[0] = prefs.absolutePath();
- args[1] = decomposeEntries( prefs );
- args[2] = decomposeNodes( prefs );
- args[3] = new Boolean( !prefs.isUserNode() );
- return new Expression( old, LocalPreferencesFactory.class,
"parse", args );
- }
- catch( Exception e )
- {
- throw new RuntimeException( e );
- }
- }
-
- /**
- * Return an object[] in the form { String name, String[][] entries,
Object[] nodes, Boolean system );
- */
- private Object[] getNodeStructure( Preferences prefs ) throws
BackingStoreException
- {
- Object[] array = new Object[3];
- array[0] = prefs.name();
- array[1] = decomposeEntries( prefs );
- array[2] = decomposeNodes( prefs );
- return array;
- }
-
- private Object[] decomposeEntries( Preferences prefs ) throws
BackingStoreException
- {
- final String[] keys = prefs.keys();
- int n = keys.length;
- final Object[] args = new Object[n];
- for( int i=0; i<n; i++ )
- {
- final String key = keys[i];
- final String[] pair = new String[2];
- pair[0] = key;
- pair[1] = prefs.get( key, null );
- args[i] = pair;
- }
- return args;
- }
-
- private Object[] decomposeNodes( Preferences prefs ) throws
BackingStoreException
- {
- String[] names = prefs.childrenNames();
- int n = names.length;
- Object[] nodes = new Object[ n ];
- for( int i=0; i<n; i++ )
- {
- String name = names[i];
- Preferences p = prefs.node( name );
- nodes[i] = getNodeStructure( p );
- }
- return nodes;
- }
-
- }
-
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesFactory.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesFactory.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/main/net/dpml/transit/util/LocalPreferencesFactory.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,135 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.util;
-
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferencesFactory;
-
-/**
- * <p>A implementation of the Preferences services that provides persistence
for
- * the duration of the JVM.
- * The implementation holds preferences attribue values in memory using
Properties.
- * The implementation is suitable for the construction of preferences that
for
- * usage in non-shared scenarios (such as testcases or short running
applications).
- * The preference implementation is established via declaration of the
following
- * system property prior to preferences usage:</p>
- *
- * <pre>
- * System.setProperty(
- * "java.util.prefs.PreferencesFactory",
- * "net.dpml.transit.store.LocalPreferencesFactory" );
- * </pre>
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class LocalPreferencesFactory implements PreferencesFactory
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- private static final Preferences SYSTEM = new LocalPreferences( null,
"", true );
- private static final Preferences USER = new LocalPreferences( null, "",
false );
-
- //
------------------------------------------------------------------------
- // PreferencesFactory
- //
------------------------------------------------------------------------
-
- /**
- * Return the root system preferences node.
- * @return the root node of the system prefs
- */
- public Preferences systemRoot()
- {
- return SYSTEM;
- }
-
- /**
- * Return the root user preferences node.
- * @return the root node of the user prefs
- */
- public Preferences userRoot()
- {
- return USER;
- }
-
- //
------------------------------------------------------------------------
- // special
- //
------------------------------------------------------------------------
-
- /**
- * Return a preferences instance using the supplied arguments.
- * @param path the preference node path
- * @param entries the preference attribute node array
- * @param nodes subsidary nodes
- * @param system true if declaring the node as system scope
- * @return the new prefernces instance
- */
- public static Preferences parse( String path, Object[] entries, Object[]
nodes, boolean system )
- {
- Preferences root = getRootPreferences( system );
- Preferences prefs = root.node( path );
- applyAttributes( prefs, entries );
- applyNodes( prefs, nodes );
- return prefs;
- }
-
- private static Preferences getRootPreferences( boolean system )
- {
- if( system )
- {
- return new LocalPreferences( null, "", true );
- }
- else
- {
- return new LocalPreferences( null, "", false );
- }
- }
-
- private static void applyAttributes( Preferences prefs, Object[] entries
)
- {
- //System.out.println( "applying attributes to: " + prefs );
- for( int i=0; i<entries.length; i++ )
- {
- String[] entry = (String[]) entries[i];
- if( entry.length != 2 )
- {
- throw new IllegalArgumentException(
- "Invalid attribute array length - expecting 2 but
encountered " + entry.length );
- }
- String key = entry[0];
- String value = entry[1];
- prefs.put( key, value );
- }
- }
-
- private static void applyNodes( Preferences prefs, Object[] nodes )
- {
- //System.out.println( "applying nodes to: " + prefs );
- for( int i=0; i<nodes.length; i++ )
- {
- Object[] node = (Object[]) nodes[i];
- String name = (String) node[0];
- Preferences p = prefs.node( name );
- String[][] entries = (String[][]) node[1];
- applyAttributes( p, entries );
- Object[] subnodes = (Object[]) node[2];
- applyNodes( p, subnodes );
- }
- }
-}

Added: trunk/main/transit/core/src/test/net/dpml/lang/test/PluginTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/lang/test/PluginTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/core/src/test/net/dpml/lang/test/PluginTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2004-2006 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.lang.test;
+
+import java.net.URI;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import net.dpml.lang.DefaultPlugin;
+import net.dpml.lang.Plugin;
+import net.dpml.lang.Strategy;
+import net.dpml.lang.DefaultStrategy;
+import net.dpml.lang.Category;
+import net.dpml.lang.PluginBuilder;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.DefaultClasspath;
+
+/**
+ * Plugin test case.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PluginTestCase extends TestCase
+{
+ private URI[] m_system;
+ private URI[] m_public;
+ private URI[] m_protected;
+ private URI[] m_private;
+ private Classpath m_classpath;
+ private String m_title = "Sample Plugin";
+ private String m_description = "Plugin generated via a testcase used for
validation of the externalization of a plugin definition to XML and the
subsequent reading in of the XML form and cronstruction of an equivalent
plugin definition.";
+
+ /**
+ * Testcase setup.
+ * @exception Exception if an error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_system =
+ new URI[]
+ {
+ new URI( "thing:a" ),
+ new URI( "thing:b" )
+ };
+ m_public =
+ new URI[]
+ {
+ new URI( "thing:c" ),
+ new URI( "thing:d" ),
+ new URI( "thing:e" )
+ };
+ m_protected =
+ new URI[]
+ {
+ new URI( "thing:f" )
+ };
+ m_private =
+ new URI[]
+ {
+ new URI( "thing:g" ),
+ new URI( "thing:h" ),
+ new URI( "thing:i" ),
+ new URI( "thing:j" )
+ };
+ m_classpath = new DefaultClasspath( m_system, m_public, m_protected,
m_private );
+ }
+
+ /**
+ * Test invalid null path argument.
+ * @exception Exception if an unexpected error occurs
+ */
+ public void testPluginCreation() throws Exception
+ {
+ URI uri = new URI( "plugin:test" );
+ Properties properties = new Properties();
+ properties.setProperty( "foo", "bar" );
+ properties.setProperty( "pi", "3.142" );
+ Strategy strategy = new DefaultStrategy( "Test", properties );
+ Plugin plugin =
+ new DefaultPlugin(
+ m_title, m_description, uri, strategy, m_classpath );
+ assertEquals( "title", m_title, plugin.getTitle() );
+ assertEquals( "description", m_description, plugin.getDescription()
);
+ assertEquals( "uri", uri, plugin.getURI() );
+ assertEquals( "strategy", strategy, plugin.getStrategy() );
+ Classpath classpath = plugin.getClasspath();
+ assertEquals( "classpath", m_classpath, classpath );
+ assertEquals( "system", m_system.length, classpath.getDependencies(
Category.SYSTEM ).length );
+ assertEquals( "public", m_public.length, classpath.getDependencies(
Category.PUBLIC ).length );
+ assertEquals( "protected", m_protected.length,
classpath.getDependencies( Category.PROTECTED ).length );
+ assertEquals( "private", m_private.length,
classpath.getDependencies( Category.PRIVATE ).length );
+ }
+
+ /**
+ * Test the generation of a plugin xml file using the simple strategy.
+ * @exception Exception if an unexpected error occurs
+ */
+ public void testSimpleStrategyExternalization() throws Exception
+ {
+ File file = new File( "target/test/plugin.xml" );
+ Properties properties = new Properties();
+ properties.setProperty( "foo", "bar" );
+ properties.setProperty( "pi", "3.142" );
+ URI uri = file.toURI();
+ Strategy strategy = new DefaultStrategy( "Test", properties );
+ Plugin plugin =
+ new DefaultPlugin(
+ m_title, m_description, uri, strategy, m_classpath );
+ FileOutputStream output = new FileOutputStream( file );
+ plugin.write( output );
+ PluginBuilder builder = new PluginBuilder();
+ Plugin p = builder.load( file.toURI().toURL() );
+ assertEquals( "plugin", plugin, p );
+ }
+
+}

Deleted:
trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,195 +0,0 @@
-/*
- * 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.InputStream;
-import java.net.URI;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id: PropertiesPluginTestCase.java 2445 2005-04-28 23:44:22Z
niclas AT hedhman.org $
- */
-public class PropertiesPluginTestCase extends TestCase
-{
- private PropertiesPlugin m_plugin;
-
- /**
- * Test case setup.
- * @exception Exception if an error occurs during setup.
- */
- protected void setUp() throws Exception
- {
- Properties props = new Properties();
- InputStream stream = getClass().getResourceAsStream(
"/plugin.properties" );
- props.load( stream );
- m_plugin = new PropertiesPlugin( props );
- }
-
- /**
- * Test artifact name accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testArtifactName() throws Exception
- {
- Artifact artifact = Artifact.createArtifact( m_plugin.getURI() );
- assertEquals( "Artifact name", "dpml-metro-cli", artifact.getName()
);
- }
-
- /**
- * Test artifact uri accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testArtifactToURI() throws Exception
- {
- Artifact artifact = Artifact.createArtifact( m_plugin.getURI() );
- URI uri = URI.create(
"artifact:plugin:dpml/metro/dpml-metro-cli#123" );
- assertEquals( "Artifact URI", uri, artifact.toURI() );
- }
-
- /**
- * Test artifact domain accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testDomain() throws Exception
- {
- assertEquals( "Domain", "net.dpml",
m_plugin.getSpecificationNamespace() );
- }
-
- /**
- * Test artifact version accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testVersion() throws Exception
- {
- assertEquals( "Version", "1.0", m_plugin.getSpecificationVersion() );
- }
-
- /**
- * Test artifact classname accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testClassname() throws Exception
- {
- assertEquals( "Classname", "net.dpml.metro.Metro",
m_plugin.getClassname() );
- }
-
- /**
- * Test artifact interfaces accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testInterface() throws Exception
- {
- // TODO: Fix a better sample
- assertEquals( "Interface", null, m_plugin.getInterface() );
- }
-
- /**
- * Test artifact PUBLIC dependencies accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testPublicDependencies() throws Exception
- {
- URI[] facts = m_plugin.getDependencies( Category.PUBLIC );
- assertEquals( "API deps", 4, facts.length );
-
- URI uri = URI.create(
"artifact:jar:dpml/logging/dpml-logging-api#123" );
- assertEquals( "API Artifact URI", uri, facts[0] );
- uri = URI.create( "artifact:jar:dpml/activity/dpml-activity-api#123"
);
- assertEquals( "API Artifact URI", uri, facts[1] );
- uri = URI.create( "artifact:jar:dpml/context/dpml-context-api#123" );
- assertEquals( "API Artifact URI", uri, facts[2] );
- uri = URI.create( "artifact:jar:dpml/transit/dpml-transit-main#123"
);
- assertEquals( "API Artifact URI", uri, facts[3] );
- }
-
- /**
- * Test artifact PROTECTED dependencies accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testProtectedDependencies() throws Exception
- {
- URI[] facts = m_plugin.getDependencies( Category.PROTECTED );
- assertEquals( "SPI deps", 2, facts.length );
-
- URI uri = URI.create(
"artifact:jar:dpml/transit/dpml-transit-spi#123" );
- assertEquals( "SPI Artifact URI", uri, facts[0] );
- uri = URI.create( "artifact:jar:dpml/logging/dpml-logging-spi#123" );
- assertEquals( "SPI Artifact URI", uri, facts[1] );
- }
-
- /**
- * Test artifact PRIVATE dependencies accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testPrivateDependencies() throws Exception
- {
- URI[] facts = m_plugin.getDependencies( Category.PRIVATE );
- assertEquals( "Impl deps", 5, facts.length );
-
- URI uri = URI.create( "artifact:jar:dpml/util/dpml-util-i18n#123" );
- assertEquals( "Impl Artifact URI", uri, facts[0] );
- uri = URI.create( "artifact:jar:dpml/util/dpml-util-exception#123" );
- assertEquals( "Impl Artifact URI", uri, facts[1] );
- uri = URI.create( "artifact:jar:dpml/util/dpml-util-cli#123" );
- assertEquals( "Impl Artifact URI", uri, facts[2] );
- uri = URI.create( "artifact:jar:commons-cli/commons-cli#1.0" );
- assertEquals( "Impl Artifact URI", uri, facts[3] );
- uri = URI.create( "artifact:jar:dpml/metro/dpml-metro-cli#123" );
- assertEquals( "Impl Artifact URI", uri, facts[4] );
- }
-
- /**
- * Test artifact dependencies accessor.
- * @exception Exception if an error occurs during setup.
- */
- public void testAllDependencies() throws Exception
- {
- URI[] facts = m_plugin.getDependencies();
- assertEquals( "All deps", 11, facts.length );
-
- URI uri = URI.create(
"artifact:jar:dpml/logging/dpml-logging-api#123" );
- assertEquals( "API Artifact URI", uri, facts[0] );
- uri = URI.create( "artifact:jar:dpml/activity/dpml-activity-api#123"
);
- assertEquals( "API Artifact URI", uri, facts[1] );
- uri = URI.create( "artifact:jar:dpml/context/dpml-context-api#123" );
- assertEquals( "API Artifact URI", uri, facts[2] );
- uri = URI.create( "artifact:jar:dpml/transit/dpml-transit-main#123"
);
- assertEquals( "API Artifact URI", uri, facts[3] );
-
- uri = URI.create( "artifact:jar:dpml/transit/dpml-transit-spi#123" );
- assertEquals( "SPI Artifact URI", uri, facts[4] );
- uri = URI.create( "artifact:jar:dpml/logging/dpml-logging-spi#123" );
- assertEquals( "SPI Artifact URI", uri, facts[5] );
-
- uri = URI.create( "artifact:jar:dpml/util/dpml-util-i18n#123" );
- assertEquals( "Impl Artifact URI", uri, facts[6] );
- uri = URI.create( "artifact:jar:dpml/util/dpml-util-exception#123" );
- assertEquals( "Impl Artifact URI", uri, facts[7] );
- uri = URI.create( "artifact:jar:dpml/util/dpml-util-cli#123" );
- assertEquals( "Impl Artifact URI", uri, facts[8] );
- uri = URI.create( "artifact:jar:commons-cli/commons-cli#1.0" );
- assertEquals( "Impl Artifact URI", uri, facts[9] );
- uri = URI.create( "artifact:jar:dpml/metro/dpml-metro-cli#123" );
- assertEquals( "Impl Artifact URI", uri, facts[10] );
- }
-}
-

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -72,6 +72,7 @@
* @return the result of decoding the encoded form of the supplied object
* @exception Exception is an error occurs
*/
+ /*
public Object doEncodingTest( Object object, String filename ) throws
Exception
{
String base = System.getProperty( "project.test.dir" );
@@ -102,4 +103,5 @@
assertEquals( "hash", object.hashCode(), result.hashCode() );
return result;
}
+ */
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -129,9 +129,9 @@
* Test directive encoding.
* @exception Exception if an error occurs during setup.
*/
- public void testEncoding() throws Exception
- {
- CacheDirective result = (CacheDirective) doEncodingTest(
m_directive, "cache.xml" );
- assertEquals( "encoded", m_directive, result );
- }
+ //public void testEncoding() throws Exception
+ //{
+ // CacheDirective result = (CacheDirective) doEncodingTest(
m_directive, "cache.xml" );
+ // assertEquals( "encoded", m_directive, result );
+ //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -140,10 +140,10 @@
* Test encoding.
* @exception Exception if an error occurs during setup.
*/
- public void testEncoding() throws Exception
- {
- CodeBaseDirective directive = new CodeBaseDirective( m_codebase,
m_values );
- CodeBaseDirective result = (CodeBaseDirective) doEncodingTest(
directive, "value-directive.xml" );
- assertEquals( "encoded", directive, result );
- }
+ //public void testEncoding() throws Exception
+ //{
+ // CodeBaseDirective directive = new CodeBaseDirective( m_codebase,
m_values );
+ // CodeBaseDirective result = (CodeBaseDirective) doEncodingTest(
directive, "value-directive.xml" );
+ // assertEquals( "encoded", directive, result );
+ //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -107,14 +107,14 @@
* Test encoding.
* @exception Exception if an error occurs during setup.
*/
- public void testEncoding() throws Exception
- {
- String codebase = getCodebaseValue();
- ValueDirective[] values = getValueDirectives();
- ContentDirective directive =
- new ContentDirective( m_id, m_title, codebase, values );
- ContentDirective result =
- (ContentDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
- assertEquals( "encoded", directive, result );
- }
+ //public void testEncoding() throws Exception
+ //{
+ // String codebase = getCodebaseValue();
+ // ValueDirective[] values = getValueDirectives();
+ // ContentDirective directive =
+ // new ContentDirective( m_id, m_title, codebase, values );
+ // ContentDirective result =
+ // (ContentDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
+ // assertEquals( "encoded", directive, result );
+ //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -268,13 +268,13 @@
* Test encoding.
* @exception Exception if an error occurs
*/
- public void testEncoding() throws Exception
- {
- HostDirective directive =
- new HostDirective(
- m_id, m_priority, m_host, m_index, m_username, m_password,
m_enabled, m_trusted,
- m_layout, m_scheme, m_prompt );
- HostDirective result = (HostDirective) doEncodingTest( directive,
"host-directive.xml" );
- assertEquals( "encoded", directive, result );
- }
+ //public void testEncoding() throws Exception
+ //{
+ // HostDirective directive =
+ // new HostDirective(
+ // m_id, m_priority, m_host, m_index, m_username, m_password,
m_enabled, m_trusted,
+ // m_layout, m_scheme, m_prompt );
+ // HostDirective result = (HostDirective) doEncodingTest( directive,
"host-directive.xml" );
+ // assertEquals( "encoded", directive, result );
+ //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -107,14 +107,14 @@
* Test encoding.
* @exception Exception if an error occurs
*/
- public void testEncoding() throws Exception
- {
- String codebase = getCodebaseValue();
- ValueDirective[] values = getValueDirectives();
- LayoutDirective directive =
- new LayoutDirective( m_id, m_title, codebase, values );
- LayoutDirective result =
- (LayoutDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
- assertEquals( "encoded", directive, result );
- }
+ //public void testEncoding() throws Exception
+ //{
+ // String codebase = getCodebaseValue();
+ // ValueDirective[] values = getValueDirectives();
+ // LayoutDirective directive =
+ // new LayoutDirective( m_id, m_title, codebase, values );
+ // LayoutDirective result =
+ // (LayoutDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
+ // assertEquals( "encoded", directive, result );
+ //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -139,16 +139,16 @@
* Test classic encoding.
* @exception Exception if an error occurs
*/
- public void testClassicEncoding() throws Exception
- {
- String host = "http://localhost:1234";;
- String[] excludes = new String[]{"http://www.osm.net"};
- String username = "me";
- char[] password = new char[0];
- ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
- ProxyDirective result = (ProxyDirective) doEncodingTest( directive,
"proxy-directive.xml" );
- assertEquals( "encoded", directive, result );
- }
+ //public void testClassicEncoding() throws Exception
+ //{
+ // String host = "http://localhost:1234";;
+ // String[] excludes = new String[]{"http://www.osm.net"};
+ // String username = "me";
+ // char[] password = new char[0];
+ // ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
+ // ProxyDirective result = (ProxyDirective) doEncodingTest(
directive, "proxy-directive.xml" );
+ // assertEquals( "encoded", directive, result );
+ //}

/**
* Test serailization with null fields.
@@ -168,14 +168,14 @@
* Test encoding with null fields.
* @exception Exception if an error occurs
*/
- public void testNullEncoding() throws Exception
- {
- String host = "http://localhost:1234";;
- String[] excludes = null;
- String username = null;
- char[] password = null;
- ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
- ProxyDirective result = (ProxyDirective) doEncodingTest( directive,
"proxy-directive.xml" );
- assertEquals( "encoded", directive, result );
- }
+ //public void testNullEncoding() throws Exception
+ //{
+ // String host = "http://localhost:1234";;
+ // String[] excludes = null;
+ // String username = null;
+ // char[] password = null;
+ // ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
+ // ProxyDirective result = (ProxyDirective) doEncodingTest(
directive, "proxy-directive.xml" );
+ // assertEquals( "encoded", directive, result );
+ //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -80,9 +80,9 @@
* Test directive encoding.
* @exception Exception if an error occurs
*/
- public void testEncoding() throws Exception
- {
- TransitDirective result = (TransitDirective) doEncodingTest(
m_directive, "transit.xml" );
- assertEquals( "encoded", m_directive, result );
- }
+ //public void testEncoding() throws Exception
+ //{
+ // TransitDirective result = (TransitDirective) doEncodingTest(
m_directive, "transit.xml" );
+ // assertEquals( "encoded", m_directive, result );
+ //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -206,16 +206,16 @@
* Test encoding.
* @exception Exception if an error occurs
*/
- public void testEncoding() throws Exception
- {
- String target = "java.io.File";
- ValueDirective base = new ValueDirective( "java.io.File", "." );
- ValueDirective spec = new ValueDirective( "test" );
- ValueDirective[] args = new ValueDirective[]{base, spec};
- ValueDirective directive = new ValueDirective( target, args );
- ValueDirective result = (ValueDirective) doEncodingTest( directive,
"value-directive.xml" );
- assertEquals( "encoded", directive, result );
- }
+ //public void testEncoding() throws Exception
+ //{
+ // String target = "java.io.File";
+ // ValueDirective base = new ValueDirective( "java.io.File", "." );
+ // ValueDirective spec = new ValueDirective( "test" );
+ // ValueDirective[] args = new ValueDirective[]{base, spec};
+ // ValueDirective directive = new ValueDirective( target, args );
+ // ValueDirective result = (ValueDirective) doEncodingTest(
directive, "value-directive.xml" );
+ // assertEquals( "encoded", directive, result );
+ //}
}



Modified: trunk/main/transit/tools/src/main/net/dpml/transit/antlib.xml
===================================================================
--- trunk/main/transit/tools/src/main/net/dpml/transit/antlib.xml
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/tools/src/main/net/dpml/transit/antlib.xml
2006-02-22 19:36:10 UTC (rev 1125)
@@ -4,5 +4,4 @@
<taskdef name="plugin" classname="net.dpml.transit.tools.PluginTask"/>
<taskdef name="import"
classname="net.dpml.transit.tools.ImportArtifactTask"/>
<taskdef name="get" classname="net.dpml.transit.tools.GetTask"/>
- <taskdef name="prefs"
classname="net.dpml.transit.tools.PreferencesTask"/>
</antlib>

Modified:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
===================================================================
---
trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -42,6 +42,8 @@
* A flag indicating that nested directives have been provided.
*/
private boolean m_flag = false;
+
+ private boolean m_init = false;

/**
* Set the project.
@@ -51,8 +53,20 @@
{
super.setProject( project );
setTaskName( "import" );
- TransitTask.initialize( this );
}
+
+ /**
+ * Task initialization.
+ */
+ public synchronized void init()
+ {
+ if( !m_init )
+ {
+ TransitTask.initialize( this );
+ super.init();
+ m_init = true;
+ }
+ }

//
------------------------------------------------------------------------
// Task

Modified:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
===================================================================
--- trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
2006-02-22 19:26:50 UTC (rev 1124)
+++ trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -27,7 +27,7 @@

import net.dpml.transit.Transit;
import net.dpml.transit.Repository;
-import net.dpml.transit.Plugin;
+import net.dpml.lang.Plugin;
import net.dpml.transit.util.ElementHelper;

import org.apache.tools.ant.BuildException;
@@ -280,11 +280,12 @@
private void loadAntlib(
URI uri, ClassLoader classloader, ComponentHelper helper, Antlib
antlib ) throws Exception
{
- Plugin descriptor = getRepository().getPluginDescriptor( uri );
+ Plugin plugin = getRepository().getPluginDescriptor( uri );
+
String resource = antlib.getPath();
if( null == resource )
{
- resource = descriptor.getResource();
+ resource = plugin.getStrategy().getProperties().getProperty(
"project.plugin.resource" );
}
if( null == resource )
{
@@ -296,7 +297,7 @@
throw new BuildException( error, getLocation() );
}

- String urn = getAntLibURN( antlib, descriptor );
+ String urn = getAntLibURN( antlib, plugin );
if( null == urn )
{
final String error =
@@ -328,7 +329,7 @@
}
}

- private String getAntLibURN( Antlib antlib, Plugin descriptor )
+ private String getAntLibURN( Antlib antlib, Plugin plugin )
{
if( null != m_urn )
{
@@ -341,7 +342,7 @@
}
else
{
- return descriptor.getURN();
+ return plugin.getStrategy().getProperties().getProperty(
"project.plugin.urn" );
}
}


Deleted:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/PreferencesTask.java
===================================================================
---
trunk/main/transit/tools/src/main/net/dpml/transit/tools/PreferencesTask.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/tools/src/main/net/dpml/transit/tools/PreferencesTask.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -1,151 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.tools;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
-import java.util.prefs.Preferences;
-
-import net.dpml.transit.util.LocalPreferences;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-/**
- * Task supports the creation of preference as readable xml files.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PreferencesTask extends NodeTask
-{
- private File m_destination;
- private boolean m_system = false;
- private String m_base;
-
- /**
- * Set the project.
- * @param project the project
- */
- public void setProject( Project project )
- {
- setTaskName( "prefs" );
- super.setProject( project );
- }
-
- /**
- * Set the destination output file.
- * @param dest the destination file
- */
- public void setDest( File dest )
- {
- m_destination = dest;
- }
-
- /**
- * Set the scope.
- * @param value - either 'user' or 'system' scope
- */
- public void setScope( String value )
- {
- if( "user".equals( value ) )
- {
- m_system = false;
- }
- else if( "system".equals( value ) )
- {
- m_system = true;
- }
- else
- {
- final String error =
- "Scope attribute value [" + value + "] does not match 'user'
or 'system'.";
- throw new BuildException( error, getLocation() );
- }
- }
-
- /**
- * Set the base node address.
- * @param base the base address
- */
- public void setBase( String base )
- {
- m_base = base;
- }
-
- Preferences buildPreferences()
- {
- Preferences prefs = createPreferences();
- apply( prefs );
- return prefs;
- }
-
- /**
- * Execute the task.
- */
- public void execute()
- {
- Preferences prefs = buildPreferences();
- try
- {
- if( null == m_destination )
- {
- prefs.exportSubtree( System.out );
- }
- else
- {
- File parent = m_destination.getParentFile();
- if( null != parent )
- {
- parent.mkdirs();
- }
- FileOutputStream output = new FileOutputStream(
m_destination );
- BufferedOutputStream buffer = new BufferedOutputStream(
output );
- try
- {
- prefs.exportSubtree( buffer );
- }
- finally
- {
- output.close();
- }
- }
- }
- catch( Throwable e )
- {
- final String error =
- "Export failure.";
- throw new BuildException( error, e, getLocation() );
- }
- }
-
- private Preferences createPreferences()
- {
- if( null == m_base )
- {
- return new LocalPreferences( null, "", m_system );
- }
- else
- {
- Preferences root = new LocalPreferences( null, "", m_system );
- return root.node( m_base );
- }
- }
-}

Modified:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
===================================================================
---
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
2006-02-22 19:26:50 UTC (rev 1124)
+++
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
2006-02-22 19:36:10 UTC (rev 1125)
@@ -23,7 +23,7 @@
import java.util.Hashtable;
import java.net.URI;

-import net.dpml.transit.Plugin;
+import net.dpml.lang.Plugin;
import net.dpml.transit.Repository;
import net.dpml.transit.Transit;
import net.dpml.transit.util.ElementHelper;
@@ -209,7 +209,6 @@
addTaskDefinition( TRANSIT_PLUGIN_URN, PluginTask.class );
addTaskDefinition( TRANSIT_IMPORT_URN, ImportArtifactTask.class
);
addTaskDefinition( TRANSIT_GET_URN, GetTask.class );
- addTaskDefinition( TRANSIT_PREFS_URN, PreferencesTask.class );
}
}

@@ -344,16 +343,17 @@
Plugin descriptor = loader.getPluginDescriptor( uri );
ClassLoader current =
Thread.currentThread().getContextClassLoader();
ClassLoader classloader = loader.getPluginClassLoader( current,
uri );
- if( null != descriptor.getClassname() )
+ String pluginClassname =
descriptor.getStrategy().getProperties().getProperty( "project.plugin.class"
);
+ if( null != pluginClassname )
{
- Class clazz = classloader.loadClass(
descriptor.getClassname() );
+ Class clazz = classloader.loadClass( pluginClassname );
final String key = uri + ":" + name;
getProject().log( "installing single task plugin [" + key +
"]", Project.MSG_VERBOSE );
super.addTaskDefinition( key, clazz );
}
else
{
- String resource = descriptor.getResource();
+ String resource =
descriptor.getStrategy().getProperties().getProperty(
"project.plugin.resource" );
getProject().log( "installing antlib plugin [" + resource +
"]", Project.MSG_VERBOSE );
InputStream input = classloader.getResourceAsStream(
resource );
if( null == input )




  • r1125 - in trunk/main: depot/library/common/src/main/net/dpml/library depot/library/common/src/main/net/dpml/library/impl depot/library/common/src/main/net/dpml/library/info depot/library/common/src/main/net/dpml/library/model depot/library/common/src/main/net/dpml/library/util depot/library/common/src/test/net/dpml/library/impl depot/library/common/src/test/net/dpml/library/info depot/tools/builder/etc/deliverables/plugins depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks metro metro/builder metro/builder/etc metro/builder/etc/main metro/builder/etc/main/net metro/builder/etc/main/net/dpml metro/builder/etc/main/net/dpml/metro metro/builder/src metro/builder/src/main metro/builder/src/main/net metro/builder/src/main/net/dpml metro/builder/src/main/net/dpml/metro metro/builder/src/main/net/dpml/metro/builder metro/model/src/main/net/dpml/metro/data metro/model/src/test/net/dpml/metro/data/test metro/runtime/src/mai! n/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools planet/http planet/http/server planet/http/server/etc planet/http/server/etc/plugin transit/console/src/main/net/dpml/transit/console transit/core transit/core/etc/prefs transit/core/etc/prefs/xmls transit/core/src/main/net/dpml/lang transit/core/src/main/net/dpml/transit transit/core/src/main/net/dpml/transit/artifact transit/core/src/main/net/dpml/transit/info transit/core/src/main/net/dpml/transit/util transit/core/src/test/net/dpml transit/core/src/test/net/dpml/lang transit/core/src/test/net/dpml/lang/test transit/core/src/test/net/dpml/transit transit/core/src/test/net/dpml/transit/info transit/tools/src/main/net/dpml/transit transit/tools/src/main/net/dpml/transit/tools, mcconnell at BerliOS, 02/22/2006

Archive powered by MHonArc 2.6.24.

Top of Page