for (int i = 0; i < parameters.length; ++i) {
parameters[i] = clone(method.getParameterTypes()[i], parameterCloner, invocation.getParameters()[i], allowPassByReference);
}
}
final InterceptorContext context = new InterceptorContext();
context.setParameters(parameters);
context.setMethod(method);
context.setTarget(invocation.getInvokedProxy());
context.setContextData(new HashMap<String, Object>());
context.putPrivateData(Component.class, ejbComponent);
context.putPrivateData(ComponentView.class, view);
if (locator instanceof StatefulEJBLocator) {
final SessionID sessionID = ((StatefulEJBLocator) locator).getSessionId();
context.putPrivateData(SessionID.SESSION_ID_KEY, sessionID);
} else if (locator instanceof EntityEJBLocator) {
final Object primaryKey = ((EntityEJBLocator) locator).getPrimaryKey();
context.putPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, primaryKey);
}
final ClonerConfiguration config = new ClonerConfiguration();
config.setClassCloner(new ClassLoaderClassCloner(invocation.getInvokedProxy().getClass().getClassLoader()));
final ObjectCloner resultCloner = ObjectCloners.getSerializingObjectClonerFactory().createCloner(config);
if (async) {
if (ejbComponent instanceof SessionBeanComponent) {
final SessionBeanComponent component = (SessionBeanComponent) ejbComponent;
final CancellationFlag flag = new CancellationFlag();
final AsyncInvocationTask task = new AsyncInvocationTask(flag) {
@Override
protected Object runInvocation() throws Exception {
return view.invoke(context);
}
};
context.putPrivateData(CancellationFlag.class, flag);
component.getAsynchronousExecutor().submit(task);
//TODO: we do not clone the result of an async task
//TODO: we do not clone the exception of an async task
receiverContext.resultReady(new ImmediateResultProducer(task));
} else {