notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1984 - in trunk/main/metro/part: etc/xsds src/main/net/dpml/lang src/main/net/dpml/runtime
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1984 - in trunk/main/metro/part: etc/xsds src/main/net/dpml/lang src/main/net/dpml/runtime
- Date: Mon, 23 Apr 2007 18:26:12 +0200
Author: mcconnell
Date: 2007-04-23 18:26:11 +0200 (Mon, 23 Apr 2007)
New Revision: 1984
Modified:
trunk/main/metro/part/etc/xsds/component.xsd
trunk/main/metro/part/src/main/net/dpml/lang/PartContentHandler.java
trunk/main/metro/part/src/main/net/dpml/runtime/PartsDirective.java
Log:
Updates to the part XSD to include option for inclusion of a part by
reference - and corresponding updates to the part content handler and
internal parts directive.
Modified: trunk/main/metro/part/etc/xsds/component.xsd
===================================================================
--- trunk/main/metro/part/etc/xsds/component.xsd 2007-04-23 16:24:44
UTC (rev 1983)
+++ trunk/main/metro/part/etc/xsds/component.xsd 2007-04-23 16:26:11
UTC (rev 1984)
@@ -17,6 +17,7 @@
<element name="param" type="part:ValueType"
substitutionGroup="part:param"/>
<element name="profile" type="this:ProfileType"/>
<element name="parts" type="this:PartsType"/>
+ <element name="part" type="this:PartType"/>
<complexType name="component">
<complexContent>
@@ -106,10 +107,26 @@
<complexType name="PartsType">
<sequence>
- <element ref="part:strategy" minOccurs="0" maxOccurs="unbounded"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="part:strategy" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="part" type="this:PartType" minOccurs="0"
maxOccurs="unbounded"/>
+ </choice>
</sequence>
</complexType>
+ <complexType name="PartType">
+ <sequence>
+ <element name="param" type="this:ParamType" minOccurs="0"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="key" type="string" use="required"/>
+ <attribute name="uri" type="anyURI" use="required"/>
+ </complexType>
+
+ <complexType name="ParamType">
+ <attribute name="key" type="string" use="required"/>
+ <attribute name="value" type="string" use="required"/>
+ </complexType>
+
<simpleType name="activation">
<restriction base="string">
<enumeration value="demand"/>
Modified: trunk/main/metro/part/src/main/net/dpml/lang/PartContentHandler.java
===================================================================
--- trunk/main/metro/part/src/main/net/dpml/lang/PartContentHandler.java
2007-04-23 16:24:44 UTC (rev 1983)
+++ trunk/main/metro/part/src/main/net/dpml/lang/PartContentHandler.java
2007-04-23 16:26:11 UTC (rev 1984)
@@ -591,6 +591,8 @@
*/
private static Classpath getClasspath( Element root ) throws
DecodingException
{
+ // TODO: update to support different classpath defintions (e.g. 277
module scenario)
+
Element classpath = ElementHelper.getChild( root, "classpath" );
if( null == classpath )
{
@@ -669,6 +671,9 @@
private static Element getStrategyElement( Element root ) throws
DecodingException
{
+ // TODO: update this to select the strategy element based on type
overwise
+ // we risk issues when dealing with a non-standard classpath element
+
Element[] children = ElementHelper.getChildren( root );
for( Element element : children )
{
Modified: trunk/main/metro/part/src/main/net/dpml/runtime/PartsDirective.java
===================================================================
--- trunk/main/metro/part/src/main/net/dpml/runtime/PartsDirective.java
2007-04-23 16:24:44 UTC (rev 1983)
+++ trunk/main/metro/part/src/main/net/dpml/runtime/PartsDirective.java
2007-04-23 16:26:11 UTC (rev 1984)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Stephen J. McConnell.
+ * Copyright 2005-2007 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.
@@ -115,6 +115,34 @@
private Strategy buildStrategy( ClassLoader classloader,
Element element, Resolver resolver, String partition ) throws
DecodingException
{
+ String name = element.getLocalName();
+ if( name.equals( "part" ) )
+ {
+ URI codebase = getCodebase( element, resolver );
+ try
+ {
+ return Strategy.load( classloader, null, codebase, partition
);
+
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to create strategy from nested reference ["
+ + codebase
+ + "].";
+ throw new DecodingException( error, e, element );
+ }
+ }
+ else
+ {
+ return buildLocalStrategy( classloader, element, resolver,
partition );
+ }
+ }
+
+ private Strategy buildLocalStrategy(
+ ClassLoader classloader, Element element, Resolver resolver, String
partition )
+ throws DecodingException
+ {
try
{
StrategyHandler handler = PartContentHandler.getStrategyHandler(
element );
@@ -306,4 +334,32 @@
buffer.nl( "</parts>" );
}
}
+
+ private static URI getCodebase( Element element, Resolver resolver )
throws DecodingException
+ {
+ String spec = ElementHelper.getAttribute( element, "uri", null,
resolver );
+ if( null == spec )
+ {
+ final String error =
+ "Mising uri attribute.";
+ throw new DecodingException( error, element );
+ }
+
+ Element[] params = ElementHelper.getChildren( element, "param" );
+ for( int i=0; i<params.length; i++ )
+ {
+ Element e = params[i];
+ String key = ElementHelper.getAttribute( e, "key", null,
resolver );
+ String value = ElementHelper.getAttribute( e, "value", null,
resolver );
+ if( i==0 )
+ {
+ spec = spec + "?" + key + "=" + value;
+ }
+ else
+ {
+ spec = spec + "&" + key + "=" + value;
+ }
+ }
+ return URI.create( spec );
+ }
}
- r1984 - in trunk/main/metro/part: etc/xsds src/main/net/dpml/lang src/main/net/dpml/runtime, mcconnell at BerliOS, 04/23/2007
Archive powered by MHonArc 2.6.24.