org.apache.tapestry5.ioc.internal
Class ServiceBinderImpl

java.lang.Object
  extended by org.apache.tapestry5.ioc.internal.ServiceBinderImpl
All Implemented Interfaces:
ServiceBinder, ServiceBindingOptions

public class ServiceBinderImpl
extends Object
implements ServiceBinder, ServiceBindingOptions


Constructor Summary
ServiceBinderImpl(ServiceDefAccumulator accumulator, Method bindMethod, PlasticProxyFactory proxyFactory, Set<Class> defaultMarkers, boolean moduleDefaultPreventDecoration)
           
 
Method Summary
<T> ServiceBindingOptions
bind(Class<T> serviceClass)
          Defines a service in terms of an implementation class, without a service interface.
<T> ServiceBindingOptions
bind(Class<T> serviceInterface, Class<? extends T> serviceImplementation)
          Binds the service interface to a service implementation class.
<T> ServiceBindingOptions
bind(Class<T> serviceInterface, ServiceBuilder<T> builder)
          Alternative implementation that supports a callback to build the service, rather than instantiating a particular class.
 ServiceBindingOptions eagerLoad()
          Turns eager loading on for this service.
 void finish()
           
protected  void flush()
           
 ServiceBindingOptions preventDecoration()
          Disallows service decoration for this service.
 ServiceBindingOptions preventReloading()
          Identifies a service for which live class reloading is not desired.
 ServiceBindingOptions scope(String scope)
          Sets the scope of the service, overriding the Scope annotation on the service implementation class.
 ServiceBindingOptions withId(String id)
          Allows a specific service id for the service to be provided, rather than the default (from the service interface).
<T extends Annotation>
ServiceBindingOptions
withMarker(Class<T>... 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.
 ServiceBindingOptions withSimpleId()
          Uses the the simple (unqualified) class name of the implementation class as the id of the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceBinderImpl

public ServiceBinderImpl(ServiceDefAccumulator accumulator,
                         Method bindMethod,
                         PlasticProxyFactory proxyFactory,
                         Set<Class> defaultMarkers,
                         boolean moduleDefaultPreventDecoration)
Method Detail

finish

public void finish()

flush

protected void flush()

bind

public <T> ServiceBindingOptions bind(Class<T> serviceClass)
Description copied from interface: ServiceBinder
Defines a service in terms of an implementation class, without a service interface. In this case, 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:
bind in interface ServiceBinder
Parameters:
serviceClass - class to instantiate as the service
Returns:
binding options, used to specify additional details about the service

bind

public <T> ServiceBindingOptions bind(Class<T> serviceInterface,
                                      ServiceBuilder<T> builder)
Description copied from interface: ServiceBinder
Alternative implementation that supports a callback to build the service, rather than instantiating a particular class.

Specified by:
bind in interface ServiceBinder
Parameters:
serviceInterface - interface implemented by the service
builder - constructs the core service implementation
Returns:
binding options, used to specify additional details about the service

bind

public <T> ServiceBindingOptions bind(Class<T> serviceInterface,
                                      Class<? extends T> serviceImplementation)
Description copied from interface: ServiceBinder
Binds 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 the Scope annotation.

Specified by:
bind in interface ServiceBinder
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

eagerLoad

public ServiceBindingOptions eagerLoad()
Description copied from interface: ServiceBindingOptions
Turns eager loading on for this service. This may also be accomplished using the EagerLoad annotation on the service implementation class.

Specified by:
eagerLoad in interface ServiceBindingOptions
Returns:
this binding options, for further configuration

preventDecoration

public ServiceBindingOptions preventDecoration()
Description copied from interface: ServiceBindingOptions
Disallows service decoration for this service.

Specified by:
preventDecoration in interface ServiceBindingOptions
Returns:
this binding options, for further configuration

preventReloading

public ServiceBindingOptions preventReloading()
Description copied from interface: ServiceBindingOptions
Identifies 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:
preventReloading in interface ServiceBindingOptions

withId

public ServiceBindingOptions withId(String id)
Description copied from 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.

Specified by:
withId in interface ServiceBindingOptions
Returns:
this binding options, for further configuration

withSimpleId

public ServiceBindingOptions withSimpleId()
Description copied from interface: ServiceBindingOptions
Uses the the simple (unqualified) class name of the implementation class as the id of the service.

Specified by:
withSimpleId in interface ServiceBindingOptions
Returns:
this binding options, for further configuration

scope

public ServiceBindingOptions scope(String scope)
Description copied from interface: ServiceBindingOptions
Sets the scope of the service, overriding the Scope annotation on the service implementation class.

Specified by:
scope in interface ServiceBindingOptions
Returns:
this binding options, for further configuration
See Also:
ScopeConstants

withMarker

public <T extends Annotation> ServiceBindingOptions withMarker(Class<T>... marker)
Description copied from interface: ServiceBindingOptions
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. 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:
withMarker in interface ServiceBindingOptions
Parameters:
marker - one or more markers to add
Returns:
this binding options, for further configuration


Copyright © 2003-2012 The Apache Software Foundation.