org.openxava.ejbx
Class EJB11Context

java.lang.Object
  extended by org.openxava.ejbx.EJB11Context
All Implemented Interfaces:
java.io.Serializable, IEJBContext, IEJBContextInit, IConnectionProvider

public class EJB11Context
extends java.lang.Object
implements IEJBContextInit, java.io.Serializable

Implementation of IEJBContext for a EJB 1.1 server.

Since EJB 1.1 standardizes enough things only it's needed one version, and it is not required additional properties files.
If you can use getConnection() without argument, you need to define in the bean a property named DATA_SOURCE that indicate the default data source.

In the DATA_SOURCE property you can put also the username and password by default, thus datasource;usuario;clave.

Author:
Javier Paniza
See Also:
Serialized Form

Constructor Summary
EJB11Context()
           
 
Method Summary
 java.security.Principal getCallerPrincipal()
          As EJBContext.getCallerPrincipal in EJB 1.1.
 java.sql.Connection getConnection()
          The connection is obtained from data source defined in DATA_SOURCE property of bean.
 java.sql.Connection getConnection(java.lang.String name)
          Returns a JDBC connection from a identifier.
 java.lang.String getProperty(java.lang.String name)
          Property value from name.
 boolean isCallerInRole(java.lang.String roleName)
          As EJBContext.isCallerInRole in EJB 1.1.
 void setDefaultDataSource(java.lang.String dataSourceName)
          Sets the datasource name used when using IConnectionProvider.getConnection().
 void setEJBContext(EJBContext ejbContext)
          Sets a EJBContext needed for implementing.
 void setPassword(java.lang.String password)
          Sets password used to create connection.
 void setUser(java.lang.String user)
          Sets the user used to craete the connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EJB11Context

public EJB11Context()
Method Detail

getCallerPrincipal

public java.security.Principal getCallerPrincipal()
Description copied from interface: IEJBContext
As EJBContext.getCallerPrincipal in EJB 1.1.

Specified by:
getCallerPrincipal in interface IEJBContext

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
The connection is obtained from data source defined in DATA_SOURCE property of bean.
Also you can specify with code the default data source calling to {#setDefaultDataSource}, this have priority over the defined in DATA_SOURCE.

Specified by:
getConnection in interface IConnectionProvider
Throws:
java.sql.SQLException - If there are problem obtaining the connetion

getConnection

public java.sql.Connection getConnection(java.lang.String name)
                                  throws java.sql.SQLException
Description copied from interface: IConnectionProvider
Returns a JDBC connection from a identifier.

Specified by:
getConnection in interface IConnectionProvider
Parameters:
name - Name of data source from what I obtain the connection
Throws:
java.sql.SQLException - If there are problem obtaining the connetion

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: IEJBContext
Property value from name.
Returns null if the property does not exist or it is not possible obtain it.
If the property exists but it does not have value then return empty string.

Specified by:
getProperty in interface IEJBContext

isCallerInRole

public boolean isCallerInRole(java.lang.String roleName)
Description copied from interface: IEJBContext
As EJBContext.isCallerInRole in EJB 1.1.

Specified by:
isCallerInRole in interface IEJBContext

setPassword

public void setPassword(java.lang.String password)
Description copied from interface: IConnectionProvider
Sets password used to create connection.

* Must to call to IConnectionProvider.setUser(java.lang.String) too. Although set user and password is not mandatory.

Specified by:
setPassword in interface IConnectionProvider

setDefaultDataSource

public void setDefaultDataSource(java.lang.String dataSourceName)
Description copied from interface: IConnectionProvider
Sets the datasource name used when using IConnectionProvider.getConnection().

Specified by:
setDefaultDataSource in interface IConnectionProvider

setEJBContext

public void setEJBContext(EJBContext ejbContext)
Description copied from interface: IEJBContextInit
Sets a EJBContext needed for implementing.
It's required call to this method so IEJBContext can be used.

Specified by:
setEJBContext in interface IEJBContextInit

setUser

public void setUser(java.lang.String user)
Description copied from interface: IConnectionProvider
Sets the user used to craete the connection.

It is not mandatory to call this method.

Specified by:
setUser in interface IConnectionProvider