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 2007/03/09 20:49:55 UTC
svn commit: r516524 [2/3] - in
/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src:
main/java/org/apache/tapestry/ioc/
main/java/org/apache/tapestry/ioc/annotations/
main/java/org/apache/tapestry/ioc/def/ main/java/org/apache/tape...
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -15,7 +15,7 @@
package org.apache.tapestry.ioc.internal.services;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newLinkedList;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
import java.util.LinkedList;
import java.util.List;
@@ -29,7 +29,7 @@
private final List<SymbolProvider> _providers;
/** Cache of symbol name to fully expanded symbol value. */
- private final Map<String, String> _cache = newThreadSafeMap();
+ private final Map<String, String> _cache = newConcurrentMap();
/**
* Contains execution data needed when performing an expansion (largely, to check for endless
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java Fri Mar 9 11:49:51 2007
@@ -18,7 +18,7 @@
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newSet;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
import static org.apache.tapestry.ioc.internal.util.Defense.notNull;
import java.util.Collection;
@@ -42,7 +42,7 @@
// Access to the cache must be thread safe
- private final Map<CacheKey, Coercion> _cache = newThreadSafeMap();
+ private final Map<CacheKey, Coercion> _cache = newConcurrentMap();
static class CacheKey
{
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java Fri Mar 9 11:49:51 2007
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.tapestry.ioc.util.CaseInsensitiveMap;
@@ -84,9 +85,9 @@
}
/**
- * Constructs a new thread safe map.
+ * Constructs a new concurrent map, which is safe to access via multiple threads.
*/
- public static <K, V> Map<K, V> newThreadSafeMap()
+ public static <K, V> ConcurrentMap<K, V> newConcurrentMap()
{
return new ConcurrentHashMap<K, V>();
}
@@ -133,7 +134,7 @@
{
return new CaseInsensitiveMap<V>();
}
-
+
public static <V> Map<String, V> newCaseInsensitiveMap(Map<String, ? extends V> map)
{
return new CaseInsensitiveMap<V>(map);
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -218,9 +218,7 @@
private Collection<DependencyNode<T>> findDependencies(String sourceId, String patternList)
{
- String sourceModuleId = IOCUtilities.extractModuleId(sourceId);
-
- IdMatcher matcher = buildMatcherForPattern(sourceModuleId, patternList);
+ IdMatcher matcher = buildMatcherForPattern(patternList);
Collection<DependencyNode<T>> result = newList();
@@ -234,15 +232,14 @@
return result;
}
- private IdMatcher buildMatcherForPattern(String sourceModuleId, String patternList)
+ private IdMatcher buildMatcherForPattern(String patternList)
{
List<IdMatcher> matchers = newList();
for (String pattern : patternList.split(","))
{
- IdMatcher matcher = new IdMatcherImpl(IOCUtilities.toQualifiedId(
- sourceModuleId,
- pattern.trim()));
+ IdMatcher matcher = new IdMatcherImpl(pattern.trim());
+
matchers.add(matcher);
}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -27,7 +27,6 @@
import org.apache.tapestry.ioc.ObjectProvider;
import org.apache.tapestry.ioc.OrderedConfiguration;
import org.apache.tapestry.ioc.ServiceLifecycle;
-import org.apache.tapestry.ioc.annotations.Id;
import org.apache.tapestry.ioc.annotations.InjectService;
import org.apache.tapestry.ioc.annotations.Lifecycle;
import org.apache.tapestry.ioc.internal.services.ChainBuilderImpl;
@@ -52,7 +51,6 @@
/**
* Defines the base set of services for the Tapestry IOC container.
*/
-@Id("tapestry.ioc")
public final class TapestryIOCModule
{
private final ClassFactory _classFactory;
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -191,11 +191,6 @@
protected final void train_getLog(LogSource source, String serviceId, Log log)
{
expect(source.getLog(serviceId)).andReturn(log).atLeastOnce();
- }
-
- protected final void train_getModuleId(ModuleDef def, String moduleId)
- {
- expect(def.getModuleId()).andReturn(moduleId).atLeastOnce();
}
/** Frequently used as a placeholder for an arbitrary service (but its nice and simple). */
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,127 +12,123 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.util;
-
+package org.apache.tapestry.ioc.util;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
import java.util.List;
import java.util.Map;
import org.apache.tapestry.ioc.internal.util.InheritanceSearch;
-import org.apache.tapestry.ioc.internal.util.InternalUtils;
-
-/**
- * A key component in implementing the "Gang of Four" Strategy pattern. A StrategyRegistry will
- * match up a given input type with a registered strategy for that type.
- *
- * @param <A>
- * the type of the strategy adapter
- */
-public final class StrategyRegistry<A>
-{
- private final Class<A> _adapterType;
-
- private final Map<Class, A> _registrations = newMap();
-
- private final Map<Class, A> _cache = newThreadSafeMap();
-
- /**
- * Creates a strategy registry for the given adapter type.
- *
- * @param adapterType
- * the type of adapter retrieved from the registry
- * @param registrations
- * map of registrations (the contents of the map are copied)
- */
- public StrategyRegistry(final Class<A> adapterType, Map<Class, A> registrations)
- {
- _adapterType = adapterType;
- _registrations.putAll(registrations);
- }
-
- public static <A> StrategyRegistry<A> newInstance(Class<A> adapterType,
- Map<Class, A> registrations)
- {
- return new StrategyRegistry<A>(adapterType, registrations);
- }
-
- public void clearCache()
- {
- _cache.clear();
- }
-
- public Class<A> getAdapterType()
- {
- return _adapterType;
- }
-
- /**
- * Gets an adapter for an object. Searches based on the value's class, unless the value is null,
- * in which case, a search on class void is used.
- *
- * @param value
- * for which an adapter is needed
- * @return the adaptoer for the value
- * @throws IllegalArgumentException
- * if no matching adapter may be found
- */
-
- public A getByInstance(Object value)
- {
- return get(value == null ? void.class : value.getClass());
- }
-
- /**
- * Searches for an adapter corresponding to the given input type.
- *
- * @param type
- * the type to search
- * @return the corresponding adapter
- * @throws IllegalArgumentException
- * if no matching adapter may be found
- */
- public A get(Class type)
- {
- A result = _cache.get(type);
-
- if (result == null)
- {
- result = findMatch(type);
- _cache.put(type, result);
- }
-
- return result;
- }
-
- private A findMatch(Class type)
- {
- for (Class t : new InheritanceSearch(type))
- {
- A result = _registrations.get(t);
-
- if (result != null)
- return result;
- }
-
- // Report the error. These things really confused the hell out of people in Tap4, so we're
- // going the extra mile on the exception message.
-
- List<String> names = newList();
- for (Class t : _registrations.keySet())
- names.add(t.getName());
-
- throw new IllegalArgumentException(UtilMessages.noStrategyAdapter(
- type,
- _adapterType,
- InternalUtils.joinSorted(names)));
- }
-
- @Override
- public String toString()
- {
- return String.format("StrategyRegistry[%s]", _adapterType.getName());
- }
-}
+
+/**
+ * A key component in implementing the "Gang of Four" Strategy pattern. A StrategyRegistry will
+ * match up a given input type with a registered strategy for that type.
+ *
+ * @param <A>
+ * the type of the strategy adapter
+ */
+public final class StrategyRegistry<A>
+{
+ private final Class<A> _adapterType;
+
+ private final Map<Class, A> _registrations = newMap();
+
+ private final Map<Class, A> _cache = newConcurrentMap();
+
+ /**
+ * Creates a strategy registry for the given adapter type.
+ *
+ * @param adapterType
+ * the type of adapter retrieved from the registry
+ * @param registrations
+ * map of registrations (the contents of the map are copied)
+ */
+ public StrategyRegistry(final Class<A> adapterType, Map<Class, A> registrations)
+ {
+ _adapterType = adapterType;
+ _registrations.putAll(registrations);
+ }
+
+ public static <A> StrategyRegistry<A> newInstance(Class<A> adapterType,
+ Map<Class, A> registrations)
+ {
+ return new StrategyRegistry<A>(adapterType, registrations);
+ }
+
+ public void clearCache()
+ {
+ _cache.clear();
+ }
+
+ public Class<A> getAdapterType()
+ {
+ return _adapterType;
+ }
+
+ /**
+ * Gets an adapter for an object. Searches based on the value's class, unless the value is null,
+ * in which case, a search on class void is used.
+ *
+ * @param value
+ * for which an adapter is needed
+ * @return the adaptoer for the value
+ * @throws IllegalArgumentException
+ * if no matching adapter may be found
+ */
+
+ public A getByInstance(Object value)
+ {
+ return get(value == null ? void.class : value.getClass());
+ }
+
+ /**
+ * Searches for an adapter corresponding to the given input type.
+ *
+ * @param type
+ * the type to search
+ * @return the corresponding adapter
+ * @throws IllegalArgumentException
+ * if no matching adapter may be found
+ */
+ public A get(Class type)
+ {
+ A result = _cache.get(type);
+
+ if (result == null)
+ {
+ result = findMatch(type);
+ _cache.put(type, result);
+ }
+
+ return result;
+ }
+
+ private A findMatch(Class type)
+ {
+ for (Class t : new InheritanceSearch(type))
+ {
+ A result = _registrations.get(t);
+
+ if (result != null) return result;
+ }
+
+ // Report the error. These things really confused the hell out of people in Tap4, so we're
+ // going the extra mile on the exception message.
+
+ List<String> names = newList();
+ for (Class t : _registrations.keySet())
+ names.add(t.getName());
+
+ throw new IllegalArgumentException(UtilMessages
+ .noStrategyAdapter(type, _adapterType, names));
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format("StrategyRegistry[%s]", _adapterType.getName());
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -14,7 +14,10 @@
package org.apache.tapestry.ioc.util;
+import java.util.Collection;
+
import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
import org.apache.tapestry.ioc.internal.util.MessagesImpl;
/**
@@ -28,13 +31,13 @@
{
}
- static String noStrategyAdapter(Class inputType, Class adapterType, String catalog)
+ static String noStrategyAdapter(Class inputType, Class adapterType, Collection<String> catalog)
{
return MESSAGES.format(
"no-strategy-adapter",
inputType.getName(),
adapterType.getName(),
- catalog);
+ InternalUtils.joinSorted(catalog));
}
static String stackIsEmpty()
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-# Copyright 2006 The Apache Software Foundation
+# Copyright 2006, 2007 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.
@@ -19,12 +19,9 @@
The method has been ignored.
decorator-method-wrong-return-type=Method %s is named like a service decorator method, \
but the return type (%s) is not acceptible (try Object). The method has been ignored.
-missing-service=Service '%s' does not exist.
builder-locked=The Registry Builder has created the Registry, further operations are not allowed.
-module-id-conflict=Module '%s' has already been defined. The duplicate definition will be ignored.
-no-such-module=Module '%s' does not exist. Please ensure that the JAR file for the module is on the classpath. Available modules: %s.
service-wrong-interface=Service '%s' implements interface %s, which is not compatible with the requested type %s.
-instantiate-builder-error=Unable to instantiate class %s as builder for module '%s': %s
+instantiate-builder-error=Unable to instantiate class %s as a module builder: %s
builder-method-error=Error invoking service builder method %s (for service '%s'): %s
decorator-method-error=Error invoking service decorator method %s (for service '%s'): %s
builder-method-returned-null=Builder method %s (for service '%s') returned null.
@@ -67,12 +64,13 @@
generic-type-not-supported=Generic type '%s' is not supported. Only simple parameterized lists are \
supported.
error-building-service=Error building service proxy for service '%s' (at %s): %s
-no-public-constructors=Module builder for module '%s' (class %s) does not contain any public constructors.
-too-many-public-constructors=Module bulider for module '%s' (class %s) contains more than one public constructor. \
+no-public-constructors=Module builder class %s does not contain any public constructors.
+too-many-public-constructors=Module bulider class %s contains more than one public constructor. \
The first constructor, %s, is being used. \
You should change the class to have only a single public constructor.
-recursive-module-constructor=The constructor for module '%s' (class %s) is recursive: it depends on itself in some way. \
+recursive-module-constructor=The constructor for module class %s is recursive: it depends on itself in some way. \
The constructor, %s, is in some way is triggering a service builder, decorator or contribution method within the class.
registry-shutdown=Proxy for service %s is no longer active because the IOC Registry has been shut down.
constructed-configuration=Constructed configuration: %s
-service-construction-failed=Construction of service %s failed: %s
\ No newline at end of file
+service-construction-failed=Construction of service %s failed: %s
+no-such-service=Service id '%s' is not defined by any module. Defined services: %s.
\ No newline at end of file
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/BarneyModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/BarneyModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/BarneyModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/BarneyModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,110 +12,105 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc;
-
+package org.apache.tapestry.ioc;
+
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.Match;
-import org.apache.tapestry.ioc.annotations.Order;
-
-/**
- * Module used to demonstrate decorator ordering.
- */
-
-@Id("barney")
-public class BarneyModule
-{
- @Match("fred.*")
- @Order("after:fred.Beta")
- public Object decorateGamma(Object delegate, DecoratorList list)
- {
- list.add("gamma");
-
- return null;
- }
-
- public Sizer buildSizer(final Map<Class, Sizer> configuration)
- {
- return new Sizer()
- {
- public int size(Object object)
- {
- if (object == null)
- return 0;
-
- Sizer sizer = configuration.get(object.getClass());
-
- if (sizer != null)
- return sizer.size(object);
-
- return 1;
- }
-
- };
- }
-
- public void contributeSizer(MappedConfiguration<Class, Sizer> configuration)
- {
- Sizer listSizer = new Sizer()
- {
- public int size(Object object)
- {
- List list = (List) object;
-
- return list.size();
- }
- };
-
- Sizer mapSizer = new Sizer()
- {
- public int size(Object object)
- {
- Map map = (Map) object;
-
- return map.size();
- }
- };
-
- // Have to work on concrete class, rather than type, until we move the StrategyFactory
- // over from HiveMind.
-
- configuration.add(ArrayList.class, listSizer);
- configuration.add(HashMap.class, mapSizer);
- }
-
- /**
- * Put DecoratorList in module barney, where so it won't accidentally be decorated (which
- * recusively builds the service, and is caught as a failure).
- */
- public DecoratorList buildDecoratorList()
- {
- return new DecoratorList()
- {
- private List<String> _names = newList();
-
- public void add(String name)
- {
- _names.add(name);
- }
-
- public List<String> getNames()
- {
- return _names;
- }
- };
- }
-
- @Contribute("fred.UnorderedNames")
- public void contributeGamma(Configuration<String> configuration)
- {
- configuration.add("Gamma");
- }
-}
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tapestry.ioc.annotations.Match;
+import org.apache.tapestry.ioc.annotations.Order;
+
+/**
+ * Module used to demonstrate decorator ordering.
+ */
+
+public class BarneyModule
+{
+ @Match(
+ { "UnorderedNames", "Fred", "PrivateFredAlias" })
+ @Order("after:Beta")
+ public Object decorateGamma(Object delegate, DecoratorList list)
+ {
+ list.add("gamma");
+
+ return null;
+ }
+
+ public Sizer buildSizer(final Map<Class, Sizer> configuration)
+ {
+ return new Sizer()
+ {
+ public int size(Object object)
+ {
+ if (object == null) return 0;
+
+ Sizer sizer = configuration.get(object.getClass());
+
+ if (sizer != null) return sizer.size(object);
+
+ return 1;
+ }
+
+ };
+ }
+
+ public void contributeSizer(MappedConfiguration<Class, Sizer> configuration)
+ {
+ Sizer listSizer = new Sizer()
+ {
+ public int size(Object object)
+ {
+ List list = (List) object;
+
+ return list.size();
+ }
+ };
+
+ Sizer mapSizer = new Sizer()
+ {
+ public int size(Object object)
+ {
+ Map map = (Map) object;
+
+ return map.size();
+ }
+ };
+
+ // Have to work on concrete class, rather than type, until we move the StrategyFactory
+ // over from HiveMind.
+
+ configuration.add(ArrayList.class, listSizer);
+ configuration.add(HashMap.class, mapSizer);
+ }
+
+ /**
+ * Put DecoratorList in module barney, where so it won't accidentally be decorated (which
+ * recusively builds the service, and is caught as a failure).
+ */
+ public DecoratorList buildDecoratorList()
+ {
+ return new DecoratorList()
+ {
+ private List<String> _names = newList();
+
+ public void add(String name)
+ {
+ _names.add(name);
+ }
+
+ public List<String> getNames()
+ {
+ return _names;
+ }
+ };
+ }
+
+ public void contributeUnorderedNames(Configuration<String> configuration)
+ {
+ configuration.add("Gamma");
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,26 +12,22 @@
// 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.EagerLoad;
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used to test service eager loading.
- *
- *
- */
-@Id("ioc.eager")
-public class EagerLoadModule
-{
- public static boolean _eagerLoadDidHappen = false;
-
- @EagerLoad
- public StringHolder buildStringHolder()
- {
- _eagerLoadDidHappen = true;
-
- return new StringHolderImpl();
- }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.EagerLoad;
+
+/**
+ * Used to test service eager loading.
+ */
+public class EagerLoadModule
+{
+ public static boolean _eagerLoadDidHappen = false;
+
+ @EagerLoad
+ public StringHolder buildStringHolder()
+ {
+ _eagerLoadDidHappen = true;
+
+ return new StringHolderImpl();
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/FredModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/FredModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/FredModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/FredModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,143 +12,130 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc;
-
+package org.apache.tapestry.ioc;
+
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.apache.tapestry.ioc.annotations.Match;
-import org.apache.tapestry.ioc.annotations.Order;
-import org.apache.tapestry.ioc.annotations.Private;
-
-/**
- * Module used to demonstrate decorator ordering.
- *
- *
- */
-@Id("fred")
-public class FredModule
-{
-
- /**
- * Doesn't matter what the service does, we just want to verify that the decorators are invoked
- * in the order we expect.
- */
- public Runnable buildFred()
- {
- return new Runnable()
- {
- public void run()
- {
- }
- };
- }
-
- @Private
- public Runnable buildPrivateFred()
- {
- return buildFred();
- }
-
- /** A public alias of a private service. */
- public Runnable buildPrivateFredAlias(@InjectService("PrivateFred")
- Runnable privateFred)
- {
- return privateFred;
- }
-
- @Match("fred.*")
- @Order("before:Beta")
- public Object decorateAlpha(Object delegate, DecoratorList list)
- {
- list.add("alpha");
-
- return null;
- }
-
- @Match("fred.*")
- public Object decorateBeta(Object delegate, DecoratorList list)
- {
- list.add("beta");
-
- return null;
- }
-
- public NameListHolder buildUnorderedNames(Collection<String> configuration)
- {
- final List<String> sorted = newList(configuration);
-
- Collections.sort(sorted);
-
- return new NameListHolder()
- {
-
- public List<String> getNames()
- {
- return sorted;
- }
-
- };
- }
-
- public NameListHolder buildOrderedNames(final List<String> configuration)
- {
- return new NameListHolder()
- {
-
- public List<String> getNames()
- {
- return configuration;
- }
-
- };
- }
-
- public void contributeOrderedNames(OrderedConfiguration<String> configuration)
- {
- // Order "FRED" after "BARNEY"
-
- configuration.add("fred", "FRED", "after:barney");
- configuration.add("barney", "BARNEY");
- }
-
- public void contributeUnorderedNames(Configuration<String> configuration)
- {
- configuration.add("UnorderedNames");
- }
-
- @Contribute("UnorderedNames")
- public void contributeBeta(Configuration<String> configuration)
- {
- configuration.add("Beta");
- }
-
- @Private
- public NameListHolder buildPrivateUnorderedNames(final Collection<String> configuration)
- {
- return buildUnorderedNames(configuration);
- }
-
- public void contributePrivateUnorderedNames(Configuration<String> configuration)
- {
- configuration.add("PrivateUnorderedNames");
- }
-
- @Contribute("PrivateUnorderedNames")
- public void contributeOmega(Configuration<String> configuration)
- {
- configuration.add("Omega");
- }
-
- public NameListHolder buildPrivateUnorderedNamesAlias(@InjectService("PrivateUnorderedNames")
- NameListHolder privateService)
- {
- return privateService;
- }
-}
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.ioc.annotations.Match;
+import org.apache.tapestry.ioc.annotations.Order;
+import org.apache.tapestry.ioc.annotations.Private;
+
+/**
+ * Module used to demonstrate decorator ordering.
+ */
+public class FredModule
+{
+
+ /**
+ * Doesn't matter what the service does, we just want to verify that the decorators are invoked
+ * in the order we expect.
+ */
+ public Runnable buildFred()
+ {
+ return new Runnable()
+ {
+ public void run()
+ {
+ }
+ };
+ }
+
+ @Private
+ public Runnable buildPrivateFred()
+ {
+ return buildFred();
+ }
+
+ /** A public alias of a private service. */
+ public Runnable buildPrivateFredAlias(@InjectService("PrivateFred")
+ Runnable privateFred)
+ {
+ return privateFred;
+ }
+
+ @Match(
+ { "UnorderedNames", "Fred", "PrivateFredAlias", "PrivateFred" })
+ @Order("before:Beta")
+ public Object decorateAlpha(Object delegate, DecoratorList list)
+ {
+ list.add("alpha");
+
+ return null;
+ }
+
+ @Match(
+ { "UnorderedNames", "Fred", "PrivateFredAlias", "PrivateFred" })
+ public Object decorateBeta(Object delegate, DecoratorList list)
+ {
+ list.add("beta");
+
+ return null;
+ }
+
+ public NameListHolder buildUnorderedNames(Collection<String> configuration)
+ {
+ final List<String> sorted = newList(configuration);
+
+ Collections.sort(sorted);
+
+ return new NameListHolder()
+ {
+
+ public List<String> getNames()
+ {
+ return sorted;
+ }
+
+ };
+ }
+
+ public NameListHolder buildOrderedNames(final List<String> configuration)
+ {
+ return new NameListHolder()
+ {
+
+ public List<String> getNames()
+ {
+ return configuration;
+ }
+
+ };
+ }
+
+ public void contributeOrderedNames(OrderedConfiguration<String> configuration)
+ {
+ // Order "FRED" after "BARNEY"
+
+ configuration.add("fred", "FRED", "after:barney");
+ configuration.add("barney", "BARNEY");
+ }
+
+ public void contributeUnorderedNames(Configuration<String> configuration)
+ {
+ configuration.add("UnorderedNames");
+ configuration.add("Beta");
+ }
+
+ @Private
+ public NameListHolder buildPrivateUnorderedNames(final Collection<String> configuration)
+ {
+ return buildUnorderedNames(configuration);
+ }
+
+ public void contributePrivateUnorderedNames(Configuration<String> configuration)
+ {
+ configuration.add("PrivateUnorderedNames");
+ configuration.add("Omega");
+ }
+
+ public NameListHolder buildPrivateUnorderedNamesAlias(@InjectService("PrivateUnorderedNames")
+ NameListHolder privateService)
+ {
+ return privateService;
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -14,12 +14,9 @@
package org.apache.tapestry.ioc;
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
import org.apache.tapestry.ioc.annotations.Inject;
import org.apache.tapestry.ioc.annotations.InjectService;
-@Id("indirection")
public class IndirectionModule
{
public Indirection buildInner()
@@ -57,14 +54,13 @@
};
}
- @Contribute("tapestry.ioc.FactoryDefaults")
- public void contributeDefaults(MappedConfiguration<String, String> configuration)
+ public void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
{
// You tend to want to use the fully qualified service id, since you can't tell under which
// context the
// symbols will be expanded.
- configuration.add("indirection.inner", "indirection.Inner");
- configuration.add("indirection.object-inner", "service:indirection.Inner");
+ configuration.add("indirection.inner", "Inner");
+ configuration.add("indirection.object-inner", "service:Inner");
}
}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -14,11 +14,8 @@
package org.apache.tapestry.ioc;
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
import org.apache.tapestry.ioc.annotations.Inject;
-@Id("inject.literal")
public class InjectLiteralModule
{
public static IntHolder buildIntHolder(@Inject("${value}")
@@ -27,8 +24,7 @@
return new IntHolderImpl(value);
}
- @Contribute("tapestry.ioc.FactoryDefaults")
- public static void contributeDefaults(MappedConfiguration<String, String> configuration)
+ public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
{
configuration.add("value", "42");
}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -43,7 +43,7 @@
Registry r = buildRegistry(StaticModule.class);
- Runnable fred = r.getService("static.Fred", Runnable.class);
+ Runnable fred = r.getService("Fred", Runnable.class);
fred.run();
@@ -59,7 +59,7 @@
Registry r = buildRegistry(StaticModule.class);
- Runnable fred = r.getService("static.Barney", Runnable.class);
+ Runnable fred = r.getService("Barney", Runnable.class);
fred.run();
@@ -74,7 +74,7 @@
Registry r = buildRegistry(StaticModule.class);
- NameListHolder holder = r.getService("static.Names", NameListHolder.class);
+ NameListHolder holder = r.getService("Names", NameListHolder.class);
List<String> names = holder.getNames();
@@ -88,7 +88,7 @@
{
Registry r = buildRegistry();
- Runnable service = r.getService("fred.Fred", Runnable.class);
+ Runnable service = r.getService("Fred", Runnable.class);
service.run();
@@ -103,12 +103,12 @@
{
assertEquals(
ex.getMessage(),
- "Proxy for service fred.Fred is no longer active because the IOC Registry has been shut down.");
+ "Proxy for service Fred is no longer active because the IOC Registry has been shut down.");
}
// Show that toString() still works, even for a shutdown proxy.
- assertEquals(service.toString(), "<Proxy for fred.Fred(java.lang.Runnable)>");
+ assertEquals(service.toString(), "<Proxy for Fred(java.lang.Runnable)>");
}
/**
@@ -120,7 +120,7 @@
{
Registry r = buildRegistry();
- Runnable service = r.getService("fred.Fred", Runnable.class);
+ Runnable service = r.getService("Fred", Runnable.class);
// Force creation
@@ -143,7 +143,7 @@
{
Registry r = buildRegistry();
- Runnable service = r.getService("fred.PrivateFredAlias", Runnable.class);
+ Runnable service = r.getService("PrivateFredAlias", Runnable.class);
// Force creation
@@ -163,7 +163,7 @@
{
Registry r = buildRegistry();
- NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
+ NameListHolder service = r.getService("UnorderedNames", NameListHolder.class);
List<String> names = service.getNames();
@@ -180,7 +180,7 @@
{
Registry r = buildRegistry();
- NameListHolder service = r.getService("fred.OrderedNames", NameListHolder.class);
+ NameListHolder service = r.getService("OrderedNames", NameListHolder.class);
List<String> names = service.getNames();
@@ -194,7 +194,7 @@
{
Registry r = buildRegistry();
- Sizer sizer = r.getService("barney.Sizer", Sizer.class);
+ Sizer sizer = r.getService("Sizer", Sizer.class);
assertEquals(sizer.size(null), 0);
@@ -223,9 +223,7 @@
{
Registry r = buildRegistry();
- NameListHolder service = r.getService(
- "fred.PrivateUnorderedNamesAlias",
- NameListHolder.class);
+ NameListHolder service = r.getService("PrivateUnorderedNamesAlias", NameListHolder.class);
List<String> names = service.getNames();
@@ -239,14 +237,14 @@
try
{
- r.getService("ioc.test.UnknownLifecycle", Runnable.class);
+ r.getService("UnknownLifecycle", Runnable.class);
unreachable();
}
catch (Exception ex)
{
assertEquals(
ex.getMessage(),
- "Error building service proxy for service 'ioc.test.UnknownLifecycle' "
+ "Error building service proxy for service 'UnknownLifecycle' "
+ "(at org.apache.tapestry.ioc.UnknownLifecycleModule.buildUnknownLifecycle()): "
+ "Unknown service lifecycle 'magic'.");
}
@@ -319,9 +317,7 @@
{
Registry r = buildRegistry(ServiceObjectProviderModule.class);
- StringTransformer st = r.getObject(
- "service:ioc.test.PublicTransformer",
- StringTransformer.class);
+ StringTransformer st = r.getObject("service:PublicTransformer", StringTransformer.class);
// The PublicTransform gets the PrivateTransformer via
// an @Inject.
@@ -336,7 +332,7 @@
try
{
- Runnable runnable = r.getService("recursive.Runnable", Runnable.class);
+ Runnable runnable = r.getService("Runnable", Runnable.class);
// We can get the proxy, but invoking a method causes
// the module to be instantiated ... but that also invokes a method on
@@ -372,7 +368,7 @@
{
Registry r = buildRegistry(IndirectionModule.class);
- Indirection outer = r.getService("indirection.Outer", Indirection.class);
+ Indirection outer = r.getService("Outer", Indirection.class);
assertEquals(outer.getName(), "OUTER[INNER]");
}
@@ -382,7 +378,7 @@
{
Registry r = buildRegistry(IndirectionModule.class);
- Indirection outer = r.getService("indirection.Outer2", Indirection.class);
+ Indirection outer = r.getService("Outer2", Indirection.class);
assertEquals(outer.getName(), "OUTER2[INNER]");
}
@@ -422,8 +418,8 @@
{
Registry r = buildRegistry(FredModule.class);
- Runnable fred = r.getService("fred.Fred", Runnable.class);
+ Runnable fred = r.getService("Fred", Runnable.class);
- assertSame(r.getService("FRED.FRED", Runnable.class), fred);
+ assertSame(r.getService("FRED", Runnable.class), fred);
}
}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/MasterModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/MasterModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/MasterModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/MasterModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,20 +12,16 @@
// 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;
-import org.apache.tapestry.ioc.annotations.SubModule;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.RegistryBuilderTest}.
- *
- *
- */
-@Id("master")
-@SubModule(
-{ FredModule.class, BarneyModule.class })
-public final class MasterModule
-{
-
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.SubModule;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.RegistryBuilderTest}.
+ */
+@SubModule(
+{ FredModule.class, BarneyModule.class })
+public final class MasterModule
+{
+
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,15 @@
// 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;
-import org.apache.tapestry.ioc.annotations.Lifecycle;
-
-@Id("ioc.test")
-public class PerThreadModule
-{
- @Lifecycle("perthread")
- public StringHolder buildStringHolder()
- {
- return new StringHolderImpl();
- }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.Lifecycle;
+
+public class PerThreadModule
+{
+ @Lifecycle("perthread")
+ public StringHolder buildStringHolder()
+ {
+ return new StringHolderImpl();
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,36 +12,32 @@
// 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;
-import org.apache.tapestry.ioc.annotations.InjectService;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.IntegrationTest}.
- *
- *
- */
-@Id("recursive")
-public class RecursiveConstructorModule
-{
-
- public RecursiveConstructorModule(@InjectService("Runnable")
- Runnable r)
- {
- // Invoking a method on the service proxy is going to cause a recursive attempt to
- // instantiate the module. Hilarity ensues.
-
- r.run();
- }
-
- public Runnable buildRunnable()
- {
- return new Runnable()
- {
- public void run()
- {
- }
- };
- }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.IntegrationTest}.
+ */
+public class RecursiveConstructorModule
+{
+
+ public RecursiveConstructorModule(@InjectService("Runnable")
+ Runnable r)
+ {
+ // Invoking a method on the service proxy is going to cause a recursive attempt to
+ // instantiate the module. Hilarity ensues.
+
+ r.run();
+ }
+
+ public Runnable buildRunnable()
+ {
+ return new Runnable()
+ {
+ public void run()
+ {
+ }
+ };
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,119 +12,119 @@
// 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;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-@Test
-public class RegistryBuilderOverrideTest extends Assert
-{
- private RegistryBuilder builder;
-
- private Registry registry;
-
- public interface Transformer<T>
- {
- T transform(T input);
- }
-
- public static class IdentifyTransformer<T> implements Transformer<T>
- {
- public T transform(T input)
- {
- return input;
- }
- }
-
- public static class UppercaseTransformer implements Transformer<String>
- {
- public String transform(String input)
- {
- return input.toUpperCase();
- }
- }
-
- @Id("test")
- public static class TestModule
- {
- public static Transformer buildService1()
- {
- return new IdentifyTransformer<String>();
- }
-
- public static Transformer buildService2()
- {
- return new IdentifyTransformer<String>();
- }
-
- // Just a proxy for Service2.
- public static Transformer buildService3(@InjectService("Service2")
- Transformer s2)
- {
- return s2;
- }
- }
-
- @BeforeMethod
- public void before()
- {
- builder = new RegistryBuilder();
- builder.add(TestModule.class);
- }
-
- @AfterMethod
- public void after()
- {
- if (registry != null)
- {
- registry.shutdown();
- }
- }
-
- @Test
- public void service_override()
- {
- builder.addServiceOverride("test.Service2", new UppercaseTransformer());
- registry = builder.build();
- @SuppressWarnings("unchecked")
- Transformer<String> s1 = registry.getService("test.Service1", Transformer.class);
- assertEquals(s1.transform("a"), "a");
- @SuppressWarnings("unchecked")
- Transformer<String> s2 = registry.getService("test.Service2", Transformer.class);
- assertEquals(s2.transform("a"), "A");
- }
-
- @Test
- public void overidden_service_injected_into_other_service()
- {
- builder.addServiceOverride("test.Service2", new UppercaseTransformer());
- registry = builder.build();
- @SuppressWarnings("unchecked")
- Transformer<String> s3 = registry.getService("test.Service3", Transformer.class);
- assertEquals(s3.transform("a"), "A");
- }
-
- @Test
- public void overridden_service_with_incorrect_interface_causes_exception()
- {
- builder = new RegistryBuilder();
- builder.add(TestModule.class);
- builder.addServiceOverride("test.Service2", "bad impl");
- registry = builder.build();
- try
- {
- registry.getService("test.Service2", Transformer.class);
- }
- catch (RuntimeException e)
- {
- String errorMsg = e.getMessage();
- assertTrue(errorMsg.contains("String"));
- assertTrue(errorMsg.contains("Transformer"));
- }
- }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.ioc.test.TestBase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+@Test
+public class RegistryBuilderOverrideTest extends TestBase
+{
+ private RegistryBuilder builder;
+
+ private Registry registry;
+
+ public interface Transformer<T>
+ {
+ T transform(T input);
+ }
+
+ public static class IdentifyTransformer<T> implements Transformer<T>
+ {
+ public T transform(T input)
+ {
+ return input;
+ }
+ }
+
+ public static class UppercaseTransformer implements Transformer<String>
+ {
+ public String transform(String input)
+ {
+ return input.toUpperCase();
+ }
+ }
+
+ public static class TestModule
+ {
+ public static Transformer buildService1()
+ {
+ return new IdentifyTransformer<String>();
+ }
+
+ public static Transformer buildService2()
+ {
+ return new IdentifyTransformer<String>();
+ }
+
+ // Just a proxy for Service2.
+ public static Transformer buildService3(@InjectService("Service2")
+ Transformer s2)
+ {
+ return s2;
+ }
+ }
+
+ @BeforeMethod
+ public void before()
+ {
+ builder = new RegistryBuilder();
+ builder.add(TestModule.class);
+ }
+
+ @AfterMethod
+ public void after()
+ {
+ if (registry != null)
+ {
+ registry.shutdown();
+ }
+ }
+
+ @Test
+ public void service_override()
+ {
+ builder.addServiceOverride("Service2", new UppercaseTransformer());
+ registry = builder.build();
+ @SuppressWarnings("unchecked")
+ Transformer<String> s1 = registry.getService("Service1", Transformer.class);
+ assertEquals(s1.transform("a"), "a");
+ @SuppressWarnings("unchecked")
+ Transformer<String> s2 = registry.getService("Service2", Transformer.class);
+ assertEquals(s2.transform("a"), "A");
+ }
+
+ @Test
+ public void overidden_service_injected_into_other_service()
+ {
+ builder.addServiceOverride("Service2", new UppercaseTransformer());
+ registry = builder.build();
+ @SuppressWarnings("unchecked")
+ Transformer<String> s3 = registry.getService("Service3", Transformer.class);
+ assertEquals(s3.transform("a"), "A");
+ }
+
+ @Test
+ public void overridden_service_with_incorrect_interface_causes_exception()
+ {
+ builder = new RegistryBuilder();
+ builder.add(TestModule.class);
+ builder.addServiceOverride("Service2", "bad impl");
+ registry = builder.build();
+ try
+ {
+ registry.getService("Service2", Transformer.class);
+
+ unreachable();
+ }
+ catch (RuntimeException e)
+ {
+ String errorMsg = e.getMessage();
+ assertTrue(errorMsg.contains("String"));
+ assertTrue(errorMsg.contains("Transformer"));
+ }
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -35,7 +35,7 @@
// Borrowed from IntegrationTest, this will only work if both FredModule and BarneyModule
// are loaded.
- NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
+ NameListHolder service = r.getService("UnorderedNames", NameListHolder.class);
List<String> names = service.getNames();
@@ -67,8 +67,6 @@
// This proves that the IOC works, the service builder method was invoked, that the
// ClassFactory service was accessed and used.
- assertEquals(
- service.toString(),
- "<Proxy for ioc.test.Square(org.apache.tapestry.ioc.Square)>");
+ assertEquals(service.toString(), "<Proxy for Square(org.apache.tapestry.ioc.Square)>");
}
}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,22 +12,19 @@
// 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;
-
-@Id("ioc.test")
-public class RegistryBuilderTestModule
-{
- /** Arbitrary interface and service name. */
- public Square buildSquare()
- {
- return new Square()
- {
- public long square(long input)
- {
- return input * input;
- }
- };
- }
-}
+package org.apache.tapestry.ioc;
+
+public class RegistryBuilderTestModule
+{
+ /** Arbitrary interface and service name. */
+ public Square buildSquare()
+ {
+ return new Square()
+ {
+ public long square(long input)
+ {
+ return input * input;
+ }
+ };
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/ServiceObjectProviderModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/ServiceObjectProviderModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/ServiceObjectProviderModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/ServiceObjectProviderModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,35 +12,31 @@
// 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;
-import org.apache.tapestry.ioc.annotations.Inject;
-import org.apache.tapestry.ioc.annotations.Private;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.IntegrationTest}.
- *
- *
- */
-@Id("ioc.test")
-public class ServiceObjectProviderModule
-{
- @Private
- public StringTransformer buildPrivateTransformer()
- {
- return new StringTransformer()
- {
- public String transform(String input)
- {
- return input.toUpperCase();
- }
- };
- }
-
- public StringTransformer buildPublicTransformer(@Inject("service:PrivateTransformer")
- StringTransformer privateTransformer)
- {
- return privateTransformer;
- }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.Inject;
+import org.apache.tapestry.ioc.annotations.Private;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.IntegrationTest}.
+ */
+public class ServiceObjectProviderModule
+{
+ @Private
+ public StringTransformer buildPrivateTransformer()
+ {
+ return new StringTransformer()
+ {
+ public String transform(String input)
+ {
+ return input.toUpperCase();
+ }
+ };
+ }
+
+ public StringTransformer buildPublicTransformer(@Inject("service:PrivateTransformer")
+ StringTransformer privateTransformer)
+ {
+ return privateTransformer;
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/StaticModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/StaticModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/StaticModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/StaticModule.java Fri Mar 9 11:49:51 2007
@@ -18,13 +18,8 @@
import java.util.Collections;
import java.util.List;
-import org.apache.tapestry.ioc.annotations.Id;
import org.apache.tapestry.ioc.internal.util.CollectionFactory;
-/**
- *
- */
-@Id("static")
public class StaticModule
{
private static boolean _instantiated;
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,20 +12,15 @@
// 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;
-import org.apache.tapestry.ioc.annotations.Lifecycle;
-
-/**
- *
- */
-@Id("ioc.test")
-public class UnknownLifecycleModule
-{
- @Lifecycle("magic")
- public Runnable buildUnknownLifecycle()
- {
- return null;
- }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.Lifecycle;
+
+public class UnknownLifecycleModule
+{
+ @Lifecycle("magic")
+ public Runnable buildUnknownLifecycle()
+ {
+ return null;
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java Fri Mar 9 11:49:51 2007
@@ -17,7 +17,6 @@
import static org.apache.tapestry.ioc.internal.IOCMessages.buildMethodConflict;
import java.lang.reflect.Method;
-import java.math.BigDecimal;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -28,44 +27,11 @@
import org.apache.tapestry.ioc.def.ServiceDef;
import org.apache.tapestry.ioc.internal.util.InternalUtils;
import org.apache.tapestry.ioc.test.IOCTestCase;
-import org.testng.Assert;
import org.testng.annotations.Test;
public class DefaultModuleDefImplTest extends IOCTestCase
{
@Test
- public void module_builder_without_id()
- {
- Log log = newLog();
-
- replay();
-
- // BigDecimal is arbitrary, any class would do.
-
- ModuleDef md = new DefaultModuleDefImpl(BigDecimal.class, log);
-
- Assert.assertEquals("java.math", md.getModuleId());
-
- verify();
- }
-
- @Test
- public void module_builder_with_id()
- {
- Log log = newLog();
-
- replay();
-
- // BigDecimal is arbitrary, any class would do.
-
- ModuleDef md = new DefaultModuleDefImpl(ModuleBuilderWithId.class, log);
-
- Assert.assertEquals("tapestry.ioc", md.getModuleId());
-
- verify();
- }
-
- @Test
public void simple_module() throws Exception
{
String className = SimpleModule.class.getName();
@@ -78,18 +44,18 @@
ModuleDef md = new DefaultModuleDefImpl(SimpleModule.class, log);
- assertEquals(md.toString(), "ModuleDef[" + className + " ioc.Barney, ioc.Fred, ioc.Wilma]");
+ assertEquals(md.toString(), "ModuleDef[" + className + " Barney, Fred, Wilma]");
Set<String> ids = md.getServiceIds();
assertEquals(ids.size(), 3);
- assertTrue(ids.contains("ioc.Fred"));
- assertTrue(ids.contains("ioc.Barney"));
- assertTrue(ids.contains("ioc.Wilma"));
+ assertTrue(ids.contains("Fred"));
+ assertTrue(ids.contains("Barney"));
+ assertTrue(ids.contains("Wilma"));
- ServiceDef sd = md.getServiceDef("ioc.Fred");
+ ServiceDef sd = md.getServiceDef("Fred");
- assertEquals(sd.getServiceId(), "ioc.Fred");
+ assertEquals(sd.getServiceId(), "Fred");
assertEquals(sd.getServiceInterface(), FieService.class);
@@ -98,9 +64,9 @@
assertEquals(sd.isPrivate(), false);
assertEquals(sd.isEagerLoad(), false);
- sd = md.getServiceDef("ioc.Barney");
+ sd = md.getServiceDef("Barney");
- assertEquals(sd.getServiceId(), "ioc.Barney");
+ assertEquals(sd.getServiceId(), "Barney");
assertEquals(sd.getServiceInterface(), FoeService.class);
@@ -108,7 +74,7 @@
assertEquals(sd.getServiceLifeycle(), "threaded");
assertEquals(sd.isPrivate(), true);
- sd = md.getServiceDef("ioc.Wilma");
+ sd = md.getServiceDef("Wilma");
assertEquals(sd.isEagerLoad(), true);
// Now the decorator method.
@@ -119,7 +85,7 @@
DecoratorDef dd = defs.iterator().next();
- assertEquals(dd.getDecoratorId(), "ioc.Logging");
+ assertEquals(dd.getDecoratorId(), "Logging");
assertEquals(dd.toString(), className + ".decorateLogging(Class, Object)");
verify();
@@ -147,11 +113,11 @@
Set<String> ids = md.getServiceIds();
assertEquals(ids.size(), 1);
- assertTrue(ids.contains("ioc.Fred"));
+ assertTrue(ids.contains("Fred"));
- ServiceDef sd = md.getServiceDef("ioc.Fred");
+ ServiceDef sd = md.getServiceDef("Fred");
- assertEquals(sd.getServiceId(), "ioc.Fred");
+ assertEquals(sd.getServiceId(), "Fred");
assertEquals(sd.getServiceInterface(), FieService.class);
@@ -240,29 +206,7 @@
@Test
public void contribution_without_annotation()
{
- attemptConfigurationMethod(
- SimpleModule.class,
- "ioc.Barney",
- "contributeBarney(Configuration)");
- }
-
- @Test
- public void contribution_with_annotation()
- {
- attemptConfigurationMethod(
- ConfigurationWithContributeAnnotationModule.class,
- "ioc.test.Fred",
- "contributeSomething(Configuration)");
-
- }
-
- @Test
- public void contribution_with_annotation_to_other_module()
- {
- attemptConfigurationMethod(
- ConfigurationWithAnnotationOtherModule.class,
- "some.module.Wilma",
- "contributeOtherModule(Configuration)");
+ attemptConfigurationMethod(SimpleModule.class, "Barney", "contributeBarney(Configuration)");
}
@Test
@@ -270,7 +214,7 @@
{
attemptConfigurationMethod(
OrderedConfigurationModule.class,
- "ioc.test.Ordered",
+ "Ordered",
"contributeOrdered(OrderedConfiguration)");
}
@@ -279,7 +223,7 @@
{
attemptConfigurationMethod(
MappedConfigurationModule.class,
- "ioc.test.Mapped",
+ "Mapped",
"contributeMapped(MappedConfiguration)");
}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,34 +12,29 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.apache.tapestry.ioc.services.ClassFactory;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.ModuleImplTest}.
- *
- *
- */
-@Id("extra.public")
-public class ExtraPublicConstructorsModule
-{
-
- public ExtraPublicConstructorsModule()
- {
-
- }
-
- /**
- * Should be the first constructor, the one that gets invoked. I'm worried that different
- * compilers or JVMs will order the constructors differently.
- */
-
- public ExtraPublicConstructorsModule(@InjectService("tapestry.ioc.ClassFactory")
- ClassFactory factory)
- {
-
- }
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.ioc.services.ClassFactory;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.ModuleImplTest}.
+ */
+public class ExtraPublicConstructorsModule
+{
+
+ public ExtraPublicConstructorsModule()
+ {
+
+ }
+
+ /**
+ * Should be the first constructor, the one that gets invoked. I'm worried that different
+ * compilers or JVMs will order the constructors differently.
+ */
+ public ExtraPublicConstructorsModule(@InjectService("ClassFactory")
+ ClassFactory factory)
+ {
+
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,21 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.MappedConfiguration;
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
- *
- *
- */
-@Id("ioc.test")
-public class MappedConfigurationModule
-{
- public void contributeMapped(MappedConfiguration configuration)
- {
-
- }
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.MappedConfiguration;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
+ */
+public class MappedConfigurationModule
+{
+ public void contributeMapped(MappedConfiguration configuration)
+ {
+
+ }
+}
Modified: tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java?view=diff&rev=516524&r1=516523&r2=516524
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java (original)
+++ tapestry/tapestry5/tapestry-ioc/branches/hlship-20070309-simplifyioc/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java Fri Mar 9 11:49:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImplTest}.
- *
- *
- */
-@Id("tapestry.ioc")
-public class ModuleBuilderWithId
-{
-
-}
+package org.apache.tapestry.ioc.internal;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImplTest}.
+ */
+public class ModuleBuilderWithId
+{
+
+}