org.openxava.ejbx
Class EJBBase

java.lang.Object
  extended by org.openxava.ejbx.EJBBase
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
EntityBase, SessionBase

public class EJBBase
extends java.lang.Object
implements java.io.Serializable

Base class for a EJB.

Of course, the use of this class is optional, but it provides a lot of advantages.
Basically it have methods that wrap the access to IEJBContext, creating it and wrap the exceptions in EJBException format.
Important: It's required call to setEJBContext(EJBContext) with a not null value before use any method of this class.

Author:
Javier Paniza
See Also:
Serialized Form

Constructor Summary
EJBBase()
           
 
Method Summary
 java.security.Principal getCallerPrincipal()
          As EJBContext.getCallerPrincipal in EJB 1.1.
 java.sql.Connection getConnection()
          Default JDBC connection.
 java.sql.Connection getConnection(java.lang.String dataSourceName)
          A JDBC connection from identifier name.
 IContext getContext()
          Context used for look up homes of EJBs.
protected  IEJBContext getPortableContext()
          The context used for implementing the methods.
 java.lang.String getProperty(java.lang.String nombre)
          Property value from name.
 boolean isCallerInRole(java.lang.String roleName)
          As EJBContext.isCallerInRole in EJB 1.1.
protected  boolean isTrue(java.lang.String variable, java.lang.String bean)
          Examine a environment variable that can contain true or false (ignoring case).
 void setDefaultDataSource(java.lang.String nombreDataSource)
          Sets the name of datasource used when call to getConnection().
protected  void setEJBContext(EJBContext ejbContext)
          Sets the subcontext used to implement the methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EJBBase

public EJBBase()
Method Detail

getCallerPrincipal

public java.security.Principal getCallerPrincipal()
As EJBContext.getCallerPrincipal in EJB 1.1.


getConnection

public java.sql.Connection getConnection()
Default JDBC connection.


getConnection

public java.sql.Connection getConnection(java.lang.String dataSourceName)
A JDBC connection from identifier name.

Parameters:
dataSourceName - Name of data source from obtain the connection.

getContext

public IContext getContext()
Context used for look up homes of EJBs.

The look up is direct without using standards subcontext like java:comp/env/ejb. Of course, you can use subcontext for qualifying way.


getPortableContext

protected IEJBContext getPortableContext()
The context used for implementing the methods.


getProperty

public java.lang.String getProperty(java.lang.String nombre)
Property value from name.
Return null if the property does not exist or it can not obtain its value for another problem.


isCallerInRole

public boolean isCallerInRole(java.lang.String roleName)
As EJBContext.isCallerInRole in EJB 1.1.


isTrue

protected boolean isTrue(java.lang.String variable,
                         java.lang.String bean)
Examine a environment variable that can contain true or false (ignoring case).

Parameters:
variable - Name of environment variable to examine.
bean - Name of current bean, used in error messages.
Returns:
boolean true o false.
Throws:
EJBException - If the variable is not defined.

setDefaultDataSource

public void setDefaultDataSource(java.lang.String nombreDataSource)
Sets the name of datasource used when call to getConnection().


setEJBContext

protected void setEJBContext(EJBContext ejbContext)
Sets the subcontext used to implement the methods.
It'r required call to this method sending not null before use any other method of this class.
You can send null, in this case the context is disabled, it's good call to setEJBContext(null) when the EJB Server call to unsetEntityContext().