Class ServiceBinderImpl
- java.lang.Object
-
- org.apache.tapestry5.ioc.internal.ServiceBinderImpl
-
- All Implemented Interfaces:
ServiceBinder,ServiceBindingOptions
public class ServiceBinderImpl extends java.lang.Object implements ServiceBinder, ServiceBindingOptions
-
-
Constructor Summary
Constructors Constructor Description ServiceBinderImpl(ServiceDefAccumulator accumulator, java.lang.reflect.Method bindMethod, PlasticProxyFactory proxyFactory, java.util.Set<java.lang.Class> defaultMarkers, boolean moduleDefaultPreventDecoration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> ServiceBindingOptionsbind(java.lang.Class<T> serviceClass)Binds the service interface to a conventionally named service implementation class or defines a service in terms of an implementation class, without a service interface.<T> ServiceBindingOptionsbind(java.lang.Class<T> serviceInterface, java.lang.Class<? extends T> serviceImplementation)Binds the service interface to a service implementation class.<T> ServiceBindingOptionsbind(java.lang.Class<T> serviceInterface, ServiceBuilder<T> builder)Alternative implementation that supports a callback to build the service, rather than instantiating a particular class.ServiceBindingOptionseagerLoad()Turns eager loading on for this service.voidfinish()protected voidflush()ServiceBindingOptionspreventDecoration()Disallows service decoration for this service.ServiceBindingOptionspreventReloading()Identifies a service for which live class reloading is not desired.ServiceBindingOptionsscope(java.lang.String scope)Sets the scope of the service, overriding theScopeannotation on the service implementation class.ServiceBindingOptionswithId(java.lang.String id)Allows a specific service id for the service to be provided, rather than the default (from the service interface).ServiceBindingOptionswithMarker(java.lang.Class<? extends java.lang.annotation.Annotation>... marker)Defines the marker interface(s) for the service, used to connect injections by type at the point of injection with a particular service implementation, based on the intersection of type and marker interface.ServiceBindingOptionswithSimpleId()Uses the the simple (unqualified) class name of the implementation class as the id of the service.
-
-
-
Constructor Detail
-
ServiceBinderImpl
public ServiceBinderImpl(ServiceDefAccumulator accumulator, java.lang.reflect.Method bindMethod, PlasticProxyFactory proxyFactory, java.util.Set<java.lang.Class> defaultMarkers, boolean moduleDefaultPreventDecoration)
-
-
Method Detail
-
finish
public void finish()
-
flush
protected void flush()
-
bind
public <T> ServiceBindingOptions bind(java.lang.Class<T> serviceClass)
Description copied from interface:ServiceBinderBinds the service interface to a conventionally named service implementation class or defines a service in terms of an implementation class, without a service interface.The conventional name for the service implementation class is the same as the name of the service interface with "Impl" appended. For example,
bind(Service.class)will implicitly attempt to bind toServiceImpl.class. UseServiceBinder.bind(Class, Class)if the name of the service implementation class does not follow the convention.In case the service is defined through the implementation class, the service will not be proxiable (proxying requires a service interface) and
ServiceDef.getServiceInterface()will return the implementation class. In this situation, the service will not be proxied; it will be instantiated fully on first reference (ignoring its scope, if any) and will not be decorated.- Specified by:
bindin interfaceServiceBinder- Parameters:
serviceClass- service interface class to bind implicitly or implementation class to instantiate as the service- Returns:
- binding options, used to specify additional details about the service
- See Also:
ServiceBinder.bind(Class, Class)
-
bind
public <T> ServiceBindingOptions bind(java.lang.Class<T> serviceInterface, ServiceBuilder<T> builder)
Description copied from interface:ServiceBinderAlternative implementation that supports a callback to build the service, rather than instantiating a particular class.- Specified by:
bindin interfaceServiceBinder- Parameters:
serviceInterface- interface implemented by the servicebuilder- constructs the core service implementation- Returns:
- binding options, used to specify additional details about the service
-
bind
public <T> ServiceBindingOptions bind(java.lang.Class<T> serviceInterface, java.lang.Class<? extends T> serviceImplementation)
Description copied from interface:ServiceBinderBinds the service interface to a service implementation class. The default service name is the unqualified name of the service interface. The default service scope is "singleton", unless the service implementation class includes theScopeannotation.The service implementation class may be omitted (in other words,
ServiceBinder.bind(Class)used instead) if the name of the service implementation class is the same as the name of the service interface with "Impl" appended.- Specified by:
bindin interfaceServiceBinder- Parameters:
serviceInterface- service interface (used when locating services, and when building proxies)serviceImplementation- implementation class that implements the service interface- Returns:
- binding options, used to specify additional details about the service
- See Also:
ServiceBinder.bind(Class)
-
eagerLoad
public ServiceBindingOptions eagerLoad()
Description copied from interface:ServiceBindingOptionsTurns eager loading on for this service. This may also be accomplished using theEagerLoadannotation on the service implementation class.- Specified by:
eagerLoadin interfaceServiceBindingOptions- Returns:
- this binding options, for further configuration
-
preventDecoration
public ServiceBindingOptions preventDecoration()
Description copied from interface:ServiceBindingOptionsDisallows service decoration for this service.- Specified by:
preventDecorationin interfaceServiceBindingOptions- Returns:
- this binding options, for further configuration
-
preventReloading
public ServiceBindingOptions preventReloading()
Description copied from interface:ServiceBindingOptionsIdentifies a service for which live class reloading is not desired. This primarily applies to certain 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.- Specified by:
preventReloadingin interfaceServiceBindingOptions
-
withId
public ServiceBindingOptions withId(java.lang.String id)
Description copied from interface:ServiceBindingOptionsAllows 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.- Specified by:
withIdin interfaceServiceBindingOptions- Returns:
- this binding options, for further configuration
-
withSimpleId
public ServiceBindingOptions withSimpleId()
Description copied from interface:ServiceBindingOptionsUses the the simple (unqualified) class name of the implementation class as the id of the service.- Specified by:
withSimpleIdin interfaceServiceBindingOptions- Returns:
- this binding options, for further configuration
-
scope
public ServiceBindingOptions scope(java.lang.String scope)
Description copied from interface:ServiceBindingOptionsSets the scope of the service, overriding theScopeannotation on the service implementation class.- Specified by:
scopein interfaceServiceBindingOptions- Returns:
- this binding options, for further configuration
- See Also:
ScopeConstants
-
withMarker
public ServiceBindingOptions withMarker(java.lang.Class<? extends java.lang.annotation.Annotation>... marker)
Description copied from interface:ServiceBindingOptionsDefines the marker interface(s) for the service, used to connect injections by type at the point of injection 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.- Specified by:
withMarkerin interfaceServiceBindingOptions- Parameters:
marker- one or more markers to add- Returns:
- this binding options, for further configuration
-
-