| Method from org.jboss.ejb.plugins.CMPPersistenceManager Detail: |
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException {
// Create a new CacheKey
Object id = ctx.getId();
Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id);
// Give it to the context
ctx.setCacheKey(cacheKey);
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE);
EntityBean eb = (EntityBean) ctx.getInstance();
eb.ejbActivate();
}
catch(Exception e)
{
if(e instanceof RemoteException)
{
// Rethrow exception
throw (RemoteException) e;
}
else if(e instanceof EJBException)
{
// Rethrow exception
throw (EJBException) e;
}
else
{
// Wrap runtime exceptions
throw new EJBException((Exception) e);
}
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
// The implementation of the call can be left absolutely empty, the
// propagation of the call is just a notification for stores that would
// need to know that an instance is being activated
store.activateEntity(ctx);
}
|
public void create() throws Exception {
if(con.getHomeClass() != null)
{
Method[] methods = con.getHomeClass().getMethods();
createMethodCache(methods);
}
if(con.getLocalHomeClass() != null)
{
Method[] methods = con.getLocalHomeClass().getMethods();
createMethodCache(methods);
}
insertAfterEjbPostCreate = con.getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate();
store.create();
}
|
public Object createBeanClassInstance() throws Exception {
return store.createBeanClassInstance();
}
Returns a new instance of the bean class or a subclass of the bean class. |
public void createEntity(Method m,
Object[] args,
EntityEnterpriseContext ctx) throws Exception {
// Deligate initialization of bean to persistence store
store.initEntity(ctx);
// Call ejbCreate on the target bean
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE);
Method createMethod = (Method) createMethods.get(m);
createMethod.invoke(ctx.getInstance(), args);
}
catch(IllegalAccessException e)
{
// Throw this as a bean exception...(?)
throw new EJBException(e);
}
catch(InvocationTargetException ite)
{
Throwable e = ite.getTargetException();
if(e instanceof EJBException)
{
// Rethrow exception
throw (EJBException) e;
}
else if(e instanceof RuntimeException)
{
// Wrap runtime exceptions
throw new EJBException((Exception) e);
}
else if(e instanceof Exception)
{
// Remote, Create, or custom app. exception
throw (Exception) e;
}
else
{
throw (Error) e;
}
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
// if insertAfterEjbPostCreate == true, this will INSERT entity
// otherwise, primary key is extracted from the context and returned
Object id;
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE);
id = store.createEntity(m, args, ctx);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
// Set the key on the target context
ctx.setId(id);
// Create a new CacheKey
Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id);
// Give it to the context
ctx.setCacheKey(cacheKey);
}
|
public void destroy() {
store.destroy();
}
|
public Collection findEntities(Method finderMethod,
Object[] args,
EntityEnterpriseContext ctx,
GenericEntityObjectFactory factory) throws Exception {
try
{
// return the finderResults so that the invoker layer can extend this back
// giving the client an OO 'cursor'
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND);
return store.findEntities(finderMethod, args, ctx, factory);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
}
|
public Object findEntity(Method finderMethod,
Object[] args,
EntityEnterpriseContext ctx,
GenericEntityObjectFactory factory) throws Exception {
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND);
return store.findEntity(finderMethod, args, ctx, factory);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
}
|
public EntityPersistenceStore getPersistenceStore() {
return store;
}
Gets the entity persistence store. |
public void invokeEjbStore(EntityEnterpriseContext ctx) throws RemoteException {
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE);
try
{
// if call-ejb-store-for-clean=true then invoke ejbStore first (the last chance to modify the instance)
if(ejbStoreForClean)
{
ejbStore(ctx);
}
else
{
// else check whether the instance is dirty and invoke ejbStore only if it is really dirty
boolean modified = false;
try
{
modified = isStoreRequired(ctx);
}
catch(Exception e)
{
throwRemoteException(e);
}
if(modified)
{
ejbStore(ctx);
}
}
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
}
|
protected void invokeLoad(EntityEnterpriseContext ctx) throws RemoteException {
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_LOAD);
EntityBean eb = (EntityBean) ctx.getInstance();
eb.ejbLoad();
}
catch(Exception e)
{
throwRemoteException(e);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
}
|
public boolean isModified(EntityEnterpriseContext ctx) throws Exception {
return store.isModified(ctx);
}
|
public boolean isStoreRequired(EntityEnterpriseContext ctx) throws Exception {
return store.isStoreRequired(ctx);
}
|
public void loadEntity(EntityEnterpriseContext ctx) throws RemoteException {
//long lStart = System.currentTimeMillis();
// Have the store load the fields of the instance
store.loadEntity(ctx);
//mLoad.add( System.currentTimeMillis() - lStart );
invokeLoad(ctx);
}
|
public void passivateEntity(EntityEnterpriseContext ctx) throws RemoteException {
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE);
EntityBean eb = (EntityBean) ctx.getInstance();
eb.ejbPassivate();
}
catch(Exception e)
{
throwRemoteException(e);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
store.passivateEntity(ctx);
ctx.setEJBObject(null);
ctx.setEJBLocalObject(null);
}
|
public void postCreateEntity(Method m,
Object[] args,
EntityEnterpriseContext ctx) throws Exception {
// this call should go first as it sets up relationships
// for fk fields mapped to pk fields
store.postCreateEntity(m, args, ctx);
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE);
Method postCreateMethod = (Method) postCreateMethods.get(m);
postCreateMethod.invoke(ctx.getInstance(), args);
if(insertAfterEjbPostCreate)
{
store.createEntity(m, args, ctx);
}
}
catch(IllegalAccessException e)
{
// Throw this as a bean exception...(?)
throw new EJBException(e);
}
catch(InvocationTargetException ite)
{
Throwable e = ite.getTargetException();
if(e instanceof EJBException)
{
// Rethrow exception
throw (EJBException) e;
}
else if(e instanceof RuntimeException)
{
// Wrap runtime exceptions
throw new EJBException((Exception) e);
}
else if(e instanceof Exception)
{
// Remote, Create, or custom app. exception
throw (Exception) e;
}
else
{
throw (Error) e;
}
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
}
|
public void removeEntity(EntityEnterpriseContext ctx) throws RemoveException, RemoteException {
try
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE);
EntityBean eb = (EntityBean) ctx.getInstance();
eb.ejbRemove();
}
catch(Exception e)
{
if(e instanceof RemoveException)
{
// Rethrow exception
throw (RemoveException) e;
}
else
{
throwRemoteException(e);
}
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
store.removeEntity(ctx);
}
|
public void setContainer(Container c) {
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
con = (EntityContainer) c;
if(store != null)
{
store.setContainer(c);
}
if(con != null)
{
ConfigurationMetaData configuration = con.getBeanMetaData().getContainerConfiguration();
ejbStoreForClean = configuration.isEjbStoreForClean();
}
}
|
public void setPersistenceStore(EntityPersistenceStore store) {
this.store = store;
//Give it the container
if(con != null) store.setContainer(con);
}
|
public void start() throws Exception {
store.start();
}
|
public void stop() {
store.stop();
}
|
public void storeEntity(EntityEnterpriseContext ctx) throws RemoteException {
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE);
try
{
store.storeEntity(ctx);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
}
|