new Component(FooBar.class, appContext) );
final Foo foo = new Foo();
final FooBar fooBar = new FooBar();
final BijectionInterceptor bi = new BijectionInterceptor();
bi.setComponent( new Component(FooBar.class, appContext) );
final Method m = FooBar.class.getMethod("delayedGetFoo", InvocationControl.class);
final InvocationControl invocationAControl = new InvocationControl("A");
final InvocationControl invocationBControl = new InvocationControl("B");
final InvocationControl invocationCControl = new InvocationControl("C");
final Map<String, Foo> invocationResults = new HashMap<String, Foo>();
final InvocationContext invocationA = new MockInvocationContext() {
@Override public Object getTarget() { return fooBar; }
@Override public Method getMethod() { return m; }
@Override public Object[] getParameters() { return new Object[] { invocationAControl }; }
@Override public Object proceed() throws Exception { return Reflections.invoke(getMethod(), getTarget(), getParameters()); }
};
final InvocationContext invocationB = new MockInvocationContext() {
@Override public Object getTarget() { return fooBar; }
@Override public Method getMethod() { return m; }
@Override public Object[] getParameters() { return new Object[] { invocationBControl }; }
@Override public Object proceed() throws Exception { return Reflections.invoke(getMethod(), getTarget(), getParameters()); }
};
final InvocationContext invocationC = new MockInvocationContext() {
@Override public Object getTarget() { return fooBar; }
@Override public Method getMethod() { return m; }
@Override public Object[] getParameters() { return new Object[] { invocationCControl }; }
@Override public Object proceed() throws Exception { return Reflections.invoke(getMethod(), getTarget(), getParameters()); }
};
final WrappedException thread1Exception = new WrappedException();
final WrappedException thread2Exception = new WrappedException();
final WrappedException thread3Exception = new WrappedException();
new Thread(new Runnable() {
public void run() {
try
{
FacesLifecycle.beginRequest(externalContext);
Manager.instance().setCurrentConversationId("1");
FacesLifecycle.resumeConversation(externalContext);
FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
Contexts.getSessionContext().set("foo", foo);
Foo result = (Foo) bi.aroundInvoke( invocationA );
invocationResults.put("A", result);
}
catch (Exception ex)
{
thread1Exception.exception = ex;
}
finally
{
invocationAControl.markFinished();
}
}
}).start();
new Thread(new Runnable() {
public void run() {
try
{
FacesLifecycle.beginRequest(externalContext);
Manager.instance().setCurrentConversationId("1");
FacesLifecycle.resumeConversation(externalContext);
FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
Contexts.getSessionContext().set("foo", foo);
Foo result = (Foo) bi.aroundInvoke( invocationB );
invocationResults.put("B", result);
}
catch (Exception ex)
{
thread2Exception.exception = ex;
}
finally
{
invocationBControl.markFinished();
}
}
}).start();
new Thread(new Runnable() {
public void run() {
try
{
FacesLifecycle.beginRequest(externalContext);
Manager.instance().setCurrentConversationId("1");
FacesLifecycle.resumeConversation(externalContext);
FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
Contexts.getSessionContext().set("foo", foo);
Foo result = (Foo) bi.aroundInvoke( invocationC );
invocationResults.put("C", result);
}
catch (Exception ex)
{
thread3Exception.exception = ex;