Search in sources :

Example 1 with InvocationType

use of org.jboss.as.ee.component.interceptors.InvocationType in project wildfly by wildfly.

the class StatefulInitMethodInterceptor method processInvocation.

@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
    final Method method = SessionBeanHomeInterceptorFactory.INIT_METHOD.get();
    final Object[] params = SessionBeanHomeInterceptorFactory.INIT_PARAMETERS.get();
    //we remove them immediately, so they are not set for the rest of the invocation
    //TODO: find a better way to handle this
    SessionBeanHomeInterceptorFactory.INIT_METHOD.remove();
    SessionBeanHomeInterceptorFactory.INIT_PARAMETERS.remove();
    if (method != null) {
        final InvocationType invocationType = context.getPrivateData(InvocationType.class);
        try {
            context.putPrivateData(InvocationType.class, InvocationType.SFSB_INIT_METHOD);
            method.invoke(context.getTarget(), params);
        } catch (InvocationTargetException e) {
            if (CreateException.class.isAssignableFrom(e.getCause().getClass())) {
                EjbExceptionTransformingInterceptorFactories.setCreateException((CreateException) e.getCause());
            }
            throw Interceptors.rethrow(e.getCause());
        } finally {
            context.putPrivateData(InvocationType.class, invocationType);
        }
    }
    return context.proceed();
}
Also used : InvocationType(org.jboss.as.ee.component.interceptors.InvocationType) Method(java.lang.reflect.Method) CreateException(javax.ejb.CreateException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with InvocationType

use of org.jboss.as.ee.component.interceptors.InvocationType in project wildfly by wildfly.

the class AllowedMethodsInformation method checkAllowed.

/**
     * Checks that the current method
     */
public static void checkAllowed(final MethodType methodType) {
    final InterceptorContext context = CurrentInvocationContext.get();
    if (context == null) {
        return;
    }
    final Component component = context.getPrivateData(Component.class);
    if (!(component instanceof EJBComponent)) {
        return;
    }
    final InvocationType invocationType = context.getPrivateData(InvocationType.class);
    ((EJBComponent) component).getAllowedMethodsInformation().realCheckPermission(methodType, invocationType);
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext) InvocationType(org.jboss.as.ee.component.interceptors.InvocationType) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) Component(org.jboss.as.ee.component.Component) EJBComponent(org.jboss.as.ejb3.component.EJBComponent)

Example 3 with InvocationType

use of org.jboss.as.ee.component.interceptors.InvocationType in project wildfly by wildfly.

the class SessionBeanSetSessionContextMethodInvocationInterceptor method processInvocation.

@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
    SessionBeanComponentInstance instance = (SessionBeanComponentInstance) context.getPrivateData(ComponentInstance.class);
    final InvocationType invocationType = context.getPrivateData(InvocationType.class);
    try {
        context.putPrivateData(InvocationType.class, InvocationType.DEPENDENCY_INJECTION);
        ((SessionBean) context.getTarget()).setSessionContext(instance.getEjbContext());
    } finally {
        context.putPrivateData(InvocationType.class, invocationType);
    }
    return context.proceed();
}
Also used : ComponentInstance(org.jboss.as.ee.component.ComponentInstance) InvocationType(org.jboss.as.ee.component.interceptors.InvocationType) SessionBean(javax.ejb.SessionBean)

Example 4 with InvocationType

use of org.jboss.as.ee.component.interceptors.InvocationType in project wildfly by wildfly.

the class EjbSuspendInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext context) throws Exception {
    InvocationType invocation = context.getPrivateData(InvocationType.class);
    if (invocation != InvocationType.REMOTE && invocation != InvocationType.MESSAGE_DELIVERY) {
        return context.proceed();
    }
    // see if control point accepts or rejects this invocation
    EJBComponent component = getComponent(context, EJBComponent.class);
    ControlPoint entryPoint = component.getControlPoint();
    RunResult result = entryPoint.beginRequest();
    if (result == RunResult.REJECTED) {
        // if control point rejected, check with suspend handler
        if (!component.getEjbSuspendHandlerService().acceptInvocation(context))
            throw EjbLogger.ROOT_LOGGER.containerSuspended();
    }
    try {
        return context.proceed();
    } finally {
        if (result == RunResult.REJECTED)
            component.getEjbSuspendHandlerService().invocationComplete();
        else
            entryPoint.requestComplete();
    }
}
Also used : InvocationType(org.jboss.as.ee.component.interceptors.InvocationType) ControlPoint(org.wildfly.extension.requestcontroller.ControlPoint) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) RunResult(org.wildfly.extension.requestcontroller.RunResult)

Aggregations

InvocationType (org.jboss.as.ee.component.interceptors.InvocationType)4 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 CreateException (javax.ejb.CreateException)1 SessionBean (javax.ejb.SessionBean)1 Component (org.jboss.as.ee.component.Component)1 ComponentInstance (org.jboss.as.ee.component.ComponentInstance)1 InterceptorContext (org.jboss.invocation.InterceptorContext)1 ControlPoint (org.wildfly.extension.requestcontroller.ControlPoint)1 RunResult (org.wildfly.extension.requestcontroller.RunResult)1