Author: hlship
Date: Tue Sep 27 21:16:58 2011
New Revision: 1176624
URL: http://svn.apache.org/viewvc?rev=1176624&view=rev
Log:
TAP5-1674: Add ServiceBinder.withSimpleId() that generates a service id from
the implementation class name
Added:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/NoImplementationClassForSimpleIdModule.java
- copied, changed from r1176623,
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java
Modified:
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/main/java/org/apache/tapestry5/beanvalidator/BeanValidatorModule.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceBindingOptions.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/services/TapestryIOCModule.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PreventDecorationModule.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/MutlipleAutobuildServiceConstructorsModule.java
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/JpaModule.java
Modified:
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/main/java/org/apache/tapestry5/beanvalidator/BeanValidatorModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/main/java/org/apache/tapestry5/beanvalidator/BeanValidatorModule.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/main/java/org/apache/tapestry5/beanvalidator/BeanValidatorModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/main/java/org/apache/tapestry5/beanvalidator/BeanValidatorModule.java
Tue Sep 27 21:16:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010 The Apache Software Foundation
+// Copyright 2009, 2010, 2011 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.
@@ -13,25 +13,10 @@
// limitations under the License.
package org.apache.tapestry5.beanvalidator;
-import javax.validation.MessageInterpolator;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Null;
-import javax.validation.constraints.Pattern;
-import javax.validation.constraints.Size;
-import javax.validation.groups.Default;
-
import org.apache.tapestry5.Asset;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.RenderSupport;
-import
org.apache.tapestry5.internal.beanvalidator.BeanFieldValidatorDefaultSource;
-import
org.apache.tapestry5.internal.beanvalidator.BeanValidationGroupSourceImpl;
-import org.apache.tapestry5.internal.beanvalidator.BeanValidatorSourceImpl;
-import
org.apache.tapestry5.internal.beanvalidator.ClientConstraintDescriptorImpl;
-import org.apache.tapestry5.internal.beanvalidator.MessageInterpolatorImpl;
+import org.apache.tapestry5.internal.beanvalidator.*;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
@@ -39,92 +24,93 @@ import org.apache.tapestry5.ioc.ServiceB
import org.apache.tapestry5.ioc.annotations.Local;
import org.apache.tapestry5.ioc.services.PropertyShadowBuilder;
import org.apache.tapestry5.ioc.services.ThreadLocale;
-import org.apache.tapestry5.services.AssetSource;
-import org.apache.tapestry5.services.Environment;
-import org.apache.tapestry5.services.FieldValidatorDefaultSource;
-import org.apache.tapestry5.services.MarkupRenderer;
-import org.apache.tapestry5.services.MarkupRendererFilter;
+import org.apache.tapestry5.services.*;
+
+import javax.validation.MessageInterpolator;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.constraints.*;
+import javax.validation.groups.Default;
/**
* Module for JSR-303 services.
- *
+ *
* @since 5.2.0.0
*/
-public class BeanValidatorModule
+public class BeanValidatorModule
{
- public static void bind(final ServiceBinder binder)
- {
- binder.bind(FieldValidatorDefaultSource.class,
BeanFieldValidatorDefaultSource.class)
-
.withId("BeanFieldValidatorDefaultSource");
- binder.bind(BeanValidatorGroupSource.class,
BeanValidationGroupSourceImpl.class);
- binder.bind(BeanValidatorSource.class,
BeanValidatorSourceImpl.class);
- binder.bind(ClientConstraintDescriptorSource.class,
ClientConstraintDescriptorImpl.class);
- }
-
- public static void contributeServiceOverride(
- MappedConfiguration<Class, Object> configuration,
- @Local FieldValidatorDefaultSource source)
- {
- configuration.add(FieldValidatorDefaultSource.class, source);
- }
-
- public static Validator buildBeanValidator(ValidatorFactory
validatorFactory, PropertyShadowBuilder propertyShadowBuilder)
- {
- return propertyShadowBuilder.build(validatorFactory,
"validator", Validator.class);
- }
-
-
- public static ValidatorFactory buildValidatorFactory(
BeanValidatorSource beanValidatorSource, PropertyShadowBuilder
propertyShadowBuilder)
- {
- return propertyShadowBuilder.build(beanValidatorSource,
"validatorFactory", ValidatorFactory.class);
- }
-
- public static void contributeBeanValidatorGroupSource(
- final Configuration<Class> configuration)
- {
- configuration.add(Default.class);
- }
-
- public static void contributeBeanValidatorSource(
- final OrderedConfiguration<BeanValidatorConfigurer>
configuration, final ThreadLocale threadLocale)
- {
- configuration.add("LocaleAwareMessageInterpolator", new
BeanValidatorConfigurer()
- {
- public void configure(javax.validation.Configuration<?>
configuration)
- {
- MessageInterpolator defaultInterpolator =
configuration.getDefaultMessageInterpolator();
-
- configuration.messageInterpolator(new
MessageInterpolatorImpl(defaultInterpolator, threadLocale));
- }
- });
- }
-
- public static void contributeClientConstraintDescriptorSource(
- final Configuration<ClientConstraintDescriptor>
configuration)
- {
- configuration.add(new ClientConstraintDescriptor(Max.class,
"maxnumber", "value"));
- configuration.add(new ClientConstraintDescriptor(Min.class,
"minnumber", "value"));
- configuration.add(new ClientConstraintDescriptor(NotNull.class,
"notnull"));
- configuration.add(new ClientConstraintDescriptor(Null.class,
"isnull"));
- configuration.add(new ClientConstraintDescriptor(Pattern.class,
"pattern", "regexp"));
- configuration.add(new ClientConstraintDescriptor(Size.class,
"size", "min", "max"));
- }
-
- public void contributeMarkupRenderer(
- OrderedConfiguration<MarkupRendererFilter>
configuration,
-
- final AssetSource assetSource,
-
- final ThreadLocale threadLocale,
-
- final Environment environment)
- {
+ public static void bind(final ServiceBinder binder)
+ {
+ binder.bind(FieldValidatorDefaultSource.class,
BeanFieldValidatorDefaultSource.class).withSimpleId();
+ binder.bind(BeanValidatorGroupSource.class,
BeanValidationGroupSourceImpl.class);
+ binder.bind(BeanValidatorSource.class, BeanValidatorSourceImpl.class);
+ binder.bind(ClientConstraintDescriptorSource.class,
ClientConstraintDescriptorImpl.class);
+ }
+
+ public static void contributeServiceOverride(
+ MappedConfiguration<Class, Object> configuration,
+ @Local FieldValidatorDefaultSource source)
+ {
+ configuration.add(FieldValidatorDefaultSource.class, source);
+ }
+
+ public static Validator buildBeanValidator(ValidatorFactory
validatorFactory, PropertyShadowBuilder propertyShadowBuilder)
+ {
+ return propertyShadowBuilder.build(validatorFactory, "validator",
Validator.class);
+ }
+
+
+ public static ValidatorFactory buildValidatorFactory(BeanValidatorSource
beanValidatorSource, PropertyShadowBuilder propertyShadowBuilder)
+ {
+ return propertyShadowBuilder.build(beanValidatorSource,
"validatorFactory", ValidatorFactory.class);
+ }
+
+ public static void contributeBeanValidatorGroupSource(
+ final Configuration<Class> configuration)
+ {
+ configuration.add(Default.class);
+ }
+
+ public static void contributeBeanValidatorSource(
+ final OrderedConfiguration<BeanValidatorConfigurer> configuration,
final ThreadLocale threadLocale)
+ {
+ configuration.add("LocaleAwareMessageInterpolator", new
BeanValidatorConfigurer()
+ {
+ public void configure(javax.validation.Configuration<?>
configuration)
+ {
+ MessageInterpolator defaultInterpolator =
configuration.getDefaultMessageInterpolator();
+
+ configuration.messageInterpolator(new
MessageInterpolatorImpl(defaultInterpolator, threadLocale));
+ }
+ });
+ }
+
+ public static void contributeClientConstraintDescriptorSource(
+ final Configuration<ClientConstraintDescriptor> configuration)
+ {
+ configuration.add(new ClientConstraintDescriptor(Max.class,
"maxnumber", "value"));
+ configuration.add(new ClientConstraintDescriptor(Min.class,
"minnumber", "value"));
+ configuration.add(new ClientConstraintDescriptor(NotNull.class,
"notnull"));
+ configuration.add(new ClientConstraintDescriptor(Null.class,
"isnull"));
+ configuration.add(new ClientConstraintDescriptor(Pattern.class,
"pattern", "regexp"));
+ configuration.add(new ClientConstraintDescriptor(Size.class, "size",
"min", "max"));
+ }
+
+ public void contributeMarkupRenderer(
+ OrderedConfiguration<MarkupRendererFilter> configuration,
+
+ final AssetSource assetSource,
+
+ final ThreadLocale threadLocale,
+
+ final Environment environment)
+ {
MarkupRendererFilter injectBeanValidatorScript = new
MarkupRendererFilter()
{
public void renderMarkup(MarkupWriter writer, MarkupRenderer
renderer)
{
RenderSupport renderSupport =
environment.peek(RenderSupport.class);
-
+
Asset validators = assetSource.getAsset(null,
"org/apache/tapestry5/beanvalidator/tapestry-beanvalidator.js",
threadLocale.getLocale());
@@ -133,9 +119,9 @@ public class BeanValidatorModule
renderer.renderMarkup(writer);
}
};
-
-
+
+
configuration.add("BeanValidatorScript", injectBeanValidatorScript,
"after:*");
- }
+ }
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Tue Sep 27 21:16:58 2011
@@ -321,13 +321,12 @@ public final class TapestryModule
binder.bind(ComponentDefaultProvider.class,
ComponentDefaultProviderImpl.class);
binder.bind(MarkupWriterFactory.class, MarkupWriterFactoryImpl.class);
binder.bind(FieldValidationSupport.class,
FieldValidationSupportImpl.class);
- binder.bind(ObjectRenderer.class,
LocationRenderer.class).withId("LocationRenderer");
- binder.bind(ObjectProvider.class,
AssetObjectProvider.class).withId("AssetObjectProvider");
+ binder.bind(ObjectRenderer.class,
LocationRenderer.class).withSimpleId();
+ binder.bind(ObjectProvider.class,
AssetObjectProvider.class).withSimpleId();
binder.bind(RequestExceptionHandler.class,
DefaultRequestExceptionHandler.class);
- binder.bind(ComponentEventResultProcessor.class,
ComponentInstanceResultProcessor.class).withId(
- "ComponentInstanceResultProcessor");
+ binder.bind(ComponentEventResultProcessor.class,
ComponentInstanceResultProcessor.class).withSimpleId();
binder.bind(NullFieldStrategySource.class,
NullFieldStrategySourceImpl.class);
- binder.bind(HttpServletRequestFilter.class,
IgnoredPathsFilter.class).withId("IgnoredPathsFilter");
+ binder.bind(HttpServletRequestFilter.class,
IgnoredPathsFilter.class).withSimpleId();
binder.bind(ContextValueEncoder.class, ContextValueEncoderImpl.class);
binder.bind(BaseURLSource.class, BaseURLSourceImpl.class);
binder.bind(BeanBlockOverrideSource.class,
BeanBlockOverrideSourceImpl.class);
@@ -335,18 +334,16 @@ public final class TapestryModule
binder.bind(PageDocumentGenerator.class,
PageDocumentGeneratorImpl.class);
binder.bind(ResponseRenderer.class, ResponseRendererImpl.class);
binder.bind(FieldTranslatorSource.class,
FieldTranslatorSourceImpl.class);
- binder.bind(BindingFactory.class,
MessageBindingFactory.class).withId("MessageBindingFactory");
- binder.bind(BindingFactory.class,
ValidateBindingFactory.class).withId("ValidateBindingFactory");
- binder.bind(BindingFactory.class,
TranslateBindingFactory.class).withId("TranslateBindingFactory");
- binder.bind(BindingFactory.class,
AssetBindingFactory.class).withId("AssetBindingFactory");
- binder.bind(BindingFactory.class,
ContextBindingFactory.class).withId("ContextBindingFactory");
- binder.bind(BindingFactory.class,
NullFieldStrategyBindingFactory.class).withId(
- "NullFieldStrategyBindingFactory");
- binder.bind(BindingFactory.class,
SymbolBindingFactory.class).withId("SymbolBindingFactory");
+ binder.bind(BindingFactory.class,
MessageBindingFactory.class).withSimpleId();
+ binder.bind(BindingFactory.class,
ValidateBindingFactory.class).withSimpleId();
+ binder.bind(BindingFactory.class,
TranslateBindingFactory.class).withSimpleId();
+ binder.bind(BindingFactory.class,
AssetBindingFactory.class).withSimpleId();
+ binder.bind(BindingFactory.class,
ContextBindingFactory.class).withSimpleId();
+ binder.bind(BindingFactory.class,
NullFieldStrategyBindingFactory.class).withSimpleId();
+ binder.bind(BindingFactory.class,
SymbolBindingFactory.class).withSimpleId();
binder.bind(URLEncoder.class, URLEncoderImpl.class);
binder.bind(ContextPathEncoder.class, ContextPathEncoderImpl.class);
- binder.bind(ApplicationStatePersistenceStrategy.class,
SessionApplicationStatePersistenceStrategy.class)
- .withId("SessionApplicationStatePersistenceStrategy");
+ binder.bind(ApplicationStatePersistenceStrategy.class,
SessionApplicationStatePersistenceStrategy.class).withSimpleId();
binder.bind(SessionFactory.class, SessionFactoryImpl.class);
binder.bind(AssetPathConverter.class,
IdentityAssetPathConverter.class);
binder.bind(NumericTranslatorSupport.class);
@@ -356,7 +353,7 @@ public final class TapestryModule
binder.bind(ValidatorMacro.class, ValidatorMacroImpl.class);
binder.bind(PropertiesFileParser.class,
PropertiesFileParserImpl.class);
binder.bind(PageActivator.class, PageActivatorImpl.class);
- binder.bind(Dispatcher.class,
AssetDispatcher.class).withId("AssetDispatcher");
+ binder.bind(Dispatcher.class, AssetDispatcher.class).withSimpleId();
binder.bind(AssetPathConstructor.class,
AssetPathConstructorImpl.class);
binder.bind(JavaScriptStackSource.class,
JavaScriptStackSourceImpl.class);
binder.bind(TranslatorAlternatesSource.class,
TranslatorAlternatesSourceImpl.class);
Modified:
tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
Tue Sep 27 21:16:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2008, 2009 The Apache Software Foundation
+// Copyright 2008, 2009, 2011 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.
@@ -36,7 +36,7 @@ import java.util.List;
* Defines core services that support initialization of Hibernate and access
to the Hibernate {@link
* org.hibernate.Session}.
*/
-@SuppressWarnings({ "JavaDoc" })
+@SuppressWarnings({"JavaDoc"})
@Marker(HibernateCore.class)
public class HibernateCoreModule
{
@@ -44,7 +44,7 @@ public class HibernateCoreModule
{
binder.bind(HibernateTransactionDecorator.class,
HibernateTransactionDecoratorImpl.class);
binder.bind(HibernateTransactionAdvisor.class,
HibernateTransactionAdvisorImpl.class);
- binder.bind(HibernateConfigurer.class,
DefaultHibernateConfigurer.class).withId("DefaultHibernateConfigurer");
+ binder.bind(HibernateConfigurer.class,
DefaultHibernateConfigurer.class).withSimpleId();
}
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceBindingOptions.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceBindingOptions.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceBindingOptions.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceBindingOptions.java
Tue Sep 27 21:16:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2007, 2009 The Apache Software Foundation
+// Copyright 2007, 2009, 2011 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.
@@ -22,7 +22,7 @@ import java.lang.annotation.Annotation;
/**
* Allows additional options for a service to be specified, overriding hard
coded defaults or defaults from annotations
* on the service.
- *
+ *
* @see org.apache.tapestry5.ioc.def.ServiceDef2
*/
public interface ServiceBindingOptions
@@ -31,15 +31,25 @@ public interface ServiceBindingOptions
* Allows a specific service id for the service to be provided, rather
than the default (from the service
* interface). This is useful when multiple services implement the same
interface, since service ids must be
* unique.
- *
+ *
* @param id
* @return this binding options, for further configuration
*/
ServiceBindingOptions withId(String id);
/**
+ * Uses the the simple (unqualified) class name of the implementation
class as the id of the service.
+ *
+ * @return this binding options, for further configuration
+ * @throws IllegalStateException if the class name was not defined (via
{@link ServiceBinder#bind(Class, Class)} or
+ * {@link ServiceBinder#bind(Class)}).
+ * @since 5.3
+ */
+ ServiceBindingOptions withSimpleId();
+
+ /**
* Sets the scope of the service, overriding the {@link Scope} annotation
on the service implementation class.
- *
+ *
* @param scope
* @return this binding options, for further configuration
* @see org.apache.tapestry5.ioc.ScopeConstants
@@ -49,14 +59,14 @@ public interface ServiceBindingOptions
/**
* Turns eager loading on for this service. This may also be accomplished
using the {@link EagerLoad} annotation on
* the service implementation class.
- *
+ *
* @return this binding options, for further configuration
*/
ServiceBindingOptions eagerLoad();
/**
* Disallows service decoration for this service.
- *
+ *
* @return this binding options, for further configuration
*/
ServiceBindingOptions preventDecoration();
@@ -66,7 +76,7 @@ public interface ServiceBindingOptions
* internal Tapestry services, and is necessary during the development of
Tapestry itself. In user applications,
* services defined in library modules are not subject to reloading
because the class files are stored in JARs, not
* as local file system files.
- *
+ *
* @since 5.2.0
*/
ServiceBindingOptions preventReloading();
@@ -76,10 +86,9 @@ public interface ServiceBindingOptions
* with a particular service implementation, based on the intersection of
type and marker interface. The containing
* module will sometimes provide a set of default marker annotations for
all services within the module, this method
* allows that default to be extended.
- *
+ *
* @param <T>
- * @param marker
- * one or more markers to add
+ * @param marker one or more markers to add
* @return this binding options, for further configuration
*/
<T extends Annotation> ServiceBindingOptions withMarker(Class<T>...
marker);
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=1176624&r1=1176623&r2=1176624&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
Tue Sep 27 21:16:58 2011
@@ -14,29 +14,23 @@
package org.apache.tapestry5.ioc.internal;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Set;
-
-import org.apache.tapestry5.ioc.ObjectCreator;
-import org.apache.tapestry5.ioc.ScopeConstants;
-import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.ServiceBindingOptions;
-import org.apache.tapestry5.ioc.ServiceBuilder;
-import org.apache.tapestry5.ioc.ServiceBuilderResources;
+import org.apache.tapestry5.ioc.*;
import org.apache.tapestry5.ioc.annotations.EagerLoad;
import org.apache.tapestry5.ioc.annotations.Marker;
import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
import org.apache.tapestry5.ioc.annotations.Scope;
-import org.apache.tapestry5.ioc.annotations.ServiceId;
import org.apache.tapestry5.ioc.def.ServiceDef;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.internal.util.OneShotLock;
import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Set;
+
@SuppressWarnings("all")
public class ServiceBinderImpl implements ServiceBinder, ServiceBindingOptions
{
@@ -53,7 +47,7 @@ public class ServiceBinderImpl implement
private final boolean moduleDefaultPreventDecoration;
public ServiceBinderImpl(ServiceDefAccumulator accumulator, Method
bindMethod, PlasticProxyFactory proxyFactory,
- Set<Class> defaultMarkers, boolean moduleDefaultPreventDecoration)
+ Set<Class> defaultMarkers, boolean
moduleDefaultPreventDecoration)
{
this.accumulator = accumulator;
this.bindMethod = bindMethod;
@@ -185,11 +179,13 @@ public class ServiceBinderImpl implement
Class<T> implementationClass = (Class<T>)
classLoader.loadClass(expectedImplName);
- if (!implementationClass.isInterface() &&
serviceClass.isAssignableFrom(implementationClass)) { return bind(
- serviceClass, implementationClass); }
+ if (!implementationClass.isInterface() &&
serviceClass.isAssignableFrom(implementationClass))
+ {
+ return bind(
+ serviceClass, implementationClass);
+ }
throw new
RuntimeException(IOCMessages.noServiceMatchesType(serviceClass));
- }
- catch (ClassNotFoundException ex)
+ } catch (ClassNotFoundException ex)
{
throw new
RuntimeException(IOCMessages.noConventionServiceImplementationFound(serviceClass));
}
@@ -310,6 +306,16 @@ public class ServiceBinderImpl implement
return this;
}
+ public ServiceBindingOptions withSimpleId()
+ {
+ if (serviceImplementation == null)
+ {
+ throw new IllegalArgumentException("No defined implementation
class to generate simple id from.");
+ }
+
+ return withId(serviceImplementation.getSimpleName());
+ }
+
public ServiceBindingOptions scope(String scope)
{
assert InternalUtils.isNonBlank(scope);
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=1176624&r1=1176623&r2=1176624&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
Tue Sep 27 21:16:58 2011
@@ -62,7 +62,7 @@ public final class TapestryIOCModule
.withMarker(ApplicationDefaults.class);
binder.bind(SymbolProvider.class,
MapSymbolProvider.class).withId("FactoryDefaults")
.withMarker(FactoryDefaults.class);
- binder.bind(Runnable.class,
RegistryStartup.class).withId("RegistryStartup");
+ binder.bind(Runnable.class, RegistryStartup.class).withSimpleId();
binder.bind(MasterObjectProvider.class,
MasterObjectProviderImpl.class).preventReloading();
binder.bind(ClassNameLocator.class, ClassNameLocatorImpl.class);
binder.bind(AspectDecorator.class, AspectDecoratorImpl.class);
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java
Tue Sep 27 21:16:58 2011
@@ -1591,4 +1591,19 @@ public class IntegrationTest extends IOC
assertEquals(source.valueForSymbol("bool-false"), "false");
assertEquals(source.valueForSymbol("num-12345"), "12345");
}
+
+ /**
+ * TAP5-1674
+ */
+ @Test
+ public void no_implemention_class_defined_for_ServiceBinder_withSimpleId()
+ {
+ try
+ {
+ buildRegistry(NoImplementationClassForSimpleIdModule.class);
+ } catch (RuntimeException ex)
+ {
+ assertMessageContains(ex, "No defined implementation class to
generate simple id from");
+ }
+ }
}
Copied:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/NoImplementationClassForSimpleIdModule.java
(from r1176623,
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java)
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/NoImplementationClassForSimpleIdModule.java?p2=tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/NoImplementationClassForSimpleIdModule.java&p1=tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java&r1=1176623&r2=1176624&rev=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/NoImplementationClassForSimpleIdModule.java
Tue Sep 27 21:16:58 2011
@@ -1,10 +1,10 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2011 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,10 +14,16 @@
package org.apache.tapestry5.ioc;
-public class PostInjectionMethodModule
+public class NoImplementationClassForSimpleIdModule
{
public static void bind(ServiceBinder binder)
{
- binder.bind(Greeter.class,
ServiceIdGreeter.class).withId("ServiceIdGreeter");
+ binder.bind(Runnable.class, new ServiceBuilder<Runnable>()
+ {
+ public Runnable buildService(ServiceResources resources)
+ {
+ return null;
+ }
+ }).withSimpleId();
}
}
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PostInjectionMethodModule.java
Tue Sep 27 21:16:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2011 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.
@@ -18,6 +18,6 @@ public class PostInjectionMethodModule
{
public static void bind(ServiceBinder binder)
{
- binder.bind(Greeter.class,
ServiceIdGreeter.class).withId("ServiceIdGreeter");
+ binder.bind(Greeter.class, ServiceIdGreeter.class).withSimpleId();
}
}
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PreventDecorationModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PreventDecorationModule.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PreventDecorationModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PreventDecorationModule.java
Tue Sep 27 21:16:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2011 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.
@@ -21,7 +21,7 @@ public class PreventDecorationModule
{
public static void bind(ServiceBinder binder)
{
- binder.bind(Greeter.class,
ServiceIdGreeter.class).withId("ServiceIdGreeter").preventDecoration();
+ binder.bind(Greeter.class,
ServiceIdGreeter.class).withSimpleId().preventDecoration();
binder.bind(Rocket.class, RocketImpl.class);
}
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/MutlipleAutobuildServiceConstructorsModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/MutlipleAutobuildServiceConstructorsModule.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/MutlipleAutobuildServiceConstructorsModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/MutlipleAutobuildServiceConstructorsModule.java
Tue Sep 27 21:16:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2007, 2010 The Apache Software Foundation
+// Copyright 2007, 2010, 2011 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.
@@ -21,8 +21,7 @@ public class MutlipleAutobuildServiceCon
{
public static void bind(ServiceBinder binder)
{
- binder.bind(StringHolder.class,
ToUpperCaseStringHolder.class).withId("ToUpperCaseStringHolder")
- .preventReloading();
+ binder.bind(StringHolder.class,
ToUpperCaseStringHolder.class).withSimpleId().preventReloading();
binder.bind(StringHolder.class,
MultipleConstructorsAutobuildService.class).preventReloading();
}
}
Modified:
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/JpaModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/JpaModule.java?rev=1176624&r1=1176623&r2=1176624&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/JpaModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/JpaModule.java
Tue Sep 27 21:16:58 2011
@@ -42,8 +42,7 @@ public class JpaModule
public static void bind(final ServiceBinder binder)
{
binder.bind(JpaTransactionAdvisor.class,
JpaTransactionAdvisorImpl.class);
- binder.bind(PersistenceUnitConfigurer.class,
PackageNamePersistenceUnitConfigurer.class).withId(
- "PackageNamePersistenceUnitConfigurer");
+ binder.bind(PersistenceUnitConfigurer.class,
PackageNamePersistenceUnitConfigurer.class).withSimpleId();
}
public static EntityManagerSource buildEntityManagerSource(final Logger
logger,