Search in sources :

Example 1 with ComponentClientInstance

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();
}
Also used : ComponentClientInstance(org.jboss.as.ee.component.ComponentClientInstance) Component(org.jboss.as.ee.component.Component) SessionID(org.jboss.ejb.client.SessionID)

Example 2 with ComponentClientInstance

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);
        }
    }
}
Also used : ComponentClientInstance(org.jboss.as.ee.component.ComponentClientInstance) ComponentInstance(org.jboss.as.ee.component.ComponentInstance) Component(org.jboss.as.ee.component.Component)

Aggregations

Component (org.jboss.as.ee.component.Component)2 ComponentClientInstance (org.jboss.as.ee.component.ComponentClientInstance)2 ComponentInstance (org.jboss.as.ee.component.ComponentInstance)1 SessionID (org.jboss.ejb.client.SessionID)1