Search in sources :

Example 11 with InterceptorContext

use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.

the class SessionContextImpl method getMessageContext.

public MessageContext getMessageContext() throws IllegalStateException {
    final InterceptorContext invocation = CurrentInvocationContext.get();
    final MessageContext context = invocation.getPrivateData(MessageContext.class);
    if (context == null) {
        throw EjbLogger.ROOT_LOGGER.cannotCall("getMessageContext()", "MessageContext");
    }
    return context;
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext) MessageContext(javax.xml.rpc.handler.MessageContext)

Example 12 with InterceptorContext

use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.

the class SessionContextImpl method wasCancelCalled.

public boolean wasCancelCalled() throws IllegalStateException {
    final InterceptorContext invocation = CurrentInvocationContext.get();
    final CancellationFlag flag = invocation.getPrivateData(CancellationFlag.class);
    if (flag == null) {
        throw EjbLogger.ROOT_LOGGER.noAsynchronousInvocationInProgress();
    }
    return flag.isCancelFlagSet();
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext) CancellationFlag(org.jboss.as.ejb3.component.interceptors.CancellationFlag)

Example 13 with InterceptorContext

use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.

the class SessionContextImpl method getEJBLocalObject.

public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
    AllowedMethodsInformation.checkAllowed(MethodType.GET_EJB_LOCAL_OBJECT);
    // to allow override per invocation
    final InterceptorContext invocation = CurrentInvocationContext.get();
    return getComponent().getEJBLocalObject(invocation);
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext)

Example 14 with InterceptorContext

use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.

the class StatefulSessionSynchronizationInterceptorTestCase method testDifferentTx.

/**
     * After the bean is accessed within a tx and the tx has committed, the
     * association should be gone (and thus it is ready for another tx).
     */
@Test
public void testDifferentTx() throws Exception {
    final Interceptor interceptor = new StatefulSessionSynchronizationInterceptor(true);
    final InterceptorContext context = new InterceptorContext();
    context.setInterceptors(Arrays.asList(noop()));
    final StatefulSessionComponent component = mock(StatefulSessionComponent.class);
    context.putPrivateData(Component.class, component);
    when(component.getAccessTimeout(null)).thenReturn(defaultAccessTimeout());
    Cache<SessionID, StatefulSessionComponentInstance> cache = mock(Cache.class);
    when(component.getCache()).thenReturn(cache);
    final TransactionSynchronizationRegistry transactionSynchronizationRegistry = mock(TransactionSynchronizationRegistry.class);
    when(component.getTransactionSynchronizationRegistry()).thenReturn(transactionSynchronizationRegistry);
    when(transactionSynchronizationRegistry.getTransactionKey()).thenReturn("TX1");
    final List<Synchronization> synchronizations = new LinkedList<Synchronization>();
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            Synchronization synchronization = (Synchronization) invocation.getArguments()[0];
            synchronizations.add(synchronization);
            return null;
        }
    }).when(transactionSynchronizationRegistry).registerInterposedSynchronization((Synchronization) any());
    final StatefulSessionComponentInstance instance = new StatefulSessionComponentInstance(component, org.jboss.invocation.Interceptors.getTerminalInterceptor(), Collections.EMPTY_MAP, Collections.emptyMap());
    context.putPrivateData(ComponentInstance.class, instance);
    interceptor.processInvocation(context);
    // commit
    for (Synchronization synchronization : synchronizations) {
        synchronization.beforeCompletion();
    }
    for (Synchronization synchronization : synchronizations) {
        synchronization.afterCompletion(Status.STATUS_COMMITTED);
    }
    synchronizations.clear();
    when(transactionSynchronizationRegistry.getTransactionKey()).thenReturn("TX2");
    interceptor.processInvocation(context);
}
Also used : Synchronization(javax.transaction.Synchronization) LinkedList(java.util.LinkedList) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) InvocationOnMock(org.mockito.invocation.InvocationOnMock) InterceptorContext(org.jboss.invocation.InterceptorContext) Interceptor(org.jboss.invocation.Interceptor) SessionID(org.jboss.ejb.client.SessionID) Test(org.junit.Test)

Example 15 with InterceptorContext

use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.

the class BasicComponent method constructComponentInstance.

/**
     * Construct the component instance.  Upon return, the object instance should have injections and lifecycle
     * invocations completed already.
     *
     *
     * @param instance An instance to be wrapped, or null if a new instance should be created
     * @return the component instance
     */
protected BasicComponentInstance constructComponentInstance(ManagedReference instance, boolean invokePostConstruct, final Map<Object, Object> context) {
    waitForComponentStart();
    // create the component instance
    final BasicComponentInstance basicComponentInstance = this.instantiateComponentInstance(preDestroyInterceptor, interceptorInstanceMap, context);
    if (instance != null) {
        basicComponentInstance.setInstanceData(BasicComponentInstance.INSTANCE_KEY, instance);
    }
    if (invokePostConstruct) {
        // now invoke the postconstruct interceptors
        final InterceptorContext interceptorContext = new InterceptorContext();
        interceptorContext.putPrivateData(Component.class, this);
        interceptorContext.putPrivateData(ComponentInstance.class, basicComponentInstance);
        interceptorContext.putPrivateData(InvocationType.class, InvocationType.POST_CONSTRUCT);
        interceptorContext.setContextData(new HashMap<String, Object>());
        try {
            postConstructInterceptor.processInvocation(interceptorContext);
        } catch (Exception e) {
            throw EeLogger.ROOT_LOGGER.componentConstructionFailure(e);
        }
    }
    componentInstanceCreated(basicComponentInstance);
    // return the component instance
    return basicComponentInstance;
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext)

Aggregations

InterceptorContext (org.jboss.invocation.InterceptorContext)29 Interceptor (org.jboss.invocation.Interceptor)8 Method (java.lang.reflect.Method)4 Component (org.jboss.as.ee.component.Component)4 ComponentView (org.jboss.as.ee.component.ComponentView)4 ManagedReference (org.jboss.as.naming.ManagedReference)4 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)3 SessionBeanComponent (org.jboss.as.ejb3.component.session.SessionBeanComponent)3 SecurityContext (org.jboss.security.SecurityContext)3 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)3 PrivilegedAction (java.security.PrivilegedAction)2 HashMap (java.util.HashMap)2 ComponentFactory (org.jboss.as.ee.component.ComponentFactory)2 StartupCountdown (org.jboss.as.ee.component.deployers.StartupCountdown)2 InvocationType (org.jboss.as.ee.component.interceptors.InvocationType)2 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)2 CancellationFlag (org.jboss.as.ejb3.component.interceptors.CancellationFlag)2 BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)2 SkeletonStrategy (org.wildfly.iiop.openjdk.rmi.marshal.strategy.SkeletonStrategy)2 ObjectStreamException (java.io.ObjectStreamException)1