use of org.jboss.as.ee.component.ComponentClientInstance in project wildfly by wildfly.
the class StatefulComponentSessionIdGeneratingInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext context) throws Exception {
final Component component = context.getPrivateData(Component.class);
if (component instanceof StatefulSessionComponent == false) {
throw EjbLogger.ROOT_LOGGER.unexpectedComponent(component, StatefulSessionComponent.class);
}
ComponentClientInstance clientInstance = context.getPrivateData(ComponentClientInstance.class);
SessionID existing = context.getPrivateData(SessionID.class);
if (existing != null) {
clientInstance.setViewInstanceData(SessionID.class, existing);
} else {
StatefulSessionComponent statefulComponent = (StatefulSessionComponent) component;
statefulComponent.waitForComponentStart();
StatefulSessionComponentInstance statefulSessionComponentInstance = statefulComponent.getCache().create();
clientInstance.setViewInstanceData(SessionID.class, statefulSessionComponentInstance.getId());
}
// move to the next interceptor in chain
return context.proceed();
}
use of org.jboss.as.ee.component.ComponentClientInstance in project wildfly by wildfly.
the class ManagedBeanCreateInterceptor method processInvocation.
public Object processInvocation(final InterceptorContext context) throws Exception {
final ComponentClientInstance instance = context.getPrivateData(ComponentClientInstance.class);
final Component component = context.getPrivateData(Component.class);
final ComponentInstance componentInstance = component.createInstance();
boolean ok = false;
try {
context.putPrivateData(ComponentInstance.class, componentInstance);
instance.setViewInstanceData(ComponentInstance.class, componentInstance);
final Object result = context.proceed();
ok = true;
return result;
} finally {
context.putPrivateData(ComponentInstance.class, null);
if (!ok) {
componentInstance.destroy();
instance.setViewInstanceData(ComponentInstance.class, null);
}
}
}
Aggregations