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/06/10 00:23:09 UTC
cvs commit: jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/impl CheckInitializeService.java
hlship 2003/06/09 15:23:09
Modified: hivemind/src/java/org/apache/commons/hivemind
HiveMindMessages.properties
IServiceExtensionPoint.java
hivemind/xdocs descriptor.xml services.xml
hivemind project.xml project.properties
hivemind/src/test/hivemind/test HiveMindSuite.java
hivemind/src/java/org/apache/commons/hivemind/parse
DescriptorParser.java HiveMind_1.0.xsd
ExpressionDescriptor.java
hivemind/common links.xml
hivemind/src/test/hivemind/test/config
TestConfiguration.java
hivemind/src/test/hivemind/test/services TestServices.java
hivemind/src/java/org/apache/commons/hivemind/impl
RegistryBuilder.java ServiceExtensionPoint.java
hivemind/src/test/hivemind/test/parse
TestDescriptorParser.java
Added: hivemind/src/java/org/apache/commons/hivemind
IInitializeService.java
hivemind maven.xml
hivemind/src/test/hivemind/test TestRegistryBuilder.java
hivemind/src/test/hivemind/test/config
ExpressionVariables.xml
hivemind/src/test/hivemind/test/services Initialize.xml
ICheckInitializeService.java
hivemind/src/test-data/TestRegistryBuilder/META-INF
hivemodule.xml
hivemind/src/test/hivemind/test/parse
SetExpressionExtended.xml SetValueExtended.xml
hivemind/src/test/hivemind/test/services/impl
CheckInitializeService.java
Log:
Allow HiveMind variable references inside OGNL expressions.
Allow <set> and <set-expression> to provide the value or expression in the body of the element.
Add IInitializeService interface, to allow core implementations to initialize once configured.
Revision Changes Path
1.4 +2 -2 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HiveMindMessages.properties 4 Jun 2003 21:46:05 -0000 1.3
+++ HiveMindMessages.properties 9 Jun 2003 22:23:07 -0000 1.4
@@ -45,7 +45,7 @@
RegistryBuilder.one-or-more=at least one
RegistryBuilder.optional=an optional
RegistryBuilder.required=exactly one
-
+RegistryBuilder.unable-to-find-modules=Unable to locate HiveMind module deployment descriptors in {0}: {1}
InterceptorStack.interceptor-does-not-implement-interface=The service interceptor ({0}) generated by service {1} for service extension point {2} does not implement the {3} interface defined by the extension point.
InterceptorStack.null-interceptor=Service {0} generated a null interceptor (for service extension point {1}).
1.4 +19 -2 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/IServiceExtensionPoint.java
Index: IServiceExtensionPoint.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/IServiceExtensionPoint.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IServiceExtensionPoint.java 4 Jun 2003 23:52:49 -0000 1.3
+++ IServiceExtensionPoint.java 9 Jun 2003 22:23:07 -0000 1.4
@@ -100,7 +100,24 @@
/**
* Constructs a new instance of the service (including
- * any interceptors).
+ * any interceptors). This should only be invoked by
+ * the registry.
+ *
+ * <p>Once the core implementation is created and the interceptor
+ * stack is assembled, the core implementation is checked
+ * to see if it implements {@link IInitializeService}.
+ * If so {@link IInitializeService#initializeService(IServiceExtensionPoint, IFactoryContribution, Object)}
+ * is invoked, to let the core service implementation
+ * initialize.
+ *
+ * <p>May return null if the service is optional and no
+ * factory contribution has been made.
+ *
+ * @returns the outermost interceptor for the service, or the
+ * core implementation if there are no interceptors.
+ *
+ * @throws org.apache.tapestry.ApplicationRuntimeException if there
+ * is any problem creating the service.
*/
public Object constructService();
}
1.1 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/IInitializeService.java
Index: IInitializeService.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;
/**
* Interface that may be implemented by a core service implementation
* (in addition to the service interface), which is used by HiveMind
* to inform a newly created implementation service extension point
* it was created for.
*
* <p>
* The final version of the service is provided (this will
* be the receiver if the service extension point has no interceptors; otherwise,
* it will be the outermost interceptor). This allows the
* service to, for example, establish a callback to the core implementation that
* uses the interceptor stack (rather than bypassing it).
*
* @author Howard Lewis Ship
* @version $Id: IInitializeService.java,v 1.1 2003/06/09 22:23:06 hlship Exp $
*/
public interface IInitializeService
{
/**
* Invoked after the core implementation is instantiated, and the interceptor
* stack has been created.
* @param point the service extension point the core service was created for.
* @param factoryContribution the contribution which created the core implementation.
* @param service the outside representation of the service, this may be the
* same as the receiver, or can be the outermost interceptor.
*/
public void initializeService(
IServiceExtensionPoint point,
Object service);
}
1.3 +39 -11 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- descriptor.xml 6 Jun 2003 21:56:29 -0000 1.2
+++ descriptor.xml 9 Jun 2003 22:23:07 -0000 1.3
@@ -413,8 +413,8 @@
</td>
<td>0..n.</td>
<td>Reads an XML file and assigns the root element, as an instance of
- IElement. The configuation extension point must also be type
- IElement.</td>
+ <a href="apidocs/org/apache/commons/hivemind/IElement.html">IElement</a>. The configuation extension point must also be type
+ <a href="apidocs/org/apache/commons/hivemind/IElement.html">IElement</a>.</td>
</tr>
<tr>
<td colspan="2">
@@ -483,8 +483,8 @@
</td>
<td>0..n.</td>
<td>Reads an XML file and assigns the root element, as an instance of
- IElement. The configuation extension point must also by type
- IElement.</td>
+ <a href="apidocs/org/apache/commons/hivemind/IElement.html">IElement</a>. The configuation extension point must also by type
+ <a href="apidocs/org/apache/commons/hivemind/IElement.html">IElement</a>.</td>
</tr>
<tr>
<td colspan="2">
@@ -553,7 +553,7 @@
</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 IElement.</td>
+ file. The property must be type <a href="apidocs/org/apache/commons/hivemind/IElement.html">IElement</a>.</td>
</tr>
<tr>
<td colspan="2">
@@ -665,6 +665,11 @@
<p>The contributing module is the root object for the expression (meaning
properties of the module may be used, including <code>repository</code>
to access the HiveMind repository).</p>
+
+ <p>
+ Variable references in the value are expanded.
+ </p>
+
</section>
<section name="set-expression">
<p>&_set-expression; is similar to &expression;, but is used to update a
@@ -685,17 +690,30 @@
<tr>
<td>expression</td>
<td>string</td>
- <td>yes</td>
+ <td>no</td>
<td>The OGNL expression to evaluate. The result is assigned to the
property.</td>
</tr>
</table>
+
+ <p>
+ If a value is not given for the <code>expression</code> attribute,
+ then the body of the &_set-expression; element is used as the expression.
+ This is useful for long or complex expressions.
+ </p>
+
+ <p>
+ Variable references in the expression are expanded before the expression is evaluated.
+ </p>
</section>
<section name="value">
<p>&_value; is used to contribute a literal value to a configuration
extension point. Simple conversions from string to boolean or a numeric
- type occur automatically. Variable references in the value are expanded.</p>
+ 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.
+ </p>
</section>
<section name="set">
<p>&_set; sets a property of an object to a literal value. Internally, it
@@ -716,10 +734,20 @@
<tr>
<td>value</td>
<td>string</td>
- <td>yes</td>
+ <td>no</td>
<td>The literal value to assign to the property.</td>
</tr>
</table>
+
+ <p>
+ If the <code>value</code> attribute is not specified, then the body of the
+ &_set; element is used as the value. This is useful for long values, or values
+ that have a mix of quotes.
+ </p>
+
+ <p>
+ Variable references in the value are expanded.
+ </p>
</section>
<section name="service-ref">
<p>&_service-ref; is used to contribute a service instance to a
@@ -765,7 +793,7 @@
</section>
<section name="xml">
<p> &_xml; reads an XML file and parses it into a light-wieght DOM. An
- instance of IElement, representing the root element of the XML file, is
+ instance of <a href="apidocs/org/apache/commons/hivemind/IElement.html">IElement</a>, representing the root element of the XML file, is
contributed to the configuration.</p>
<table>
<tr>
@@ -805,7 +833,7 @@
<td>yes</td>
<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 IElement, is assigned to the property.</td>
+ an instance of <a href="apidocs/org/apache/commons/hivemind/IElement.html">IElement</a>, is assigned to the property.</td>
</tr>
</table>
</section>
1.4 +27 -3 jakarta-commons-sandbox/hivemind/xdocs/services.xml
Index: services.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/services.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- services.xml 6 Jun 2003 21:56:29 -0000 1.3
+++ services.xml 9 Jun 2003 22:23:07 -0000 1.4
@@ -51,7 +51,10 @@
<p>An instance factory is represented by a &factory; element. It
includes a service-id attribute. This is the fully qualfied id of a
factory service, a service which implements the
- org.apache.commons.hivemind.IFactory interface.</p>
+
+ <a href="apidocs/org/apache/commons/hivemind/IFactory.html">IFactory</a>
+
+ interface.</p>
<p>In both cases, the properties of the core instance may be configured
using enclosed &set;, &set-expression;, &set-create;, &set-factory;
&set-service-ref; and &set-xml;
@@ -61,7 +64,10 @@
<p>An interceptor contribution is represented by a &interceptor;
element. The service-id attribute identifies an interceptor factory
service: a service that implements the
- org.apache.commons.hivemind.IInterceptorFactory interface.</p>
+
+ <a href="apidocs/org/apache/commons/hivemind/IInterceptorFactory.html">IInterceptorFactory</a>
+
+ interface.</p>
<p>An interceptor factory knows how to create an object that implements
an arbitrary interface, adding the functionality of that interface.
For example, a logging interceptor factory would create an object
@@ -191,7 +197,25 @@
ApplicationRuntimeException. So, if a service is required, you don't
have to check for null.</p>
</li>
+
+ <li>
+ <strong>What if I need to do some initializations in my service?</strong>
+ <p>
+ If you have additional initializations that can't occur inside your
+ core service implementations constructor (for instance, if
+ the initializations are based on properties set after object
+ is constructed), then
+ your class should implement the
+
+ <a href="apidocs/org/apache/commons/hivemind/IInitializeService.html">IInitializeService</a>
+ interface (in addition to the service interface).
+ This interface defines a callback that occurs only after
+ the core service has been constructed and configured, and the interceptor stack
+ has been assembled.
+ </p>
+ </li>
</ul>
+
</section>
</body>
</document>
1.5 +5 -10 jakarta-commons-sandbox/hivemind/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/project.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- project.xml 6 Jun 2003 21:56:29 -0000 1.4
+++ project.xml 9 Jun 2003 22:23:07 -0000 1.5
@@ -89,7 +89,8 @@
</dependency>
<dependency>
- <id>jakarta-tapestry</id>
+ <!-- Note: just until the Maven folks put this in the right spot! -->
+ <id>tapestry</id>
<artifactId>tapestry</artifactId>
<version>3.0-beta-1a</version>
<url>http://jakarta.apache.org/tapestry/</url>
@@ -182,15 +183,9 @@
<include>**/*.xsd</include>
<include>**/*.properties</include>
</includes>
- </resource>
+ </resource>
- <resource>
- <directory>src/META-INF</directory>
- <targetPath>META-INF</targetPath>
- <includes>
- <include>*</include>
- </includes>
- </resource>
+ <!-- We don't package src/META-INF here, because it screws up some of the unit tests. -->
</resources>
1.2 +3 -2 jakarta-commons-sandbox/hivemind/project.properties
Index: project.properties
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/project.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- project.properties 6 Jun 2003 21:56:29 -0000 1.1
+++ project.properties 9 Jun 2003 22:23:07 -0000 1.2
@@ -1,3 +1,4 @@
# $Id$
-maven.username=hlship
\ No newline at end of file
+maven.username=hlship
+maven.xdoc.date=left
1.1 jakarta-commons-sandbox/hivemind/maven.xml
Index: maven.xml
===================================================================
<?xml version="1.0"?>
<!-- $Id: maven.xml,v 1.1 2003/06/09 22:23:07 hlship Exp $ -->
<project
xmlns:m="maven"
xmlns:ant="jelly:ant"
xmlns:j="jelly:core"
xmlns:u="jelly:util">
<postGoal name="jar:jar">
<ant:echo>Adding META-INF/hivemodule.xml to ${maven.final.name}.jar</ant:echo>
<ant:jar
jarfile="${maven.build.dir}/${maven.final.name}.jar"
basedir="${maven.build.dest}"
update="true"
excludes="${maven.jar.excludes}">
<ant:fileset dir="src">
<ant:include name="META-INF/**"/>
</ant:fileset>
</ant:jar>
</postGoal>
</project>
1.5 +1 -0 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindSuite.java
Index: HiveMindSuite.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindSuite.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HiveMindSuite.java 4 Jun 2003 23:52:48 -0000 1.4
+++ HiveMindSuite.java 9 Jun 2003 22:23:07 -0000 1.5
@@ -75,6 +75,7 @@
suite.addTestSuite(TestExternalParser.class);
suite.addTestSuite(TestServices.class);
suite.addTestSuite(TestConfiguration.class);
+ suite.addTestSuite(TestRegistryBuilder.class);
suite.addTestSuite(TestToString.class);
return suite;
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/TestRegistryBuilder.java
Index: TestRegistryBuilder.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;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;
import org.apache.commons.hivemind.IRegistry;
import org.apache.commons.hivemind.impl.RegistryBuilder;
import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IResourceResolver;
import org.apache.tapestry.util.DefaultResourceResolver;
/**
* Tests the {@link org.apache.commons.hivemind.impl.RegistryBuilder} class.
*
* @author Howard Lewis Ship
* @version $Id: TestRegistryBuilder.java,v 1.1 2003/06/09 22:23:07 hlship Exp $
*/
public class TestRegistryBuilder extends HiveMindTestCase
{
public TestRegistryBuilder(String name)
{
super(name);
}
public void testEmpty() throws Exception
{
RegistryBuilder b = new RegistryBuilder();
b.processModules(_resolver);
IRegistry r = b.constructRegistry();
try
{
r.getConfiguration("org.apache.commons.hivemind.VariableSource");
unreachable();
}
catch (ApplicationRuntimeException ex)
{
checkException(ex, "Registry does not contain module 'org.apache.commons.hivemind'.");
}
}
/**
* Reproduce test {@link hivemind.test.config.TestConfiguration#testValueVariables()} using
* dynamic lookup of hivemodule resources.
*/
public void testLookup() throws Exception
{
File f1 = new File("src");
File f2 = new File("src/test-data/TestRegistryBuilder");
URL[] urls = new URL[] { f1.toURL(), f2.toURL()};
ClassLoader loader =
new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
IResourceResolver resolver = new DefaultResourceResolver(loader);
RegistryBuilder b = new RegistryBuilder();
b.processModules(resolver);
IRegistry r = b.constructRegistry();
List l = r.getConfiguration("hivemind.test.config.Dogs");
assertEquals(1, l.size());
String dog = (String) l.get(0);
assertEquals("Dino", dog);
}
}
1.5 +13 -17 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DescriptorParser.java 4 Jun 2003 23:52:47 -0000 1.4
+++ DescriptorParser.java 9 Jun 2003 22:23:08 -0000 1.5
@@ -83,7 +83,7 @@
*/
public class DescriptorParser
{
- private static final Log LOG = LogFactory.getLog(DescriptorParser.class);
+ private static final Log LOG = LogFactory.getLog(DescriptorParser.class);
public static final String HIVE_MIND_SCHEMA_URL =
"http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd";
@@ -277,10 +277,8 @@
result.addObjectCreate(pattern, ValueDescriptor.class);
result.addRule(pattern, setLocationRule);
- result.addSetLimitedProperties(
- pattern,
- new String[] { "property", "value" },
- new String[] { "propertyName", "value" });
+ result.addSetLimitedProperties(pattern, "property", "propertyName");
+ result.addSetExtendedProperty(pattern, "value", "value", true);
result.addSetNext(pattern, "addConfigurator");
pattern = "*/service-ref";
@@ -321,10 +319,8 @@
result.addObjectCreate(pattern, ExpressionDescriptor.class);
result.addRule(pattern, setLocationRule);
- result.addSetLimitedProperties(
- pattern,
- new String[] { "property", "expression" },
- new String[] { "propertyName", "expression" });
+ result.addSetLimitedProperties(pattern, "property", "propertyName");
+ result.addSetExtendedProperty(pattern, "expression", "expression", true);
result.addSetNext(pattern, "addConfigurator");
pattern = "*/set-create";
@@ -347,13 +343,13 @@
new String[] { "propertyName", "factoryServiceId" });
result.addSetNext(pattern, "addConfigurator");
- pattern = "*/set-location";
-
- result.addObjectCreate(pattern, SetLocationDescriptor.class);
- result.addRule(pattern, setLocationRule);
- result.addSetLimitedProperties(pattern, "property", "propertyName");
- result.addSetTop(pattern, "setContainer");
- result.addSetNext(pattern, "addConfigurator");
+ pattern = "*/set-location";
+
+ result.addObjectCreate(pattern, SetLocationDescriptor.class);
+ result.addRule(pattern, setLocationRule);
+ result.addSetLimitedProperties(pattern, "property", "propertyName");
+ result.addSetTop(pattern, "setContainer");
+ result.addSetNext(pattern, "addConfigurator");
pattern = "*/interceptor";
1.4 +12 -12 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HiveMind_1.0.xsd 4 Jun 2003 21:46:03 -0000 1.3
+++ HiveMind_1.0.xsd 9 Jun 2003 22:23:08 -0000 1.4
@@ -157,12 +157,12 @@
<xs:documentation>Sets the value of an object property to a literal value.</xs:documentation>
</xs:annotation>
<xs:complexType>
- <xs:attribute name="value" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The value to be assigned to the property. Simple data type conversions (from strings to other basic types) will automatically occur. The value may contain variable references.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attributeGroup ref="property-setter"/>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attributeGroup ref="property-setter"/>
+ <xs:attribute name="value" type="xs:string" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="set-expression">
@@ -170,12 +170,12 @@
<xs:documentation>Sets the value of a property to a computed OGNL expression. The module is the root object of the expression.</xs:documentation>
</xs:annotation>
<xs:complexType>
- <xs:attributeGroup ref="property-setter"/>
- <xs:attribute name="expression" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The OGNL expression to evaluate and assign to the property.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="expression" type="xs:string" use="optional"/>
+ <xs:attributeGroup ref="property-setter"/>
+ </xs:extension>
+ </xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="set-create">
1.5 +9 -3 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/ExpressionDescriptor.java
Index: ExpressionDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/ExpressionDescriptor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExpressionDescriptor.java 4 Jun 2003 23:52:47 -0000 1.4
+++ ExpressionDescriptor.java 9 Jun 2003 22:23:08 -0000 1.5
@@ -93,16 +93,22 @@
{
IResourceResolver resolver = module.getResourceResolver();
+ // Convert variable references in the expression.
+ // Should we cache this?
+
+ String convertedExpression =
+ module.getRegistry().convertVariableReferences(_expression, getLocation());
+
try
{
- return OgnlUtils.get(_expression, resolver, module);
+ return OgnlUtils.get(convertedExpression, resolver, module);
}
catch (Exception ex)
{
throw new ApplicationRuntimeException(
HiveMind.format(
"ExpressionDescriptor.unable-to-evaluate",
- _expression,
+ convertedExpression,
module,
ex.getMessage()),
getLocation(),
1.3 +24 -24 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- links.xml 6 Jun 2003 21:56:30 -0000 1.2
+++ links.xml 9 Jun 2003 22:23:08 -0000 1.3
@@ -1,69 +1,69 @@
<!-- $Id$ -->
-<!ENTITY _module '<module>'>
+<!ENTITY _module '<code><code><module></code></code>'>
<!ENTITY module '<a href="descriptor.html#module">&_module;</a>'>
-<!ENTITY _service '<service>'>
+<!ENTITY _service '<code><service></code>'>
<!ENTITY service '<a href="descriptor.html#service">&_service;</a>'>
-<!ENTITY _create-instance '<create-instance>'>
+<!ENTITY _create-instance '<code><create-instance></code>'>
<!ENTITY create-instance '<a href="descriptor.html#create-instance">&_create-instance;</a>'>
-<!ENTITY _factory '<factory>'>
+<!ENTITY _factory '<code><factory></code>'>
<!ENTITY factory '<a href="descriptor.html#factory">&_factory;</a>'>
-<!ENTITY _set '<set>'>
+<!ENTITY _set '<code><set></code>'>
<!ENTITY set '<a href="descriptor.html#set">&_set;</a>'>
-<!ENTITY _set-expression '<set-expression>'>
+<!ENTITY _set-expression '<code><set-expression></code>'>
<!ENTITY set-expression '<a href="descriptor.html#set-expression">&_set-expression;</a>'>
-<!ENTITY _set-create '<set-create>'>
+<!ENTITY _set-create '<code><set-create></code>'>
<!ENTITY set-create '<a href="descriptor.html#set-create">&_set-create;</a>'>
-<!ENTITY _set-factory '<set-factory>'>
+<!ENTITY _set-factory '<code><set-factory></code>'>
<!ENTITY set-factory '<a href="descriptor.html#set-factory">&_set-factory;</a>'>
-<!ENTITY _interceptor '<interceptor>'>
+<!ENTITY _interceptor '<code><interceptor></code>'>
<!ENTITY interceptor '<a href="descriptor.html#interceptor">&_interceptor;</a>'>
-<!ENTITY _meta '<meta>'>
+<!ENTITY _meta '<code><meta></code>'>
<!ENTITY meta '<a href="descriptor.html#meta">&_meta;</a>'>
-<!ENTITY _description '<description>'>
+<!ENTITY _description '<code><description></code>'>
<!ENTITY description '<a href="descriptor.html#description">&_description;</a>'>
-<!ENTITY _dependency '<dependency>'>
+<!ENTITY _dependency '<code><dependency></code>'>
<!ENTITY dependency '<a href="descriptor.html#dependency">&_dependency;</a>'>
-<!ENTITY _library '<library>'>
+<!ENTITY _library '<code><library></code>'>
<!ENTITY library '<a href="descriptor.html#library">&_library;</a>'>
-<!ENTITY _configuration '<configuration>'>
+<!ENTITY _configuration '<code><configuration></code>'>
<!ENTITY configuration '<a href="descriptor.html#configuration">&_configuration;</a>'>
-<!ENTITY _expression '<expression>'>
+<!ENTITY _expression '<code><expression></code>'>
<!ENTITY expression '<a href="descriptor.html#expression">&_expression;</a>'>
-<!ENTITY _value '<value>'>
+<!ENTITY _value '<code><value></code>'>
<!ENTITY value '<a href="descriptor.html#value">&_value;</a>'>
-<!ENTITY _service-ref '<service-ref>'>
+<!ENTITY _service-ref '<code><service-ref></code>'>
<!ENTITY service-ref '<a href="descriptor.html#service-ref">&_service-ref;</a>'>
-<!ENTITY _set-service-ref '<set-service-ref>'>
+<!ENTITY _set-service-ref '<code><set-service-ref></code>'>
<!ENTITY set-service-ref '<a href="descriptor.html#set-service-ref">&_set-service-ref;</a>'>
-<!ENTITY _xml '<xml>'>
+<!ENTITY _xml '<code><xml></code>'>
<!ENTITY xml '<a href="descriptor.html#xml">&_xml;</a>'>
-<!ENTITY _set-xml '<set-xml>'>
+<!ENTITY _set-xml '<code><set-xml></code>'>
<!ENTITY set-xml '<a href="descriptor.html#set-xml">&_set-xml;</a>'>
-<!ENTITY _contribute-service '<contribute-service>'>
+<!ENTITY _contribute-service '<code><contribute-service></code>'>
<!ENTITY contribute-service '<a href="descriptor.html#contribute-service">&_contribute-service;</a>'>
-
-<!ENTITY _contribute-configuration '<contribute-configuration>'>
+<!ENTITY _contribute-configuration '<code><contribute-configuration></code>'>
<!ENTITY contribute-configuration '<a href="descriptor.html#contribute-configuration">&_contribute-configuration;</a>'>
+
1.6 +18 -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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestConfiguration.java 6 Jun 2003 21:56:29 -0000 1.5
+++ TestConfiguration.java 9 Jun 2003 22:23:08 -0000 1.6
@@ -342,4 +342,22 @@
assertEquals("Dino", dog);
}
+
+ public void testExpressionVariables() throws Exception
+ {
+ RegistryBuilder b = new RegistryBuilder();
+ DescriptorParser p = new DescriptorParser();
+
+ b.processModule(_resolver, p.parse(getMasterModuleLocation()));
+ b.processModule(_resolver, p.parse(getLocation("ExpressionVariables.xml")));
+
+ IRegistry r = b.constructRegistry();
+
+ List l = r.getConfiguration("hivemind.test.config.Dogs");
+ assertEquals(1, l.size());
+
+ String dog = (String) l.get(0);
+
+ assertEquals("Dino", dog);
+ }
}
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/ExpressionVariables.xml
Index: ExpressionVariables.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: ExpressionVariables.xml,v 1.1 2003/06/09 22:23:08 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">
<contribute-configuration configuration-id="org.apache.commons.hivemind.VariableSource">
<create-instance class="org.apache.commons.hivemind.VariableSourceContribution">
<set-create property="source" class="hivemind.test.external.PropertiesVariableSource"/>
</create-instance>
</contribute-configuration>
<configuration id="Dogs" element-type="java.lang.String">
<expression>"${dog}"</expression>
</configuration>
</module>
1.4 +12 -0 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java
Index: TestServices.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestServices.java 4 Jun 2003 23:52:49 -0000 1.3
+++ TestServices.java 9 Jun 2003 22:23:08 -0000 1.4
@@ -140,4 +140,16 @@
TrackerFactory.getInvocations().toArray());
}
+
+ public void testInitialize() throws Exception
+ {
+ IRegistry r = buildRegistry("Initialize.xml");
+
+ ICheckInitializeService c =
+ (ICheckInitializeService) r.getService(
+ "hivemind.test.services.CheckInitialize",
+ ICheckInitializeService.class);
+
+ assertEquals(true, c.didInitialize());
+ }
}
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/Initialize.xml
Index: Initialize.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: Initialize.xml,v 1.1 2003/06/09 22:23:08 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.services"
version="1.0.0">
<service id="CheckInitialize" interface="hivemind.test.services.ICheckInitializeService">
<create-instance class="hivemind.test.services.impl.CheckInitializeService"/>
</service>
</module>
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/ICheckInitializeService.java
Index: ICheckInitializeService.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.services;
/**
* Used for testing support of {@link org.apache.commons.hivemind.IInitializeService}.
*
* @author Howard Lewis Ship
* @version $Id: ICheckInitializeService.java,v 1.1 2003/06/09 22:23:08 hlship Exp $
*/
public interface ICheckInitializeService
{
public boolean didInitialize();
}
1.1 jakarta-commons-sandbox/hivemind/src/test-data/TestRegistryBuilder/META-INF/hivemodule.xml
Index: hivemodule.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: hivemodule.xml,v 1.1 2003/06/09 22:23:09 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">
<contribute-configuration configuration-id="org.apache.commons.hivemind.VariableSource">
<create-instance class="org.apache.commons.hivemind.VariableSourceContribution">
<set-create property="source" class="hivemind.test.external.PropertiesVariableSource"/>
</create-instance>
</contribute-configuration>
<configuration id="Dogs" element-type="java.lang.String">
<value>${dog}</value>
</configuration>
</module>
1.4 +69 -14 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RegistryBuilder.java 4 Jun 2003 23:52:48 -0000 1.3
+++ RegistryBuilder.java 9 Jun 2003 22:23:09 -0000 1.4
@@ -57,7 +57,10 @@
package org.apache.commons.hivemind.impl;
+import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -67,17 +70,20 @@
import org.apache.commons.hivemind.IModule;
import org.apache.commons.hivemind.IRegistry;
import org.apache.commons.hivemind.Occurances;
+import org.apache.commons.hivemind.parse.AbstractInstanceBuilderDescriptor;
import org.apache.commons.hivemind.parse.ConfigurationDescriptor;
import org.apache.commons.hivemind.parse.ContributeConfigurationDescriptor;
import org.apache.commons.hivemind.parse.ContributeServiceDescriptor;
+import org.apache.commons.hivemind.parse.DescriptorParser;
import org.apache.commons.hivemind.parse.IValueProvider;
-import org.apache.commons.hivemind.parse.AbstractInstanceBuilderDescriptor;
import org.apache.commons.hivemind.parse.InterceptorDescriptor;
import org.apache.commons.hivemind.parse.ModuleDescriptor;
import org.apache.commons.hivemind.parse.ServiceDescriptor;
+import org.apache.commons.hivemind.util.URLResourceLocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry.ApplicationRuntimeException;
+import org.apache.tapestry.IResourceLocation;
import org.apache.tapestry.IResourceResolver;
import org.apache.tapestry.Tapestry;
@@ -108,7 +114,6 @@
{
private static final Log LOG = LogFactory.getLog(RegistryBuilder.class);
-
/**
* List of {@link ModuleDescriptor}.
*/
@@ -138,7 +143,56 @@
private Map _configurationPoints = new HashMap();
+ /**
+ * Processes all modules that can be found using the resolver.
+ */
+ public void processModules(IResourceResolver resolver)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Processing modules visible to " + resolver);
+
+ ClassLoader loader = resolver.getClassLoader();
+ Enumeration e = null;
+ int count = 0;
+
+ try
+ {
+
+ e = loader.getResources("META-INF/hivemodule.xml");
+ }
+ catch (IOException ex)
+ {
+ throw new ApplicationRuntimeException(
+ HiveMind.format("RegistryBuilder.unable-to-find-modules", resolver, ex),
+ ex);
+ }
+
+ DescriptorParser parser = new DescriptorParser();
+ while (e.hasMoreElements())
+ {
+ URL descriptorURL = (URL) e.nextElement();
+ IResourceLocation descriptorLocation = new URLResourceLocation(descriptorURL);
+
+ ModuleDescriptor md = parser.parse(descriptorLocation);
+
+ processModule(resolver, md);
+
+ count++;
+ }
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Processed " + count + " module descriptors.");
+
+ }
+
+ /**
+ * Processes a parsed HiveMind module descriptor. This may be called
+ * repeatedly before invoking {@link #constructRegistry()}.
+ *
+ * @param resolver A resolver used to access resources and classes within the module.
+ * @param md the parsed module descriptor
+ */
public void processModule(IResourceResolver resolver, ModuleDescriptor md)
{
String id = md.getModuleId();
@@ -165,8 +219,8 @@
module.setLocation(md.getLocation());
module.setModuleId(id);
- module.setResourceResolver(resolver);
-
+ module.setResourceResolver(resolver);
+
addServiceExtensionPoints(module, md);
addConfigurationExtensionPoints(module, md);
@@ -237,11 +291,11 @@
point.setElementTypeName(cd.getElementTypeName());
point.setCacheElements(cd.getCacheElements());
- module.addConfigurationExtensionPoint(point);
-
- // Needed later when we reconcile the rest
- // of the configuration contributions.
-
+ module.addConfigurationExtensionPoint(point);
+
+ // Needed later when we reconcile the rest
+ // of the configuration contributions.
+
_configurationPoints.put(pointId, point);
addConfigurationContributions(module, point, cd.getValueProviders());
@@ -259,7 +313,8 @@
if (LOG.isDebugEnabled())
LOG.debug(
- "Adding contributions to configuration extension point " + point.getExtensionPointId());
+ "Adding contributions to configuration extension point "
+ + point.getExtensionPointId());
for (int i = 0; i < count; i++)
{
@@ -346,7 +401,7 @@
}
checkForMissingServices();
-
+
checkConfigurationCounts();
BaseRegistry result = new BaseRegistry();
@@ -580,8 +635,8 @@
int count = point.getContributionCount();
- // Ok, so sometimes a case statement for Enums
- // would be nice. Guess that's coming in JDK 1.5.
+ // Ok, so sometimes a case statement for Enums
+ // would be nice. Guess that's coming in JDK 1.5.
if (expected == Occurances.ONE_PLUS)
{
1.5 +11 -2 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPoint.java
Index: ServiceExtensionPoint.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPoint.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServiceExtensionPoint.java 4 Jun 2003 23:52:48 -0000 1.4
+++ ServiceExtensionPoint.java 9 Jun 2003 22:23:09 -0000 1.5
@@ -64,6 +64,7 @@
import org.apache.commons.hivemind.HiveMind;
import org.apache.commons.hivemind.IFactoryContribution;
+import org.apache.commons.hivemind.IInitializeService;
import org.apache.commons.hivemind.IInterceptorContribution;
import org.apache.commons.hivemind.IServiceExtensionPoint;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -255,7 +256,15 @@
fc.getLocation(),
null);
- return addInterceptors(core);
+ Object intercepted = addInterceptors(core);
+
+ if (core instanceof IInitializeService)
+ {
+ IInitializeService initializeCore = (IInitializeService) core;
+ initializeCore.initializeService(this, intercepted);
+ }
+
+ return intercepted;
}
catch (Exception ex)
{
1.5 +32 -1 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestDescriptorParser.java 4 Jun 2003 23:52:50 -0000 1.4
+++ TestDescriptorParser.java 9 Jun 2003 22:23:09 -0000 1.5
@@ -470,4 +470,35 @@
assertSame(ibd, d.getContainer());
}
+ public void testSetValueExtended() throws Exception
+ {
+ ModuleDescriptor d = parse("SetValueExtended.xml");
+ ServiceDescriptor s = d.getService("Foo");
+ AbstractInstanceBuilderDescriptor ibd = s.getInstanceBuilder();
+ CreateInstanceDescriptor cid = (CreateInstanceDescriptor) ibd;
+
+ List l = cid.getConfigurators();
+ assertEquals(2, Tapestry.size(l));
+
+ ValueDescriptor vd = (ValueDescriptor) l.get(0);
+
+ assertEquals("gromit", vd.getPropertyName());
+ assertEquals("greyhound", vd.getValue());
+ }
+
+ public void testSetExpressionExtended() throws Exception
+ {
+ ModuleDescriptor d = parse("SetExpressionExtended.xml");
+ ServiceDescriptor s = d.getService("Foo");
+ AbstractInstanceBuilderDescriptor ibd = s.getInstanceBuilder();
+ CreateInstanceDescriptor cid = (CreateInstanceDescriptor) ibd;
+
+ List l = cid.getConfigurators();
+ assertEquals(2, Tapestry.size(l));
+
+ ExpressionDescriptor ed = (ExpressionDescriptor) l.get(1);
+
+ assertEquals("aProperty", ed.getPropertyName());
+ assertEquals("an extended expression", ed.getExpression());
+ }
}
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/SetExpressionExtended.xml
Index: SetExpressionExtended.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: SetExpressionExtended.xml,v 1.1 2003/06/09 22:23:09 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="package.TwoServices" version="0.0.2">
<service id="Foo" interface="package.IFoo">
<create-instance class="package.impl.Foo">
<set-create property="fred" class="package.impl.Fred"/>
<set-expression property="aProperty">
an extended expression
</set-expression>
</create-instance>
</service>
</module>
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/SetValueExtended.xml
Index: SetValueExtended.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: SetValueExtended.xml,v 1.1 2003/06/09 22:23:09 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="package.TwoServices"
version="0.0.2">
<service id="Foo" interface="package.IFoo">
<create-instance class="package.impl.Foo">
<set property="gromit">
greyhound
</set>
<set-create property="fred" class="package.impl.Fred"/>
</create-instance>
</service>
</module>
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/impl/CheckInitializeService.java
Index: CheckInitializeService.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.services.impl;
import hivemind.test.services.ICheckInitializeService;
import org.apache.commons.hivemind.IInitializeService;
import org.apache.commons.hivemind.IServiceExtensionPoint;
/**
* Used for testing support of {@link org.apache.commons.hivemind.IInitializeService}.
*
* @author Howard Lewis Ship
* @version $Id: CheckInitializeService.java,v 1.1 2003/06/09 22:23:09 hlship Exp $
*/
public class CheckInitializeService implements IInitializeService, ICheckInitializeService
{
private boolean _didInitialize;
public void initializeService(IServiceExtensionPoint point, Object service)
{
_didInitialize = true;
}
public boolean didInitialize()
{
return _didInitialize;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org