notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2615 - in development/main: . metro/composition/content/src/main/net/dpml/composition/content test/components/plus test/unit/plus test/unit/plus/src/test/net/dpml/test/acme/plus transit/core/handler/src/main/net/dpml/transit/content
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2615 - in development/main: . metro/composition/content/src/main/net/dpml/composition/content test/components/plus test/unit/plus test/unit/plus/src/test/net/dpml/test/acme/plus transit/core/handler/src/main/net/dpml/transit/content
- Date: Thu, 19 May 2005 03:14:48 +0000
Author: mcconnell AT dpml.net
Date: Thu May 19 03:14:46 2005
New Revision: 2615
Added:
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
Modified:
development/main/build.bat
development/main/build.xml
development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java
development/main/test/components/plus/build.xml
development/main/test/unit/plus/build.xml
development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentHandlerRegistry.java
Log:
Updates to the transit content handler to separate handler aquisition from
handler creation, updates to the FT content handler to use this when handling
request for "part" type when not configured, and add a testcase dealing with
url content handling.
Modified: development/main/build.bat
==============================================================================
--- development/main/build.bat (original)
+++ development/main/build.bat Thu May 19 03:14:46 2005
@@ -11,9 +11,10 @@
REM where the first argument is product group and the second (optional)
argument is the
REM build revision identifier. Allowable product group names include:
REM
-REM all builds transit, util, magic, metro
+REM all builds transit, util, magic, depot, metro and test
REM transit build transit and util
REM magic build magic
+REM depot build depot
REM metro build metro
REM
@@ -27,6 +28,7 @@
IF "%TARGET%" == "magic" CALL :magic
IF "%TARGET%" == "depot" CALL :depot
IF "%TARGET%" == "metro" CALL :metro
+IF "%TARGET%" == "test" CALL :test
IF "%TARGET%" == "all" CALL :all
goto end
@@ -78,6 +80,12 @@
POPD
GOTO :EOF
+:test
+PUSHD test
+CALL :build clean install
+POPD
+GOTO :EOF
+
:build
IF not "%ID%" == "" set BUILD_ID=-Ddpml.release.signature=%ID%
ECHO building project with release ID [%ID%]
@@ -92,7 +100,8 @@
echo transit -- build the transit distribution
echo magic -- build the magic distribution
echo metro -- build the metro distribution
-echo all -- builds transit, magic, metro distributions
+echo test -- build and execute integration tests
+echo all -- builds transit, magic, metro distributions and
executes integration tests
echo [revision] optional build revision identified used when
echo building number releases.
goto :EOF
Modified: development/main/build.xml
==============================================================================
--- development/main/build.xml (original)
+++ development/main/build.xml Thu May 19 03:14:46 2005
@@ -33,12 +33,16 @@
<ant dir="magic"/>
</target>
- <target name="metro" description="Build Metro (requires Magic).">
+ <target name="depot" description="Build Depot (requires Magic).">
+ <ant dir="depot"/>
+ </target>
+
+ <target name="metro" description="Build Metro (requires Depot).">
<ant dir="metro"/>
</target>
- <target name="depot" description="Build Depot (requires Magic).">
- <ant dir="depot"/>
+ <target name="test" description="Build Integration Tests (requires
Metro).">
+ <ant dir="test"/>
</target>
<target name="clean" description="Clean all subprojects.">
Modified:
development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java
==============================================================================
---
development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java
(original)
+++
development/main/metro/composition/content/src/main/net/dpml/composition/content/CompositionContentHandlerRegistry.java
Thu May 19 03:14:46 2005
@@ -63,7 +63,24 @@
public ContentHandler getContentHandler( final String type ) throws
IOException
{
- return super.getContentHandler( type );
+ ContentHandler handler = super.getContentHandler( type );
+ if( null != handler )
+ {
+ return handler;
+ }
+ else if( "part".equals( type ) )
+ {
+ Preferences prefs = Preferences.systemNodeForPackage( getClass()
);
+ Preferences p = prefs.node( "part" );
+ p.put( "title", "Part Content Handler" );
+ p.put( "uri", "@COMPOSITION-CONTENT-PART-HANDLER-PLUGIN-URI@" );
+ ContentHandlerDescriptor descriptor = new
CompositionContentHandlerDescriptor( m_logger, p );
+ return getContentHandler( descriptor );
+ }
+ else
+ {
+ return null;
+ }
}
//
------------------------------------------------------------------------
Modified: development/main/test/components/plus/build.xml
==============================================================================
--- development/main/test/components/plus/build.xml (original)
+++ development/main/test/components/plus/build.xml Thu May 19 03:14:46
2005
@@ -7,12 +7,22 @@
<transit:import uri="artifact:template:dpml/magic/standard"/>
<target name="build" depends="standard.build">
+
<types xmlns="plugin:dpml/composition/dpml-composition-builder">
<type class="net.dpml.test.acme.plus.ConfigurableComponent"
threadsafe="true"/>
<type class="net.dpml.test.acme.plus.ConfigurableContainer"
threadsafe="true"/>
<type class="net.dpml.test.acme.plus.ManagedComponent"
threadsafe="true"/>
<type class="net.dpml.test.acme.plus.ManagingContainer"
threadsafe="true"/>
</types>
+
+ <component xmlns="plugin:dpml/composition/dpml-composition-builder"
+ type="net.dpml.test.acme.plus.ManagingContainer"
+ name="container">
+ <parts>
+ <component key="test"
type="net.dpml.test.acme.plus.ManagedComponent"/>
+ </parts>
+ </component>
+
</target>
</project>
Modified: development/main/test/unit/plus/build.xml
==============================================================================
--- development/main/test/unit/plus/build.xml (original)
+++ development/main/test/unit/plus/build.xml Thu May 19 03:14:46 2005
@@ -6,6 +6,15 @@
<transit:import uri="artifact:template:dpml/magic/standard"/>
+ <target name="init" depends="standard.init">
+ <x:property key="dpml-composition-content" feature="uri" type="plugin"
name="content.plugin"/>
+ <filter token="CONTENT-MANAGER-PLUGIN" value="${content.plugin}"/>
+ <x:property key="dpml-test-simple" feature="uri" type="part"
name="simple.part"/>
+ <filter token="SIMPLE-TEST-PART" value="${simple.part}"/>
+ <x:property key="dpml-test-plus" feature="uri" type="part"
name="plus.part"/>
+ <filter token="PLUS-TEST-PART" value="${plus.part}"/>
+ </target>
+
<target name="build" depends="standard.build">
<!--
Added:
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
==============================================================================
--- (empty file)
+++
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
Thu May 19 03:14:46 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004 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.test.acme.plus;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.part.Part;
+
+/**
+ * Test URL content handling.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta
+ * Library</a>
+ */
+public class URLTestCase extends TestCase
+{
+ public void setUp() throws Exception
+ {
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ System.setProperty( "java.util.logging.config.class",
"net.dpml.depot.logging.ConfigurationHandler" );
+ System.setProperty( "dpml.transit.preferences.enabled", "true" );
+ System.setProperty( "dpml.transit.content.plugin",
"@CONTENT-MANAGER-PLUGIN@" );
+ }
+
+ /**
+ * Check that the loading of a url results in the loading of the Part
class from the same classloader.
+ * (i.e. validate that the caching of plugins in Transit is doing what it
should be doing).
+ */
+ public void testPartLoading() throws Exception
+ {
+ URL urlA = new URL( "@SIMPLE-TEST-PART@" );
+ Part partA = (Part) urlA.getContent();
+ URL urlB = new URL( "@PLUS-TEST-PART@" );
+ Part partB = (Part) urlB.getContent();
+ assertEquals( "same class", partA.getClass(), partB.getClass() );
+ }
+}
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentHandlerRegistry.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentHandlerRegistry.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/content/DefaultContentHandlerRegistry.java
Thu May 19 03:14:46 2005
@@ -34,8 +34,9 @@
import net.dpml.io.CascadingIOException;
+import net.dpml.transit.Transit;
import net.dpml.transit.TransitException;
-import net.dpml.transit.repository.StandardLoader;
+import net.dpml.transit.repository.Repository;
/**
* A registry of descriptions of plugable content handlers. This
implementation
@@ -87,47 +88,57 @@
public ContentHandler getContentHandler( final String type ) throws
IOException
{
- URI uri = getContentHandlerDescriptorURI( type );
- if( null == uri )
+ ContentHandlerDescriptor descriptor = getContentHandlerDescriptor(
type );
+ if( null == descriptor )
{
return null;
}
else
{
+ URI uri = descriptor.getPluginURI();
ContentHandler handler = (ContentHandler) m_links.get( uri );
if( null != handler )
{
return handler;
}
+ else
+ {
+ return getContentHandler( descriptor );
+ }
+ }
+ }
- try
+ protected ContentHandler getContentHandler( ContentHandlerDescriptor
descriptor ) throws IOException
+ {
+ String type = descriptor.getContentType();
+ URI uri = descriptor.getPluginURI();
+ try
+ {
+ m_logger.info( "loading content handler for: " + type );
+ Repository loader = Transit.getInstance().getRepository();
+ ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
+ Object plugin = loader.getPlugin( classloader, uri, new
Object[0] );
+ if( plugin instanceof ContentHandler )
{
- m_logger.info( "loading content handler for: " + type );
- StandardLoader loader = new StandardLoader();
- ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
- Object plugin = loader.getPlugin( classloader, uri, new
Object[0] );
- if( plugin instanceof ContentHandler )
- {
- handler = (ContentHandler) plugin;
- m_links.put( uri, handler );
- return handler;
- }
- else
- {
- final String error =
- "Content handler plugin uri does not resolve to a
java.net.ContentHandler."
- + "\nHandler URI: " + uri
- + "\nHandler Class: " + plugin.getClass().getName();
- throw new TransitException( error );
- }
+ ContentHandler handler = (ContentHandler) plugin;
+ m_links.put( uri, handler );
+ return handler;
}
- catch( Exception e )
+ else
{
final String error =
- "Unable to load a content handler plugin.";
- throw new CascadingIOException( error, e );
+ "Content handler plugin uri does not resolve to a
java.net.ContentHandler."
+ + "\nHandler URI: " + uri
+ + "\nHandler Class: " + plugin.getClass().getName();
+ throw new TransitException( error );
}
}
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to load a content handler plugin.";
+ throw new CascadingIOException( error, e );
+ }
}
//
------------------------------------------------------------------------
- svn commit: r2615 - in development/main: . metro/composition/content/src/main/net/dpml/composition/content test/components/plus test/unit/plus test/unit/plus/src/test/net/dpml/test/acme/plus transit/core/handler/src/main/net/dpml/transit/content, mcconnell, 05/18/2005
Archive powered by MHonArc 2.6.24.