org.granite.tide.seam.lazy
Class SeamInitializer

java.lang.Object
  extended by org.granite.tide.seam.lazy.SeamInitializer
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SeamHibernateInitializer

@Name(value="org.granite.tide.seam.seamInitializer")
@Scope(value=CONVERSATION)
@Install(precedence=10)
@BypassInterceptors
public class SeamInitializer
extends Object
implements Serializable

Initializes a request for a passed in entity and a lazy property.

Author:
CIngram,VDanda
See Also:
Serialized Form

Constructor Summary
SeamInitializer()
           
 
Method Summary
protected  EntityManager findEntityManager()
          Try to find the entityManager if possible.
 org.granite.tide.TidePersistenceManager getTidePersistenceManager()
           
static SeamInitializer instance()
           
 Object lazyInitialize(Object entity, String[] propertyNames)
          Initiliazes the property for the passed in entity.
 void restoreLoadedEntities()
           
 void saveLoadedEntities()
           
 void setTidePersistenceManager(org.granite.tide.TidePersistenceManager pm)
           
protected  org.granite.tide.TidePersistenceManager tryToDetermineInitiailzer()
          Try to determine what type of persistence the application is using.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeamInitializer

public SeamInitializer()
Method Detail

lazyInitialize

@Transactional
public Object lazyInitialize(Object entity,
                                           String[] propertyNames)
Initiliazes the property for the passed in entity. It is attached to an associated context and then the property is accessed.

Returns:
Returns result from initializing the property.

tryToDetermineInitiailzer

protected org.granite.tide.TidePersistenceManager tryToDetermineInitiailzer()
Try to determine what type of persistence the application is using. If the EntityManager is stored under entityManager or if the Hibernate session is stored under session. Then the context will be found and used. This is only called if a ITidePersistenceManager is not found, probably because the query was not run in a conversation.

Returns:
The appropriate manager for the persistence context being used, if it can be determined otherwise a null is returned.

findEntityManager

protected EntityManager findEntityManager()
Try to find the entityManager if possible. Assume that the entityManager is stored under entityManager.

Returns:
The Current Entity manager

instance

public static SeamInitializer instance()
Returns:
A instance of this component for the conversation.

setTidePersistenceManager

public void setTidePersistenceManager(org.granite.tide.TidePersistenceManager pm)

getTidePersistenceManager

public org.granite.tide.TidePersistenceManager getTidePersistenceManager()

restoreLoadedEntities

public void restoreLoadedEntities()

saveLoadedEntities

public void saveLoadedEntities()