use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EjbDescriptor method getConstructorInterceptors.
/**
* Return bean constructor for AroundConstruct interceptors
*/
private List<EjbInterceptor> getConstructorInterceptors(ClassLoader classLoader) {
List<EjbInterceptor> callbackInterceptors = null;
String shortClassName = ejbClassName;
int i = ejbClassName.lastIndexOf('.');
if (i > -1) {
shortClassName = ejbClassName.substring(i + 1);
}
JCDIService jcdiService = (sl == null) ? null : sl.getService(JCDIService.class);
if (jcdiService != null && jcdiService.isJCDIEnabled(getEjbBundleDescriptor())) {
try {
Class<?> beanClass = classLoader.loadClass(getEjbClassName());
Constructor<?>[] ctors = beanClass.getDeclaredConstructors();
String[] parameterClassNames = null;
MethodDescriptor dummy = new MethodDescriptor();
for (Constructor<?> ctor : ctors) {
if (ctor.getAnnotation(Inject.class) != null) {
// @Inject constructor
Class<?>[] ctorParamTypes = ctor.getParameterTypes();
parameterClassNames = dummy.getParameterClassNamesFor(null, ctorParamTypes);
callbackInterceptors = getClassOrMethodInterceptors(new MethodDescriptor(shortClassName, null, parameterClassNames, MethodDescriptor.EJB_BEAN));
break;
}
}
} catch (Throwable t) {
_logger.log(Level.SEVERE, "enterprise.deployment.backend.methodClassLoadFailure", new Object[] { this.getEjbClassName() });
throw new RuntimeException(t);
}
}
if (callbackInterceptors == null) {
// non-CDI or no @Inject constructor - use no-arg constructor
callbackInterceptors = getClassOrMethodInterceptors(new MethodDescriptor(shortClassName, null, new String[0], MethodDescriptor.EJB_BEAN));
}
return callbackInterceptors;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EjbDescriptor method getContainerTransaction.
/**
* returns a ContainerTransaction if all the transactional methods on the ejb descriptor have the same transaction type
* else return null
*
* @return
*/
public ContainerTransaction getContainerTransaction() {
Vector<MethodDescriptor> transactionalMethods = new Vector<>(getTransactionMethodDescriptors());
MethodDescriptor md = transactionalMethods.firstElement();
if (md != null) {
ContainerTransaction first = getContainerTransactionFor(md);
for (Enumeration<MethodDescriptor> e = transactionalMethods.elements(); e.hasMoreElements(); ) {
MethodDescriptor next = e.nextElement();
ContainerTransaction nextCt = this.getContainerTransactionFor(next);
if (nextCt != null && !nextCt.equals(first)) {
return null;
}
}
return first;
}
return null;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EjbDescriptor method convertMethodContainerTransactionsOfStyle.
private void convertMethodContainerTransactionsOfStyle(int requestedStyleForConversion, Hashtable<MethodDescriptor, ContainerTransaction> convertedMethods) {
Collection<MethodDescriptor> transactionMethods = this.getTransactionMethodDescriptors();
Hashtable<MethodDescriptor, ContainerTransaction> transactions = getMethodContainerTransactions();
for (Enumeration<MethodDescriptor> e = transactions.keys(); e.hasMoreElements(); ) {
MethodDescriptor md = e.nextElement();
if (md.getStyle() == requestedStyleForConversion) {
ContainerTransaction ct = getMethodContainerTransactions().get(md);
for (Enumeration<MethodDescriptor> mds = md.doStyleConversion(this, transactionMethods).elements(); mds.hasMoreElements(); ) {
MethodDescriptor next = mds.nextElement();
convertedMethods.put(next, new ContainerTransaction(ct));
}
}
}
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class TransactionAttributeHandler method postProcessAnnotation.
/**
* Set the default value (from class type annotation) on all
* methods that don't have a value.
*/
public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext) throws AnnotationProcessorException {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
TransactionAttribute taAn = (TransactionAttribute) ainfo.getAnnotation();
ContainerTransaction containerTransaction = getContainerTransaction(taAn.value());
Class classAn = (Class) ainfo.getAnnotatedElement();
Set txBusMethods = ejbDesc.getTxBusinessMethodDescriptors();
for (Object mdObj : txBusMethods) {
MethodDescriptor md = (MethodDescriptor) mdObj;
// override by xml
if (classAn.equals(ejbContext.getDeclaringClass(md)) && ejbDesc.getContainerTransactionFor(md) == null) {
ejbDesc.setContainerTransactionFor(md, containerTransaction);
}
}
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class AccessTimeoutHandler method matchesExistingAccessTimeoutMethod.
private boolean matchesExistingAccessTimeoutMethod(Method methodToMatch, EjbSessionDescriptor desc) {
List<MethodDescriptor> timeoutMethods = desc.getAccessTimeoutMethods();
boolean match = false;
for (MethodDescriptor next : timeoutMethods) {
Method m = next.getMethod(desc);
if ((m.getDeclaringClass().equals(methodToMatch.getDeclaringClass())) && TypeUtil.sameMethodSignature(m, methodToMatch)) {
match = true;
break;
}
}
return match;
}
Aggregations