use of org.apache.openejb.SystemException in project tomee by apache.
the class PoolEndpointHandler method afterDelivery.
public void afterDelivery() throws ApplicationServerInternalException, UnavailableException {
// verify current state
switch(state) {
case RELEASED:
throw new IllegalStateException("Message endpoint factory has been released");
case NONE:
throw new IllegalStateException("afterDelivery may only be called if message delivery began with a beforeDelivery call");
}
// call afterDelivery on the container
try {
container.afterDelivery(instance);
} catch (final SystemException se) {
final Throwable throwable = se.getRootCause() != null ? se.getRootCause() : se;
throw new ApplicationServerInternalException(throwable);
} finally {
// we are now in the default NONE state
state = State.NONE;
this.instance = null;
}
}
use of org.apache.openejb.SystemException in project tomee by apache.
the class RAFPassivater method activate.
@Override
public synchronized Object activate(final Object primaryKey) throws SystemException {
final Pointer pointer = (Pointer) masterTable.get(primaryKey);
if (pointer == null) {
return null;
}
try (final RandomAccessFile ras = new RandomAccessFile(JavaSecurityManagers.getSystemProperty("java.io.tmpdir", File.separator + "tmp") + File.separator + "passivation" + pointer.fileid + ".ser", "r")) {
final byte[] bytes = new byte[pointer.bytesize];
ras.seek(pointer.filepointer);
ras.readFully(bytes);
return Serializer.deserialize(bytes);
} catch (final Exception e) {
throw new SystemException(e);
}
}
use of org.apache.openejb.SystemException in project tomee by apache.
the class SimplePassivater method passivate.
public void passivate(final Object primaryKey, final Object state) throws SystemException {
try {
final String filename = primaryKey.toString().replace(':', '=');
final File sessionFile = new File(sessionDirectory, filename);
logger.info("Passivating to file " + sessionFile);
try (final OutputStream os = IO.write(sessionFile);
final ObjectOutputStream oos = new ObjectOutputStream(os)) {
// passivate just the bean instance
oos.writeObject(state);
} finally {
sessionFile.deleteOnExit();
}
} catch (final NotSerializableException nse) {
logger.error("Passivation failed ", nse);
throw (SystemException) new SystemException("The type " + nse.getMessage() + " is not serializable as mandated by the EJB specification.").initCause(nse);
} catch (final Exception t) {
logger.error("Passivation failed ", t);
throw new SystemException(t);
}
}
use of org.apache.openejb.SystemException in project tomee by apache.
the class LocalClientRunner method createDeployment.
private BeanContext createDeployment(final Class<?> testClass) {
try {
final AppContext appContext = new AppContext("", SystemInstance.get(), testClass.getClassLoader(), new IvmContext(), new IvmContext(), false);
final ModuleContext moduleContext = new ModuleContext("", null, "", appContext, new IvmContext(), null);
return new BeanContext(null, new IvmContext(), moduleContext, testClass, null, null, null, null, null, null, null, null, null, BeanType.MANAGED, false, false);
} catch (final SystemException e) {
throw new IllegalStateException(e);
}
}
use of org.apache.openejb.SystemException in project tomee by apache.
the class StatefulContainer method afterInvoke.
private void afterInvoke(final ThreadContext callContext, final TransactionPolicy txPolicy, final Instance instance) throws OpenEJBException {
try {
if (instance != null && txPolicy instanceof BeanTransactionPolicy) {
// suspend the currently running transaction if any
SuspendedTransaction suspendedTransaction = null;
try {
final BeanTransactionPolicy beanTxEnv = (BeanTransactionPolicy) txPolicy;
suspendedTransaction = beanTxEnv.suspendUserTransaction();
} catch (final SystemException e) {
EjbTransactionUtil.handleSystemException(txPolicy, e, callContext);
} finally {
instance.setBeanTransaction(suspendedTransaction);
}
}
} finally {
if (instance != null) {
instance.setInUse(false);
}
EjbTransactionUtil.afterInvoke(txPolicy, callContext);
if (instance != null) {
instance.releaseLock();
}
}
}
Aggregations