Search in sources :

Example 66 with MethodDescriptor

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

the class EjbDescriptor method setMethodContainerTransactions.

/**
 * Sets the container transactions for all the method descriptors of this ejb. The Hashtable is keyed
 * by method descriptor and the values are the corresponding container transaction objects..
 * Throws an Illegal argument if this ejb has transaction type BEAN_TRANSACTION_TYPE.
 * @param methodContainerTransactions
 */
public void setMethodContainerTransactions(Hashtable methodContainerTransactions) {
    if (methodContainerTransactions != null) {
        for (Enumeration e = methodContainerTransactions.keys(); e.hasMoreElements(); ) {
            MethodDescriptor methodDescriptor = (MethodDescriptor) e.nextElement();
            ContainerTransaction containerTransaction = (ContainerTransaction) methodContainerTransactions.get(methodDescriptor);
            setContainerTransactionFor(methodDescriptor, containerTransaction);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 67 with MethodDescriptor

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

the class EjbDescriptor method convertMethodContainerTransactionsOfStyle.

private void convertMethodContainerTransactionsOfStyle(int requestedStyleForConversion, Hashtable convertedMethods) {
    Collection transactionMethods = this.getTransactionMethodDescriptors();
    Hashtable transactions = this.getMethodContainerTransactions();
    for (Enumeration e = transactions.keys(); e.hasMoreElements(); ) {
        MethodDescriptor md = (MethodDescriptor) e.nextElement();
        if (md.getStyle() == requestedStyleForConversion) {
            ContainerTransaction ct = (ContainerTransaction) getMethodContainerTransactions().get(md);
            for (Enumeration mds = md.doStyleConversion(this, transactionMethods).elements(); mds.hasMoreElements(); ) {
                MethodDescriptor next = (MethodDescriptor) mds.nextElement();
                convertedMethods.put(next, new ContainerTransaction(ct));
            }
        }
    }
}
Also used : Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable) Collection(java.util.Collection) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 68 with MethodDescriptor

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

the class EjbDescriptor method getStyledPermissionedMethodsByPermission.

/**
 * @return a map of permission to style 1 or 2 method descriptors
 */
public Map getStyledPermissionedMethodsByPermission() {
    if (styledMethodDescriptors == null) {
        return null;
    }
    // the current info is structured as MethodDescriptors as keys to
    // method permission, let's reverse this to make the Map using the
    // method permission as a key.
    Map styledMethodDescriptorsByPermission = new HashMap();
    for (Iterator mdIterator = styledMethodDescriptors.keySet().iterator(); mdIterator.hasNext(); ) {
        MethodDescriptor md = (MethodDescriptor) mdIterator.next();
        Set methodPermissions = (Set) styledMethodDescriptors.get(md);
        for (Iterator mpIterator = methodPermissions.iterator(); mpIterator.hasNext(); ) {
            MethodPermission mp = (MethodPermission) mpIterator.next();
            Set methodDescriptors = (Set) styledMethodDescriptorsByPermission.get(mp);
            if (methodDescriptors == null) {
                methodDescriptors = new HashSet();
            }
            methodDescriptors.add(md);
            styledMethodDescriptorsByPermission.put(mp, methodDescriptors);
        }
    }
    return styledMethodDescriptorsByPermission;
}
Also used : Set(java.util.Set) OrderedSet(com.sun.enterprise.deployment.OrderedSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) MethodPermission(com.sun.enterprise.deployment.MethodPermission) HashSet(java.util.HashSet)

Example 69 with MethodDescriptor

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

the class EjbDescriptor method getBusinessMethodDescriptorFor.

/**
 * @param m
 * @param methodIntf
 * @return the MethodDescriptor for the given Method object
 */
public MethodDescriptor getBusinessMethodDescriptorFor(Method m, String methodIntf) {
    Set businessMethodDescriptors = getBusinessMethodDescriptors();
    MethodDescriptor methodDesc = new MethodDescriptor(m, methodIntf);
    MethodDescriptor match = null;
    for (Object next : businessMethodDescriptors) {
        MethodDescriptor nextMethodDesc = (MethodDescriptor) next;
        if (nextMethodDesc.equals(methodDesc)) {
            match = nextMethodDesc;
            break;
        }
    }
    return match;
}
Also used : Set(java.util.Set) OrderedSet(com.sun.enterprise.deployment.OrderedSet) HashSet(java.util.HashSet) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 70 with MethodDescriptor

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

the class EjbDescriptor method convertMethodPermissions.

/**
 * convert all style 1 and style 2 method descriptors contained in
 * our tables into style 3 method descriptors.
 */
private void convertMethodPermissions() {
    if (styledMethodDescriptors == null)
        return;
    Set allMethods = getMethodDescriptors();
    Set unpermissionedMethods = getMethodDescriptors();
    Set methodDescriptors = styledMethodDescriptors.keySet();
    for (Iterator styledMdItr = methodDescriptors.iterator(); styledMdItr.hasNext(); ) {
        MethodDescriptor styledMd = (MethodDescriptor) styledMdItr.next();
        // Get the new permissions we are trying to set for this
        // method(s)
        Set newPermissions = (Set) styledMethodDescriptors.get(styledMd);
        // Convert to style 3 method descriptors
        Vector mds = styledMd.doStyleConversion(this, allMethods);
        for (Iterator mdItr = mds.iterator(); mdItr.hasNext(); ) {
            MethodDescriptor md = (MethodDescriptor) mdItr.next();
            // remove it from the list of unpermissioned methods.
            // it will be used at the end to set all remaining methods
            // with the unchecked method permission
            unpermissionedMethods.remove(md);
            // method descriptor and update the table
            for (Iterator newPermissionsItr = newPermissions.iterator(); newPermissionsItr.hasNext(); ) {
                MethodPermission newMp = (MethodPermission) newPermissionsItr.next();
                updateMethodPermissionForMethod(newMp, md);
            }
        }
    }
    // All remaining methods should now be defined as unchecked...
    MethodPermission mp = MethodPermission.getUncheckedMethodPermission();
    Iterator iterator = unpermissionedMethods.iterator();
    while (iterator.hasNext()) {
        MethodDescriptor md = (MethodDescriptor) iterator.next();
        if (getMethodPermissions(md).isEmpty()) {
            addMethodPermissionForMethod(mp, md);
        }
    }
    // finally we reset the list of method descriptors that need style conversion
    styledMethodDescriptors = null;
}
Also used : Set(java.util.Set) OrderedSet(com.sun.enterprise.deployment.OrderedSet) HashSet(java.util.HashSet) Iterator(java.util.Iterator) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) Vector(java.util.Vector) MethodPermission(com.sun.enterprise.deployment.MethodPermission)

Aggregations

MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)97 Method (java.lang.reflect.Method)37 Iterator (java.util.Iterator)25 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)23 Set (java.util.Set)18 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)17 Enumeration (java.util.Enumeration)16 ArrayList (java.util.ArrayList)12 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)11 MethodPermission (com.sun.enterprise.deployment.MethodPermission)10 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)10 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)10 Result (com.sun.enterprise.tools.verifier.Result)9 HashSet (java.util.HashSet)9 Vector (java.util.Vector)7 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)7 MethodNode (com.sun.enterprise.deployment.node.MethodNode)6 Collection (java.util.Collection)6 HashMap (java.util.HashMap)6 ScheduledTimerDescriptor (org.glassfish.ejb.deployment.descriptor.ScheduledTimerDescriptor)6