Search in sources :

Example 21 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class Generator method getTxAttribute.

protected String getTxAttribute(EjbDescriptor dd, Method method) {
    // com.sun.ejb.Container.
    if (dd instanceof EjbSessionDescriptor && ((EjbSessionDescriptor) dd).getTransactionType().equals("Bean"))
        return "TX_BEAN_MANAGED";
    String txAttr = null;
    MethodDescriptor mdesc = new MethodDescriptor(method, ejbClassSymbol);
    ContainerTransaction ct = dd.getContainerTransactionFor(mdesc);
    if (ct != null) {
        String attr = ct.getTransactionAttribute();
        if (attr.equals(ContainerTransaction.NOT_SUPPORTED))
            txAttr = "TX_NOT_SUPPORTED";
        else if (attr.equals(ContainerTransaction.SUPPORTS))
            txAttr = "TX_SUPPORTS";
        else if (attr.equals(ContainerTransaction.REQUIRED))
            txAttr = "TX_REQUIRED";
        else if (attr.equals(ContainerTransaction.REQUIRES_NEW))
            txAttr = "TX_REQUIRES_NEW";
        else if (attr.equals(ContainerTransaction.MANDATORY))
            txAttr = "TX_MANDATORY";
        else if (attr.equals(ContainerTransaction.NEVER))
            txAttr = "TX_NEVER";
    }
    if (txAttr == null) {
        throw new RuntimeException("Transaction Attribute not found for method " + method);
    }
    return txAttr;
}
Also used : ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 22 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class AbstractAuthAnnotationHandler method postProcessAnnotation.

/**
 * This method is for processing security annotation associated to ejb.
 * Dervied class call this method may like to override
 *
 * protected void processEjbMethodSecurity(Annotation authAnnotation,
 *         MethodDescriptor md, EjbDescriptor ejbDesc)
 */
@Override
public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext) throws AnnotationProcessorException {
    EjbDescriptor ejbDesc = ejbContext.getDescriptor();
    Annotation authAnnotation = ainfo.getAnnotation();
    if (!ejbContext.isInherited() && (ejbDesc.getMethodPermissionsFromDD() == null || ejbDesc.getMethodPermissionsFromDD().size() == 0)) {
        for (MethodDescriptor md : getMethodAllDescriptors(ejbDesc)) {
            processEjbMethodSecurity(authAnnotation, md, ejbDesc);
        }
    } else {
        Class classAn = (Class) ainfo.getAnnotatedElement();
        for (Object next : ejbDesc.getSecurityBusinessMethodDescriptors()) {
            MethodDescriptor md = (MethodDescriptor) next;
            // override by existing info
            if (classAn.equals(ejbContext.getDeclaringClass(md)) && !hasMethodPermissionsFromDD(md, ejbDesc)) {
                processEjbMethodSecurity(authAnnotation, md, ejbDesc);
            }
        }
    }
}
Also used : MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) Annotation(java.lang.annotation.Annotation)

Example 23 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class AsynchronousTask method initSessionSyncMethods.

private void initSessionSyncMethods() throws Exception {
    if (SessionSynchronization.class.isAssignableFrom(ejbClass)) {
        try {
            afterBeginMethod = ejbClass.getMethod("afterBegin");
            beforeCompletionMethod = ejbClass.getMethod("beforeCompletion");
            afterCompletionMethod = ejbClass.getMethod("afterCompletion", Boolean.TYPE);
        } catch (Exception e) {
            _logger.log(Level.WARNING, EXCEPTION_WHILE_INITIALIZING_SESSION_SYNCHRONIZATION, e);
        }
    } else {
        EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDescriptor;
        MethodDescriptor afterBeginMethodDesc = sessionDesc.getAfterBeginMethod();
        if (afterBeginMethodDesc != null) {
            afterBeginMethod = afterBeginMethodDesc.getDeclaredMethod(sessionDesc);
            processSessionSynchMethod(afterBeginMethod);
        }
        MethodDescriptor beforeCompletionMethodDesc = sessionDesc.getBeforeCompletionMethod();
        if (beforeCompletionMethodDesc != null) {
            beforeCompletionMethod = beforeCompletionMethodDesc.getDeclaredMethod(sessionDesc);
            processSessionSynchMethod(beforeCompletionMethod);
        }
        MethodDescriptor afterCompletionMethodDesc = sessionDesc.getAfterCompletionMethod();
        if (afterCompletionMethodDesc != null) {
            afterCompletionMethod = afterCompletionMethodDesc.getDeclaredMethod(sessionDesc);
            if (afterCompletionMethod == null) {
                afterCompletionMethod = // 
                afterCompletionMethodDesc.getDeclaredMethod(sessionDesc, new Class[] { Boolean.TYPE });
            }
            processSessionSynchMethod(afterCompletionMethod);
        }
    }
}
Also used : EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) CheckpointAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.CheckpointAtEndOfMethodDescriptor) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Example 24 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class AsynchronousTask method loadCheckpointInfo.

protected void loadCheckpointInfo() {
    try {
        if (!isHAEnabled) {
            return;
        }
        for (InvocationInfo info : invocationInfoMap.values()) {
            info.checkpointEnabled = false;
            MethodDescriptor md = new MethodDescriptor(info.method, info.methodIntf);
            IASEjbExtraDescriptors extraDesc = ejbDescriptor.getIASEjbExtraDescriptors();
            if (extraDesc != null) {
                CheckpointAtEndOfMethodDescriptor cpDesc = extraDesc.getCheckpointAtEndOfMethodDescriptor();
                if (cpDesc != null) {
                    info.checkpointEnabled = cpDesc.isCheckpointEnabledFor(md);
                }
            }
            if (info.checkpointEnabled) {
                _logger.log(Level.FINE, () -> "[SFSBContainer] " + info.method + " MARKED for end-of-method-checkpoint");
            }
        }
    } catch (Exception ex) {
        _logger.log(Level.WARNING, EXCEPTION_WHILE_LOADING_CHECKPOINT, ex);
    }
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo) IASEjbExtraDescriptors(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) CheckpointAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.CheckpointAtEndOfMethodDescriptor) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException) CheckpointAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.CheckpointAtEndOfMethodDescriptor)

Example 25 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class AbstractMethodHelper method categorizeMethods.

/**
 * Reads all known methods and sorts them by name into specific
 * Collections for further processing.
 */
protected void categorizeMethods() {
    EjbCMPEntityDescriptor descriptor = getDescriptor();
    Iterator iterator = descriptor.getMethodDescriptors().iterator();
    while (iterator.hasNext()) {
        MethodDescriptor methodDescriptor = (MethodDescriptor) iterator.next();
        Method method = methodDescriptor.getMethod(descriptor);
        String methodName = methodDescriptor.getName();
        if (methodName.startsWith(CMPTemplateFormatter.find_))
            finders.add(method);
        else if (methodName.startsWith(CMPTemplateFormatter.ejbSelect_))
            selectors.add(method);
        else if (methodName.startsWith(CMPTemplateFormatter.create_))
            createMethods.add(method);
        else if (methodName.startsWith(CMPTemplateFormatter.get_) || methodName.startsWith(CMPTemplateFormatter.set_)) {
            // skip
            ;
        }
        // else
        // otherMethods.add(method);
        // It is OK to use HashMap here as we won't use it for possible
        // overloaded methods.
        methodNames.put(methodName, method);
    }
}
Also used : Iterator(java.util.Iterator) Method(java.lang.reflect.Method) EjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Aggregations

MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)108 Method (java.lang.reflect.Method)42 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)26 Iterator (java.util.Iterator)21 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)17 Enumeration (java.util.Enumeration)14 Set (java.util.Set)14 ArrayList (java.util.ArrayList)13 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)11 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)11 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)10 Result (com.sun.enterprise.tools.verifier.Result)9 MethodPermission (com.sun.enterprise.deployment.MethodPermission)8 MethodNode (com.sun.enterprise.deployment.node.MethodNode)7 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)7 Node (org.w3c.dom.Node)7 List (java.util.List)6 ScheduledTimerDescriptor (org.glassfish.ejb.deployment.descriptor.ScheduledTimerDescriptor)6 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)5 HashMap (java.util.HashMap)5