use of javax.ejb.EJBException in project tomee by apache.
the class BasicBmp2DataSourcesBean method ejbRemove.
/**
* A container invokes this method before it removes the EJB object
* that is currently associated with the instance. This method
* is invoked when a client invokes a remove operation on the
* enterprise Bean's home interface or the EJB object's remote interface.
* This method transitions the instance from the ready state to the pool
* of available instances.
*/
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
try {
final InitialContext jndiContext = new InitialContext();
final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/basic/entityDatabase");
final Connection con = ds.getConnection();
try {
final PreparedStatement stmt = con.prepareStatement("delete from entity where id = ?");
try {
final Integer primaryKey = (Integer) ejbContext.getPrimaryKey();
stmt.setInt(1, primaryKey.intValue());
stmt.executeUpdate();
} finally {
stmt.close();
}
} finally {
con.close();
}
} catch (final Exception e) {
e.printStackTrace();
throw new javax.ejb.EJBException(e);
}
}
use of javax.ejb.EJBException in project tomee by apache.
the class RmiIiopCmp2Bean method returnEJBMetaData.
public EJBMetaData returnEJBMetaData() {
EJBMetaData data = null;
try {
final InitialContext ctx = new InitialContext();
final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
data = home.getEJBMetaData();
} catch (final Exception e) {
throw new EJBException(e);
}
return data;
}
use of javax.ejb.EJBException in project tomee by apache.
the class RmiIiopCmp2Bean method returnEJBObject.
public EJBObject returnEJBObject() {
EncCmpObject data = null;
try {
final InitialContext ctx = new InitialContext();
final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
data = home.create("Test01 CmpBean");
} catch (final Exception e) {
throw new EJBException(e);
}
return data;
}
use of javax.ejb.EJBException in project tomee by apache.
the class RmiIiopCmp2Bean method returnEJBHome.
public EJBHome returnEJBHome() {
EJBHome data = null;
try {
final InitialContext ctx = new InitialContext();
data = (EJBHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
} catch (final Exception e) {
e.printStackTrace();
throw new EJBException(e);
}
return data;
}
use of javax.ejb.EJBException in project tomee by apache.
the class RmiIiopCmp2Bean method returnNestedEJBMetaData.
public ObjectGraph returnNestedEJBMetaData() {
ObjectGraph data = null;
try {
final InitialContext ctx = new InitialContext();
final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
final EJBMetaData object = home.getEJBMetaData();
data = new ObjectGraph(object);
} catch (final Exception e) {
throw new EJBException(e);
}
return data;
}
Aggregations