org.objectweb.speedo.mim.lib
Class AbstractHomeImpl

java.lang.Object
  extended by org.objectweb.speedo.mim.lib.AbstractHomeImpl
All Implemented Interfaces:
org.objectweb.jorm.api.PClassMapping, org.objectweb.jorm.util.api.Loggable, HomeItf, UserCacheManager
Direct Known Subclasses:
AbstractGenClassHome, EJBAbstractHomeImpl, JDOAbstractHomeImpl

public abstract class AbstractHomeImpl
extends java.lang.Object
implements HomeItf

Author:
S.Chassande-Barrioz

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.objectweb.jorm.api.PClassMapping
org.objectweb.jorm.api.PClassMapping.ReferenceConfigurator
 
Field Summary
protected  java.util.Map namedQueries
           
protected  Personality personality
           
protected  POManagerFactoryItf pmf
           
protected  TransactionalPersistenceManager tpm
           
protected  UserCache[] userCaches
           
 
Fields inherited from interface org.objectweb.speedo.mim.api.HomeItf
ALL, CACHED, FIXED, NO_CACHE, POST_ATTACH, POST_CLEAR, POST_CREATE, POST_DELETE, POST_DETACH, POST_DIRTY, POST_LOAD, POST_NEW, POST_REMOVE, POST_UPDATE, PRE_ATTACH, PRE_CLEAR, PRE_CREATE, PRE_DELETE, PRE_DETACH, PRE_DIRTY, PRE_NEW, PRE_REMOVE, PRE_UPDATE
 
Fields inherited from interface org.objectweb.jorm.api.PClassMapping
CLEANUP_DONOTHING, CLEANUP_REMOVEALL, CLEANUP_REMOVEDATA, CREATE_STRUCTURE_IF_NEEDED
 
Constructor Summary
AbstractHomeImpl(Personality p)
           
AbstractHomeImpl(TransactionalPersistenceManager _tpm, POManagerFactoryItf _pmf)
           
 
Method Summary
 boolean activeUserCache(java.lang.String cacheName)
          This method is implemented by the generated XXXHome class
 QueryDefinition addNamedQuery(java.lang.String name, QueryDefinition query)
          Defines a named query
protected  UserCache addUserCache(java.lang.String userCacheName, java.lang.String[] fields, int id)
           
 boolean allLoaded()
           
 void attachCopy(PersistentObjectItf sp, POManagerItf pm, java.util.Map map, java.lang.Object clone, StateItf sa)
           
 PersistentObjectItf detachCopy(PersistentObjectItf sp, POManagerItf pm, java.util.Map map, java.lang.Object clone, java.util.Collection fgHints)
           
 java.util.Collection fgGetFieldsToLoad(java.lang.String fgName)
          This default implementation does nothing and returns null.
 java.util.Collection fgGetFieldsToLoad(java.lang.String fgName, boolean onlyDirectRef)
           
 java.util.Collection fgGetNestedFetchGroups(java.lang.String fgName)
          This default implementation does nothing and returns null.
 boolean fgIsDefined(java.lang.String fgName)
          This default implementation returns always false.
 java.util.Collection getActiveUserCache()
          Retrieves the list of user cache which has been initialized.
 java.lang.Class getClassForQuery(java.lang.String className, java.lang.String queryName)
           
 QueryDefinition getNamedQuery(java.lang.String name)
          Retrieves a query defintion from its name.
 java.lang.String getPath()
           
 POManagerFactoryItf getPOManagerFactory()
           
 boolean getPrefetchOnExtent()
           
 boolean getPrefetchOnGenClass()
           
 boolean getPrefetchOnQuery()
           
 StateItf getState(PersistentObjectItf sp)
          It retrieves the StateItf instance used in the current context.
 TransactionalPersistenceManager getTransactionalPersistenceManager()
           
 UserCache getUserCache(java.util.Collection fieldNames)
          Retrieves the name of the user cache which index is exactly composed by some field names.
 UserCache getUserCache(int cacheId)
          Retrives a user cache
 boolean hasToFix()
           
 void initSH()
           
protected  boolean isAbstract()
           
 boolean isCacheable()
          Indicates if the state of persistent instance managed by this home, are kept between two transaction.
 boolean isFieldLockingLevel()
          Indicates if the locking level must be the field.
 boolean isShareable()
           
protected  PersistentObjectItf newSpeedoPOInstance(java.lang.Class clazz)
          Create a new instance of a PersistentObjectItf which the clas is given in parameter.
 StateItf readIntention(PersistentObjectItf sp, long[] fields)
          Notifies the transactional persistency manager of a read intention for the given persistent instance.
 QueryDefinition removeNamedQuery(java.lang.String name)
          Remove a named query
 void setCachePolicy(byte v)
          Permit to Indicate if the state of persistent instance managed by this home, are kept between two transaction.
 void setFieldLockingLevel(boolean val)
          Permits to Indicate if the locking level must be the field.
 void setPOManagerFactory(POManagerFactoryItf _pmf)
          It assignes a PersistenceManagerFactory
 void setPrefetchOnExtent(boolean prefetch)
          Indicates if the prefetching must be activated on extents when they return instance corresponding to this home.
 void setPrefetchOnGenClass(boolean prefetch)
          Indicates if the prefetching must be activated genclass loading.
 void setPrefetchOnQuery(boolean prefetch)
          Indicates if the prefetching must be activated on queries when they return instance corresponding to this home.
 void setShareable(boolean v)
           
 void setTransactionalPersistenceManager(TransactionalPersistenceManager _tpm)
          It assignes a TransactionalPersistenceManager
 void userCacheEntryUnbound(java.lang.Object oid)
          An entry of user cache has been unbound from the real cache.
 StateItf writeIntention(PersistentObjectItf sp, long[] fields)
           
 StateItf writeIntention(PersistentObjectItf sp, long[] fields, java.lang.Object thinLock)
          Notifies the transactional persistency manager of a write intention for the given persistent instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.speedo.mim.api.HomeItf
addInstanceLifeCycleListener, getClassProperties, getProjectName, getVersioningStrategy, hasInstanceLifeCycleListeners, isDetachable, removeInstanceLifeCycleListener, sendEvent
 
Methods inherited from interface org.objectweb.jorm.api.PClassMapping
addAssociation, classDefined, configureRefFields, createPBinding, exist, getAssociationTable, getClassName, getClassPNameCoder, getDecodedPName, getGenClassMapping, getGenClassMapping, getIndexesTable, getMetaInfo, getPBinder, getPMapper, getPNameCoder, getPNameCoder, getPNameIterator, getPNameIterator, getPType, getSubPCMs, init, init, isConform, match, read, read, read, resolve, setPBinder, write
 
Methods inherited from interface org.objectweb.jorm.util.api.Loggable
getLogger, getLoggerFactory, setLogger, setLoggerFactory
 

Field Detail

tpm

protected TransactionalPersistenceManager tpm

pmf

protected POManagerFactoryItf pmf

namedQueries

protected java.util.Map namedQueries

personality

protected Personality personality

userCaches

protected UserCache[] userCaches
Constructor Detail

AbstractHomeImpl

public AbstractHomeImpl(Personality p)

AbstractHomeImpl

public AbstractHomeImpl(TransactionalPersistenceManager _tpm,
                        POManagerFactoryItf _pmf)
Method Detail

isAbstract

protected boolean isAbstract()
Returns:
false because it corresponds to most of case Subclass to change the behavior

newSpeedoPOInstance

protected PersistentObjectItf newSpeedoPOInstance(java.lang.Class clazz)
                                           throws java.lang.Exception
Create a new instance of a PersistentObjectItf which the clas is given in parameter. The default implementation does a simple 'clazz.newInstance()'.

Throws:
java.lang.Exception

isCacheable

public boolean isCacheable()
Description copied from interface: HomeItf
Indicates if the state of persistent instance managed by this home, are kept between two transaction.

Specified by:
isCacheable in interface HomeItf
Returns:
true means the state is kept between transaction.

allLoaded

public boolean allLoaded()
Specified by:
allLoaded in interface HomeItf

hasToFix

public boolean hasToFix()
Specified by:
hasToFix in interface HomeItf

setCachePolicy

public void setCachePolicy(byte v)
Description copied from interface: HomeItf
Permit to Indicate if the state of persistent instance managed by this home, are kept between two transaction.

Specified by:
setCachePolicy in interface HomeItf

isShareable

public boolean isShareable()
Specified by:
isShareable in interface HomeItf

setShareable

public void setShareable(boolean v)
Specified by:
setShareable in interface HomeItf

isFieldLockingLevel

public boolean isFieldLockingLevel()
Description copied from interface: HomeItf
Indicates if the locking level must be the field. A false value (default) means the locking level has to be done at instance level.

Specified by:
isFieldLockingLevel in interface HomeItf

setFieldLockingLevel

public void setFieldLockingLevel(boolean val)
Description copied from interface: HomeItf
Permits to Indicate if the locking level must be the field. A false value (default) means the locking level has to be done at instance level.

Specified by:
setFieldLockingLevel in interface HomeItf

fgGetNestedFetchGroups

public java.util.Collection fgGetNestedFetchGroups(java.lang.String fgName)
This default implementation does nothing and returns null. Subclass to change the behavior


fgIsDefined

public boolean fgIsDefined(java.lang.String fgName)
This default implementation returns always false. Subclass to change the behavior


fgGetFieldsToLoad

public java.util.Collection fgGetFieldsToLoad(java.lang.String fgName)
This default implementation does nothing and returns null. Subclass to change the behavior


getPOManagerFactory

public final POManagerFactoryItf getPOManagerFactory()
Specified by:
getPOManagerFactory in interface HomeItf
Returns:
the PersistenceManagerFactory which represents the data support inside which the po is persistent.

setPOManagerFactory

public final void setPOManagerFactory(POManagerFactoryItf _pmf)
It assignes a PersistenceManagerFactory

Specified by:
setPOManagerFactory in interface HomeItf
Parameters:
_pmf - is the PersistenceManagerFactory which represents the data support inside which the po is persistent.

getTransactionalPersistenceManager

public final TransactionalPersistenceManager getTransactionalPersistenceManager()
Specified by:
getTransactionalPersistenceManager in interface HomeItf
Returns:
the TransactionalPersistenceManager which manage the concurrency, loading, ... of the po.

setTransactionalPersistenceManager

public final void setTransactionalPersistenceManager(TransactionalPersistenceManager _tpm)
It assignes a TransactionalPersistenceManager

Specified by:
setTransactionalPersistenceManager in interface HomeItf
Parameters:
_tpm - is the TransactionalPersistenceManager which manage the concurrency, loading, ... of the po.

readIntention

public final StateItf readIntention(PersistentObjectItf sp,
                                    long[] fields)
Notifies the transactional persistency manager of a read intention for the given persistent instance.

Specified by:
readIntention in interface HomeItf
Parameters:
sp - is the PersistentObjectItf which the read access is requested.
fields - the ids of the fields that may be accessed by the caller of this method. If the i-th bit of 'fields' is set to 1, then the i-th field of the given speedo accessor may be accessed by the caller of this method.

writeIntention

public final StateItf writeIntention(PersistentObjectItf sp,
                                     long[] fields)
Specified by:
writeIntention in interface HomeItf

writeIntention

public StateItf writeIntention(PersistentObjectItf sp,
                               long[] fields,
                               java.lang.Object thinLock)
Notifies the transactional persistency manager of a write intention for the given persistent instance.

Specified by:
writeIntention in interface HomeItf
Parameters:
sp - is the PersistentObjectItf which the write access is requested.
fields - the ids of the fields that may be accessed by the caller of this method. If the i-th bit of 'fields' is set to 1, then the i-th field of the given speedo accessor may be accessed by the caller of this method.
thinLock - permits to allocate a lock on only a part of the resource. The locking size is thinner than a lock on the persistent object entirely. This parameter can be typically used to lock at the field or the genclass element levels.

getState

public final StateItf getState(PersistentObjectItf sp)
It retrieves the StateItf instance used in the current context. If the po is not active then the reference accessor is returned. If there is an active then the $classNameFields used in the context is returned. Be careul, if the persistent object is not used in the current context, then a null value will be returned, because no StateItf is registered in the working set.

Specified by:
getState in interface HomeItf

detachCopy

public final PersistentObjectItf detachCopy(PersistentObjectItf sp,
                                            POManagerItf pm,
                                            java.util.Map map,
                                            java.lang.Object clone,
                                            java.util.Collection fgHints)
Specified by:
detachCopy in interface HomeItf

attachCopy

public final void attachCopy(PersistentObjectItf sp,
                             POManagerItf pm,
                             java.util.Map map,
                             java.lang.Object clone,
                             StateItf sa)
Specified by:
attachCopy in interface HomeItf

fgGetFieldsToLoad

public final java.util.Collection fgGetFieldsToLoad(java.lang.String fgName,
                                                    boolean onlyDirectRef)

setPrefetchOnExtent

public void setPrefetchOnExtent(boolean prefetch)
Description copied from interface: HomeItf
Indicates if the prefetching must be activated on extents when they return instance corresponding to this home.

Specified by:
setPrefetchOnExtent in interface HomeItf

getPrefetchOnExtent

public boolean getPrefetchOnExtent()
Specified by:
getPrefetchOnExtent in interface HomeItf

setPrefetchOnGenClass

public void setPrefetchOnGenClass(boolean prefetch)
Description copied from interface: HomeItf
Indicates if the prefetching must be activated genclass loading. This method is only applicable for gen class home.

Specified by:
setPrefetchOnGenClass in interface HomeItf

getPrefetchOnGenClass

public boolean getPrefetchOnGenClass()
Specified by:
getPrefetchOnGenClass in interface HomeItf

setPrefetchOnQuery

public void setPrefetchOnQuery(boolean prefetch)
Description copied from interface: HomeItf
Indicates if the prefetching must be activated on queries when they return instance corresponding to this home.

Specified by:
setPrefetchOnQuery in interface HomeItf

getPrefetchOnQuery

public boolean getPrefetchOnQuery()
Specified by:
getPrefetchOnQuery in interface HomeItf

initSH

public void initSH()
Specified by:
initSH in interface HomeItf

getClassForQuery

public java.lang.Class getClassForQuery(java.lang.String className,
                                        java.lang.String queryName)

addNamedQuery

public final QueryDefinition addNamedQuery(java.lang.String name,
                                           QueryDefinition query)
Description copied from interface: HomeItf
Defines a named query

Specified by:
addNamedQuery in interface HomeItf
Parameters:
name - is the name identifying the query
query - is the definition of the query
Returns:
the old query definition corresponding to the name, if it existed one.

removeNamedQuery

public final QueryDefinition removeNamedQuery(java.lang.String name)
Description copied from interface: HomeItf
Remove a named query

Specified by:
removeNamedQuery in interface HomeItf
Parameters:
name - is the name of the query definition to remove
Returns:
the removed query definition (null if not found)

getNamedQuery

public final QueryDefinition getNamedQuery(java.lang.String name)
Description copied from interface: HomeItf
Retrieves a query defintion from its name. If the name is not known, the null value is returned.

Specified by:
getNamedQuery in interface HomeItf
Parameters:
name - is the name the wanted query definition

getPath

public java.lang.String getPath()
Specified by:
getPath in interface HomeItf

addUserCache

protected UserCache addUserCache(java.lang.String userCacheName,
                                 java.lang.String[] fields,
                                 int id)

activeUserCache

public boolean activeUserCache(java.lang.String cacheName)
This method is implemented by the generated XXXHome class

Specified by:
activeUserCache in interface UserCacheManager
Parameters:
cacheName - is the name of the user cache to initialize
Returns:
indicates if the cache has been initialized correctly

getUserCache

public UserCache getUserCache(int cacheId)
Description copied from interface: UserCacheManager
Retrives a user cache

Specified by:
getUserCache in interface UserCacheManager
Parameters:
cacheId - is the identifier of the asked user cache
Returns:
the user cache instance if found, null otherwise

getUserCache

public UserCache getUserCache(java.util.Collection fieldNames)
Description copied from interface: UserCacheManager
Retrieves the name of the user cache which index is exactly composed by some field names.

Specified by:
getUserCache in interface UserCacheManager
Parameters:
fieldNames - is the collection of field names (String). The order of the collection is not important here.
Returns:
an user cache name if it has been found, null otherwise.

getActiveUserCache

public java.util.Collection getActiveUserCache()
Description copied from interface: UserCacheManager
Retrieves the list of user cache which has been initialized.

Specified by:
getActiveUserCache in interface UserCacheManager
Returns:
a collection of UserCache instance

userCacheEntryUnbound

public void userCacheEntryUnbound(java.lang.Object oid)
Description copied from interface: UserCacheManager
An entry of user cache has been unbound from the real cache. A typical implementation, undinds from active user caches, the entry. To do this the a persistent object which has been previously unexported.

Specified by:
userCacheEntryUnbound in interface UserCacheManager
Parameters:
oid - is the identifier of the persistent object to unbind