You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hl...@apache.org on 2003/07/01 22:13:03 UTC
cvs commit: jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl RegistryBuilder.java
hlship 2003/07/01 13:13:03
Modified: hivemind/xdocs descriptor.xml configuration.xml
hivemind/src/java/org/apache/commons/hivemind/parse
DescriptorParser.java HiveMind_1.0.xsd
AbstractConfigurationDescriptor.java
hivemind/src/test/hivemind/test/config
TestConfiguration.java
hivemind/common links.xml
hivemind/src/xsl hivemind.xsl
hivemind/src/java/org/apache/commons/hivemind
HiveMindMessages.properties
hivemind/src/java/org/apache/commons/hivemind/util
URLResourceLocation.java
hivemind/src/test/hivemind/test/parse
TestDescriptorParser.java TestToString.java
hivemind/src/java/org/apache/commons/hivemind/impl
RegistryBuilder.java
Added: hivemind/src/java/org/apache/commons/hivemind/parse
ResourceDescriptor.java
hivemind/src/test/hivemind/test/config SetResource.xml
SetResourceMissing.xml ResourceElement.java
hivemind/src/test/hivemind/test/parse Resource.xml
SetResource.xml
Log:
Add support for <resource> and <set-resource>
Revision Changes Path
1.10 +101 -181 jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml
Index: descriptor.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- descriptor.xml 30 Jun 2003 23:04:28 -0000 1.9
+++ descriptor.xml 1 Jul 2003 20:12:57 -0000 1.10
@@ -413,6 +413,15 @@
<a href="apidocs/org/apache/commons/hivemind/Element.html">Element</a>. The configuation extension point must also be type
Element.</td>
</tr>
+ <tr>
+ <td colspan="2">
+ <a href="#resource">resource</a>
+ </td>
+ <td>0..n</td>
+ <td>Adds the location (as an instance of <code>IResourceLocation</code>) of a resource file.
+ </td>
+ </tr>
+
<tr>
<td colspan="2">
<a href="#create-instance">create-instance</a>
@@ -455,68 +464,16 @@
<td>yes</td>
<td>The fully qualified id of the service extension point to
contribute to.</td>
- </tr>
- <tr>
- <th colspan="2">Element</th>
- <th>Count</th>
- <th>Description</th>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#expression">expression</a>
- </td>
- <td>0..n</td>
- <td>Evaluates an OGNL expression and adds the result as a contribution
- to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#value">value</a>
- </td>
- <td>0..n</td>
- <td>Includes a literal value as a contribution to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#service-ref">service-ref</a>
- </td>
- <td>0..n</td>
- <td>Obtains a service as a contribution to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#xml">xml</a>
- </td>
- <td>0..n.</td>
- <td>Reads an XML file and assigns the root element, as an instance of
- <a href="apidocs/org/apache/commons/hivemind/IElement.html">Element</a>. The configuation extension point must also by type
- Element.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#create-instance">create-instance</a>
- </td>
- <td>0..n</td>
- <td>Creates an element as a contribution to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#factory">factory</a>
- </td>
- <td>0..n</td>
- <td>Uses a factory service to create an instance as a contribution to
- the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#new">new</a>
- </td>
- <td>0..n</td>
- <td>
- Configures a new object, created by the extension point.
- </td>
- </tr>
- </table>
+ </tr>
+
+ </table>
+ <p>
+ &_contribute-configuration; accepts the same elements
+ as &configuration; (with the exception of &description;).
+ </p>
+
+
+
</section>
<section name="create-instance">
<p> &_create-instance; instantiates an object from a class name, and then
@@ -529,7 +486,7 @@
then the newly created object's <code>location</code> property
is set to the location of the &_create-instance; element.
<em>Note:</em>
- This applies to &set-create;, &factory; and &set-factory;
+ This applies to &set-create;, &factory; and similar elements
as well.
</p>
@@ -579,7 +536,15 @@
</td>
<td>0..n</td>
<td>Sets a property of the object to the root element of a parsed XML
- file. The property must be type <a href="apidocs/org/apache/commons/hivemind/Element.html">Element</a>.</td>
+ file.</td>
+ </tr>
+
+ <tr>
+ <td colspan="2">
+ <a href="#set-resource">set-resource</a>
+ </td>
+ <td>0..n</td>
+ <td>Sets a property to the location of a resource file.</td>
</tr>
<tr>
<td colspan="2">
@@ -699,52 +664,13 @@
</tr>
<tr>
- <td colspan="2">
- <a href="#set-expression">set-expression</a>
- </td>
- <td>0..n</td>
- <td>Evaluates an OGNL expression and assigns its value to a property
- of the object</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#set">set</a>
- </td>
- <td>0..n</td>
- <td>Sets a property of the object to a literal value.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#setservice-ref">set-service-ref</a>
- </td>
- <td>0..n</td>
- <td>Sets a property of the object by looking up a service.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#set-xml">set-xml</a>
- </td>
- <td>0..n</td>
- <td>Sets a property of the object to the root element of a parsed XML
- file. The property must be type <a href="apidocs/org/apache/commons/hivemind/Element.html">Element</a>.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#set-create">set-create</a>
+ <td colspan="4">
+ The remaining elements are the same
+ as for &create-instance;
</td>
- <td>0..n</td>
- <td>Sets a property of the object to a newly created (and configured)
- object.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#set-factory">set-factory</a>
- </td>
- <td>0..n</td>
- <td>Sets a property of the object to a newly created (and configured)
- object obtained from a factory service.</td>
</tr>
-
+
+
</table>
</section>
@@ -755,74 +681,11 @@
</p>
- <table>
- <tr>
- <th>Attribute</th>
- <th>Type</th>
- <th>Required ?</th>
- <th>Description</th>
- </tr>
-
- <tr>
- <th colspan="2">Element</th>
- <th>Count</th>
- <th>Description</th>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#description">description</a>
- </td>
- <td>0..1</td>
- <td>Description of this configuration extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#expression">expression</a>
- </td>
- <td>0..n</td>
- <td>Evaluates an OGNL expression and adds the result as a contribution
- to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#value">value</a>
- </td>
- <td>0..n</td>
- <td>Includes a literal value as a contribution to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#service-ref">service-ref</a>
- </td>
- <td>0..n</td>
- <td>Obtains a service as a contribution to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#xml">xml</a>
- </td>
- <td>0..n.</td>
- <td>Reads an XML file and assigns the root element, as an instance of
- <a href="apidocs/org/apache/commons/hivemind/Element.html">Element</a>. The configuation extension point must also be type
- Element.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#create-instance">create-instance</a>
- </td>
- <td>0..n</td>
- <td>Creates an element as a contribution to the extension point.</td>
- </tr>
- <tr>
- <td colspan="2">
- <a href="#factory">factory</a>
- </td>
- <td>0..n</td>
- <td>Uses a factory service to create an instance as a contribution to
- the extension point.</td>
- </tr>
- </table>
-
+
+ <p>
+ &_parameters; accepts the same elements as &configuration;
+ </p>
+
</section>
<section name="interceptor">
@@ -864,7 +727,7 @@
to access the HiveMind repository).</p>
<p>
- Variable references in the expression are expanded.
+ Symbol references in the expression are expanded.
</p>
</section>
@@ -900,7 +763,7 @@
</p>
<p>
- Variable references in the expression are expanded before the expression is evaluated.
+ Symbol references in the expression are expanded before the expression is evaluated.
</p>
</section>
<section name="value">
@@ -909,7 +772,7 @@
type occur automatically. </p>
<p>The body of the &_value; element is the literal value to contribute.</p>
<p>
- Variable references in the value are expanded.
+ Symbol references in the value are expanded.
</p>
</section>
<section name="set">
@@ -943,7 +806,7 @@
</p>
<p>
- Variable references in the value are expanded.
+ Symbol references in the value are expanded.
</p>
</section>
<section name="service-ref">
@@ -1031,6 +894,63 @@
<td>The path, relative to the contributing module's descriptor, of the
XML file to read. The root element of the XML file, represented as
an instance of <a href="apidocs/org/apache/commons/hivemind/Element.html">Element</a>, is assigned to the property.</td>
+ </tr>
+ </table>
+
+
+ </section>
+
+ <section name="resource">
+
+ <p> &_resource; contributes the location of a resource file as
+ an instance of <code>IResourceLocation</code>. </p>
+
+ <p>
+ The referenced file must exist.
+ </p>
+ <table>
+ <tr>
+ <th>Attribute</th>
+ <th>Type</th>
+ <th>Required ?</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>path</td>
+ <td>string</td>
+ <td>yes</td>
+ <td>The path, relative to the contributing module's descriptor, of the
+ resource file.</td>
+ </tr>
+ </table>
+ </section>
+ <section name="set-resource">
+ <p> &_set-resource; updates a property of an object to the location
+ of a resource file (as an instance of
+ <code>IResourceLocation</code>).</p>
+
+ <p>
+ The referenced file must exist.
+ </p>
+ <table>
+ <tr>
+ <th>Attribute</th>
+ <th>Type</th>
+ <th>Required ?</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>property</td>
+ <td>string</td>
+ <td>yes</td>
+ <td>The name of the property to be updated.</td>
+ </tr>
+ <tr>
+ <td>path</td>
+ <td>string</td>
+ <td>yes</td>
+ <td>The path, relative to the contributing module's descriptor, of
+ resource file.</td>
</tr>
</table>
</section>
1.6 +3 -2 jakarta-commons-sandbox/hivemind/xdocs/configuration.xml
Index: configuration.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/configuration.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- configuration.xml 30 Jun 2003 23:04:28 -0000 1.5
+++ configuration.xml 1 Jul 2003 20:12:57 -0000 1.6
@@ -57,6 +57,7 @@
<li>Elements created by the extension point (&new;)</li>
<li>Parsed contents of XML files (&xml;)</li>
<li>References to HiveMind services (&service-ref;)</li>
+<li>Locations of resource files (&resource;)</li>
</ul>
</p>
@@ -146,7 +147,7 @@
<p>
HiveMind supports this notion through <em>substitution symbols</em>. These are references to values
that are supplied at runtime. Substitution symbols can appear inside literal values and OGNL expressions (in
-a module descriptor). In addition, when the &xml; element reads an external XML file, substitution variables
+a module descriptor). In addition, when the &xml; element reads an external XML file, substitution symbols
in attributes and inside element content are expanded.
</p>
1.10 +18 -2 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/DescriptorParser.java
Index: DescriptorParser.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/DescriptorParser.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DescriptorParser.java 26 Jun 2003 20:31:25 -0000 1.9
+++ DescriptorParser.java 1 Jul 2003 20:13:01 -0000 1.10
@@ -182,7 +182,6 @@
// TBD: meta
// TBD: dependency
- // TBD: library
pattern = "module/service";
@@ -315,6 +314,13 @@
result.addSetLimitedProperties(pattern, "path", "path");
result.addSetNext(pattern, "addProvider");
+ pattern = "*/resource";
+
+ result.addObjectCreate(pattern, ResourceDescriptor.class);
+ result.addRule(pattern, setLocationRule);
+ result.addSetLimitedProperties(pattern, "path", "path");
+ result.addSetNext(pattern, "addProvider");
+
pattern = "*/new";
result.addObjectCreate(pattern, NewDescriptor.class);
@@ -330,7 +336,17 @@
new String[] { "property", "path" },
new String[] { "propertyName", "path" });
result.addSetNext(pattern, "addConfigurator");
+
+ pattern = "*/set-resource";
+ result.addObjectCreate(pattern, ResourceDescriptor.class);
+ result.addRule(pattern, setLocationRule);
+ result.addSetLimitedProperties(
+ pattern,
+ new String[] { "property", "path" },
+ new String[] { "propertyName", "path" });
+ result.addSetNext(pattern, "addConfigurator");
+
pattern = "*/set-expression";
result.addObjectCreate(pattern, ExpressionDescriptor.class);
1.10 +30 -1 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/HiveMind_1.0.xsd
Index: HiveMind_1.0.xsd
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/HiveMind_1.0.xsd,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HiveMind_1.0.xsd 26 Jun 2003 20:31:25 -0000 1.9
+++ HiveMind_1.0.xsd 1 Jul 2003 20:13:01 -0000 1.10
@@ -242,6 +242,20 @@
</xs:attribute>
</xs:complexType>
</xs:element>
+ <xs:element name="set-resource">
+ <xs:annotation>
+ <xs:documentation>Assigns the location of a file as a property.</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="property-setter"/>
+ <xs:attribute name="path" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>The path of the file, relative to the
+ contributing module's descriptor.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
</xs:choice>
</xs:group>
<xs:group name="value-providers-group">
@@ -255,6 +269,7 @@
<xs:element ref="xml"/>
<xs:element ref="create-instance"/>
<xs:element ref="factory"/>
+ <xs:element ref="resource"/>
</xs:choice>
</xs:group>
<xs:group name="contribute-group">
@@ -471,6 +486,20 @@
<xs:element name="xml">
<xs:annotation>
<xs:documentation>Contributes the contents of an XML file.</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute name="path" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>The path of the XML file, relative to the
+ contributing module's module descriptor.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="resource">
+ <xs:annotation>
+ <xs:documentation>Contributes the location of an arbitrary file (relative
+ to the contributing module deployment descriptor).</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="path" type="xs:string" use="required">
1.7 +2 -2 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/AbstractConfigurationDescriptor.java
Index: AbstractConfigurationDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/AbstractConfigurationDescriptor.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractConfigurationDescriptor.java 30 Jun 2003 23:04:58 -0000 1.6
+++ AbstractConfigurationDescriptor.java 1 Jul 2003 20:13:01 -0000 1.7
@@ -105,7 +105,7 @@
* null if this descriptor has no value providers. The caller
* should not modify the returned list.
*/
- public List getElementProviders()
+ public List getProviders()
{
return _elementProviders;
}
1.1 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/ResourceDescriptor.java
Index: ResourceDescriptor.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.hivemind.parse;
import org.apache.commons.hivemind.HiveMind;
import org.apache.commons.hivemind.Module;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IResourceLocation;
/**
* Descriptor for the <resource> and <set-resource>
* elements.
*
* @author Howard Lewis Ship
* @version $Id: ResourceDescriptor.java,v 1.1 2003/07/01 20:13:01 hlship Exp $
*/
public class ResourceDescriptor extends AbstractConfigurator
{
private String _path;
protected void extendDescription(ToStringBuilder builder)
{
builder.append("path", _path);
}
public void configure(Object object, Module module)
{
Object value = provideValue(module);
configureProperty(object, value, module);
}
/**
* Returns a location relative to the module's resource location.
*/
public Object provideValue(Module module)
{
IResourceLocation moduleLocation = module.getLocation().getResourceLocation();
IResourceLocation result = moduleLocation.getRelativeLocation(_path);
if (result.getResourceURL() == null)
throw new ApplicationRuntimeException(
HiveMind.format(
"ResourceDescriptor.missing-resource",
_path,
module.getModuleId(),
moduleLocation));
return result;
}
public String getPath()
{
return _path;
}
public void setPath(String string)
{
_path = string;
}
}
1.11 +34 -0 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestConfiguration.java
Index: TestConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestConfiguration.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TestConfiguration.java 30 Jun 2003 23:04:41 -0000 1.10
+++ TestConfiguration.java 1 Jul 2003 20:13:01 -0000 1.11
@@ -497,4 +497,38 @@
}
+ public void testSetResource() throws Exception
+ {
+ Registry r = buildRegistry("SetResource.xml");
+ List l = r.getConfiguration("hivemind.test.config.Config");
+
+ assertEquals(1, l.size());
+
+ ResourceElement e = (ResourceElement) l.get(0);
+
+ IResourceLocation expected = getLocation("Symbols.xml");
+
+ assertEquals(expected, e.getLocation());
+
+ }
+
+ public void testSetResourceMissing() throws Exception
+ {
+ Registry r = buildRegistry("SetResourceMissing.xml");
+
+ try
+ {
+
+ r.getConfiguration("hivemind.test.config.Config");
+
+ unreachable();
+ }
+ catch (ApplicationRuntimeException ex)
+ {
+ Throwable t = findNestedException(ex);
+
+ checkException(t, "Resource Xyzzyx relative to module hivemind.test.config");
+ }
+
+ }
}
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/SetResource.xml
Index: SetResource.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: SetResource.xml,v 1.1 2003/07/01 20:13:01 hlship Exp $ -->
<module
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"
id="hivemind.test.config"
version="1.0.0">
<configuration id="Config" element-type="hivemind.test.config.ResourceElement">
<new>
<set-resource property="location" path="Symbols.xml"/>
</new>
</configuration>
</module>
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/SetResourceMissing.xml
Index: SetResourceMissing.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: SetResourceMissing.xml,v 1.1 2003/07/01 20:13:01 hlship Exp $ -->
<module
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"
id="hivemind.test.config"
version="1.0.0">
<configuration id="Config" element-type="hivemind.test.config.ResourceElement">
<new>
<set-resource property="location" path="Xyzzyx"/>
</new>
</configuration>
</module>
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/ResourceElement.java
Index: ResourceElement.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package hivemind.test.config;
import org.apache.tapestry.IResourceLocation;
/**
* Used to test the <set-resource> descriptor element.
*
* @author Howard Lewis Ship
* @version $Id: ResourceElement.java,v 1.1 2003/07/01 20:13:01 hlship Exp $
*/
public class ResourceElement
{
private IResourceLocation _location;
public IResourceLocation getLocation()
{
return _location;
}
public void setLocation(IResourceLocation location)
{
_location = location;
}
}
1.8 +8 -2 jakarta-commons-sandbox/hivemind/common/links.xml
Index: links.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/common/links.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- links.xml 26 Jun 2003 20:31:27 -0000 1.7
+++ links.xml 1 Jul 2003 20:13:02 -0000 1.8
@@ -74,4 +74,10 @@
<!ENTITY new '<a href="descriptor.html#new">&_new;</a>'>
<!ENTITY _parameters '<code><parameters></code>'>
-<!ENTITY parameters '<a href="descriptor.html#parameters">&_parameters;</a>'>
\ No newline at end of file
+<!ENTITY parameters '<a href="descriptor.html#parameters">&_parameters;</a>'>
+
+<!ENTITY _resource '<code><resource></code>'>
+<!ENTITY resource '<a href="descriptor.html#resource">&_resource;</a>'>
+
+<!ENTITY _set-resource '<code><set-resource></code>'>
+<!ENTITY set-resource '<a href="descriptor.html#set-resource">&_set-resource;</a>'>
\ No newline at end of file
1.7 +17 -0 jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl
Index: hivemind.xsl
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- hivemind.xsl 26 Jun 2003 20:31:27 -0000 1.6
+++ hivemind.xsl 1 Jul 2003 20:13:02 -0000 1.7
@@ -564,4 +564,21 @@
</li>
</xsl:template>
+ <xsl:template match="resource">
+ <li>
+ <span class="tag"><resource</span>
+ <span class="attribute"> path</span>"<xsl:value-of select="@path"/>
+ <span class="tag">/></span>
+ </li>
+ </xsl:template>
+
+ <xsl:template match="set-resource">
+ <li>
+ <span class="tag"><set-resource</span>
+ <span class="attribute"> property</span>="<xsl:value-of select="@property"/>"
+ <span class="attribute"> path</span>"<xsl:value-of select="@path"/>
+ <span class="tag">/></span>
+ </li>
+ </xsl:template>
+
</xsl:stylesheet>
1.8 +3 -1 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties
Index: HiveMindMessages.properties
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HiveMindMessages.properties 26 Jun 2003 20:31:29 -0000 1.7
+++ HiveMindMessages.properties 1 Jul 2003 20:13:02 -0000 1.8
@@ -68,6 +68,8 @@
XMLDescriptor.unable-to-parse=Unable to parse {0} (referenced at {1}): {2}
+ResourceDescriptor.missing-resource=Resource {0} relative to module {1} ({2}) not found.
+
# service.impl package
RemoteExceptionCoordinator.method-while-locked=RemoteExceptionCoordinator method {0} was invoked during a notification.
1.4 +16 -2 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/util/URLResourceLocation.java
Index: URLResourceLocation.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/util/URLResourceLocation.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- URLResourceLocation.java 4 Jun 2003 23:52:50 -0000 1.3
+++ URLResourceLocation.java 1 Jul 2003 20:13:02 -0000 1.4
@@ -57,6 +57,8 @@
package org.apache.commons.hivemind.util;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
@@ -104,12 +106,24 @@
{
try
{
- _url = new URL(getPath());
+ URL test = new URL(getPath());
+
+ InputStream stream = test.openStream();
+
+ stream.close();
+
+ _url = test;
}
catch (MalformedURLException ex)
{
throw new ApplicationRuntimeException(ex);
}
+ catch (IOException ex)
+ {
+ // If the resource can't be opened,
+ // then return null.
+ }
+
}
return _url;
1.10 +43 -8 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java
Index: TestDescriptorParser.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TestDescriptorParser.java 1 Jul 2003 11:28:53 -0000 1.9
+++ TestDescriptorParser.java 1 Jul 2003 20:13:02 -0000 1.10
@@ -66,6 +66,7 @@
import org.apache.commons.hivemind.parse.ContributeConfigurationDescriptor;
import org.apache.commons.hivemind.parse.ContributeServiceDescriptor;
import org.apache.commons.hivemind.parse.CreateInstanceDescriptor;
+import org.apache.commons.hivemind.parse.DescriptorParser;
import org.apache.commons.hivemind.parse.ExpressionDescriptor;
import org.apache.commons.hivemind.parse.FactoryDescriptor;
import org.apache.commons.hivemind.parse.InstanceBuilder;
@@ -73,6 +74,7 @@
import org.apache.commons.hivemind.parse.ModuleDescriptor;
import org.apache.commons.hivemind.parse.NewDescriptor;
import org.apache.commons.hivemind.parse.ParametersDescriptor;
+import org.apache.commons.hivemind.parse.ResourceDescriptor;
import org.apache.commons.hivemind.parse.ServiceDescriptor;
import org.apache.commons.hivemind.parse.ServiceRefDescriptor;
import org.apache.commons.hivemind.parse.ValueDescriptor;
@@ -305,7 +307,7 @@
ModuleDescriptor d = parse("Configuration.xml");
ConfigurationDescriptor cd = d.getConfiguration("Blat");
- List l = cd.getElementProviders();
+ List l = cd.getProviders();
assertEquals(4, Tapestry.size(l));
ValueDescriptor vd = (ValueDescriptor) l.get(0);
@@ -330,7 +332,7 @@
ModuleDescriptor d = parse("ContributeConfiguration.xml");
ContributeConfigurationDescriptor cd = d.getConfigurationContribution("foo.bar.Blat");
- List l = cd.getElementProviders();
+ List l = cd.getProviders();
assertEquals(4, Tapestry.size(l));
ValueDescriptor vd = (ValueDescriptor) l.get(0);
@@ -397,7 +399,7 @@
ModuleDescriptor md = parse("ServiceRef.xml");
ConfigurationDescriptor cd = md.getConfiguration("Blat");
- List l = cd.getElementProviders();
+ List l = cd.getProviders();
assertEquals(1, l.size());
ServiceRefDescriptor d = (ServiceRefDescriptor) l.get(0);
@@ -410,7 +412,7 @@
ModuleDescriptor md = parse("SetServiceRef.xml");
ConfigurationDescriptor cd = md.getConfiguration("Blat");
- List l = cd.getElementProviders();
+ List l = cd.getProviders();
assertEquals(1, l.size());
CreateInstanceDescriptor cid = (CreateInstanceDescriptor) l.get(0);
@@ -431,7 +433,7 @@
ModuleDescriptor md = parse("ContributeXML.xml");
ContributeConfigurationDescriptor cd = md.getConfigurationContribution("foo.bar.Blat");
- List l = cd.getElementProviders();
+ List l = cd.getProviders();
assertEquals(1, l.size());
XMLDescriptor xd = (XMLDescriptor) l.get(0);
@@ -444,7 +446,7 @@
ModuleDescriptor md = parse("ContributeSetXML.xml");
ContributeConfigurationDescriptor cd = md.getConfigurationContribution("foo.bar.Blat");
- List l = cd.getElementProviders();
+ List l = cd.getProviders();
assertEquals(1, l.size());
CreateInstanceDescriptor cid = (CreateInstanceDescriptor) l.get(0);
@@ -524,7 +526,7 @@
ModuleDescriptor d = parse("ConfigurationNew.xml");
ConfigurationDescriptor cd = d.getConfiguration("Blat");
- List l = cd.getElementProviders();
+ List l = cd.getProviders();
assertEquals(1, l.size());
NewDescriptor nd = (NewDescriptor) l.get(0);
@@ -541,6 +543,7 @@
public void testContributeFactoryParameters() throws Exception
{
ModuleDescriptor d;
+
try
{
@@ -574,4 +577,36 @@
assertEquals("blat", vd.getValue());
}
+
+ public void testResource() throws Exception
+ {
+ ModuleDescriptor d = parse("Resource.xml");
+ ConfigurationDescriptor cd = d.getConfiguration("Resource");
+
+ List l = cd.getProviders();
+ assertEquals(1, l.size());
+
+ ResourceDescriptor rd = (ResourceDescriptor) l.get(0);
+
+ assertEquals("foo/bar.baz", rd.getPath());
+ }
+
+ public void testSetResource() throws Exception
+ {
+ ModuleDescriptor d = parse("SetResource.xml");
+ ConfigurationDescriptor cd = d.getConfiguration("Resource");
+
+ List l = cd.getProviders();
+ assertEquals(1, l.size());
+
+ NewDescriptor nd = (NewDescriptor) l.get(0);
+
+ l = nd.getConfigurators();
+ assertEquals(1, l.size());
+
+ ResourceDescriptor rd = (ResourceDescriptor) l.get(0);
+
+ assertEquals("foo", rd.getPropertyName());
+ assertEquals("biff.blat", rd.getPath());
+ }
}
1.6 +3 -1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestToString.java
Index: TestToString.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestToString.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestToString.java 1 Jul 2003 11:28:53 -0000 1.5
+++ TestToString.java 1 Jul 2003 20:13:02 -0000 1.6
@@ -77,6 +77,7 @@
import org.apache.commons.hivemind.parse.InterceptorDescriptor;
import org.apache.commons.hivemind.parse.ModuleDescriptor;
import org.apache.commons.hivemind.parse.ParametersDescriptor;
+import org.apache.commons.hivemind.parse.ResourceDescriptor;
import org.apache.commons.hivemind.parse.ServiceDescriptor;
import org.apache.commons.hivemind.parse.ServiceRefDescriptor;
import org.apache.commons.hivemind.parse.ValueDescriptor;
@@ -112,6 +113,7 @@
new XMLDescriptor().toString();
new InterceptorDescriptor().toString();
new ParametersDescriptor().toString();
+ new ResourceDescriptor().toString();
new FactoryContributionImpl().toString();
new BaseModule().toString();
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/Resource.xml
Index: Resource.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: Resource.xml,v 1.1 2003/07/01 20:13:02 hlship Exp $ -->
<module
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"
id="hivemind.test.parse"
version="1.0.0">
<configuration id="Resource" element-type="org.apache.tapestry.IResourceLocation">
<resource path="foo/bar.baz"/>
</configuration>
</module>
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/SetResource.xml
Index: SetResource.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: SetResource.xml,v 1.1 2003/07/01 20:13:02 hlship Exp $ -->
<module
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"
id="hivemind.test.parse"
version="1.0.0">
<configuration id="Resource" element-type="fie.fie.foh.Fum">
<new>
<set-resource property="foo" path="biff.blat"/>
</new>
</configuration>
</module>
1.9 +3 -3 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryBuilder.java
Index: RegistryBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryBuilder.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- RegistryBuilder.java 30 Jun 2003 23:04:29 -0000 1.8
+++ RegistryBuilder.java 1 Jul 2003 20:13:03 -0000 1.9
@@ -302,7 +302,7 @@
_configurationPoints.put(pointId, point);
- addConfigurationContributions(module, point, cd.getElementProviders());
+ addConfigurationContributions(module, point, cd.getProviders());
}
}
@@ -472,7 +472,7 @@
continue;
}
- addConfigurationContributions(sourceModule, point, cd.getElementProviders());
+ addConfigurationContributions(sourceModule, point, cd.getProviders());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org