Author: hlship
Date: Fri Oct 8 09:42:04 2010
New Revision: 1005748
URL: http://svn.apache.org/viewvc?rev=1005748&view=rev
Log:
TAP5-1299: Allow live class reloading to be disabled for the services layer
Also relocate IOCSymbols to the ioc package
Also move IOCInternalTestCase to src/test/java
Added:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCSymbols.java
- copied, changed from r1005348,
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
(contents, props changed)
- copied, changed from r1005348,
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
Removed:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutor.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ParallelExecutor.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelModule.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java
Fri Oct 8 09:42:04 2010
@@ -29,7 +29,7 @@ public interface Request
{
/**
* Gets the {...@link Session}. If create is false and the session has not
be created previously, returns null. Also,
- * if the session is invalided and create is false, returns null.
+ * if the session is invalidated and create is false, returns null.
*
* @param create
* true to force the creation of the session
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java
Fri Oct 8 09:42:04 2010
@@ -1,10 +1,10 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2010 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
+// 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,
@@ -14,35 +14,13 @@
package org.apache.tapestry5;
+// Note: refactored this down into the ioc package where it belongs.
+
/**
- * Configuration symbols used by the IoC container.
- *
- * @since 5.1.0.1
+ * @deprecated Use {...@link org.apache.tapestry5.ioc.IOCSymbols} instead. To
be removed after Tapestry 5.2.
+ * @since 5.1.0
*/
-public class IOCSymbols
+public class IOCSymbols extends org.apache.tapestry5.ioc.IOCSymbols
{
- /**
- * The minimum size of the thread pool. The default is 3.
- */
- public static final String THREAD_POOL_CORE_SIZE =
"tapestry.thread-pool.core-pool-size";
-
- /**
- * Maximium size of the pool before submitted invocations must wait to
execute; the default is 20.
- */
- public static final String THREAD_POOL_MAX_SIZE =
"tapestry.thread-pool.max-pool-size";
-
- /**
- * Time in milliseconds (via {...@link
org.apache.tapestry5.ioc.util.TimeInterval}) to keep waiting threads alive.
- * Default is one minute (an epoch in application time).
- */
- public static final String THREAD_POOL_KEEP_ALIVE =
"tapestry.thread-pool.keep-alive";
- /**
- * By default, the {...@link
org.apache.tapestry5.ioc.services.ParallelExecutor} service uses a thread pool.
In
- * environments (such as Google Application Engine) where thread creation
is not allowed, this can be set to
- * "false", and deferred logic will, instead, execute immediately.
- *
- * @since 5.1.0.3
- */
- public static final String THREAD_POOL_ENABLED =
"tapestry.thread-pool-enabled";
}
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java
Fri Oct 8 09:42:04 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010 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
+// 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,
@@ -17,12 +17,14 @@ package org.apache.tapestry5.ioc;
public class IOCConstants
{
/**
- * @deprecated Use {...@link
org.apache.tapestry5.ioc.ScopeConstants#DEFAULT} instead.
+ * @deprecated Use {...@link
org.apache.tapestry5.ioc.ScopeConstants#DEFAULT} instead. To be removed after
Tapestry
+ * 5.2.
*/
public static final String DEFAULT_SCOPE = ScopeConstants.DEFAULT;
/**
- * @deprecated Use {...@link
org.apache.tapestry5.ioc.ScopeConstants#PERTHREAD} instead.
+ * @deprecated Use {...@link
org.apache.tapestry5.ioc.ScopeConstants#PERTHREAD} instead. To be removed after
Tapestry
+ * 5.2.
*/
public static final String PERTHREAD_SCOPE = ScopeConstants.PERTHREAD;
@@ -30,7 +32,11 @@ public class IOCConstants
public static final String MASTER_OBJECT_PROVIDER_SERVICE_ID =
"MasterObjectProvider";
- private IOCConstants()
- {
- }
+ /**
+ * Name of a JVM System Property (but not, alas, a configuration symbol)
that is used to disable
+ * live service reloading entirely (i.e., reverting to Tapestry 5.1
behavior).
+ *
+ * @since 5.2.2
+ */
+ public static final String SERVICE_CLASS_RELOADING_ENABLED =
"tapestry.service-reloading-enabled";
}
Copied:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCSymbols.java
(from r1005348,
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java)
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCSymbols.java?p2=tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCSymbols.java&p1=tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java&r1=1005348&r2=1005748&rev=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/IOCSymbols.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCSymbols.java
Fri Oct 8 09:42:04 2010
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2010 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,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry5;
+package org.apache.tapestry5.ioc;
/**
* Configuration symbols used by the IoC container.
*
- * @since 5.1.0.1
+ * @since 5.2.2
*/
public class IOCSymbols
{
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
Fri Oct 8 09:42:04 2010
@@ -996,7 +996,8 @@ public class RegistryImpl implements Reg
{
assert interfaceClass != null;
assert implementationClass != null;
- if (InternalUtils.isLocalFile(implementationClass))
+
+ if (InternalUtils.SERVICE_CLASS_RELOADING_ENABLED &&
InternalUtils.isLocalFile(implementationClass))
return createReloadingProxy(interfaceClass, implementationClass,
locator);
return createNonReloadingProxy(interfaceClass, implementationClass,
locator);
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
Fri Oct 8 09:42:04 2010
@@ -127,7 +127,7 @@ public class ServiceBinderImpl implement
private ObjectCreatorSource
createObjectCreatorSourceFromImplementationClass()
{
- if (!preventReloading && isProxiable() && reloadableScope() &&
InternalUtils.isLocalFile(serviceImplementation))
+ if (InternalUtils.SERVICE_CLASS_RELOADING_ENABLED && !preventReloading
&& isProxiable() && reloadableScope() &&
InternalUtils.isLocalFile(serviceImplementation))
return createReloadableConstructorBasedObjectCreatorSource();
return createStandardConstructorBasedObjectCreatorSource();
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutor.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutor.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutor.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutor.java
Fri Oct 8 09:42:04 2010
@@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
- * Implementation of {...@link ParallelExecutor} used when {...@linkplain
org.apache.tapestry5.IOCSymbols#THREAD_POOL_ENABLED
+ * Implementation of {...@link ParallelExecutor} used when {...@linkplain
org.apache.tapestry5.ioc.IOCSymbols#THREAD_POOL_ENABLED
* the thread pool is disabled}.
*
* @since 5.1.0.3
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
Fri Oct 8 09:42:04 2010
@@ -14,8 +14,6 @@
package org.apache.tapestry5.ioc.internal.util;
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newList;
-
import java.io.Closeable;
import java.io.IOException;
import java.lang.annotation.Annotation;
@@ -54,11 +52,15 @@ import org.apache.tapestry5.ioc.services
import org.apache.tapestry5.ioc.services.Coercion;
/**
- * Utilities used within various internal implementations of Tapestry IOC and
the rest of the tapestry-core framework.
+ * Utilities used within various internal implementations of the tapestry-ioc
module.
*/
@SuppressWarnings("all")
public class InternalUtils
{
+ /** @since 5.2.2 */
+ public static final boolean SERVICE_CLASS_RELOADING_ENABLED =
Boolean.parseBoolean(System.getProperty(
+ IOCConstants.SERVICE_CLASS_RELOADING_ENABLED, "true"));
+
/**
* Leading punctuation on member names that is stripped off to form a
property name or new member name.
*/
@@ -158,7 +160,7 @@ public class InternalUtils
*/
public static List<String> toList(Enumeration e)
{
- List<String> result = newList();
+ List<String> result = CollectionFactory.newList();
while (e.hasMoreElements())
{
@@ -481,7 +483,7 @@ public class InternalUtils
if (elements == null || elements.isEmpty())
return "(none)";
- List<String> list = newList();
+ List<String> list = CollectionFactory.newList();
for (Object o : elements)
list.add(String.valueOf(o));
@@ -559,7 +561,7 @@ public class InternalUtils
if (map == null)
return Collections.emptyList();
- List<String> keys = newList();
+ List<String> keys = CollectionFactory.newList();
for (Object o : map.keySet())
keys.add(String.valueOf(o));
@@ -705,7 +707,7 @@ public class InternalUtils
/**
* Adds a value to a specially organized map where the values are lists of
objects. This somewhat simulates a map
- * that allows mutiple values for the same key.
+ * that allows multiple values for the same key.
*
* @param map
* to store value into
@@ -724,7 +726,7 @@ public class InternalUtils
if (list == null)
{
- list = newList();
+ list = CollectionFactory.newList();
map.put(key, list);
}
@@ -798,7 +800,7 @@ public class InternalUtils
+ "You should make the constructor public,
or mark an alternate public constructor with the @Inject annotation.",
constructor));
}
-
+
public static InternalServiceDef toInternalServiceDef(final ServiceDef sd)
{
if (sd instanceof InternalServiceDef)
@@ -840,7 +842,7 @@ public class InternalUtils
{
return sd.isEagerLoad();
}
-
+
public Class getImplementationClass()
{
return null;
@@ -1078,7 +1080,7 @@ public class InternalUtils
/**
* Generates a unique value for the current execution of the application.
This initial UUID value
- * is not easily predicatable; subsequent UUIDs are allocated in ascending
series.
+ * is not easily predictable; subsequent UUIDs are allocated in ascending
series.
*
* @since 5.2.0
*/
@@ -1086,4 +1088,5 @@ public class InternalUtils
{
return uuidGenerator.incrementAndGet();
}
+
}
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ParallelExecutor.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ParallelExecutor.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ParallelExecutor.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ParallelExecutor.java
Fri Oct 8 09:42:04 2010
@@ -22,7 +22,7 @@ import java.util.concurrent.Future;
* A service that allows work to occur in parallel using a thread pool. The
thread pool is started lazily, and is
* shutdown when the Registry is shutdown.
*
- * @see org.apache.tapestry5.IOCSymbols
+ * @see org.apache.tapestry5.ioc.IOCSymbols
* @since 5.1.0.1
*/
public interface ParallelExecutor
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
Fri Oct 8 09:42:04 2010
@@ -4,7 +4,7 @@
// 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
+// 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,
@@ -17,27 +17,36 @@ package org.apache.tapestry5.ioc.service
import static org.apache.tapestry5.ioc.OrderConstraintBuilder.after;
import static org.apache.tapestry5.ioc.OrderConstraintBuilder.before;
-import org.apache.tapestry5.IOCSymbols;
-import org.apache.tapestry5.ioc.*;
-import org.apache.tapestry5.ioc.annotations.*;
-import org.apache.tapestry5.ioc.internal.services.*;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.util.TimeInterval;
-import org.apache.tapestry5.services.UpdateListenerHub;
-
import java.io.File;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import org.apache.tapestry5.ioc.*;
+import org.apache.tapestry5.ioc.annotations.Contribute;
+import org.apache.tapestry5.ioc.annotations.IntermediateType;
+import org.apache.tapestry5.ioc.annotations.Local;
+import org.apache.tapestry5.ioc.annotations.Marker;
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.ioc.internal.services.*;
+import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.ioc.util.TimeInterval;
+import org.apache.tapestry5.services.UpdateListenerHub;
+
/**
* Defines the base set of services for the Tapestry IOC container.
*/
+...@suppresswarnings("all")
@Marker(Builtin.class)
public final class TapestryIOCModule
{
@@ -98,22 +107,31 @@ public final class TapestryIOCModule
/**
* Contributes the "perthread" scope.
*/
- public static void
contributeServiceLifecycleSource(MappedConfiguration<String, ServiceLifecycle>
configuration)
+ @Contribute(ServiceLifecycleSource.class)
+ public static void providePerthreadScope(MappedConfiguration<String,
ServiceLifecycle> configuration)
{
configuration.addInstance(ScopeConstants.PERTHREAD,
PerThreadServiceLifecycle.class);
}
/**
- * <dl> <dt>AnnotationBasedContributions</dt> <dd>Empty placeholder used
to seperate annotation-based ObjectProvider
- * contributions (which come before) from non-annotation based
(ServiceOverride here, Alias in tapestry-core) which
- * come after. </dd> <dt>Value</dt> <dd>Supports the {...@link
org.apache.tapestry5.ioc.annotations.Value}
- * annotation</dd> <dt>Symbol</dt> <dd>Supports the {...@link
org.apache.tapestry5.ioc.annotations.Symbol}
- * annotations</dd> <dt>Autobuild</dt> <dd>Supports the {...@link
org.apache.tapestry5.ioc.annotations.Autobuild}
- * annotation</dd> <dt>ServiceOverride</dt> <dd>Allows simple service
overrides via the {...@link
- * org.apache.tapestry5.ioc.services.ServiceOverride} service (and its
configuration)</dl>
+ * <dl>
+ * <dt>AnnotationBasedContributions</dt>
+ * <dd>Empty placeholder used to seperate annotation-based ObjectProvider
contributions (which come before) from
+ * non-annotation based (ServiceOverride here, Alias in tapestry-core)
which come after.</dd>
+ * <dt>Value</dt>
+ * <dd>Supports the {...@link org.apache.tapestry5.ioc.annotations.Value}
annotation</dd>
+ * <dt>Symbol</dt>
+ * <dd>Supports the {...@link org.apache.tapestry5.ioc.annotations.Symbol}
annotations</dd>
+ * <dt>Autobuild</dt>
+ * <dd>Supports the {...@link
org.apache.tapestry5.ioc.annotations.Autobuild} annotation</dd>
+ * <dt>ServiceOverride</dt>
+ * <dd>Allows simple service overrides via the {...@link
org.apache.tapestry5.ioc.services.ServiceOverride} service
+ * (and its configuration)
+ * </dl>
*/
- public static void
contributeMasterObjectProvider(OrderedConfiguration<ObjectProvider>
configuration,
- @Local final
ServiceOverride serviceOverride)
+ @Contribute(MasterObjectProvider.class)
+ public static void
setupObjectProviders(OrderedConfiguration<ObjectProvider> configuration, @Local
+ final ServiceOverride serviceOverride)
{
configuration.add("AnnotationBasedContributions", null);
@@ -121,7 +139,6 @@ public final class TapestryIOCModule
configuration.addInstance("Symbol", SymbolObjectProvider.class,
before("AnnotationBasedContributions").build());
configuration.add("Autobuild", new AutobuildObjectProvider(),
before("AnnotationBasedContributions").build());
-
ObjectProvider wrapper = new ObjectProvider()
{
public <T> T provide(Class<T> objectType, AnnotationProvider
annotationProvider, ObjectLocator locator)
@@ -134,20 +151,39 @@ public final class TapestryIOCModule
}
/**
- * Contributes a set of standard type coercions to the {...@link
TypeCoercer} service: <ul> <li>Object to String</li>
- * <li>String to Double</li> <li>String to BigDecimal</li> <li>BigDecimal
to Double</li> <li>Double to
- * BigDecimal</li> <li>String to BigInteger</li> <li>BigInteger to
Long</li> <li>String to Long</li> <li>Long to
- * Byte</li> <li>Long to Short</li> <li>Long to Integer</li> <li>Double to
Long</li> <li>Double to Float</li>
- * <li>Float to Double</li> <li>Long to Double</li> <li>String to Boolean
("false" is always false, other non-blank
- * strings are true)</li> <li>Long to Boolean (true if long value is non
zero)</li> <li>Null to Boolean (always
- * false)</li> <li>Collection to Boolean (false if empty)</li>
<li>Object[] to List</li> <li>primitive[] to
- * List</li> <li>Object to List (by wrapping as a singleton list)</li>
<li>String to File</li> <li>String to {...@link
- * org.apache.tapestry5.ioc.util.TimeInterval}</li> <li>{...@link
org.apache.tapestry5.ioc.util.TimeInterval} to
- * Long</li> <li>Object to Object[] (wrapping the object as an array)</li>
<li>Collection to Object[] (via the
- * toArray() method)</ul>
+ * Contributes a set of standard type coercions to the {...@link
TypeCoercer} service:
+ * <ul>
+ * <li>Object to String</li>
+ * <li>String to Double</li>
+ * <li>String to BigDecimal</li>
+ * <li>BigDecimal to Double</li>
+ * <li>Double to BigDecimal</li>
+ * <li>String to BigInteger</li>
+ * <li>BigInteger to Long</li>
+ * <li>String to Long</li>
+ * <li>Long to Byte</li>
+ * <li>Long to Short</li>
+ * <li>Long to Integer</li>
+ * <li>Double to Long</li>
+ * <li>Double to Float</li>
+ * <li>Float to Double</li>
+ * <li>Long to Double</li>
+ * <li>String to Boolean ("false" is always false, other non-blank strings
are true)</li>
+ * <li>Long to Boolean (true if long value is non zero)</li>
+ * <li>Null to Boolean (always false)</li>
+ * <li>Collection to Boolean (false if empty)</li>
+ * <li>Object[] to List</li>
+ * <li>primitive[] to List</li>
+ * <li>Object to List (by wrapping as a singleton list)</li>
+ * <li>String to File</li>
+ * <li>String to {...@link org.apache.tapestry5.ioc.util.TimeInterval}</li>
+ * <li>{...@link org.apache.tapestry5.ioc.util.TimeInterval} to Long</li>
+ * <li>Object to Object[] (wrapping the object as an array)</li>
+ * <li>Collection to Object[] (via the toArray() method)
+ * </ul>
*/
- @SuppressWarnings("unchecked")
- public static void contributeTypeCoercer(Configuration<CoercionTuple>
configuration)
+ @Contribute(TypeCoercer.class)
+ public static void provideBasicTypeCoercions(Configuration<CoercionTuple>
configuration)
{
add(configuration, Object.class, String.class, new Coercion<Object,
String>()
{
@@ -254,7 +290,8 @@ public final class TapestryIOCModule
{
String trimmed = input == null ? "" : input.trim();
- if (trimmed.equalsIgnoreCase("false") || trimmed.length() ==
0) return false;
+ if (trimmed.equalsIgnoreCase("false") || trimmed.length() == 0)
+ return false;
// Any non-blank string but "false"
@@ -278,7 +315,6 @@ public final class TapestryIOCModule
}
});
-
add(configuration, Collection.class, Boolean.class, new
Coercion<Collection, Boolean>()
{
public Boolean coerce(Collection input)
@@ -362,7 +398,8 @@ public final class TapestryIOCModule
{
public Object[] coerce(Object input)
{
- return new Object[] { input };
+ return new Object[]
+ { input };
}
});
@@ -375,51 +412,52 @@ public final class TapestryIOCModule
});
}
- private static <S, T> void add(Configuration<CoercionTuple> configuration,
Class<S> sourceType, Class<T> targetType,
- Coercion<S, T> coercion)
+ private static <S, T> void add(Configuration<CoercionTuple> configuration,
Class<S> sourceType,
+ Class<T> targetType, Coercion<S, T> coercion)
{
CoercionTuple<S, T> tuple = new CoercionTuple<S, T>(sourceType,
targetType, coercion);
configuration.add(tuple);
}
- public static void
contributeSymbolSource(OrderedConfiguration<SymbolProvider> configuration,
- @ApplicationDefaults
SymbolProvider applicationDefaults,
+ @Contribute(SymbolSource.class)
+ public static void
setupStandardSymbolProviders(OrderedConfiguration<SymbolProvider> configuration,
+ @ApplicationDefaults
+ SymbolProvider applicationDefaults,
- @FactoryDefaults SymbolProvider
factoryDefaults)
+ @FactoryDefaults
+ SymbolProvider factoryDefaults)
{
configuration.add("SystemProperties", new
SystemPropertiesSymbolProvider(), "before:*");
configuration.add("ApplicationDefaults", applicationDefaults,
"after:SystemProperties");
configuration.add("FactoryDefaults", factoryDefaults,
"after:ApplicationDefaults");
}
- public static ParallelExecutor buildDeferredExecution(
- @Symbol(IOCSymbols.THREAD_POOL_CORE_SIZE)
- int coreSize,
+ public static ParallelExecutor
buildDeferredExecution(@Symbol(IOCSymbols.THREAD_POOL_CORE_SIZE)
+ int coreSize,
- @Symbol(IOCSymbols.THREAD_POOL_MAX_SIZE)
- int maxSize,
+ @Symbol(IOCSymbols.THREAD_POOL_MAX_SIZE)
+ int maxSize,
- @Symbol(IOCSymbols.THREAD_POOL_KEEP_ALIVE)
- @IntermediateType(TimeInterval.class)
- int keepAliveMillis,
+ @Symbol(IOCSymbols.THREAD_POOL_KEEP_ALIVE)
+ @IntermediateType(TimeInterval.class)
+ int keepAliveMillis,
- @Symbol(IOCSymbols.THREAD_POOL_ENABLED)
- boolean threadPoolEnabled,
+ @Symbol(IOCSymbols.THREAD_POOL_ENABLED)
+ boolean threadPoolEnabled,
- PerthreadManager perthreadManager,
+ PerthreadManager perthreadManager,
- RegistryShutdownHub shutdownHub,
+ RegistryShutdownHub shutdownHub,
- ThunkCreator thunkCreator)
+ ThunkCreator thunkCreator)
{
if (!threadPoolEnabled)
return new NonParallelExecutor();
- final ThreadPoolExecutor executorService = new
ThreadPoolExecutor(coreSize, maxSize,
-
keepAliveMillis, TimeUnit.MILLISECONDS,
- new
LinkedBlockingQueue());
+ final ThreadPoolExecutor executorService = new
ThreadPoolExecutor(coreSize, maxSize, keepAliveMillis,
+ TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
shutdownHub.addRegistryShutdownListener(new RegistryShutdownListener()
{
@@ -432,7 +470,9 @@ public final class TapestryIOCModule
return new ParallelExecutorImpl(executorService, thunkCreator,
perthreadManager);
}
- public static void contributeFactoryDefaults(MappedConfiguration<String,
String> configuration)
+ @Contribute(SymbolProvider.class)
+ @FactoryDefaults
+ public static void setupDefaultSymbols(MappedConfiguration<String, String>
configuration)
{
configuration.add(IOCSymbols.THREAD_POOL_CORE_SIZE, "3");
configuration.add(IOCSymbols.THREAD_POOL_MAX_SIZE, "20");
Copied:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
(from r1005348,
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java)
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java?p2=tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java&p1=tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java&r1=1005348&r2=1005748&rev=1005748&view=diff
==============================================================================
(empty)
Propchange:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelModule.java?rev=1005748&r1=1005747&r2=1005748&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelModule.java
Fri Oct 8 09:42:04 2010
@@ -14,7 +14,7 @@
package org.apache.tapestry5.ioc.internal.services;
-import org.apache.tapestry5.IOCSymbols;
+import org.apache.tapestry5.ioc.IOCSymbols;
import org.apache.tapestry5.ioc.MappedConfiguration;
public class NonParallelModule