com.wideplay.warp.persist.spi
Class AbstractPersistenceModule

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by com.wideplay.warp.persist.spi.AbstractPersistenceModule
All Implemented Interfaces:
com.google.inject.Module, PersistenceModule

public abstract class AbstractPersistenceModule
extends com.google.inject.AbstractModule
implements PersistenceModule

Base module for persistence strategies that holds a bunch of utility methods for easier configuration.


Constructor Summary
protected AbstractPersistenceModule(PersistenceConfiguration configuration, Class<? extends Annotation> unitAnnotation)
           
 
Method Summary
protected  void bindFinderInterceptor(MethodInterceptor finderInterceptor)
          Binds a finder interceptor with support for multiple modules.
protected  void bindTransactionalDynamicAccessors(MethodInterceptor finderInterceptor, MethodInterceptor txInterceptor)
          Binds the finder and transaction interceptor for use with Dynamic Accessors.
protected  void bindTransactionInterceptor(MethodInterceptor txInterceptor)
          Bind the transaction interceptor.
protected
<T> com.google.inject.binder.LinkedBindingBuilder<T>
bindWithUnitAnnotation(Class<T> tClass)
          Bind with an optional unit annotation type, which is a binding annotation used only in multimodules mode and specified in the constructor of this class.
protected abstract  void configure()
          To be implemented by subclasses.
protected  boolean inMultiModulesMode()
           
protected
<T> com.google.inject.Key<T>
keyWithUnitAnnotation(Class<T> clazz)
          Generates a key for the given class, with an optional unit annotation (multimodules mode).
protected  boolean unitOfWorkRequest()
           
 
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindScope, configure, convertToTypes, currentStage, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.wideplay.warp.persist.spi.PersistenceModule
visit
 
Methods inherited from interface com.google.inject.Module
configure
 

Constructor Detail

AbstractPersistenceModule

protected AbstractPersistenceModule(PersistenceConfiguration configuration,
                                    Class<? extends Annotation> unitAnnotation)
Parameters:
configuration - the non-null PersistenceConfiguration obtained from PersistenceStrategy.getBindings(PersistenceConfiguration).
unitAnnotation - the unit annotation or null if there is none
Method Detail

configure

protected abstract void configure()
To be implemented by subclasses.

Specified by:
configure in class com.google.inject.AbstractModule
See Also:
AbstractModule.configure()

bindWithUnitAnnotation

protected <T> com.google.inject.binder.LinkedBindingBuilder<T> bindWithUnitAnnotation(Class<T> tClass)
Bind with an optional unit annotation type, which is a binding annotation used only in multimodules mode and specified in the constructor of this class.

Parameters:
tClass - the type to bind
Returns:
the next step in the binding builder

bindTransactionalDynamicAccessors

protected void bindTransactionalDynamicAccessors(MethodInterceptor finderInterceptor,
                                                 MethodInterceptor txInterceptor)
Binds the finder and transaction interceptor for use with Dynamic Accessors. The transaction interceptor will use the same matchers used for regular transactions.

Parameters:
finderInterceptor - the finder interceptor to bind for dynamic accessors
txInterceptor - the transaction interceptor to use for transactional dynamic accessors

bindTransactionInterceptor

protected void bindTransactionInterceptor(MethodInterceptor txInterceptor)
Bind the transaction interceptor.

Parameters:
txInterceptor - the transaction interceptor to bind

bindFinderInterceptor

protected void bindFinderInterceptor(MethodInterceptor finderInterceptor)
Binds a finder interceptor with support for multiple modules. When the user specifies an annotation to bind the module to, we match on @Finder(unit=UserAnnotation.class).

Parameters:
finderInterceptor - the finder interceptor to bind

inMultiModulesMode

protected boolean inMultiModulesMode()
Returns:
whether we're in multimodules mode or not

unitOfWorkRequest

protected boolean unitOfWorkRequest()
Returns:
whether the UnitOfWork.REQUEST was configured or not

keyWithUnitAnnotation

protected <T> com.google.inject.Key<T> keyWithUnitAnnotation(Class<T> clazz)
Generates a key for the given class, with an optional unit annotation (multimodules mode).

Type Parameters:
T - the bound type
Parameters:
clazz - the type to bind
Returns:
the generated key