com.caucho.ejb.entity
Class EntityServer

java.lang.Object
  extended by com.caucho.ejb.AbstractServer
      extended by com.caucho.ejb.entity.EntityServer
All Implemented Interfaces:
EnvironmentBean

public class EntityServer
extends AbstractServer

EntityServer is a container for the instances of an entity bean.


Field Summary
 
Fields inherited from class com.caucho.ejb.AbstractServer
_component, _contextImplClass, _ejbClass, _ejbContainer, _ejbName, _handleEncoder, _handleServerId, _homeStubClass, _id, _initInject, _initProgram, _jvmClient, _loader, _local21, _localApiList, _localHome, _localHomeClass, _mappedName, _metaData, _moduleName, _primaryKeyClass, _protocolEncoderMap, _remote21, _remoteApiList, _remoteHome, _remoteHomeClass, _remoteHomeView, _remoteObjectClass, _remoteStubClass, _serviceEndpointClass, _transactionTimeout, log
 
Constructor Summary
EntityServer(EjbContainer ejbContainer)
          Creates a new EntityServer.
 
Method Summary
 void addRemoveListener(QEntityContext context)
          Adds a remove listener.
 void addUpdateListener(EntityServer listener)
          Adds an update listener.
static java.lang.IllegalStateException createGetStateException(int state)
           
protected  AbstractHandle createHandle(java.lang.Object primaryKey)
          Creates a handle for the primary key.
static java.lang.IllegalStateException createSetStateException(int state)
           
 void destroy()
          Cleans up the entity server nicely.
 boolean doLoad(long loadTime)
          Returns true if the bean should be loaded.
 java.lang.String encodeId(java.lang.Object primaryKey)
          Returns the encoded id.
 AbstractContext findByPrimaryKey(int key)
          Returns the underlying object by searching the primary key.
 AbstractContext findByPrimaryKey(java.lang.Object key)
          Returns the underlying object by searching the primary key.
 java.lang.Object findKnownObjectByPrimaryKey(int key)
          Returns the underlying object by searching the primary key.
 AbstractContext findKnownObjectByPrimaryKey(java.lang.Object key)
          Returns the underlying object by searching the primary key.
 EntityItem getAmberCacheItem(java.lang.Object key)
           
 AmberEntityHome getAmberEntityHome()
          Sets the amber entity home.
 boolean getBeanManagedPersistence()
          Gets the persistence scheme for the entity bean
 EJBHome getClientHome()
          Returns the EJBHome stub for the container
 EJBLocalHome getClientLocalHome()
          Returns the EJBLocalHome stub for the container
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(boolean isReadOnly)
          Returns a new connection.
 AbstractContext getContext(java.lang.Object key)
           
 AbstractContext getContext(java.lang.Object key, boolean forceLoad)
          Finds the remote bean by its key.
 AbstractContext getContext(java.lang.Object key, boolean forceLoad, boolean isFindEntityItem)
          Finds the remote bean by its key.
 javax.sql.DataSource getDataSource()
          Returns the server's DataSource
 EJBHome getEJBHome()
          Returns the EJBHome stub for the container
 java.lang.Object getHomeObject()
          Returns the EJBHome stub for the container
 java.lang.Class getPrimaryKeyClass()
          Gets the primary key class
 void init()
          Initializes the EntityServer, generating and compiling the skeletons if necessary.
 void invalidateCache()
          Invalidates all cache entries, forcing them to reload.
 boolean isCMP()
          Sets CMP.
 boolean isLoadLazyOnTransaction()
          Sets true if entities should be loaded lazily on transaction.
 void postCreate(java.lang.Object key, QEntityContext cxt)
          Associate the skeleton with a key.
 int randomInt(int max, int i)
          Returns a random integer for a new id
 java.lang.String randomString(int max, int i)
          Returns a random string for a new id
 void remove(java.lang.Object key)
          Remove an object.
 void removeCache(java.lang.Object key)
           
 void setAmberEntityHome(AmberEntityHome home)
          Sets the amber entity home.
 void setCMP(boolean isCMP)
          Sets CMP.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets the server's DataSource
 void setJdbcIsolation(int isolation)
           
 void setLoadLazyOnTransaction(boolean isLoadLazy)
          Sets true if entities should be loaded lazily on transaction.
 void setPrimaryKeyClass(java.lang.Class cl)
          Sets the primary key class.
 void update(java.lang.Object key)
          Updates the named entity bean
 void updateView(java.lang.Object key)
          Updates the named entity bean
 
Methods inherited from class com.caucho.ejb.AbstractServer
addClientRemoteConfig, addHandleEncoder, bindInjection, getBeanSkelClass, getClassLoader, getClientObject, getContext, getContext, getEjbClass, getEjbContainer, getEJBLocalHome, getEJBMetaData, getEJBName, getEJBObject, getHandleEncoder, getHandleEncoder, getHandleServerId, getHomeHandle, getHomeStubClass, getId, getInitProgram, getLocal21, getLocalApiList, getLocalHomeClass, getLocalObject, getLocalObject, getLocalObject, getMappedName, getModuleName, getPostConstruct, getPreDestroy, getProtocolId, getProtocolId, getRemote21, getRemoteApiList, getRemoteHomeClass, getRemoteObject, getRemoteObject, getRemoteObject, getRemoteObject21, getRemoteObjectClass, getRemoteStubClass, getServerProgram, getServiceEndpoint, getSessionContext, getTimerService, getTransaction, getTransactionManager, getTransactionTimeout, getType, getUserTransaction, hasRemoteObject, initInstance, isContainerTransaction, isDead, isLocal, isRemote, lookup, remove, setAroundInvoke, setBusinessInterface, setContainerTransaction, setContextImplClass, setEjbClass, setEJBName, setHandleEncoder, setId, setInitProgram, setLocal21, setLocalApiList, setLocalHomeClass, setMappedName, setModuleName, setPostConstruct, setPreDestroy, setRemote21, setRemoteApiList, setRemoteHomeClass, setRemoteObjectClass, setServerProgram, setServiceEndpoint, setTransactionTimeout, start, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntityServer

public EntityServer(EjbContainer ejbContainer)
Creates a new EntityServer.

Parameters:
serverId - the entity server's unique identifier
allowJVMCall - allows fast calls to the same JVM (with serialization)
config - the EJB configuration.
Method Detail

getPrimaryKeyClass

public java.lang.Class getPrimaryKeyClass()
Gets the primary key class

Overrides:
getPrimaryKeyClass in class AbstractServer

setCMP

public void setCMP(boolean isCMP)
Sets CMP.


isCMP

public boolean isCMP()
Sets CMP.


getBeanManagedPersistence

public boolean getBeanManagedPersistence()
Gets the persistence scheme for the entity bean


isLoadLazyOnTransaction

public boolean isLoadLazyOnTransaction()
Sets true if entities should be loaded lazily on transaction.


setLoadLazyOnTransaction

public void setLoadLazyOnTransaction(boolean isLoadLazy)
Sets true if entities should be loaded lazily on transaction.


setJdbcIsolation

public void setJdbcIsolation(int isolation)

doLoad

public boolean doLoad(long loadTime)
Returns true if the bean should be loaded.

Parameters:
loadTime - the time the bean was last loaded.

setAmberEntityHome

public void setAmberEntityHome(AmberEntityHome home)
Sets the amber entity home.


getAmberEntityHome

public AmberEntityHome getAmberEntityHome()
Sets the amber entity home.


invalidateCache

public void invalidateCache()
Invalidates all cache entries, forcing them to reload.

Overrides:
invalidateCache in class AbstractServer

setPrimaryKeyClass

public void setPrimaryKeyClass(java.lang.Class cl)
Sets the primary key class.


init

public void init()
          throws java.lang.Exception
Initializes the EntityServer, generating and compiling the skeletons if necessary.

Overrides:
init in class AbstractServer
Throws:
java.lang.Exception

createHandle

protected AbstractHandle createHandle(java.lang.Object primaryKey)
Creates a handle for the primary key.


encodeId

public java.lang.String encodeId(java.lang.Object primaryKey)
Returns the encoded id.

Overrides:
encodeId in class AbstractServer

postCreate

public void postCreate(java.lang.Object key,
                       QEntityContext cxt)
Associate the skeleton with a key.


addRemoveListener

public void addRemoveListener(QEntityContext context)
Adds a remove listener.

Parameters:
listener - the home context that's listening for events.
listenClass - the class for this server.

addUpdateListener

public void addUpdateListener(EntityServer listener)
Adds an update listener.


remove

public void remove(java.lang.Object key)
Remove an object.

Overrides:
remove in class AbstractServer

removeCache

public void removeCache(java.lang.Object key)

findByPrimaryKey

public AbstractContext findByPrimaryKey(java.lang.Object key)
                                 throws FinderException
Returns the underlying object by searching the primary key.

Throws:
FinderException

findByPrimaryKey

public AbstractContext findByPrimaryKey(int key)
                                 throws FinderException
Returns the underlying object by searching the primary key.

Throws:
FinderException

findKnownObjectByPrimaryKey

public AbstractContext findKnownObjectByPrimaryKey(java.lang.Object key)
Returns the underlying object by searching the primary key. In this case, the object is known to exist.


findKnownObjectByPrimaryKey

public java.lang.Object findKnownObjectByPrimaryKey(int key)
Returns the underlying object by searching the primary key. In this case, the object is known to exist.


getClientHome

public EJBHome getClientHome()
                      throws java.rmi.RemoteException
Returns the EJBHome stub for the container

Throws:
java.rmi.RemoteException

getEJBHome

public EJBHome getEJBHome()
Returns the EJBHome stub for the container

Overrides:
getEJBHome in class AbstractServer

getClientLocalHome

public EJBLocalHome getClientLocalHome()
Returns the EJBLocalHome stub for the container

Overrides:
getClientLocalHome in class AbstractServer

getHomeObject

public java.lang.Object getHomeObject()
Description copied from class: AbstractServer
Returns the EJBHome stub for the container

Overrides:
getHomeObject in class AbstractServer

getContext

public AbstractContext getContext(java.lang.Object key)
                           throws FinderException
Overrides:
getContext in class AbstractServer
Throws:
FinderException

getContext

public AbstractContext getContext(java.lang.Object key,
                                  boolean forceLoad)
                           throws FinderException
Finds the remote bean by its key.

Specified by:
getContext in class AbstractServer
Parameters:
key - the remote key
Returns:
the remote interface of the entity.
Throws:
FinderException

getContext

public AbstractContext getContext(java.lang.Object key,
                                  boolean forceLoad,
                                  boolean isFindEntityItem)
                           throws FinderException
Finds the remote bean by its key.

Parameters:
key - the remote key
Returns:
the remote interface of the entity.
Throws:
FinderException

getAmberCacheItem

public EntityItem getAmberCacheItem(java.lang.Object key)

getConnection

public java.sql.Connection getConnection(boolean isReadOnly)
                                  throws java.sql.SQLException
Returns a new connection.

Throws:
java.sql.SQLException

update

public void update(java.lang.Object key)
Updates the named entity bean


getDataSource

public javax.sql.DataSource getDataSource()
Returns the server's DataSource


setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Sets the server's DataSource


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

updateView

public void updateView(java.lang.Object key)
Updates the named entity bean


randomString

public java.lang.String randomString(int max,
                                     int i)
Returns a random string for a new id

Parameters:
max - the previous maximum value
i - the repetition index

randomInt

public int randomInt(int max,
                     int i)
Returns a random integer for a new id

Parameters:
max - the previous maximum value
i - the repetition index

createGetStateException

public static java.lang.IllegalStateException createGetStateException(int state)

createSetStateException

public static java.lang.IllegalStateException createSetStateException(int state)

destroy

public void destroy()
Cleans up the entity server nicely.

Overrides:
destroy in class AbstractServer