Skip to Content.
Sympa Menu

notify-dpml - r1155 - trunk/lab/test/src/test/dpmlx/schema/test

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: r1155 - trunk/lab/test/src/test/dpmlx/schema/test
  • Date: Wed, 1 Mar 2006 01:08:47 +0100

Author: mcconnell
Date: 2006-03-01 01:08:43 +0100 (Wed, 01 Mar 2006)
New Revision: 1155

Modified:
trunk/lab/test/src/test/dpmlx/schema/test/SchemaTestCase.java
Log:
get in place handler loading based on schema namespace translation

Modified: trunk/lab/test/src/test/dpmlx/schema/test/SchemaTestCase.java
===================================================================
--- trunk/lab/test/src/test/dpmlx/schema/test/SchemaTestCase.java
2006-02-28 23:45:04 UTC (rev 1154)
+++ trunk/lab/test/src/test/dpmlx/schema/test/SchemaTestCase.java
2006-03-01 00:08:43 UTC (rev 1155)
@@ -5,12 +5,14 @@
import java.net.URI;
import java.net.URL;

+import dpmlx.lang.PartHandler;
import dpmlx.schema.StandardBuilder;
import dpmlx.schema.UnresolvableHandlerException;

import net.dpml.transit.Artifact;
+import net.dpml.transit.Transit;
+import net.dpml.transit.Repository;
import net.dpml.transit.artifact.ArtifactNotFoundException;
-import net.dpml.transit.Transit;
import net.dpml.transit.util.ElementHelper;

import junit.framework.TestCase;
@@ -66,6 +68,11 @@
final Element root = doc.getDocumentElement();
final String namespace = root.getNamespaceURI();

+ // construct the classloader using the <classpath> element
+
+ // check if we are a classic plugin or if a custom strategy
+ // has been declared
+
Element plugin = ElementHelper.getChild( root, "plugin" );
if( null != plugin )
{
@@ -93,7 +100,11 @@
String urn = implementation.getNamespaceURI();
System.out.println( "strategy (namespace): " + urn );
URI uri = getImplementationHandler( urn );
- System.out.println( "handler: " + uri );
+ System.out.println( "resolved: " + uri );
+
+ PartHandler handler = loadPartHandler( uri, implementation );
+ //Object instance = handler.getInstance( classloader, new
Object[0] );
+ System.out.println( "handler: " + handler.getClass().getName() );
}
}

@@ -171,4 +182,26 @@
throw new IllegalArgumentException( error );
}
}
+
+ private PartHandler loadPartHandler( URI uri, Element implementation )
throws Exception
+ {
+ ClassLoader classloader = PartHandler.class.getClassLoader();
+ Repository repository = Transit.getInstance().getRepository();
+ Object[] args = new Object[]{ implementation };
+ Object handler = repository.getPlugin( classloader, uri, args );
+ if( handler instanceof PartHandler )
+ {
+ return (PartHandler) handler;
+ }
+ else
+ {
+ final String error =
+ "Part handler plugin ["
+ + uri
+ + "] does not implement the "
+ + PartHandler.class.getName()
+ + " interface.";
+ throw new IllegalArgumentException( error );
+ }
+ }
}




  • r1155 - trunk/lab/test/src/test/dpmlx/schema/test, mcconnell at BerliOS, 02/28/2006

Archive powered by MHonArc 2.6.24.

Top of Page