use of org.apache.openejb.core.ivm.EjbObjectInputStream in project tomee by apache.
the class CrossClassLoaderJndiReference method copy.
private static Object copy(final Object source) throws Exception {
IntraVmCopyMonitor.preCrossClassLoaderOperation();
try {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(source);
out.close();
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream in = new EjbObjectInputStream(bais);
return in.readObject();
} finally {
IntraVmCopyMonitor.postCrossClassLoaderOperation();
}
}
use of org.apache.openejb.core.ivm.EjbObjectInputStream in project tomee by apache.
the class SimplePassivater method activate.
@Override
public Object activate(final Object primaryKey) throws SystemException {
try {
final String filename = primaryKey.toString().replace(':', '=');
final File sessionFile = new File(sessionDirectory, filename);
if (sessionFile.exists()) {
logger.info("Activating from file " + sessionFile);
try (final InputStream source = IO.read(sessionFile);
final ObjectInputStream ois = new EjbObjectInputStream(source)) {
return ois.readObject();
} finally {
if (!sessionFile.delete()) {
sessionFile.deleteOnExit();
}
}
} else {
logger.info("Activation failed: file not found " + sessionFile);
return null;
}
} catch (final Exception t) {
logger.info("Activation failed ", t);
throw new SystemException(t);
}
}
use of org.apache.openejb.core.ivm.EjbObjectInputStream in project tomee by apache.
the class EjbFactory method copy.
private static Object copy(final Object source) throws Exception {
IntraVmCopyMonitor.preCrossClassLoaderOperation();
try {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(source);
out.close();
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream in = new EjbObjectInputStream(bais);
final Object copy = in.readObject();
return copy;
} finally {
IntraVmCopyMonitor.postCrossClassLoaderOperation();
}
}
use of org.apache.openejb.core.ivm.EjbObjectInputStream in project tomee by apache.
the class CrossClassLoaderProxyTest method copy.
private static Object copy(final Object source) throws Exception {
IntraVmCopyMonitor.preCrossClassLoaderOperation();
try {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(source);
out.close();
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream in = new EjbObjectInputStream(bais);
final Object copy = in.readObject();
return copy;
} finally {
IntraVmCopyMonitor.postCrossClassLoaderOperation();
}
}
Aggregations