Homepage

org.tinymarbles
Class RepositoryFactory

java.lang.Object
  extended by org.tinymarbles.RepositoryFactory

public class RepositoryFactory
extends Object

This class is able to create Repository instances.

Author:
duke
See Also:
Repository, open(), createDefault()

Constructor Summary
RepositoryFactory(HibernateConversationFactory factory)
          Constructs a new mFactory that will always use the given conversation locator
 
Method Summary
static RepositoryFactory createDefault()
          Creates a new mFactory using a transactional hibernate locator
protected  ProxyWrapper createPersistentWrapper(Crud crud)
          Creates a ProxyWrapper for persistent instances that uses the given Crud instance.
protected  CallbackFilter getCallbackFilter(Crud crud)
          Gets the CallbackFilter used to create the Repository proxy.
protected  Callback[] getCallbacks(Crud crud, ProxyWrapper pw)
          Gets the Callbacks used to used to create the Repository proxy.
 ConversationFactory getFactory()
          Gets the ConversationLocator instance used by this mFactory.
protected  Class[] getInterfaces(Crud crud)
          Gets all the interfaces to be implemented by the Repository proxy.
protected  Class<? extends RepositoryImplementor> getRepositoryImplementorClass()
          Returns the class that implements the repository.
protected  Crud newCrud()
          Creates a new Crud instance, using this mFactory's ConversationLocator.
 Repository open()
          Creates a new repository instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryFactory

public RepositoryFactory(HibernateConversationFactory factory)
Constructs a new mFactory that will always use the given conversation locator

Parameters:
factory - a ConversationFactory instance
Method Detail

createDefault

public static RepositoryFactory createDefault()
Creates a new mFactory using a transactional hibernate locator

Returns:
a new mFactory instance

open

public Repository open()
Creates a new repository instance. This implementation creates a new Crud and enhances the repository implementor to use a wrapping interceptor.

Returns:
a new proxy to the Repository
See Also:
getCallbacks(Crud, ProxyWrapper), getCallbackFilter(Crud), getInterfaces(Crud), getFactory()

getRepositoryImplementorClass

protected Class<? extends RepositoryImplementor> getRepositoryImplementorClass()
Returns the class that implements the repository. The current implementation returns RepositoryImpl.

Returns:
the class that is used to instantiate new repositories

newCrud

protected Crud newCrud()
Creates a new Crud instance, using this mFactory's ConversationLocator. This implementation uses a TransactionalHibernateCrud.

Returns:
a newly instantiated Crud implementation

getCallbackFilter

protected CallbackFilter getCallbackFilter(Crud crud)
Gets the CallbackFilter used to create the Repository proxy.

Parameters:
crud - The Crud instance to be used by the repository
Returns:
this implementation always returns null. Subclasses are allowed to override this, provided that they also override the callbacks
See Also:
getCallbacks(Crud, ProxyWrapper), open()

getCallbacks

protected Callback[] getCallbacks(Crud crud,
                                  ProxyWrapper pw)
Gets the Callbacks used to used to create the Repository proxy. This implementation always returns a single-element array with a WrappingInterceptor

Parameters:
crud - The Crud instance to be used by the repository
pw - TODO
Returns:
an array of Callback implementations
See Also:
DispatchingInterceptor, open()

createPersistentWrapper

protected ProxyWrapper createPersistentWrapper(Crud crud)
Creates a ProxyWrapper for persistent instances that uses the given Crud instance.

Parameters:
crud - a crud created by this repository factory
Returns:
a new ProxyWrapper

getFactory

public ConversationFactory getFactory()
Gets the ConversationLocator instance used by this mFactory.

Returns:
the locator instance

getInterfaces

protected Class[] getInterfaces(Crud crud)
Gets all the interfaces to be implemented by the Repository proxy. The current implementation returns a single-element array with the Repository interface

Parameters:
crud - The Crud instance to be used by the repository
Returns:
an array of Class objects representing interfaces.
See Also:
open()

Homepage