use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EjbDescriptorImpl method getRemoveMethods.
/**
* Get the remove methods of the EJB
*
* @return An iterator over the remove methods
*/
@Override
public Collection<Method> getRemoveMethods() {
Set<Method> removeMethods = new HashSet<Method>();
if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
if (sessionDesc.isStateful() && sessionDesc.hasRemoveMethods()) {
for (MethodDescriptor mDesc : sessionDesc.getRemoveMethodDescriptors()) {
Method m = mDesc.getMethod(ejbDesc);
if (m == null) {
throw new IllegalStateException("Can't resolve remove method " + mDesc + " For EJB " + sessionDesc.getName());
}
removeMethods.add(m);
}
}
}
return removeMethods;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class SafeProperties method setInterceptorChain.
private void setInterceptorChain(InvocationInfo info) {
if (info.aroundMethod != null) {
if (info.isEjbTimeout) {
MethodDescriptor md = new MethodDescriptor(info.aroundMethod, MethodDescriptor.TIMER_METHOD);
info.interceptorChain = interceptorManager.getAroundTimeoutChain(md, info.aroundMethod);
} else {
MethodDescriptor md = new MethodDescriptor(info.aroundMethod, MethodDescriptor.EJB_BEAN);
info.interceptorChain = interceptorManager.getAroundInvokeChain(md, info.aroundMethod);
}
}
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class SafeProperties method setConcurrencyInvInfo.
private void setConcurrencyInvInfo(Method invInfoMethod, String methodIntf, InvocationInfo invInfo) {
MethodLockInfo lockInfo = null;
// Set READ/WRITE lock info. Only applies to singleton beans.
if (isSingleton) {
EjbSessionDescriptor singletonDesc = (EjbSessionDescriptor) ejbDescriptor;
List<MethodDescriptor> readLockMethods = singletonDesc.getReadLockMethods();
List<MethodDescriptor> writeLockMethods = singletonDesc.getWriteLockMethods();
DistributedLockType distLockType = singletonDesc.isClustered() ? singletonDesc.getClusteredLockType() : DistributedLockType.LOCK_NONE;
for (MethodDescriptor readLockMethodDesc : readLockMethods) {
Method readLockMethod = readLockMethodDesc.getMethod(singletonDesc);
if (implMethodMatchesInvInfoMethod(invInfoMethod, methodIntf, readLockMethod)) {
lockInfo = new MethodLockInfo();
switch(distLockType) {
case INHERIT:
{
_logger.log(Level.WARNING, "Distributed Read Lock for Method {0} Upgraded to Read/Write", readLockMethod.getName());
lockInfo.setLockType(LockType.WRITE, true);
break;
}
case LOCK_NONE:
{
lockInfo.setLockType(LockType.READ, false);
}
}
break;
}
}
if (lockInfo == null) {
for (MethodDescriptor writeLockMethodDesc : writeLockMethods) {
Method writeLockMethod = writeLockMethodDesc.getMethod(singletonDesc);
if (implMethodMatchesInvInfoMethod(invInfoMethod, methodIntf, writeLockMethod)) {
lockInfo = new MethodLockInfo();
lockInfo.setLockType(LockType.WRITE, distLockType != DistributedLockType.LOCK_NONE);
break;
}
}
}
}
// Set AccessTimeout info
if (isSingleton || isStatefulSession) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDescriptor;
List<EjbSessionDescriptor.AccessTimeoutHolder> accessTimeoutInfo = sessionDesc.getAccessTimeoutInfo();
for (EjbSessionDescriptor.AccessTimeoutHolder accessTimeoutHolder : accessTimeoutInfo) {
MethodDescriptor accessTimeoutMethodDesc = accessTimeoutHolder.method;
Method accessTimeoutMethod = accessTimeoutMethodDesc.getMethod(sessionDesc);
if (implMethodMatchesInvInfoMethod(invInfoMethod, methodIntf, accessTimeoutMethod)) {
if (lockInfo == null) {
lockInfo = new MethodLockInfo();
}
lockInfo.setTimeout(accessTimeoutHolder.value, accessTimeoutHolder.unit);
break;
}
}
}
if (lockInfo != null) {
invInfo.methodLockInfo = lockInfo;
}
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class SafeProperties method addInvocationInfo.
private InvocationInfo addInvocationInfo(Method method, String methodIntf, Class originalIntf, boolean isEjbTimeout, boolean optionalLocalBusView) throws EJBException {
MethodDescriptor md = new MethodDescriptor(method, methodIntf);
boolean flushEnabled = findFlushEnabledAttr(md);
int txAttr = containerTransactionManager.findTxAttr(md);
InvocationInfo info = createInvocationInfo(method, txAttr, flushEnabled, methodIntf, originalIntf);
boolean isHomeIntf = methodIntf.equals(MethodDescriptor.EJB_HOME) || methodIntf.equals(MethodDescriptor.EJB_LOCALHOME);
if (!isHomeIntf) {
Method beanMethod = null;
if (!isEjbTimeout) {
try {
beanMethod = getEJBClass().getMethod(method.getName(), method.getParameterTypes());
} catch (NoSuchMethodException nsmEx) {
// TODO
}
} else {
// For a timeout it is the method
beanMethod = method;
}
if (beanMethod != null) {
// Can't set AroundInvoke/AroundTimeout chains here, but set up some
// state on info object so it can be done right after InterceptorManager
// is initialized.
info.aroundMethod = beanMethod;
info.isEjbTimeout = isEjbTimeout;
}
// Asynchronous method initialization
if (isEligibleForAsync(originalIntf, methodIntf)) {
Method targetMethod = optionalLocalBusView ? beanMethod : method;
boolean isAsync = ((EjbSessionDescriptor) ejbDescriptor).isAsynchronousMethod(targetMethod);
if (isAsync) {
// Check return type
if (optionalLocalBusView && beanMethod != null) {
boolean beanMethodReturnTypeVoid = beanMethod.getReturnType().equals(Void.TYPE);
boolean beanMethodReturnTypeFuture = beanMethod.getReturnType().equals(Future.class);
if (!beanMethodReturnTypeVoid && !beanMethodReturnTypeFuture) {
throw new RuntimeException("Invalid no-interface view asynchronous method '" + beanMethod + "' for bean " + ejbDescriptor.getName() + ". Async method exposed through no-interface view must " + " have return type void or java.lang.concurrent.Future<V>");
}
} else {
// Use actual interface method instead of method from generated interface
Method intfMethod = null;
try {
intfMethod = originalIntf.getMethod(method.getName(), method.getParameterTypes());
} catch (NoSuchMethodException nsmEx) {
throw new RuntimeException("No matching async intf method for method '" + beanMethod + "' on bean " + ejbDescriptor.getName());
}
if (beanMethod == null) {
throw new RuntimeException("No matching bean class method for async method '" + intfMethod + "' on bean " + ejbDescriptor.getName());
}
boolean beanMethodReturnTypeVoid = beanMethod.getReturnType().equals(Void.TYPE);
boolean beanMethodReturnTypeFuture = beanMethod.getReturnType().equals(Future.class);
boolean intfMethodReturnTypeVoid = intfMethod.getReturnType().equals(Void.TYPE);
boolean intfMethodReturnTypeFuture = intfMethod.getReturnType().equals(Future.class);
boolean bothVoid = intfMethodReturnTypeVoid && beanMethodReturnTypeVoid;
boolean bothFuture = intfMethodReturnTypeFuture && beanMethodReturnTypeFuture;
if (!bothVoid && !bothFuture) {
throw new RuntimeException(//
"Invalid asynchronous bean class / interface " + "method signatures for bean " + //
ejbDescriptor.getName() + ". beanMethod = '" + beanMethod + "' , interface method = '" + intfMethod + "'");
}
}
info.setIsAsynchronous(true);
}
}
}
if (methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) {
webServiceInvocationInfoMap.put(method, info);
} else {
invocationInfoMap.put(method, info);
}
return info;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class Generator method getSecurityAttribute.
protected String getSecurityAttribute(EjbDescriptor dd, Method m) {
// The SEC_* strings returned MUST match the SEC_* constants in
// com.sun.ejb.Container.
MethodDescriptor thisMethodDesc = new MethodDescriptor(m, ejbClassSymbol);
Set unchecked = dd.getUncheckedMethodDescriptors();
if (unchecked != null) {
Iterator i = unchecked.iterator();
while (i.hasNext()) {
MethodDescriptor md = (MethodDescriptor) i.next();
if (thisMethodDesc.equals(md))
return "SEC_UNCHECKED";
}
}
Set excluded = dd.getExcludedMethodDescriptors();
if (excluded != null) {
Iterator i = excluded.iterator();
while (i.hasNext()) {
MethodDescriptor md = (MethodDescriptor) i.next();
if (thisMethodDesc.equals(md))
return "SEC_EXCLUDED";
}
}
return "SEC_CHECKED";
}
Aggregations