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;
}
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;
}
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;
}
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;
}
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();
}
}
Aggregations