Search in sources :

Example 11 with EJBComponent

use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.

the class NonPooledEJBComponentInstanceAssociatingInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext context) throws Exception {
    final EJBComponent component = getComponent(context, EJBComponent.class);
    // create the instance
    final ComponentInstance componentInstance = component.createInstance();
    context.putPrivateData(ComponentInstance.class, componentInstance);
    // if this is set to true we do not invoke instance.destroy
    // as we are not allowed to invoke pre-destroy callbacks
    boolean discard = false;
    try {
        return context.proceed();
    } catch (Exception ex) {
        final EJBComponent ejbComponent = component;
        // Detect app exception
        if (ejbComponent.getApplicationException(ex.getClass(), context.getMethod()) != null) {
            // it's an application exception, just throw it back.
            throw ex;
        }
        if (ex instanceof ConcurrentAccessTimeoutException || ex instanceof ConcurrentAccessException) {
            throw ex;
        }
        if (ex instanceof RuntimeException || ex instanceof RemoteException) {
            discard = true;
        }
        throw ex;
    } catch (final Error e) {
        discard = true;
        throw e;
    } catch (final Throwable t) {
        discard = true;
        throw new RuntimeException(t);
    } finally {
        // destroy the instance
        if (!discard) {
            componentInstance.destroy();
        }
    }
}
Also used : ComponentInstance(org.jboss.as.ee.component.ComponentInstance) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) RemoteException(java.rmi.RemoteException) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoteException(java.rmi.RemoteException)

Example 12 with EJBComponent

use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.

the class ExecutionTimeInterceptor method processInvocation.

@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
    final EJBComponent component = getComponent(context, EJBComponent.class);
    if (!component.isStatisticsEnabled())
        return context.proceed();
    final Long startWaitTime = (Long) context.getPrivateData(WaitTimeInterceptor.START_WAIT_TIME);
    final long waitTime = startWaitTime != null && startWaitTime != 0L ? System.currentTimeMillis() - startWaitTime : 0L;
    component.getInvocationMetrics().startInvocation();
    final long start = System.currentTimeMillis();
    try {
        return context.proceed();
    } finally {
        final long executionTime = System.currentTimeMillis() - start;
        component.getInvocationMetrics().finishInvocation(context.getMethod(), waitTime, executionTime);
    }
}
Also used : EJBComponent(org.jboss.as.ejb3.component.EJBComponent)

Example 13 with EJBComponent

use of org.jboss.as.ejb3.component.EJBComponent 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 14 with EJBComponent

use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.

the class PooledInstanceInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext context) throws Exception {
    PooledComponent<ComponentInstance> component = (PooledComponent<ComponentInstance>) getComponent(context, EJBComponent.class);
    ComponentInstance instance = component.getPool().get();
    context.putPrivateData(ComponentInstance.class, instance);
    boolean discarded = false;
    try {
        return context.proceed();
    } catch (Exception ex) {
        final EJBComponent ejbComponent = (EJBComponent) component;
        // Detect app exception
        if (ejbComponent.getApplicationException(ex.getClass(), context.getMethod()) != null) {
            // it's an application exception, just throw it back.
            throw ex;
        }
        if (ex instanceof ConcurrentAccessTimeoutException || ex instanceof ConcurrentAccessException) {
            throw ex;
        }
        if (ex instanceof RuntimeException || ex instanceof RemoteException) {
            discarded = true;
            component.getPool().discard(instance);
        }
        throw ex;
    } catch (final Error e) {
        discarded = true;
        component.getPool().discard(instance);
        throw e;
    } catch (final Throwable t) {
        discarded = true;
        component.getPool().discard(instance);
        throw new RuntimeException(t);
    } finally {
        if (!discarded) {
            component.getPool().release(instance);
        }
    }
}
Also used : ComponentInstance(org.jboss.as.ee.component.ComponentInstance) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) RemoteException(java.rmi.RemoteException) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoteException(java.rmi.RemoteException)

Example 15 with EJBComponent

use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.

the class LocalEjbReceiver method createSession.

@Override
protected <T> StatefulEJBLocator<T> createSession(StatelessEJBLocator<T> statelessLocator, NamingProvider namingProvider) throws Exception {
    final EjbDeploymentInformation ejbInfo = findBean(statelessLocator);
    final EJBComponent component = ejbInfo.getEjbComponent();
    if (!(component instanceof StatefulSessionComponent)) {
        throw EjbLogger.ROOT_LOGGER.notStatefulSessionBean(statelessLocator.getAppName(), statelessLocator.getModuleName(), statelessLocator.getDistinctName(), statelessLocator.getBeanName());
    }
    final StatefulSessionComponent statefulComponent = (StatefulSessionComponent) component;
    final SessionID sessionID = statefulComponent.createSession();
    return statelessLocator.withSession(sessionID);
}
Also used : EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) StatefulSessionComponent(org.jboss.as.ejb3.component.stateful.StatefulSessionComponent) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) SessionID(org.jboss.ejb.client.SessionID)

Aggregations

EJBComponent (org.jboss.as.ejb3.component.EJBComponent)24 Component (org.jboss.as.ee.component.Component)7 ComponentView (org.jboss.as.ee.component.ComponentView)6 MethodIntf (org.jboss.as.ejb3.component.MethodIntf)5 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)5 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)5 Method (java.lang.reflect.Method)4 EjbDeploymentInformation (org.jboss.as.ejb3.deployment.EjbDeploymentInformation)4 PrivilegedActionException (java.security.PrivilegedActionException)3 IOException (java.io.IOException)2 InvalidClassException (java.io.InvalidClassException)2 RemoteException (java.rmi.RemoteException)2 PrivilegedAction (java.security.PrivilegedAction)2 ProtectionDomain (java.security.ProtectionDomain)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)2 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)2 TransactionAttributeType (javax.ejb.TransactionAttributeType)2