org.objectweb.speedo.mim.lib
Class SpeedoHomeImpl

java.lang.Object
  extended byorg.objectweb.speedo.mim.lib.SpeedoHomeImpl
All Implemented Interfaces:
SpeedoHome
Direct Known Subclasses:
SpeedoGenClassHome

public abstract class SpeedoHomeImpl
extends java.lang.Object
implements SpeedoHome

Author:
S.Chassande-Barrioz

Field Summary
protected  java.util.Map namedQueries
           
protected  ProxyManagerFactory pmf
           
protected  TransactionalPersistenceManager tpm
           
 
Constructor Summary
SpeedoHomeImpl()
           
SpeedoHomeImpl(TransactionalPersistenceManager _tpm, ProxyManagerFactory _pmf)
           
 
Method Summary
 QueryDefinition addNamedQuery(java.lang.String name, QueryDefinition query)
          Defines a named query
 void attachCopy(SpeedoProxy sp, ProxyManager pm, java.util.Map map, java.lang.Object clone, SpeedoAccessor sa, boolean makeTransactional)
           
 SpeedoProxy detachCopy(SpeedoProxy sp, ProxyManager 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.lang.Class getClassForQuery(java.lang.String className, java.lang.String queryName)
           
 QueryDefinition getNamedQuery(java.lang.String name)
          Retrieves a query defintion from its name.
 ProxyManagerFactory getProxyManagerFactory()
           
 SpeedoAccessor getSpeedoAccessor(SpeedoProxy sp)
          It retrieves the SpeedoAccessor instance used in the current context.
 TransactionalPersistenceManager getTransactionalPersistenceManager()
           
 void initSH()
           
protected  boolean isAbstract()
           
 boolean isCacheable()
          Indicates if the state of persistent instance managed by this home, are kept between two transaction.
protected  SpeedoProxy newSpeedoProxyInstance(java.lang.Class clazz)
          Create a new instance of a SpeedoProxy which the clas is given in parameter.
 SpeedoAccessor readIntention(SpeedoProxy 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 setCacheable(boolean v)
          Permit to Indicate if the state of persistent instance managed by this home, are kept between two transaction.
 void setProxyManagerFactory(ProxyManagerFactory _pmf)
          It assignes a PersistenceManagerFactory
 void setTransactionalPersistenceManager(TransactionalPersistenceManager _tpm)
          It assignes a TransactionalPersistenceManager
 SpeedoAccessor writeIntention(SpeedoProxy sp, long[] fields)
          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.SpeedoHome
getClassProperties, getProjectName, getVersioningStrategy, isDetachable
 

Field Detail

tpm

protected TransactionalPersistenceManager tpm

pmf

protected ProxyManagerFactory pmf

namedQueries

protected java.util.Map namedQueries
Constructor Detail

SpeedoHomeImpl

public SpeedoHomeImpl()

SpeedoHomeImpl

public SpeedoHomeImpl(TransactionalPersistenceManager _tpm,
                      ProxyManagerFactory _pmf)
Method Detail

isAbstract

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

newSpeedoProxyInstance

protected SpeedoProxy newSpeedoProxyInstance(java.lang.Class clazz)
                                      throws java.lang.Exception
Create a new instance of a SpeedoProxy 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: SpeedoHome
Indicates if the state of persistent instance managed by this home, are kept between two transaction.

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

setCacheable

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

Specified by:
setCacheable in interface SpeedoHome

fgGetNestedFetchGroups

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

Specified by:
fgGetNestedFetchGroups in interface SpeedoHome

fgIsDefined

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

Specified by:
fgIsDefined in interface SpeedoHome
Parameters:
fgName - is a fetch group name
Returns:
true is the fetch group is defined, otherwise false.

fgGetFieldsToLoad

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

Specified by:
fgGetFieldsToLoad in interface SpeedoHome

getProxyManagerFactory

public final ProxyManagerFactory getProxyManagerFactory()
Specified by:
getProxyManagerFactory in interface SpeedoHome
Returns:
the PersistenceManagerFactory which represents the data support inside which the proxy is persistent.

setProxyManagerFactory

public final void setProxyManagerFactory(ProxyManagerFactory _pmf)
It assignes a PersistenceManagerFactory

Specified by:
setProxyManagerFactory in interface SpeedoHome
Parameters:
_pmf - is the PersistenceManagerFactory which represents the data support inside which the proxy is persistent.

getTransactionalPersistenceManager

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

setTransactionalPersistenceManager

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

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

readIntention

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

Specified by:
readIntention in interface SpeedoHome
Parameters:
sp - is the SpeedoProxy 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 SpeedoAccessor writeIntention(SpeedoProxy sp,
                                           long[] fields)
Notifies the transactional persistency manager of a write intention for the given persistent instance.

Specified by:
writeIntention in interface SpeedoHome
Parameters:
sp - is the SpeedoProxy 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.

getSpeedoAccessor

public final SpeedoAccessor getSpeedoAccessor(SpeedoProxy sp)
It retrieves the SpeedoAccessor instance used in the current context. If the proxy 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 SpeedoAccessor is registered in the working set.

Specified by:
getSpeedoAccessor in interface SpeedoHome

detachCopy

public final SpeedoProxy detachCopy(SpeedoProxy sp,
                                    ProxyManager pm,
                                    java.util.Map map,
                                    java.lang.Object clone,
                                    java.util.Collection fgHints)
Specified by:
detachCopy in interface SpeedoHome

attachCopy

public final void attachCopy(SpeedoProxy sp,
                             ProxyManager pm,
                             java.util.Map map,
                             java.lang.Object clone,
                             SpeedoAccessor sa,
                             boolean makeTransactional)
Specified by:
attachCopy in interface SpeedoHome

fgGetFieldsToLoad

public final java.util.Collection fgGetFieldsToLoad(java.lang.String fgName,
                                                    boolean onlyDirectRef)
Specified by:
fgGetFieldsToLoad in interface SpeedoHome

initSH

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

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: SpeedoHome
Defines a named query

Specified by:
addNamedQuery in interface SpeedoHome
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: SpeedoHome
Remove a named query

Specified by:
removeNamedQuery in interface SpeedoHome
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: SpeedoHome
Retrieves a query defintion from its name. If the name is not known, the null value is returned.

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