use of org.apache.openejb.client.serializer.EJBDSerializer in project tomee by apache.
the class EjbRequestHandler method doEjbObject_BUSINESS_METHOD.
protected void doEjbObject_BUSINESS_METHOD(final EJBRequest req, final EJBResponse res) throws Exception {
final CallContext call = CallContext.getCallContext();
final BeanContext beanContext = call.getBeanContext();
final boolean asynchronous = beanContext.isAsynchronous(req.getMethodInstance());
try {
if (asynchronous) {
final AtomicBoolean invocationCancelTag = new AtomicBoolean(false);
ThreadContext.initAsynchronousCancelled(invocationCancelTag);
asynchronousInvocationCancelMap.put(req.getBody().getRequestId(), invocationCancelTag);
}
final RpcContainer c = (RpcContainer) call.getBeanContext().getContainer();
// Object result = c.invoke(req.getDeploymentId(),
// req.getInterfaceClass(), req.getMethodInstance(),
// req.getMethodParameters(),
// req.getPrimaryKey()
// );
final EJBDSerializer serializer = daemon.getSerializer();
if (serializer != null) {
req.setSerializer(serializer);
}
Object result = c.invoke(req.getDeploymentId(), InterfaceType.EJB_OBJECT, req.getInterfaceClass(), req.getMethodInstance(), req.getMethodParameters(), req.getPrimaryKey());
//Pass the internal value to the remote client, as AsyncResult is not serializable
if (result != null && asynchronous) {
result = ((Future) result).get();
}
final Object realResult;
if (serializer != null && result != null) {
realResult = new SerializationWrapper(serializer.serialize(result), result.getClass().getName());
} else {
realResult = result;
}
res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, realResult);
} finally {
if (asynchronous) {
ThreadContext.removeAsynchronousCancelled();
asynchronousInvocationCancelMap.remove(req.getBody().getRequestId());
}
}
}
Aggregations