com.caucho.ejb
Class AbstractServer

java.lang.Object
  extended by com.caucho.ejb.AbstractServer
All Implemented Interfaces:
EnvironmentBean
Direct Known Subclasses:
MessageServer, SessionServer

public abstract class AbstractServer
extends java.lang.Object
implements EnvironmentBean

Base server for a single home/object bean pair.


Field Summary
protected  ComponentImpl _component
           
protected  java.lang.Class _contextImplClass
           
protected  javax.sql.DataSource _dataSource
           
protected  ConfigProgram[] _destroyInject
           
protected  java.lang.Class _ejbClass
           
protected  EjbContainer _ejbContainer
           
protected  java.lang.String _ejbName
           
protected  java.lang.String _filename
           
protected  HandleEncoder _handleEncoder
           
protected  java.lang.String _handleServerId
           
protected  HomeHandle _homeHandle
           
protected  java.lang.Class _homeStubClass
           
protected  java.lang.String _id
           
protected  ConfigProgram[] _initInject
           
protected  ConfigProgram _initProgram
           
protected  int _line
           
protected  EnvironmentClassLoader _loader
           
protected  java.lang.Class _local21
           
protected  java.util.ArrayList<java.lang.Class> _localApiList
           
protected  EJBLocalHome _localHome
           
protected  java.lang.Class _localHomeClass
           
protected  java.lang.String _location
           
protected  java.lang.String _mappedName
           
protected  EJBMetaDataImpl _metaData
           
protected  java.lang.String _moduleName
           
protected  java.lang.Class _primaryKeyClass
           
protected  java.util.HashMap<java.lang.String,HandleEncoder> _protocolEncoderMap
           
protected  java.lang.Class _remote21
           
protected  java.util.ArrayList<java.lang.Class> _remoteApiList
           
protected  EJBHome _remoteHome
           
protected  java.lang.Class _remoteHomeClass
           
protected  EJBHome _remoteHomeView
           
protected  java.lang.Class _remoteObjectClass
           
protected  java.lang.Class _remoteStubClass
           
protected  java.lang.Class _serviceEndpointClass
           
protected  long _transactionTimeout
           
protected  UserTransaction _ut
           
 
Constructor Summary
AbstractServer(EjbContainer container)
          Creates a new server container
 
Method Summary
 void addClientRemoteConfig(java.lang.StringBuilder sb)
          Client information for connecting to the server.
 HandleEncoder addHandleEncoder(java.lang.String protocol, java.lang.String serverId)
           
protected  void bindContext()
           
protected  void bindInjection()
           
 void destroy()
          Cleans up the server on shutdown
 void destroyInstance(java.lang.Object instance)
          Remove an object.
 java.lang.String encodeId(java.lang.Object primaryKey)
          Returns the encoded id.
 ConfigException error(java.lang.String msg)
           
 java.lang.Class getBeanSkelClass()
          Gets the generated skeleton class
 DynamicClassLoader getClassLoader()
          Gets the class loader
 AbstractContext getContext()
           
 AbstractContext getContext(long key)
           
 AbstractContext getContext(java.lang.Object key)
           
abstract  AbstractContext getContext(java.lang.Object key, boolean forceLoad)
          Returns the context with the given key
protected  java.lang.Class getEjbClass()
          Sets the ejb class
 EjbContainer getEjbContainer()
          Returns the owning container.
 EJBHome getEJBHome()
          Returns the EJBHome stub for the container
 EJBLocalHome getEJBLocalHome()
          Returns the EJBLocalHome stub for the container
 EJBMetaData getEJBMetaData()
          Returns the meta data
 java.lang.String getEJBName()
          Returns the ejb's name
 EJBObject getEJBObject(java.lang.Object key)
           
 HandleEncoder getHandleEncoder()
           
 HandleEncoder getHandleEncoder(java.lang.String protocol)
           
 java.lang.String getHandleServerId()
           
 HomeHandle getHomeHandle()
          Returns the home handle for the container
 java.lang.Class getHomeStubClass()
           
 java.lang.String getId()
          Returns the id, module-path#ejb-name.
 ConfigProgram getInitProgram()
          Gets the init program.
 java.util.ArrayList<java.lang.Class> getLocalApiList()
          Sets the remote object class.
 java.lang.Class getLocalHomeClass()
          Gets the local home class.
abstract  java.lang.Object getLocalObject(java.lang.Class api)
          Returns the a new local stub for the given API
abstract  java.lang.Object getLocalProxy(java.lang.Class api)
          Returns the local jndi proxy for the given API
 java.lang.String getMappedName()
          Returns the mapped name.
 java.lang.String getModuleName()
          Returns's the module that defined this ejb.
 PostConstructConfig getPostConstruct()
           
 PreDestroyConfig getPreDestroy()
           
 java.lang.Class getPrimaryKeyClass()
          Returns the object key from a handle.
 java.lang.String getProtocolId()
          The name to use for remoting protocols, such as IIOP and Hessian.
 java.lang.String getProtocolId(java.lang.Class cl)
          The name to use for remoting protocols, such as IIOP and Hessian.
 java.lang.Class getRemote21()
          Gets the 2.1 remote interface.
 java.util.ArrayList<java.lang.Class> getRemoteApiList()
          Returns the remote object list.
 java.lang.Class getRemoteHomeClass()
          Gets the remote home class.
abstract  java.lang.Object getRemoteObject(java.lang.Class api, java.lang.String protocol)
          Returns the remote skeleton for the given API
 java.lang.Object getRemoteObject(java.lang.Object key)
          Returns the remote object.
 java.lang.Class getRemoteObjectClass()
          Gets the remote object class.
 java.lang.Class getRemoteStubClass()
           
 ConfigProgram getServerProgram()
          Sets the server program.
 java.lang.Class getServiceEndpoint()
          Gets the service endpoint
 AbstractSessionContext getSessionContext()
          Returns the session context.
 TimerService getTimerService()
          Returns the timer service.
 long getTransactionTimeout()
          Gets the transaction timeout.
protected  java.lang.String getType()
           
 UserTransaction getUserTransaction()
           
 boolean hasRemoteObject()
          Returns true if there is any remote object.
 void init()
           
 void initInstance(java.lang.Object instance)
          Initialize an instance
 void initInstance(java.lang.Object instance, ConfigContext env)
          Initialize an instance
protected  void introspectDestroy(java.util.ArrayList<ConfigProgram> injectList, java.lang.Class ejbClass)
           
 void invalidateCache()
          Invalidates caches.
 boolean isContainerTransaction()
          Returns true if container transaction is used.
 boolean isDead()
          Returns true if the server is dead.
 boolean isLocal()
          Returns true is there is a local home or local client object for the bean.
 boolean isRemote()
          Returns true is there is a remote home or remote client object for the bean.
 java.lang.Object lookup(java.lang.String jndiName)
          Looks up the JNDI object.
 java.lang.Object remove(AbstractHandle handle)
          Remove an object.
 void remove(java.lang.Object primaryKey)
          Remove an object.
 void setAroundInvoke(AroundInvokeConfig aroundInvoke)
           
 void setConfigLocation(java.lang.String filename, int line)
           
 void setContainerTransaction(boolean isContainerTransaction)
          Sets true if container transaction is used.
 void setContextImplClass(java.lang.Class cl)
          Sets the context implementation class.
 void setEjbClass(java.lang.Class cl)
          Sets the ejb class
 void setEJBName(java.lang.String ejbName)
          Sets the ejb name.
 void setHandleEncoder(HandleEncoder encoder)
           
 void setId(java.lang.String id)
          Sets the id, module-path#ejb-name.
 void setInitProgram(ConfigProgram init)
          Sets the init program.
 void setLocalApiList(java.util.ArrayList<java.lang.Class> list)
          Sets the local api class list
 void setLocalHomeClass(java.lang.Class cl)
          Sets the local home class.
 void setLocation(java.lang.String location)
           
 void setMappedName(java.lang.String mappedName)
          Sets the mapped name, default is to use the EJBName.
 void setModuleName(java.lang.String moduleName)
          Set's the module that defined this ejb.
 void setPostConstruct(PostConstructConfig postConstruct)
           
 void setPreDestroy(PreDestroyConfig preDestroy)
           
 void setRemoteApiList(java.util.ArrayList<java.lang.Class> list)
          Sets the remote object list.
 void setRemoteHomeClass(java.lang.Class cl)
          Sets the remote home class.
 void setRemoteObjectClass(java.lang.Class cl)
          Sets the remote object class.
 void setServerProgram(ConfigProgram serverProgram)
          Sets the server program.
 void setServiceEndpoint(java.lang.Class cl)
          Sets the service endpoint.
 void setTransactionTimeout(long timeout)
          Sets the transaction timeout.
 boolean start()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_ejbContainer

protected final EjbContainer _ejbContainer

_ut

protected final UserTransaction _ut

_filename

protected java.lang.String _filename

_line

protected int _line

_location

protected java.lang.String _location

_id

protected java.lang.String _id

_ejbName

protected java.lang.String _ejbName

_moduleName

protected java.lang.String _moduleName

_handleServerId

protected java.lang.String _handleServerId

_mappedName

protected java.lang.String _mappedName

_protocolEncoderMap

protected java.util.HashMap<java.lang.String,HandleEncoder> _protocolEncoderMap

_handleEncoder

protected HandleEncoder _handleEncoder

_dataSource

protected javax.sql.DataSource _dataSource

_loader

protected EnvironmentClassLoader _loader

_ejbClass

protected java.lang.Class _ejbClass

_contextImplClass

protected java.lang.Class _contextImplClass

_local21

protected java.lang.Class _local21

_remote21

protected java.lang.Class _remote21

_remoteHomeClass

protected java.lang.Class _remoteHomeClass

_remoteObjectClass

protected java.lang.Class _remoteObjectClass

_remoteApiList

protected java.util.ArrayList<java.lang.Class> _remoteApiList

_primaryKeyClass

protected java.lang.Class _primaryKeyClass

_localHomeClass

protected java.lang.Class _localHomeClass

_localApiList

protected java.util.ArrayList<java.lang.Class> _localApiList

_remoteStubClass

protected java.lang.Class _remoteStubClass

_homeStubClass

protected java.lang.Class _homeStubClass

_homeHandle

protected HomeHandle _homeHandle

_remoteHome

protected EJBHome _remoteHome

_remoteHomeView

protected EJBHome _remoteHomeView

_localHome

protected EJBLocalHome _localHome

_metaData

protected EJBMetaDataImpl _metaData

_serviceEndpointClass

protected java.lang.Class _serviceEndpointClass

_transactionTimeout

protected long _transactionTimeout

_component

protected ComponentImpl _component

_initProgram

protected ConfigProgram _initProgram

_initInject

protected ConfigProgram[] _initInject

_destroyInject

protected ConfigProgram[] _destroyInject
Constructor Detail

AbstractServer

public AbstractServer(EjbContainer container)
Creates a new server container

Parameters:
manager - the owning server container
Method Detail

getId

public java.lang.String getId()
Returns the id, module-path#ejb-name.


setId

public void setId(java.lang.String id)
Sets the id, module-path#ejb-name.


setConfigLocation

public void setConfigLocation(java.lang.String filename,
                              int line)

setLocation

public void setLocation(java.lang.String location)

getType

protected java.lang.String getType()

setAroundInvoke

public void setAroundInvoke(AroundInvokeConfig aroundInvoke)

setEJBName

public void setEJBName(java.lang.String ejbName)
Sets the ejb name.


getEJBName

public java.lang.String getEJBName()
Returns the ejb's name


setModuleName

public void setModuleName(java.lang.String moduleName)
Set's the module that defined this ejb.


getModuleName

public java.lang.String getModuleName()
Returns's the module that defined this ejb.


setMappedName

public void setMappedName(java.lang.String mappedName)
Sets the mapped name, default is to use the EJBName. This is the name for both JNDI and the protocols such as IIOP and Hessian.


getMappedName

public java.lang.String getMappedName()
Returns the mapped name.


getProtocolId

public java.lang.String getProtocolId()
The name to use for remoting protocols, such as IIOP and Hessian.


getProtocolId

public java.lang.String getProtocolId(java.lang.Class cl)
The name to use for remoting protocols, such as IIOP and Hessian.


setEjbClass

public void setEjbClass(java.lang.Class cl)
Sets the ejb class


getEjbClass

protected java.lang.Class getEjbClass()
Sets the ejb class


setContextImplClass

public void setContextImplClass(java.lang.Class cl)
Sets the context implementation class.


setRemoteHomeClass

public void setRemoteHomeClass(java.lang.Class cl)
Sets the remote home class.


getRemoteHomeClass

public java.lang.Class getRemoteHomeClass()
Gets the remote home class.


getRemote21

public java.lang.Class getRemote21()
Gets the 2.1 remote interface.


setRemoteApiList

public void setRemoteApiList(java.util.ArrayList<java.lang.Class> list)
Sets the remote object list.


getRemoteApiList

public java.util.ArrayList<java.lang.Class> getRemoteApiList()
Returns the remote object list.


hasRemoteObject

public boolean hasRemoteObject()
Returns true if there is any remote object.


setRemoteObjectClass

public void setRemoteObjectClass(java.lang.Class cl)
Sets the remote object class.


getRemoteObjectClass

public java.lang.Class getRemoteObjectClass()
Gets the remote object class.


setLocalHomeClass

public void setLocalHomeClass(java.lang.Class cl)
Sets the local home class.


getLocalHomeClass

public java.lang.Class getLocalHomeClass()
Gets the local home class.


setServiceEndpoint

public void setServiceEndpoint(java.lang.Class cl)
Sets the service endpoint.


getServiceEndpoint

public java.lang.Class getServiceEndpoint()
Gets the service endpoint


setLocalApiList

public void setLocalApiList(java.util.ArrayList<java.lang.Class> list)
Sets the local api class list


getLocalApiList

public java.util.ArrayList<java.lang.Class> getLocalApiList()
Sets the remote object class.


getHandleEncoder

public HandleEncoder getHandleEncoder(java.lang.String protocol)

encodeId

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


addHandleEncoder

public HandleEncoder addHandleEncoder(java.lang.String protocol,
                                      java.lang.String serverId)

getHandleEncoder

public HandleEncoder getHandleEncoder()

setHandleEncoder

public void setHandleEncoder(HandleEncoder encoder)

getHandleServerId

public java.lang.String getHandleServerId()

lookup

public java.lang.Object lookup(java.lang.String jndiName)
Looks up the JNDI object.


getUserTransaction

public UserTransaction getUserTransaction()

getEjbContainer

public EjbContainer getEjbContainer()
Returns the owning container.


setServerProgram

public void setServerProgram(ConfigProgram serverProgram)
Sets the server program.


getServerProgram

public ConfigProgram getServerProgram()
Sets the server program.


setTransactionTimeout

public void setTransactionTimeout(long timeout)
Sets the transaction timeout.


getTransactionTimeout

public long getTransactionTimeout()
Gets the transaction timeout.


getTimerService

public TimerService getTimerService()
Returns the timer service.


invalidateCache

public void invalidateCache()
Invalidates caches.


remove

public java.lang.Object remove(AbstractHandle handle)
Remove an object.


remove

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


getClassLoader

public DynamicClassLoader getClassLoader()
Gets the class loader

Specified by:
getClassLoader in interface EnvironmentBean

getBeanSkelClass

public java.lang.Class getBeanSkelClass()
Gets the generated skeleton class


getRemoteStubClass

public java.lang.Class getRemoteStubClass()

getHomeStubClass

public java.lang.Class getHomeStubClass()

getEJBMetaData

public EJBMetaData getEJBMetaData()
Returns the meta data


getHomeHandle

public HomeHandle getHomeHandle()
Returns the home handle for the container


getEJBHome

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


getSessionContext

public AbstractSessionContext getSessionContext()
Returns the session context.


getEJBLocalHome

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


getRemoteObject

public abstract java.lang.Object getRemoteObject(java.lang.Class api,
                                                 java.lang.String protocol)
Returns the remote skeleton for the given API

Parameters:
api - the bean's api to return a value for
protocol - the remote protocol

getLocalObject

public abstract java.lang.Object getLocalObject(java.lang.Class api)
Returns the a new local stub for the given API

Parameters:
api - the bean's api to return a value for

getLocalProxy

public abstract java.lang.Object getLocalProxy(java.lang.Class api)
Returns the local jndi proxy for the given API

Parameters:
api - the bean's api to return a value for

getPrimaryKeyClass

public java.lang.Class getPrimaryKeyClass()
Returns the object key from a handle.


getEJBObject

public EJBObject getEJBObject(java.lang.Object key)
                       throws FinderException
Throws:
FinderException

getRemoteObject

public java.lang.Object getRemoteObject(java.lang.Object key)
                                 throws FinderException
Returns the remote object.

Throws:
FinderException

getContext

public AbstractContext getContext()

getContext

public AbstractContext getContext(java.lang.Object key)
                           throws FinderException
Throws:
FinderException

getContext

public AbstractContext getContext(long key)
                           throws FinderException
Throws:
FinderException

getContext

public abstract AbstractContext getContext(java.lang.Object key,
                                           boolean forceLoad)
                                    throws FinderException
Returns the context with the given key

Throws:
FinderException

setInitProgram

public void setInitProgram(ConfigProgram init)
Sets the init program.


getInitProgram

public ConfigProgram getInitProgram()
Gets the init program.


initInstance

public void initInstance(java.lang.Object instance)
Initialize an instance


initInstance

public void initInstance(java.lang.Object instance,
                         ConfigContext env)
Initialize an instance


destroyInstance

public void destroyInstance(java.lang.Object instance)
Remove an object.


init

public void init()
          throws java.lang.Exception
Throws:
java.lang.Exception

start

public boolean start()
              throws java.lang.Exception
Throws:
java.lang.Exception

bindContext

protected void bindContext()

bindInjection

protected void bindInjection()

introspectDestroy

protected void introspectDestroy(java.util.ArrayList<ConfigProgram> injectList,
                                 java.lang.Class ejbClass)

isContainerTransaction

public boolean isContainerTransaction()
Returns true if container transaction is used.


setContainerTransaction

public void setContainerTransaction(boolean isContainerTransaction)
Sets true if container transaction is used.


isLocal

public boolean isLocal()
Returns true is there is a local home or local client object for the bean.


isRemote

public boolean isRemote()
Returns true is there is a remote home or remote client object for the bean.


isDead

public boolean isDead()
Returns true if the server is dead.


destroy

public void destroy()
Cleans up the server on shutdown


getPostConstruct

public PostConstructConfig getPostConstruct()

getPreDestroy

public PreDestroyConfig getPreDestroy()

setPostConstruct

public void setPostConstruct(PostConstructConfig postConstruct)

setPreDestroy

public void setPreDestroy(PreDestroyConfig preDestroy)

addClientRemoteConfig

public void addClientRemoteConfig(java.lang.StringBuilder sb)
Client information for connecting to the server.


error

public ConfigException error(java.lang.String msg)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object