You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/01/27 21:27:59 UTC
cvs commit: jakarta-tapestry/framework/src/descriptor/META-INF tapestry.enhance.xml tapestry.init.xml
hlship 2005/01/27 12:27:59
Modified: framework/src/java/org/apache/tapestry/services/impl
ComponentConstructorFactoryImpl.java
framework/src/test/org/apache/tapestry/services/impl
TestBasicInfrastructure.java
framework/src/descriptor/META-INF tapestry.enhance.xml
tapestry.init.xml
Removed: framework/src/java/org/apache/tapestry/services/impl
InitializerContribution.java MasterInitializer.java
EnhancementWorkerContribution.java
Log:
Refactor some services to take advantage of hivemind.lib.ChainFactory.
Revision Changes Path
1.4 +7 -38 jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentConstructorFactoryImpl.java
Index: ComponentConstructorFactoryImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentConstructorFactoryImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ComponentConstructorFactoryImpl.java 6 Jan 2005 02:17:11 -0000 1.3
+++ ComponentConstructorFactoryImpl.java 27 Jan 2005 20:27:58 -0000 1.4
@@ -16,13 +16,9 @@
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.apache.hivemind.ClassResolver;
-import org.apache.hivemind.ErrorLog;
-import org.apache.hivemind.order.Orderer;
import org.apache.hivemind.service.ClassFactory;
import org.apache.tapestry.enhance.EnhancedClassValidator;
import org.apache.tapestry.enhance.EnhancementOperationImpl;
@@ -42,18 +38,14 @@
public class ComponentConstructorFactoryImpl implements ComponentConstructorFactory,
ResetEventListener
{
- private ErrorLog _errorLog;
-
private ClassFactory _classFactory;
private ClassResolver _classResolver;
- private List _contributions;
-
- private List _workers;
-
private EnhancedClassValidator _validator;
+ private EnhancementWorker _chain;
+
/**
* Map of {@link org.apache.tapestry.services.ComponentConstructor}keyed on
* {@link org.apache.tapestry.spec.IComponentSpecification}.
@@ -66,21 +58,6 @@
_cachedConstructors.clear();
}
- public void initializeService()
- {
- Orderer orderer = new Orderer(_errorLog, "worker");
-
- Iterator i = _contributions.iterator();
- while (i.hasNext())
- {
- EnhancementWorkerContribution c = (EnhancementWorkerContribution) i.next();
-
- orderer.add(c.getWorker(), c.getId(), c.getAfter(), c.getBefore());
- }
-
- _workers = orderer.getOrderedObjects();
- }
-
public ComponentConstructor getComponentConstructor(IComponentSpecification specification,
String className)
{
@@ -93,13 +70,10 @@
EnhancementOperationImpl eo = new EnhancementOperationImpl(_classResolver,
specification, baseClass, _classFactory);
- Iterator i = _workers.iterator();
- while (i.hasNext())
- {
- EnhancementWorker w = (EnhancementWorker) i.next();
+ // Invoking on the chain is the same as invoking on every
+ // object in the chain (because performEnhancement is type void).
- w.performEnhancement(eo);
- }
+ _chain.performEnhancement(eo);
result = eo.getConstructor();
@@ -126,18 +100,13 @@
_classResolver = classResolver;
}
- public void setContributions(List contributions)
- {
- _contributions = contributions;
- }
-
public void setValidator(EnhancedClassValidator validator)
{
_validator = validator;
}
- public void setErrorLog(ErrorLog errorLog)
+ public void setChain(EnhancementWorker chain)
{
- _errorLog = errorLog;
+ _chain = chain;
}
}
\ No newline at end of file
1.5 +0 -35 jakarta-tapestry/framework/src/test/org/apache/tapestry/services/impl/TestBasicInfrastructure.java
Index: TestBasicInfrastructure.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/services/impl/TestBasicInfrastructure.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestBasicInfrastructure.java 6 Jan 2005 02:17:19 -0000 1.4
+++ TestBasicInfrastructure.java 27 Jan 2005 20:27:58 -0000 1.5
@@ -14,24 +14,18 @@
package org.apache.tapestry.services.impl;
-import java.util.Collections;
-import java.util.List;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ClassResolver;
-import org.apache.hivemind.ErrorLog;
import org.apache.hivemind.Location;
import org.apache.hivemind.Registry;
import org.apache.hivemind.impl.DefaultClassResolver;
import org.apache.hivemind.impl.RegistryBuilder;
import org.apache.hivemind.test.HiveMindTestCase;
import org.apache.hivemind.util.ClasspathResource;
-import org.apache.tapestry.ApplicationServlet;
import org.apache.tapestry.engine.IPropertySource;
-import org.apache.tapestry.services.ApplicationInitializer;
import org.apache.tapestry.services.ClasspathResourceFactory;
import org.apache.tapestry.services.Infrastructure;
import org.apache.tapestry.services.RequestGlobals;
@@ -92,35 +86,6 @@
verifyControls();
}
- public void testMasterIntializer() throws Exception
- {
- ApplicationServlet servlet = new ApplicationServlet();
-
- ApplicationInitializer ai = (ApplicationInitializer) newMock(ApplicationInitializer.class);
-
- ai.initialize(servlet);
-
- ErrorLog log = (ErrorLog) newMock(ErrorLog.class);
-
- replayControls();
-
- // Build the list.
-
- InitializerContribution ic = new InitializerContribution();
- ic.setName("test");
- ic.setInitializer(ai);
-
- List l = Collections.singletonList(ic);
-
- MasterInitializer mi = new MasterInitializer();
- mi.setErrorLog(log);
- mi.setInitializers(l);
-
- mi.initialize(servlet);
-
- verifyControls();
- }
-
public void testClasspathResourceFactory()
{
ClassResolver cr = new DefaultClassResolver();
1.6 +19 -28 jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.enhance.xml
Index: tapestry.enhance.xml
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.enhance.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- tapestry.enhance.xml 6 Jan 2005 02:17:26 -0000 1.5
+++ tapestry.enhance.xml 27 Jan 2005 20:27:58 -0000 1.6
@@ -27,14 +27,25 @@
<invoke-factory>
<construct class="org.apache.tapestry.services.impl.ComponentConstructorFactoryImpl">
<set-service property="classFactory" service-id="hivemind.ClassFactory"/>
- <set-configuration property="contributions" configuration-id="EnhancementWorkers"/>
<event-listener service-id="tapestry.ResetEventCoordinator"/>
<set-service property="validator" service-id="EnhancedClassValidator"/>
+ <set-service property="chain" service-id="EnhancementWorkerChain"/>
</construct>
</invoke-factory>
</service-point>
+ <service-point id="EnhancementWorkerChain" interface="org.apache.tapestry.enhance.EnhancementWorker">
+
+ The chain of enhancement workers built from the EnhancementWorkers configuration.
+
+ <invoke-factory service-id="hivemind.lib.ChainFactory">
+ <construct configuration-id="EnhancementWorkers"/>
+ </invoke-factory>
+
+
+ </service-point>
+
<service-point id="EnhancedClassValidator" interface="org.apache.tapestry.enhance.EnhancedClassValidator">
Validates that an enhanced class does implement all abstract methods inherited from super-classes.
@@ -44,30 +55,10 @@
</invoke-factory>
</service-point>
- <configuration-point id="EnhancementWorkers">
+ <configuration-point id="EnhancementWorkers" schema-id="hivemind.lib.ChainContribution">
Provides the logic for component class enhancements.
-
- <schema>
- <element name="worker">
- <attribute name="id" required="true" unique="true">
- A unique id for the worker (used when ordering the workers).
- </attribute>
- <attribute name="before">
- A list of workers who should operate after this worker.
- </attribute>
- <attribute name="after">
- A list of workers who should operate prior to this worker.
- </attribute>
- <attribute name="object" translator="object" required="true">
- An object implementing the EnhancementWorker interface.
- </attribute>
-
- <conversion class="org.apache.tapestry.services.impl.EnhancementWorkerContribution">
- <map attribute="object" property="worker"/>
- </conversion>
- </element>
- </schema>
+
</configuration-point>
@@ -75,18 +66,18 @@
<!-- These can actually run in any order, so we don't specify before or after. -->
- <worker id="specified-property" object="service:SpecifiedPropertyWorker" before="abstract-property"/>
- <worker id="parameter" object="service:ParameterPropertyWorker" before="abstract-property"/>
- <worker id="inject" object="service:InjectWorker" before="abstract-property"/>
+ <command id="specified-property" object="service:SpecifiedPropertyWorker" before="abstract-property"/>
+ <command id="parameter" object="service:ParameterPropertyWorker" before="abstract-property"/>
+ <command id="inject" object="service:InjectWorker" before="abstract-property"/>
<!-- This should be second to last, or at least, after all other workers have
added and claimed any properties they are going to. -->
- <worker id="abstract-property" object="service:AbstractPropertyWorker"/>
+ <command id="abstract-property" object="service:AbstractPropertyWorker"/>
<!-- This needs to be absolutely last -->
- <worker id="force-non-abstract" after="*" object="instance:org.apache.tapestry.enhance.ForceNonAbstractWorker"/>
+ <command id="force-non-abstract" after="*" object="instance:org.apache.tapestry.enhance.ForceNonAbstractWorker"/>
</contribution>
1.3 +5 -30 jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.init.xml
Index: tapestry.init.xml
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.init.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- tapestry.init.xml 6 Jan 2005 02:17:26 -0000 1.2
+++ tapestry.init.xml 27 Jan 2005 20:27:58 -0000 1.3
@@ -24,40 +24,15 @@
Master startup for the application; invokes an ordered series of other ApplicationInitializer instances contributed to
the ApplicationInitializers configuration point.
- <invoke-factory>
- <construct class="org.apache.tapestry.services.impl.MasterInitializer">
- <set-configuration property="initializers" configuration-id="ApplicationInitializers"/>
- </construct>
+ <invoke-factory service-id="hivemind.lib.ChainFactory">
+ <construct configuration-id="ApplicationInitializers"/>
</invoke-factory>
</service-point>
- <configuration-point id="ApplicationInitializers">
+ <configuration-point id="ApplicationInitializers" schema-id="hivemind.lib.ChainContribution">
An orderable list of ApplicationInitializer services.
-
- <schema>
- <element name="initializer">
- <attribute name="name" required="true">
- A unique id used when ordering the initializers.
- </attribute>
-
- <attribute name="before" translator="id-list">
- A comma-seperated list of the names of initializers that should execute after this initializer.
- </attribute>
-
- <attribute name="after" translator="id-list">
- A comma-seperated list of the names of initializers that should execute before this initializer.
- </attribute>
-
- <attribute name="object" required="true" translator="object">
- The object which implements the ApplicationInitializer interface.
- </attribute>
-
- <conversion class="org.apache.tapestry.services.impl.InitializerContribution">
- <map attribute="object" property="initializer"/>
- </conversion>
- </element>
- </schema>
+
</configuration-point>
<service-point id="ApplicationSpecificationInitializer" interface="org.apache.tapestry.services.ApplicationInitializer">
@@ -74,7 +49,7 @@
</service-point>
<contribution configuration-id="ApplicationInitializers">
- <initializer name="ApplicationSpecificationInitializer" object="service:ApplicationSpecificationInitializer"/>
+ <command id="ApplicationSpecificationInitializer" object="service:ApplicationSpecificationInitializer"/>
</contribution>
</module>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org