Search in sources :

Example 31 with EjbInvocation

use of com.sun.ejb.EjbInvocation in project Payara by payara.

the class AbstractSingletonContainer method createEjbInvocation.

@Override
protected EjbInvocation createEjbInvocation(Object ejb, ComponentContext ctx) {
    EjbInvocation inv = super.createEjbInvocation(ejb, ctx);
    setResourceHandler(inv);
    return inv;
}
Also used : EjbInvocation(com.sun.ejb.EjbInvocation)

Example 32 with EjbInvocation

use of com.sun.ejb.EjbInvocation in project Payara by payara.

the class AbstractSingletonContainer method userTransactionMethodsAllowed.

public boolean userTransactionMethodsAllowed(ComponentInvocation inv) {
    boolean utMethodsAllowed = false;
    if (isBeanManagedTran) {
        if (inv instanceof EjbInvocation) {
            EjbInvocation ejbInv = (EjbInvocation) inv;
            AbstractSessionContextImpl sc = (AbstractSessionContextImpl) ejbInv.context;
            // Allowed any time after dependency injection
            utMethodsAllowed = (sc.getInstanceKey() != null);
        }
    }
    return utMethodsAllowed;
}
Also used : EjbInvocation(com.sun.ejb.EjbInvocation)

Example 33 with EjbInvocation

use of com.sun.ejb.EjbInvocation in project Payara by payara.

the class EJBContextImpl method getContextData.

/**
 * @return Returns the contextMetaData.
 */
public Map<String, Object> getContextData() {
    Map<String, Object> contextData = (Map<String, Object>) Collections.EMPTY_MAP;
    ComponentInvocation inv = EjbContainerUtilImpl.getInstance().getCurrentInvocation();
    if (inv instanceof EjbInvocation) {
        EjbInvocation ejbInv = (EjbInvocation) inv;
        contextData = ejbInv.getContextData();
    }
    return contextData;
}
Also used : EjbInvocation(com.sun.ejb.EjbInvocation) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 34 with EjbInvocation

use of com.sun.ejb.EjbInvocation in project Payara by payara.

the class EJBContextImpl method inActivatePassivate.

protected boolean inActivatePassivate(ComponentInvocation inv) {
    boolean inActivatePassivate = false;
    if (inv instanceof EjbInvocation) {
        Method currentMethod = ((EjbInvocation) inv).method;
        inActivatePassivate = (currentMethod != null) ? (currentMethod.getName().equals("ejbActivate") || currentMethod.getName().equals("ejbPassivate")) : false;
    }
    return inActivatePassivate;
}
Also used : EjbInvocation(com.sun.ejb.EjbInvocation) Method(java.lang.reflect.Method)

Example 35 with EjbInvocation

use of com.sun.ejb.EjbInvocation in project Payara by payara.

the class EJBLocalHomeInvocationHandler method invoke.

/**
 * Called by EJBLocalHome proxy.
 */
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    ClassLoader originalClassLoader = null;
    // if method signature has 0 arguments.
    try {
        ((BaseContainer) getContainer()).onEnteringContainer();
        if (Thread.currentThread().getContextClassLoader() != getContainer().getClassLoader()) {
            originalClassLoader = Utility.setContextClassLoader(getContainer().getClassLoader());
        }
        Class methodClass = method.getDeclaringClass();
        if (methodClass == java.lang.Object.class) {
            return InvocationHandlerUtil.invokeJavaObjectMethod(this, method, args);
        } else if (methodClass == IndirectlySerializable.class) {
            return this.getSerializableObjectFactory();
        } else if (handleSpecialEJBLocalHomeMethod(method, methodClass)) {
            return invokeSpecialEJBLocalHomeMethod(method, methodClass, args);
        }
        // Use optimized version of get that takes param count as an argument.
        InvocationInfo invInfo = (InvocationInfo) invocationInfoMap_.get(method, ((args != null) ? args.length : 0));
        if (invInfo == null) {
            throw new IllegalStateException("Unknown method :" + method);
        }
        if ((methodClass == javax.ejb.EJBLocalHome.class) || invInfo.ejbIntfOverride) {
            // There is only one method on javax.ejb.EJBLocalHome
            super.remove(args[0]);
            return null;
        } else if (methodClass == GenericEJBLocalHome.class) {
            // This is a creation request through the EJB 3.0
            // client view, so just create a local business object and
            // return it.
            EJBLocalObjectImpl localImpl = createEJBLocalBusinessObjectImpl((String) args[0]);
            return localImpl.getClientObject((String) args[0]);
        }
        // Process finder, create method, or home method.
        EJBLocalObjectImpl localObjectImpl = null;
        Object returnValue = null;
        if (invInfo.startsWithCreate) {
            localObjectImpl = createEJBLocalObjectImpl();
            if (localObjectImpl != null) {
                returnValue = localObjectImpl.getClientObject();
            }
        }
        if (!isStatelessSession_) {
            if (invInfo.targetMethod1 == null) {
                Object[] params = new Object[] { invInfo.ejbName, "LocalHome", invInfo.method.toString() };
                String errorMsg = localStrings.getLocalString("ejb.bean_class_method_not_found", "", params);
                throw new EJBException(errorMsg);
            }
            EjbInvocation inv = ((BaseContainer) getContainer()).createEjbInvocation();
            inv.isLocal = true;
            inv.isHome = true;
            inv.method = method;
            inv.clientInterface = localHomeIntfClass_;
            // Set cached invocation params.  This will save additional lookups
            // in BaseContainer.
            inv.transactionAttribute = invInfo.txAttr;
            inv.invocationInfo = invInfo;
            if (localObjectImpl != null && invInfo.startsWithCreate) {
                inv.ejbObject = (EJBLocalRemoteObject) localObjectImpl;
            }
            try {
                container.preInvoke(inv);
                if (invInfo.startsWithCreate) {
                    Object ejbCreateReturnValue = invokeTargetBeanMethod(container, invInfo.targetMethod1, inv, inv.ejb, args);
                    postCreate(container, inv, invInfo, ejbCreateReturnValue, args);
                    if (inv.ejbObject != null) {
                        returnValue = ((EJBLocalObjectImpl) inv.ejbObject).getClientObject();
                    }
                } else if (invInfo.startsWithFindByPrimaryKey) {
                    returnValue = container.invokeFindByPrimaryKey(invInfo.targetMethod1, inv, args);
                } else if (invInfo.startsWithFind) {
                    Object pKeys = invokeTargetBeanMethod(container, invInfo.targetMethod1, inv, inv.ejb, args);
                    returnValue = container.postFind(inv, pKeys, null);
                } else {
                    returnValue = invokeTargetBeanMethod(container, invInfo.targetMethod1, inv, inv.ejb, args);
                }
            } catch (InvocationTargetException ite) {
                inv.exception = ite.getCause();
            } catch (Throwable c) {
                inv.exception = c;
            } finally {
                container.postInvoke(inv);
            }
            if (inv.exception != null) {
                InvocationHandlerUtil.throwLocalException(inv.exception, method.getExceptionTypes());
            }
        }
        return returnValue;
    } finally {
        if (originalClassLoader != null) {
            Utility.setContextClassLoader(originalClassLoader);
        }
        ((BaseContainer) getContainer()).onLeavingContainer();
    }
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) EjbInvocation(com.sun.ejb.EjbInvocation) IndirectlySerializable(com.sun.enterprise.container.common.spi.util.IndirectlySerializable) EJBException(javax.ejb.EJBException)

Aggregations

EjbInvocation (com.sun.ejb.EjbInvocation)44 EJBException (javax.ejb.EJBException)22 RemoteException (java.rmi.RemoteException)18 CreateException (javax.ejb.CreateException)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)16 RemoveException (javax.ejb.RemoveException)16 SystemException (javax.transaction.SystemException)15 EJBObject (javax.ejb.EJBObject)11 IOException (java.io.IOException)9 NotSerializableException (java.io.NotSerializableException)9 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)9 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)9 IllegalLoopbackException (javax.ejb.IllegalLoopbackException)9 BackingStoreException (org.glassfish.ha.store.api.BackingStoreException)9 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)7 EJBLocalRemoteObject (com.sun.ejb.containers.EJBLocalRemoteObject)6 FinderException (javax.ejb.FinderException)6 NoSuchEntityException (javax.ejb.NoSuchEntityException)6 InvocationInfo (com.sun.ejb.InvocationInfo)4