You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2006/08/03 20:00:20 UTC
svn commit: r428462 - in /tapestry/tapestry5/tapestry-core/trunk: ./
src/main/java/org/apache/tapestry/internal/ioc/services/
src/main/java/org/apache/tapestry/ioc/
src/main/java/org/apache/tapestry/ioc/annotations/
src/main/java/org/apache/tapestry/io...
Author: hlship
Date: Thu Aug 3 11:00:16 2006
New Revision: 428462
URL: http://svn.apache.org/viewvc?rev=428462&view=rev
Log:
Move implementation classes for module tapestry.ioc to org.apache.tapestry.internal.ioc.services.
Add @SubModule annotation, allowing a module class to specify other module classes to load.
Automatically load TapestryIOCModule without requiring an entry in the manifest.
Add tapestry.ioc.PipelineBuilder service.
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/BridgeBuilder.java
- copied, changed from r424849, hivemind/trunk/library/src/java/org/apache/hivemind/lib/pipeline/BridgeBuilder.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ClassPropertyAdapterImpl.java
- copied, changed from r428069, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapterImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzer.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAccessImpl.java
- copied, changed from r428069, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccessImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAdapterImpl.java
- copied, changed from r428069, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAdapterImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyShadowBuilderImpl.java
- copied, changed from r428071, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/pipeline.apt
tapestry/tapestry5/tapestry-core/trunk/src/site/resources/images/PipelineCallingSequence.png (with props)
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/BridgeBuilderTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraFilterMethod.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraFilterMethod.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraServiceMethod.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraServiceMethod.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzerTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleFilter.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleFilter.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleService.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleService.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleFilter.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleFilter.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleService.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleService.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardFilter.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardFilter.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardService.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardService.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringFilter.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringFilter.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringService.java
- copied, changed from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringService.java
Removed:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapterImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/IOCServicesMessages.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccessImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAdapterImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/ioc/services/IOCServicesStrings.properties
Modified:
tapestry/tapestry5/tapestry-core/trunk/pom.xml
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ServiceMessages.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/SubModule.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/services/ServiceStrings.properties
tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyAccessImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java
Modified: tapestry/tapestry5/tapestry-core/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/pom.xml?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/pom.xml Thu Aug 3 11:00:16 2006
@@ -83,7 +83,6 @@
<archive>
<manifestEntries>
<Tapestry-Module-Classes>
- org.apache.tapestry.ioc.services.TapestryIOCModule,
org.apache.tapestry.transform.TransformModule,
org.apache.tapestry.internal.InternalModule
</Tapestry-Module-Classes>
Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/BridgeBuilder.java (from r424849, hivemind/trunk/library/src/java/org/apache/hivemind/lib/pipeline/BridgeBuilder.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/BridgeBuilder.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/BridgeBuilder.java&p1=hivemind/trunk/library/src/java/org/apache/hivemind/lib/pipeline/BridgeBuilder.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/java/org/apache/hivemind/lib/pipeline/BridgeBuilder.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/BridgeBuilder.java Thu Aug 3 11:00:16 2006
@@ -12,64 +12,60 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.ErrorLog;
-import org.apache.hivemind.service.BodyBuilder;
-import org.apache.hivemind.service.ClassFab;
-import org.apache.hivemind.service.ClassFabUtils;
-import org.apache.hivemind.service.ClassFactory;
-import org.apache.hivemind.service.MethodIterator;
-import org.apache.hivemind.service.MethodSignature;
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.services.ClassFab;
+import org.apache.tapestry.ioc.services.ClassFactory;
+import org.apache.tapestry.ioc.services.MethodIterator;
+import org.apache.tapestry.ioc.services.MethodSignature;
+
+import static java.lang.String.format;
+import static org.apache.tapestry.util.CollectionFactory.newList;
/**
- * Used by the {@link org.apache.hivemind.lib.pipeline.PipelineAssembler} class to create bridge
- * classes and to create instances of briddge classes.
+ * Used by the {@link org.apache.tapestry.internal.ioc.services.PipelineBuilderImpl} to create bridge
+ * classes and to create instances of bridge classes. A bridge class implements the <em>service</em>
+ * interface. Within the chain, bridge 1 is passed to filter 1. Invoking methods on bridge 1 will
+ * invoke methods on filter 2.
*
* @author Howard Lewis Ship
*/
-class BridgeBuilder
+class BridgeBuilder<S, F>
{
- private ErrorLog _errorLog;
-
- private String _serviceId;
+ private final Log _log;
- private Class _serviceInterface;
+ private final Class<S> _serviceInterface;
- private Class _filterInterface;
+ private final Class<F> _filterInterface;
- private ClassFab _classFab;
+ private final ClassFab _classFab;
- private FilterMethodAnalyzer _filterMethodAnalyzer;
+ private final FilterMethodAnalyzer _filterMethodAnalyzer;
private Constructor _constructor;
- BridgeBuilder(ErrorLog errorLog, String serviceId, Class serviceInterface,
- Class filterInterface, ClassFactory classFactory)
+ BridgeBuilder(Log log, Class<S> serviceInterface, Class<F> filterInterface,
+ ClassFactory classFactory)
{
- _errorLog = errorLog;
- _serviceId = serviceId;
+ _log = log;
_serviceInterface = serviceInterface;
_filterInterface = filterInterface;
- String name = ClassFabUtils.generateClassName(_serviceInterface);
-
- _classFab = classFactory.newClass(name, Object.class);
+ _classFab = classFactory.newClass(_serviceInterface);
_filterMethodAnalyzer = new FilterMethodAnalyzer(serviceInterface);
}
private void createClass()
{
- List serviceMethods = new ArrayList();
- List filterMethods = new ArrayList();
+ List<MethodSignature> serviceMethods = newList();
+ List<MethodSignature> filterMethods = newList();
createInfrastructure();
@@ -99,9 +95,13 @@
reportExtraFilterMethods(filterMethods);
if (!toStringMethodExists)
- ClassFabUtils.addToStringMethod(_classFab, PipelineMessages.bridgeInstanceDescription(
- _serviceId,
- _serviceInterface));
+ {
+ String toString = format(
+ "<PipelineBridge from %s to %s>",
+ _serviceInterface.getName(),
+ _filterInterface.getName());
+ _classFab.addToString(toString);
+ }
Class bridgeClass = _classFab.createClass();
@@ -127,19 +127,20 @@
* @param filter
* the filter object for this step of the pipeline
*/
- public Object instantiateBridge(Object nextBridge, Object filter)
+ public S instantiateBridge(S nextBridge, F filter)
{
if (_constructor == null)
createClass();
try
{
- return _constructor.newInstance(new Object[]
- { nextBridge, filter });
+ Object instance = _constructor.newInstance(nextBridge, filter);
+
+ return _serviceInterface.cast(instance);
}
catch (Exception ex)
{
- throw new ApplicationRuntimeException(ex);
+ throw new RuntimeException(ex);
}
}
@@ -151,11 +152,9 @@
{
MethodSignature ms = (MethodSignature) i.next();
- _errorLog.error(PipelineMessages.extraFilterMethod(
- ms,
- _filterInterface,
- _serviceInterface,
- _serviceId), null, null);
+ _log.error(
+ ServiceMessages.extraFilterMethod(ms, _filterInterface, _serviceInterface),
+ null);
}
}
@@ -185,17 +184,13 @@
}
}
- String message = PipelineMessages.unmatchedServiceMethod(ms, _filterInterface);
+ String message = ServiceMessages.unmatchedServiceMethod(ms, _filterInterface);
- _errorLog.error(message, null, null);
+ _log.error(message, null);
- BodyBuilder b = new BodyBuilder();
+ String code = format("throw new %s(\"%s\");", RuntimeException.class.getName(), message);
- b.add("throw new org.apache.hivemind.ApplicationRuntimeException(");
- b.addQuoted(message);
- b.addln(");");
-
- _classFab.addMethod(Modifier.PUBLIC, ms, b.toString());
+ _classFab.addMethod(Modifier.PUBLIC, ms, code);
}
/**
@@ -207,10 +202,7 @@
{
StringBuffer buffer = new StringBuffer(100);
- if (ms.getReturnType() != void.class)
- buffer.append("return ");
-
- buffer.append("_filter.");
+ buffer.append("return ($r) _filter.");
buffer.append(ms.getName());
buffer.append("(");
Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ClassPropertyAdapterImpl.java (from r428069, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapterImpl.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ClassPropertyAdapterImpl.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ClassPropertyAdapterImpl.java&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapterImpl.java&r1=428069&r2=428462&rev=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapterImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ClassPropertyAdapterImpl.java Thu Aug 3 11:00:16 2006
@@ -12,13 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.services;
+package org.apache.tapestry.internal.ioc.services;
import java.beans.PropertyDescriptor;
import java.util.Map;
import org.apache.tapestry.internal.annotations.SuppressNullCheck;
import org.apache.tapestry.internal.ioc.IOCUtilities;
+import org.apache.tapestry.ioc.services.ClassPropertyAdapter;
+import org.apache.tapestry.ioc.services.PropertyAdapter;
import static org.apache.tapestry.util.CollectionFactory.newMap;
@@ -73,9 +75,7 @@
PropertyAdapter pa = _adapters.get(name);
if (pa == null)
- throw new IllegalArgumentException(IOCServicesMessages.noSuchProperty(
- _targetClass,
- name));
+ throw new IllegalArgumentException(ServiceMessages.noSuchProperty(_targetClass, name));
return pa;
}
Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzer.java?rev=428462&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzer.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzer.java Thu Aug 3 11:00:16 2006
@@ -0,0 +1,90 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.ioc.services;
+
+import org.apache.tapestry.ioc.services.MethodSignature;
+
+/**
+ * Used by {@link org.apache.hivemind.lib.pipeline.PipelineAssembler} to analyze service interface
+ * methods against filter interface methods to find the position of the extra service parameter (in
+ * the filter method).
+ *
+ * @author Howard Lewis Ship
+ */
+public class FilterMethodAnalyzer
+{
+ private final Class _serviceInterface;
+
+ FilterMethodAnalyzer(Class serviceInterface)
+ {
+ _serviceInterface = serviceInterface;
+ }
+
+ public int findServiceInterfacePosition(MethodSignature ms, MethodSignature fms)
+ {
+ if (ms.getReturnType() != fms.getReturnType())
+ return -1;
+
+ if (!ms.getName().equals(fms.getName()))
+ return -1;
+
+ Class[] filterParameters = fms.getParameterTypes();
+ int filterParameterCount = filterParameters.length;
+ Class[] serviceParameters = ms.getParameterTypes();
+
+ if (filterParameterCount != (serviceParameters.length + 1))
+ return -1;
+
+ // TODO: check compatible exceptions!
+
+ // This needs work; it assumes the first occurance of the service interface
+ // in the filter interface method signature is the right match. That will suit
+ // most of the time.
+
+ boolean found = false;
+ int result = -1;
+
+ for (int i = 0; i < filterParameterCount; i++)
+ {
+ if (filterParameters[i] == _serviceInterface)
+ {
+ result = i;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ return -1;
+
+ // Check that all the parameters before and after the service interface still
+ // match.
+
+ for (int i = 0; i < result; i++)
+ {
+ if (filterParameters[i] != serviceParameters[i])
+ return -1;
+ }
+
+ for (int i = result + 1; i < filterParameterCount; i++)
+ {
+ if (filterParameters[i] != serviceParameters[i - 1])
+ return -1;
+ }
+
+ return result;
+ }
+
+}
Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImpl.java?rev=428462&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImpl.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImpl.java Thu Aug 3 11:00:16 2006
@@ -0,0 +1,61 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.ioc.services;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.services.ClassFactory;
+import org.apache.tapestry.ioc.services.PipelineBuilder;
+
+/**
+ * @author Howard M. Lewis Ship
+ */
+public class PipelineBuilderImpl implements PipelineBuilder
+{
+ private final ClassFactory _classFactory;
+
+ public PipelineBuilderImpl(ClassFactory classFactory)
+ {
+ _classFactory = classFactory;
+ }
+
+ public <S, F> S buildPipeline(Log log, Class<S> serviceInterface, Class<F> filterInterface,
+ List<F> filters, S terminator)
+ {
+ if (filters.isEmpty())
+ return terminator;
+
+ BridgeBuilder<S, F> bb = new BridgeBuilder<S, F>(log, serviceInterface, filterInterface,
+ _classFactory);
+
+ // The first bridge will point to the terminator.
+ // Like service decorators, we work deepest (last)
+ // to shallowest (first)
+
+ S next = terminator;
+ int count = filters.size();
+
+ for (int i = count - 1; i >= 0; i--)
+ {
+ F filter = filters.get(i);
+
+ next = bb.instantiateBridge(next, filter);
+ }
+
+ return next;
+ }
+
+}
Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAccessImpl.java (from r428069, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccessImpl.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAccessImpl.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAccessImpl.java&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccessImpl.java&r1=428069&r2=428462&rev=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccessImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAccessImpl.java Thu Aug 3 11:00:16 2006
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.services;
+package org.apache.tapestry.internal.ioc.services;
import java.beans.BeanInfo;
import java.beans.Introspector;
@@ -20,6 +20,8 @@
import org.apache.tapestry.internal.annotations.Concurrent;
import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+import org.apache.tapestry.ioc.services.ClassPropertyAdapter;
+import org.apache.tapestry.ioc.services.PropertyAccess;
import static org.apache.tapestry.util.CollectionFactory.newMap;
Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAdapterImpl.java (from r428069, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAdapterImpl.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAdapterImpl.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAdapterImpl.java&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAdapterImpl.java&r1=428069&r2=428462&rev=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAdapterImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyAdapterImpl.java Thu Aug 3 11:00:16 2006
@@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.services;
+package org.apache.tapestry.internal.ioc.services;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+import org.apache.tapestry.ioc.services.PropertyAdapter;
import org.apache.tapestry.util.Defense;
@SuppressNullCheck
@@ -79,7 +80,7 @@
public Object get(Object instance)
{
if (_readMethod == null)
- throw new UnsupportedOperationException(IOCServicesMessages.readNotSupported(
+ throw new UnsupportedOperationException(ServiceMessages.readNotSupported(
instance,
_name));
@@ -98,13 +99,13 @@
fail = ex;
}
- throw new RuntimeException(IOCServicesMessages.readFailure(_name, instance, fail));
+ throw new RuntimeException(ServiceMessages.readFailure(_name, instance, fail));
}
public void set(Object instance, Object value)
{
if (_writeMethod == null)
- throw new UnsupportedOperationException(IOCServicesMessages.writeNotSupported(
+ throw new UnsupportedOperationException(ServiceMessages.writeNotSupported(
instance,
_name));
@@ -125,7 +126,7 @@
fail = ex;
}
- throw new RuntimeException(IOCServicesMessages.writeFailure(_name, instance, fail));
+ throw new RuntimeException(ServiceMessages.writeFailure(_name, instance, fail));
}
}
Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyShadowBuilderImpl.java (from r428071, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImpl.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyShadowBuilderImpl.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyShadowBuilderImpl.java&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImpl.java&r1=428071&r2=428462&rev=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/PropertyShadowBuilderImpl.java Thu Aug 3 11:00:16 2006
@@ -12,11 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.services;
+package org.apache.tapestry.internal.ioc.services;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
+import org.apache.tapestry.ioc.services.ClassFab;
+import org.apache.tapestry.ioc.services.ClassFactory;
+import org.apache.tapestry.ioc.services.MethodSignature;
+import org.apache.tapestry.ioc.services.PropertyAccess;
+import org.apache.tapestry.ioc.services.PropertyAdapter;
+import org.apache.tapestry.ioc.services.PropertyShadowBuilder;
+
import static java.lang.String.format;
/**
@@ -43,14 +50,13 @@
// TODO: Perhaps extend ClassPropertyAdapter to do these checks?
if (adapter == null)
- throw new RuntimeException(IOCServicesMessages
- .noSuchProperty(sourceClass, propertyName));
+ throw new RuntimeException(ServiceMessages.noSuchProperty(sourceClass, propertyName));
if (!adapter.isRead())
- throw new RuntimeException(IOCServicesMessages.readNotSupported(source, propertyName));
+ throw new RuntimeException(ServiceMessages.readNotSupported(source, propertyName));
if (!propertyType.isAssignableFrom(adapter.getType()))
- throw new RuntimeException(IOCServicesMessages.propertyTypeMismatch(
+ throw new RuntimeException(ServiceMessages.propertyTypeMismatch(
propertyName,
sourceClass,
adapter.getType(),
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ServiceMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ServiceMessages.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ServiceMessages.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/ServiceMessages.java Thu Aug 3 11:00:16 2006
@@ -74,4 +74,51 @@
{
return MESSAGES.format("thread-cleanup-error", listener, cause);
}
+
+ static String noSuchProperty(Class clazz, String propertyName)
+ {
+ return MESSAGES.format("no-such-property", clazz.getName(), propertyName);
+ }
+
+ static String readNotSupported(Object instance, String propertyName)
+ {
+ return MESSAGES.format("read-not-supported", instance.getClass().getName(), propertyName);
+ }
+
+ static String writeNotSupported(Object instance, String propertyName)
+ {
+ return MESSAGES.format("write-not-supported", instance.getClass().getName(), propertyName);
+ }
+
+ static String readFailure(String propertyName, Object instance, Throwable cause)
+ {
+ return MESSAGES.format("read-failure", propertyName, instance, cause);
+ }
+
+ static String writeFailure(String propertyName, Object instance, Throwable cause)
+ {
+ return MESSAGES.format("write-failure", propertyName, instance, cause);
+ }
+
+ static String propertyTypeMismatch(String propertyName, Class sourceClass, Class propertyType,
+ Class expectedType)
+ {
+ return MESSAGES.format("property-type-mismatch", new Object[]
+ { propertyName, sourceClass.getName(), propertyType.getName(), expectedType.getName() });
+ }
+
+ static String extraFilterMethod(MethodSignature sig, Class filterInterface,
+ Class serviceInterface)
+ {
+ return MESSAGES.format(
+ "extra-filter-method",
+ sig,
+ filterInterface.getName(),
+ serviceInterface.getName());
+ }
+
+ static String unmatchedServiceMethod(MethodSignature sig, Class filterInterface)
+ {
+ return MESSAGES.format("unmatched-service-method", sig, filterInterface.getName());
+ }
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java Thu Aug 3 11:00:16 2006
@@ -26,6 +26,7 @@
import org.apache.tapestry.internal.ioc.RegistryImpl;
import org.apache.tapestry.ioc.annotations.SubModule;
import org.apache.tapestry.ioc.def.ModuleDef;
+import org.apache.tapestry.ioc.services.TapestryIOCModule;
import static org.apache.tapestry.util.CollectionFactory.newList;
import static org.apache.tapestry.util.CollectionFactory.newMap;
@@ -63,6 +64,8 @@
_classLoader = classLoader;
_logSource = logSource;
_log = logSource.getLog(RegistryBuilder.class);
+
+ add(TapestryIOCModule.class);
}
public void add(ModuleDef moduleDef)
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/SubModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/SubModule.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/SubModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/SubModule.java Thu Aug 3 11:00:16 2006
@@ -1,3 +1,17 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package org.apache.tapestry.ioc.annotations;
import java.lang.annotation.Documented;
Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java?rev=428462&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java Thu Aug 3 11:00:16 2006
@@ -0,0 +1,62 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.services;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * Creates a pipeline from a service inteface and an ordered list of filters. Each filter is defined
+ * in terms of a filter interface: the filter interface is a variant of the service interface, where
+ * each method has an additional parameter that is an instance of the service interface. Typically,
+ * this service parameter (often named "delegate") is either the first or the last parameter of each
+ * method.
+ * <p>
+ * The implementation of a filter method is expected to pass all of its parameters to the service
+ * instance passed into it.
+ * <p>
+ * The interesting thing is that there may be multiple filters in the pipeline. A fabricated
+ * "bridge" object (that implements the service interface) is created to let each filter invoke
+ * methods on the next filter down the pipeline. This simplifies the model for creating pipelines,
+ * as each filter is coded as if it was directly "in front of" the terminator. In fact, it may be
+ * indirectly invoking methods on the next filter in the pipeline via a bridge instance.
+ * <p>
+ * The builder is fairly smart about matching up service interface methods to filter interface
+ * methods, but keeping it simple is also a good idea.
+ *
+ * @author Howard M. Lewis Ship
+ */
+public interface PipelineBuilder
+{
+ /**
+ * @param <S>
+ * service type
+ * @param <F>
+ * filter type
+ * @param log
+ * logs any warnings generated when constructing the pipeline
+ * @param serviceInterface
+ * @param filterInterface
+ * @param filters
+ * sorted list of filters
+ * @param terminator
+ * end of the pipeline
+ * @return an object that encapsulates the filters and the terminator
+ */
+ <S, F> S buildPipeline(Log log, Class<S> serviceInterface, Class<F> filterInterface,
+ List<F> filters, S terminator);
+
+}
\ No newline at end of file
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java Thu Aug 3 11:00:16 2006
@@ -21,6 +21,9 @@
import org.apache.tapestry.internal.ioc.services.ClassFactoryImpl;
import org.apache.tapestry.internal.ioc.services.LoggingDecoratorImpl;
import org.apache.tapestry.internal.ioc.services.PerThreadServiceLifecycle;
+import org.apache.tapestry.internal.ioc.services.PipelineBuilderImpl;
+import org.apache.tapestry.internal.ioc.services.PropertyAccessImpl;
+import org.apache.tapestry.internal.ioc.services.PropertyShadowBuilderImpl;
import org.apache.tapestry.internal.ioc.services.ThreadCleanupHubImpl;
import org.apache.tapestry.ioc.MappedConfiguration;
import org.apache.tapestry.ioc.ServiceLifecycle;
@@ -120,5 +123,14 @@
PropertyAccess propertyAccess)
{
return new PropertyShadowBuilderImpl(classFactory, propertyAccess);
+ }
+
+ /**
+ * Builder that creates a filter pipeline around a simple service interface.
+ */
+ public PipelineBuilder buildPipelineBuilder(@InjectService("ClassFactory")
+ ClassFactory classFactory)
+ {
+ return new PipelineBuilderImpl(classFactory);
}
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/services/ServiceStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/services/ServiceStrings.properties?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/services/ServiceStrings.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/services/ServiceStrings.properties Thu Aug 3 11:00:16 2006
@@ -19,4 +19,12 @@
unable-to-write-class=Unable to create class {0}: {1}
duplicate-method-in-class=Attempt to redefine method {0} of class {1}.
logging-interceptor=<Logging interceptor for {0}({1})>
-thread-cleanup-error=Error invoking listener {0}: {1}
\ No newline at end of file
+thread-cleanup-error=Error invoking listener {0}: {1}
+no-such-property=Class {0} does not contain a property named ''{1}''.
+read-not-supported=Class {0} does not provide an accessor ('getter') method for property ''{1}''.
+write-not-supported=Class {0} does not provide an mutator ('setter') method for property ''{1}''.
+read-failure=Error reading property ''{0}'' of {1}: {2}
+write-failure=Error updating property ''{0}'' of {1}: {2}
+property-type-mismatch=Property ''{0}'' of class {1} is of type {2}, which is not assignable to type {3}.
+extra-filter-method=Method {0} of filter interface {1} does not have a matching method in {2}.
+unmatched-service-method=Method {0} has no match in filter interface {1}.
Added: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/pipeline.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/pipeline.apt?rev=428462&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/pipeline.apt (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/pipeline.apt Thu Aug 3 11:00:16 2006
@@ -0,0 +1,99 @@
+ ----
+ Building Pipelines
+ ----
+
+Building Pipelines
+
+ A common pattern within Tapestry is the use of filtering pipelines.
+ In this pattern, an existing service is decorated with a filter.
+ The filter will delegate to the service, but has the chance to
+ alter or replace parameters before invoking the method, and
+ can perform operations before returning. This is
+ similar to {{{command.html}chain of command}}, but differs in that
+ there are two interfaces (the service interface and the filter interface)
+ and that each filter invokes the next filter via the service interface.
+ In chain of command, the chain invokes each method, which must return
+ before the next command in the chain is invoked.
+
+ The service interface and the filter interface are closely related:
+ the filter interface must match the service interface method for method,
+ but each method of the filter interface must have an additional parameter
+ whose type is the service interface. For example, a pipeline
+ that performed string transformations might use the following interfaces:
+
++------+
+public interface StringTransformService
+{
+ String transform(String input);
+}
+
+public interface StringTransformFilter
+{
+ String transform(String input, StringTransformService delegate);
+}
++-----+
+
+ An implementation of the filter might look like:
+
++-----+
+public class UpcasePreFilter implements StringTransformFilter
+{
+ public String transform(String input, StringTransformService delegate)
+ {
+ return delegate.transform(input.toUpperCase());
+ }
+}
++-----+
+
+ Alternately, the filter could pass input to delegate unchanged, but invoke
+ toUpperCase() on the result:
+
++-----+
+public class UpcasePostFilter implements StringTransformFilter
+{
+ public String transform(String input, StringTransformService delegate)
+ {
+ return delegate.transform(input).toUpperCase();
+ }
+}
++-----+
+
+ The
+ {{{../apidocs/org/apache/tapestry/ioc/services/PipelineBuilder.html}tapestry.ioc.PipelineBuilder}}
+ service is useful for constructing pipelines. The service is often injected
+ into a service builder method, along with an ordered configuration of services.
+
+ What the builder accomplishes is to represent each <filter> in the pipeline as
+ an instance of the <service> interface.
+
+[../images/PipelineCallingSequence.png] Pipeline Calling Sequence
+
+ The bridges are created by the PipelineBuilder service. The terminator
+ must be provided. The bridges and the terminator implement the service interface.
+
++-----+
+ public StringTransformService buildStringTransform(
+ @InjectService("tapestry.ioc.PipelineBuilder")
+ PipelineBuilder builder,
+ List<StringTransformFilter> configuration,
+ Log serviceLog)
+ {
+
+ StringTransformService terminator = new StringTransformService()
+ {
+ public String transform(String input)
+ {
+ return input;
+ }
+ };
+
+ return builder.buildPipeline(log,
+ StringTransformService.class, StringTransformFilter.class,
+ configuration,
+ terminator);
+ }
++-----+
+
+ Here, we create the terminator for the pipeline as an inner class instance,
+ and feed that into the builder. The result is a new service that encapsulates
+ the entire pipeline. When there are no filters, this is just the terminator.
\ No newline at end of file
Added: tapestry/tapestry5/tapestry-core/trunk/src/site/resources/images/PipelineCallingSequence.png
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/resources/images/PipelineCallingSequence.png?rev=428462&view=auto
==============================================================================
Binary file - no diff available.
Propchange: tapestry/tapestry5/tapestry-core/trunk/src/site/resources/images/PipelineCallingSequence.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml Thu Aug 3 11:00:16 2006
@@ -58,6 +58,7 @@
<item name="Configuration" href="ioc/configuration.html"/>
<item name="Ordering" href="ioc/order.html"/>
<item name="Chain Of Command" href="ioc/command.html"/>
+ <item name="Pipeline" href="ioc/pipeline.html"/>
</menu>
${reports}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java Thu Aug 3 11:00:16 2006
@@ -27,7 +27,6 @@
import org.apache.tapestry.ioc.def.ModuleDef;
import org.apache.tapestry.ioc.def.ServiceDef;
import org.apache.tapestry.ioc.services.ClassFactory;
-import org.apache.tapestry.ioc.services.TapestryIOCModule;
import org.testng.annotations.Test;
/**
@@ -216,7 +215,7 @@
private Registry buildRegistry()
{
RegistryBuilder builder = new RegistryBuilder();
- builder.add(TapestryIOCModule.class, ModuleImplTestModule.class);
+ builder.add(ModuleImplTestModule.class);
return builder.build();
}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/BridgeBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/BridgeBuilderTest.java?rev=428462&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/BridgeBuilderTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/BridgeBuilderTest.java Thu Aug 3 11:00:16 2006
@@ -0,0 +1,207 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.ioc.services;
+
+import java.io.Serializable;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.services.ClassFactory;
+import org.testng.annotations.Test;
+
+public class BridgeBuilderTest extends InternalBaseTestCase
+{
+ private ClassFactory _classFactory = new ClassFactoryImpl();
+
+ @Test
+ public void standard_interface_and_filter()
+ {
+ Log log = newLog();
+
+ replay();
+
+ BridgeBuilder<StandardService, StandardFilter> bb = new BridgeBuilder<StandardService, StandardFilter>(
+ log, StandardService.class, StandardFilter.class, _classFactory);
+
+ StandardFilter sf = new StandardFilter()
+ {
+ public int run(int i, StandardService ss)
+ {
+ return ss.run(i + 1);
+ }
+ };
+
+ StandardService ss = new StandardService()
+ {
+ public int run(int i)
+ {
+ return i * 3;
+ }
+ };
+
+ StandardService bridge = bb.instantiateBridge(ss, sf);
+
+ // The filter adds 1, then the service multiplies by 3.
+ // (5 +_1) * 3 = 18.
+
+ assertEquals(bridge.run(5), 18);
+
+ // Since toString() is not part of the service interface,
+ // it will be implemented in the bridge.
+
+ assertEquals(
+ bridge.toString(),
+ "<PipelineBridge from org.apache.tapestry.internal.ioc.services.StandardService to org.apache.tapestry.internal.ioc.services.StandardFilter>");
+
+ verify();
+ }
+
+ @Test
+ public void toString_part_of_service_interface()
+ {
+ Log log = newLog();
+
+ replay();
+
+ BridgeBuilder<ToStringService, ToStringFilter> bb = new BridgeBuilder<ToStringService, ToStringFilter>(
+ log, ToStringService.class, ToStringFilter.class, _classFactory);
+
+ ToStringFilter f = new ToStringFilter()
+ {
+ public String toString(ToStringService s)
+ {
+ return s.toString().toUpperCase();
+ }
+ };
+
+ ToStringService s = new ToStringService()
+ {
+ @Override
+ public String toString()
+ {
+ return "Service";
+ }
+ };
+
+ ToStringService bridge = bb.instantiateBridge(s, f);
+
+ assertEquals("SERVICE", bridge.toString());
+
+ verify();
+ }
+
+ @Test
+ public void service_interface_method_not_matched_in_filter_interface()
+ {
+ Log log = newLog();
+ ExtraServiceMethod next = newMock(ExtraServiceMethod.class);
+ Serializable filter = newMock(Serializable.class);
+
+ log
+ .error(
+ "Method void extraServiceMethod() has no match in filter interface java.io.Serializable.",
+ null);
+
+ replay();
+
+ BridgeBuilder<ExtraServiceMethod, Serializable> bb = new BridgeBuilder<ExtraServiceMethod, Serializable>(
+ log, ExtraServiceMethod.class, Serializable.class, _classFactory);
+
+ ExtraServiceMethod esm = bb.instantiateBridge(next, filter);
+
+ try
+ {
+ esm.extraServiceMethod();
+ unreachable();
+ }
+ catch (RuntimeException ex)
+ {
+ assertEquals(
+ ex.getMessage(),
+ "Method void extraServiceMethod() has no match in filter interface java.io.Serializable.");
+ }
+
+ verify();
+ }
+
+ @Test
+ public void filter_interface_contains_extra_methods()
+ {
+ Log log = newLog();
+ Serializable next = newMock(Serializable.class);
+ ExtraFilterMethod filter = newMock(ExtraFilterMethod.class);
+
+ log
+ .error(
+ "Method void extraFilterMethod() of filter interface "
+ + "org.apache.tapestry.internal.ioc.services.ExtraFilterMethod does not have a matching method "
+ + "in java.io.Serializable.",
+ null);
+
+ replay();
+
+ BridgeBuilder<Serializable, ExtraFilterMethod> bb = new BridgeBuilder<Serializable, ExtraFilterMethod>(
+ log, Serializable.class, ExtraFilterMethod.class, _classFactory);
+
+ assertNotNull(bb.instantiateBridge(next, filter));
+
+ verify();
+ }
+
+ @Test
+ public void service_parameter_in_middle_of_filter_method()
+ {
+ Log log = newLog();
+
+ replay();
+
+ BridgeBuilder<MiddleService, MiddleFilter> bb = new BridgeBuilder<MiddleService, MiddleFilter>(
+ log, MiddleService.class, MiddleFilter.class, _classFactory);
+
+ MiddleFilter mf = new MiddleFilter()
+ {
+ public void execute(int count, char ch, MiddleService service, StringBuffer buffer)
+ {
+ service.execute(count, ch, buffer);
+
+ buffer.append(' ');
+
+ service.execute(count + 1, Character.toUpperCase(ch), buffer);
+
+ }
+ };
+
+ MiddleService ms = new MiddleService()
+ {
+ public void execute(int count, char ch, StringBuffer buffer)
+ {
+ for (int i = 0; i < count; i++)
+ buffer.append(ch);
+ }
+ };
+
+ // This also tests building the bridge methods with a void return type.
+
+ MiddleService bridge = bb.instantiateBridge(ms, mf);
+
+ StringBuffer buffer = new StringBuffer("CODE: ");
+
+ bridge.execute(3, 'a', buffer);
+
+ assertEquals("CODE: aaa AAAA", buffer.toString());
+
+ verify();
+ }
+}
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraFilterMethod.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraFilterMethod.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraFilterMethod.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraFilterMethod.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraFilterMethod.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraFilterMethod.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraFilterMethod.java Thu Aug 3 11:00:16 2006
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface ExtraFilterMethod
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraServiceMethod.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraServiceMethod.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraServiceMethod.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraServiceMethod.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraServiceMethod.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ExtraServiceMethod.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ExtraServiceMethod.java Thu Aug 3 11:00:16 2006
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface ExtraServiceMethod
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzerTest.java?rev=428462&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzerTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/FilterMethodAnalyzerTest.java Thu Aug 3 11:00:16 2006
@@ -0,0 +1,79 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.ioc.services;
+
+import java.lang.reflect.Method;
+
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.services.MethodSignature;
+import org.testng.annotations.Test;
+
+/**
+ * @author Howard M. Lewis Ship
+ */
+public class FilterMethodAnalyzerTest extends InternalBaseTestCase
+{
+ private MethodSignature find(Class target, String name)
+ {
+ Method method = findMethod(target, name);
+
+ return new MethodSignature(method);
+ }
+
+ private void assertPosition(String methodName, int expected)
+ {
+ FilterMethodAnalyzer a = new FilterMethodAnalyzer(SampleService.class);
+
+ MethodSignature ms = find(SampleService.class, methodName);
+ MethodSignature fms = find(SampleFilter.class, methodName);
+
+ assertEquals(expected, a.findServiceInterfacePosition(ms, fms));
+ }
+
+ private void assertMismatch(String methodName)
+ {
+ assertPosition(methodName, -1);
+ }
+
+ @Test
+ public void simple_match()
+ {
+ assertPosition("simpleMatch", 0);
+ }
+
+ @Test
+ public void mismatched_parameter_count()
+ {
+ assertMismatch("mismatchParameterCount");
+ }
+
+ @Test
+ public void mismatch_on_method_return_type()
+ {
+ assertMismatch("mismatchReturnType");
+ }
+
+ @Test
+ public void service_interface_not_in_filter_method_signature()
+ {
+ assertMismatch("missingServiceInterface");
+ }
+
+ @Test
+ public void match_with_multiple_parameters()
+ {
+ assertPosition("complexMatch", 2);
+ }
+}
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleFilter.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleFilter.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleFilter.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleFilter.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleFilter.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleFilter.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleFilter.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface MiddleFilter
{
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleService.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleService.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleService.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleService.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleService.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/MiddleService.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/MiddleService.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface MiddleService
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImplTest.java?rev=428462&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImplTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/PipelineBuilderImplTest.java Thu Aug 3 11:00:16 2006
@@ -0,0 +1,122 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.ioc.services;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.Registry;
+import org.apache.tapestry.ioc.services.PipelineBuilder;
+import org.testng.annotations.Test;
+
+import static org.apache.tapestry.util.CollectionFactory.newList;
+
+/**
+ * Integration tests for the PipelineBuilder service.
+ *
+ * @author Howard M. Lewis Ship
+ */
+public class PipelineBuilderImplTest extends InternalBaseTestCase
+{
+
+ @Test
+ public void pipeline_with_filters()
+ {
+ Log log = newLog();
+
+ replay();
+
+ StandardFilter subtracter = new StandardFilter()
+ {
+ public int run(int i, StandardService service)
+ {
+ return service.run(i) - 2;
+ }
+ };
+
+ StandardFilter multiplier = new StandardFilter()
+ {
+ public int run(int i, StandardService service)
+ {
+ return 2 * service.run(i);
+ }
+ };
+
+ StandardFilter adder = new StandardFilter()
+ {
+ public int run(int i, StandardService service)
+ {
+ return service.run(i + 3);
+ }
+ };
+
+ StandardService terminator = new StandardService()
+ {
+ public int run(int i)
+ {
+ return i;
+ }
+ };
+
+ Registry registry = buildRegistry();
+
+ PipelineBuilder builder = registry.getService(
+ "tapestry.ioc.PipelineBuilder",
+ PipelineBuilder.class);
+
+ StandardService pipeline = builder.buildPipeline(
+ log,
+ StandardService.class,
+ StandardFilter.class,
+ Arrays.asList(subtracter, multiplier, adder),
+ terminator);
+
+ // Should be order subtracter, multipler, adder
+ assertEquals(pipeline.run(5), 14);
+ assertEquals(pipeline.run(10), 24);
+
+ verify();
+ }
+
+ @Test
+ public void pipline_without_filters_is_terminator()
+ {
+ Log log = newLog();
+ StandardService terminator = newMock(StandardService.class);
+
+ replay();
+
+ Registry registry = buildRegistry();
+
+ PipelineBuilder builder = registry.getService(
+ "tapestry.ioc.PipelineBuilder",
+ PipelineBuilder.class);
+
+ List<StandardFilter> filters = newList();
+
+ StandardService pipeline = builder.buildPipeline(
+ log,
+ StandardService.class,
+ StandardFilter.class,
+ filters,
+ terminator);
+
+ assertSame(pipeline, terminator);
+
+ verify();
+ }
+}
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleFilter.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleFilter.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleFilter.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleFilter.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleFilter.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleFilter.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleFilter.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,17 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.services.FilterMethodAnalyzer}.
+ *
+ * @author Howard M. Lewis Ship
+ */
public interface SampleFilter
{
public void simpleMatch(SampleService service);
-
+
public void mismatchParameterCount(int a, SampleService service);
-
+
public int mismatchReturnType(SampleService service);
-
+
public void missingServiceInterface(boolean flag);
-
+
public void complexMatch(String title, int count, SampleService service, Runnable r);
}
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleService.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleService.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleService.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleService.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleService.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/SampleService.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/SampleService.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,18 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
-
+package org.apache.tapestry.internal.ioc.services;
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.services.FilterMethodAnalyzer}.
+ *
+ * @author Howard M. Lewis Ship
+ */
public interface SampleService
{
- public void simpleMatch();
-
- public void mismatchParameterCount();
-
- public String mismatchReturnType();
-
- public void missingServiceInterface();
-
- public void complexMatch(String title, int count, Runnable r);
+ public void simpleMatch();
+
+ public void mismatchParameterCount();
+
+ public String mismatchReturnType();
+
+ public void missingServiceInterface();
+
+ public void complexMatch(String title, int count, Runnable r);
}
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardFilter.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardFilter.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardFilter.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardFilter.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardFilter.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardFilter.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardFilter.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface StandardFilter
{
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardService.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardService.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardService.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardService.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardService.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/StandardService.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/StandardService.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface StandardService
{
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringFilter.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringFilter.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringFilter.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringFilter.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringFilter.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringFilter.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringFilter.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface ToStringFilter
{
Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringService.java (from r424849, hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringService.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringService.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringService.java&p1=hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringService.java&r1=424849&r2=428462&rev=428462&view=diff
==============================================================================
--- hivemind/trunk/library/src/test/org/apache/hivemind/lib/pipeline/ToStringService.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/ToStringService.java Thu Aug 3 11:00:16 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.hivemind.lib.pipeline;
+package org.apache.tapestry.internal.ioc.services;
public interface ToStringService
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java Thu Aug 3 11:00:16 2006
@@ -37,7 +37,6 @@
import org.apache.tapestry.internal.transform.pages.BasicSubComponent;
import org.apache.tapestry.ioc.Registry;
import org.apache.tapestry.ioc.RegistryBuilder;
-import org.apache.tapestry.ioc.services.TapestryIOCModule;
import org.apache.tapestry.runtime.ComponentLifecycle;
import org.apache.tapestry.test.BaseTestCase;
import org.apache.tapestry.transform.TransformModule;
@@ -252,7 +251,7 @@
RegistryBuilder builder = new RegistryBuilder();
- builder.add(TapestryIOCModule.class, TransformModule.class, InternalModule.class);
+ builder.add(TransformModule.class, InternalModule.class);
_registry = builder.build();
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java Thu Aug 3 11:00:16 2006
@@ -21,7 +21,6 @@
import java.util.Map;
import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.services.TapestryIOCModule;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -35,7 +34,7 @@
{
private Registry buildRegistry()
{
- return buildRegistry(TapestryIOCModule.class, FredModule.class, BarneyModule.class);
+ return buildRegistry(FredModule.class, BarneyModule.class);
}
/**
@@ -162,7 +161,7 @@
@Test
public void unknown_lifecycle()
{
- Registry r = buildRegistry(TapestryIOCModule.class, UnknownLifecycleModule.class);
+ Registry r = buildRegistry(UnknownLifecycleModule.class);
try
{
@@ -182,7 +181,7 @@
@Test
public void simple_perthread() throws Exception
{
- Registry r = buildRegistry(TapestryIOCModule.class, PerThreadModule.class);
+ Registry r = buildRegistry(PerThreadModule.class);
final StringHolder holder = r.getService(StringHolder.class);
@@ -211,7 +210,7 @@
@Test
public void registry_thread_cleanup()
{
- Registry r = buildRegistry(TapestryIOCModule.class, PerThreadModule.class);
+ Registry r = buildRegistry(PerThreadModule.class);
StringHolder holder = r.getService(StringHolder.class);
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java Thu Aug 3 11:00:16 2006
@@ -1,3 +1,17 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package org.apache.tapestry.ioc;
import org.apache.tapestry.ioc.annotations.Id;
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java Thu Aug 3 11:00:16 2006
@@ -20,7 +20,6 @@
import org.apache.hivemind.service.ClassFactory;
import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.services.TapestryIOCModule;
import org.testng.annotations.Test;
/**
@@ -56,7 +55,7 @@
{
RegistryBuilder builder = new RegistryBuilder();
- builder.add(TapestryIOCModule.class, MasterModule.class);
+ builder.add(MasterModule.class);
Registry r = builder.build();
@@ -75,10 +74,8 @@
{
RegistryBuilder builder = new RegistryBuilder();
- String value = String.format(
- "%s, %s",
- TapestryIOCModule.class.getName(),
- RegistryBuilderTestModule.class.getName());
+ String value = String.format("%s, %s, %s", FredModule.class.getName(), BarneyModule.class
+ .getName(), RegistryBuilderTestModule.class.getName());
Manifest mf = new Manifest();
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyAccessImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyAccessImplTest.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyAccessImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyAccessImplTest.java Thu Aug 3 11:00:16 2006
@@ -22,6 +22,7 @@
import java.beans.PropertyDescriptor;
import java.util.Random;
+import org.apache.tapestry.internal.ioc.services.PropertyAccessImpl;
import org.apache.tapestry.internal.test.InternalBaseTestCase;
import org.apache.tapestry.ioc.Registry;
import org.testng.annotations.Test;
@@ -352,7 +353,7 @@
@Test
public void integration()
{
- Registry registry = buildRegistry(TapestryIOCModule.class);
+ Registry registry = buildRegistry();
PropertyAccess pa = registry
.getService("tapestry.ioc.PropertyAccess", PropertyAccess.class);
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java?rev=428462&r1=428461&r2=428462&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java Thu Aug 3 11:00:16 2006
@@ -33,7 +33,7 @@
@Configuration(beforeTestClass = true)
public void setBuilder()
{
- Registry registry = buildRegistry(TapestryIOCModule.class);
+ Registry registry = buildRegistry();
_builder = registry.getService(
"tapestry.ioc.PropertyShadowBuilder",