Search in sources :

Example 11 with ContainerTransaction

use of org.glassfish.ejb.deployment.descriptor.ContainerTransaction in project Payara by payara.

the class ContainerTransactionNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node in the DOM tree
 * @param nodeName name for the root element of this xml fragment
 * @param ejb the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, String nodeName, EjbDescriptor ejb) {
    Map methodToTransactions = ejb.getMethodContainerTransactions();
    MethodNode mn = new MethodNode();
    for (Object o : methodToTransactions.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        MethodDescriptor md = (MethodDescriptor) entry.getKey();
        Node ctNode = super.writeDescriptor(parent, nodeName, ejb);
        ContainerTransaction ct = (ContainerTransaction) entry.getValue();
        appendTextChild(ctNode, EjbTagNames.DESCRIPTION, ct.getDescription());
        mn.writeDescriptor(ctNode, EjbTagNames.METHOD, md, ejb.getName());
        appendTextChild(ctNode, EjbTagNames.TRANSACTION_ATTRIBUTE, ct.getTransactionAttribute());
    }
    return null;
}
Also used : MethodNode(com.sun.enterprise.deployment.node.MethodNode) ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) MethodNode(com.sun.enterprise.deployment.node.MethodNode) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) Node(org.w3c.dom.Node) Map(java.util.Map) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 12 with ContainerTransaction

use of org.glassfish.ejb.deployment.descriptor.ContainerTransaction in project Payara by payara.

the class HasValidEjbTimeoutDescriptor method check.

/**
 * Run a verifier test to check the transaction attributes of the
 * ejbTimeout method. The allowed attributes are -
 * RequiresNew or NotSupported.
 *
 * @param descriptor the Enterprise Java Bean deployment descriptor
 *
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    result = getInitializedResult();
    compName = getVerifierContext().getComponentNameConstructor();
    if (descriptor.isTimedObject()) {
        if (descriptor.getTransactionType().equals(EjbDescriptor.CONTAINER_TRANSACTION_TYPE)) {
            MethodDescriptor methodDesc = descriptor.getEjbTimeoutMethod();
            ContainerTransaction txAttr = descriptor.getContainerTransactionFor(methodDesc);
            String version = getVerifierContext().getJavaEEVersion();
            if (txAttr != null) {
                String ta = txAttr.getTransactionAttribute();
                if ((version.compareTo(SpecVersionMapper.JavaEEVersion_5) >= 0) && !(ContainerTransaction.REQUIRES_NEW.equals(ta) || ContainerTransaction.NOT_SUPPORTED.equals(ta) || ContainerTransaction.REQUIRED.equals(ta))) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error : Bean [ {0} ] Transaction attribute for timeout method" + "must be Required, RequiresNew or NotSupported", new Object[] { descriptor.getName() }));
                } else if ((version.compareTo(SpecVersionMapper.JavaEEVersion_5) < 0) && !(ContainerTransaction.REQUIRES_NEW.equals(ta) || ContainerTransaction.NOT_SUPPORTED.equals(ta))) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed2", "Error : Bean [ {0} ] Transaction attribute for ejbTimeout " + "must be RequiresNew or NotSupported", new Object[] { descriptor.getName() }));
                }
            } else if (version.compareTo(SpecVersionMapper.JavaEEVersion_5) < 0) {
                // Transaction attribute for ejbTimeout not specified in the DD
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed3", "Transaction attribute for Timeout is not specified for [ {0} ]", new Object[] { descriptor.getName() }));
            }
        }
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Transaction attributes are properly specified"));
    }
    return result;
}
Also used : ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 13 with ContainerTransaction

use of org.glassfish.ejb.deployment.descriptor.ContainerTransaction in project Payara by payara.

the class TransactionDemarcationComponentInterface method commonToBothInterfaces.

/**
 * This method is responsible for the logic of the test. It is called for both local and component interfaces.
 * @param descriptor the Enterprise Java Bean deployment descriptor
 * @param component for the Remote/Local interface of the Ejb.
 * @return boolean the results for this assertion i.e if a test has failed or not
 */
private boolean commonToBothInterfaces(String component, EjbSessionDescriptor descriptor, String methodIntf) {
    boolean oneFailed = false;
    try {
        Arrays.sort(EJBObjectMethods);
        // retrieve the component interface methods
        VerifierTestContext context = getVerifierContext();
        ClassLoader jcl = context.getClassLoader();
        Class componentInterfaceClass = Class.forName(component, false, getVerifierContext().getClassLoader());
        Method[] componentInterfaceMethods = componentInterfaceClass.getMethods();
        boolean lookForIt = false;
        for (int i = 0; i < componentInterfaceMethods.length; i++) {
            if (Arrays.binarySearch(EJBObjectMethods, componentInterfaceMethods[i].getName()) < 0) {
                try {
                    ContainerTransaction containerTransaction = null;
                    boolean resolved = false;
                    if (!descriptor.getMethodContainerTransactions().isEmpty()) {
                        for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements(); ) {
                            lookForIt = false;
                            MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                            // style 1)
                            if (methodDescriptor.getName().equals(MethodDescriptor.ALL_METHODS)) {
                                // if Remote - PASS
                                if (methodDescriptor.getEjbClassSymbol() == null) {
                                    lookForIt = true;
                                } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE) || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) {
                                    lookForIt = true;
                                // if empty String PASS
                                } else if (methodDescriptor.getEjbClassSymbol().equals("")) {
                                    lookForIt = true;
                                } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME) || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) {
                                    lookForIt = false;
                                // else (Bogus)
                                } else {
                                    // carry on & don't look for
                                    // container transaction
                                    lookForIt = false;
                                }
                            } else if (methodDescriptor.getParameterClassNames() == null) {
                                // if (getEjbClassSybol() is Remote or is the empty String AND if componentInterfaceMethods[i].getName().equals(methodDescriptor.getName())
                                if (((methodDescriptor.getEjbClassSymbol() == null) || methodDescriptor.getEjbClassSymbol().equals("") || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE) || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) && (componentInterfaceMethods[i].getName().equals(methodDescriptor.getName()))) {
                                    // PASS
                                    lookForIt = true;
                                } else {
                                    // carry on
                                    lookForIt = false;
                                }
                            } else {
                                if (((methodDescriptor.getEjbClassSymbol() == null) || methodDescriptor.getEjbClassSymbol().equals("") || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE) || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) && (componentInterfaceMethods[i].getName().equals(methodDescriptor.getName())) && (MethodUtils.stringArrayEquals(methodDescriptor.getParameterClassNames(), (new MethodDescriptor(componentInterfaceMethods[i], methodIntf)).getParameterClassNames()))) {
                                    // PASS
                                    lookForIt = true;
                                } else {
                                    // CARRY ON
                                    lookForIt = false;
                                }
                            }
                            if (lookForIt) {
                                containerTransaction = (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor);
                                if (containerTransaction != null) {
                                    String transactionAttribute = containerTransaction.getTransactionAttribute();
                                    // don't need this check here
                                    if (ContainerTransaction.NOT_SUPPORTED.equals(transactionAttribute) || ContainerTransaction.SUPPORTS.equals(transactionAttribute) || ContainerTransaction.REQUIRED.equals(transactionAttribute) || ContainerTransaction.REQUIRES_NEW.equals(transactionAttribute) || ContainerTransaction.MANDATORY.equals(transactionAttribute) || ContainerTransaction.NEVER.equals(transactionAttribute) || (!transactionAttribute.equals(""))) {
                                        addGoodDetails(result, compName);
                                        result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "Valid: TransactionAttribute [ {0} ] for method [ {1} ] is defined for component interface [ {2} ]", new Object[] { transactionAttribute, componentInterfaceMethods[i].getName(), component }));
                                        resolved = true;
                                    } else {
                                        oneFailed = true;
                                        addErrorDetails(result, compName);
                                        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: TransactionAttribute [ {0} ] for method [ {1} ] is not valid.   Transaction attributes must be defined for all methods of component interface [ {2} ].", new Object[] { transactionAttribute, componentInterfaceMethods[i].getName(), component }));
                                    }
                                } else {
                                    oneFailed = true;
                                    addErrorDetails(result, compName);
                                    result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failedException", "Error: TransactionAttribute is null for method [ {0} ]", new Object[] { methodDescriptor.getName() }));
                                }
                            }
                        }
                        // did you resolve the last one okay?
                        if (!resolved) {
                            /*
                                // This if-stmt code is a workaround introduced by Harminder
                                // because currently methodDescriptor.getEjbClassSymbol() is
                                // returning NULL
                                //if (allMethods){
                                if (!wildCardWasPresent) {
*/
                            oneFailed = true;
                            addErrorDetails(result, compName);
                            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed1", "Error: Transaction attributes must be specified for the methods defined in the component interface [ {0} ].  Method [ {1} ] has no transaction attribute defined within this bean [ {2} ].", new Object[] { component, componentInterfaceMethods[i].getName(), descriptor.getName() }));
                        /*
                                }
                                else {
                                             result.addGoodDetails(smh.getLocalString
                                                                   ("tests.componentNameConstructor",
                                                                    "For [ {0} ]",
                                                                    new Object[] {compName.toString()}));
					    result.addGoodDetails(smh.getLocalString
								  (getClass().getName() + ".passed",
								   "Valid: TransactionAttribute [ {0} ] for method [ {1} ] is defined for component interface [ {2} ]", new Object[] {"*", "*",component}));
                              }
                              // End of workaround code. Note : this else also has to be removed once
                              // the original bug of methodDesc.getEjbClassSymbol() is fixed

*/
                        }
                    } else {
                        oneFailed = true;
                        addErrorDetails(result, compName);
                        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed2", "Error: There are no transaction attributes within this bean [ {0} ].  Transaction attributes must be specified for the methods defined in the component interface [ {1} ].  Method [ {2} ] has no transaction attribute defined.", new Object[] { descriptor.getName(), component, componentInterfaceMethods[i].getName() }));
                    }
                    if (oneFailed == true)
                        return oneFailed;
                } catch (Exception e) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failedException1", "Error: Component interface [ {0} ] does not contain class [ {1} ] within bean [ {2} ]", new Object[] { component, e.getMessage(), descriptor.getName() }));
                    return oneFailed;
                }
            } else // if you found a business method
            {
                // bug 6383704
                if (componentInterfaceMethods[i].getName().equals("remove")) {
                    for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements(); ) {
                        MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                        if (methodDescriptor.getName().equals("remove")) {
                            oneFailed = true;
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString(getClass().getName() + ".failedExcep", "Error: Method [ {0} ] should not be assigned a transaction attribute.", new Object[] { methodDescriptor.getName() }));
                            break;
                        }
                    }
                }
            }
        }
        // for all component interface methods
        return oneFailed;
    } catch (ClassNotFoundException e) {
        Verifier.debug(e);
        addErrorDetails(result, compName);
        result.failed(smh.getLocalString(getClass().getName() + ".failedException2", "Error: Component interface [ {0} ] does not exist or is not loadable within bean [ {1} ]", new Object[] { component, descriptor.getName() }));
        return oneFailed;
    }
}
Also used : Enumeration(java.util.Enumeration) VerifierTestContext(com.sun.enterprise.tools.verifier.VerifierTestContext) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction)

Example 14 with ContainerTransaction

use of org.glassfish.ejb.deployment.descriptor.ContainerTransaction in project Payara by payara.

the class TransactionDemarcationSessionSynchronizationInterface method check.

/**
 * Optionally implemented SessionSynchronization interface transaction
 * demarcation test.
 * If an enterprise bean implements the javax.ejb.SessionSynchronization
 * interface, the Application Assembler can specify only the following values
 * for the transaction attributes of the bean's methods:
 *   Required
 *   RequiresNew
 *   Mandatory
 *
 * @param descriptor the Enterprise Java Bean deployment descriptor
 *
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFound = false;
    if (descriptor instanceof EjbSessionDescriptor) {
        try {
            VerifierTestContext context = getVerifierContext();
            ClassLoader jcl = context.getClassLoader();
            Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
            // walk up the class tree
            do {
                Class[] interfaces = c.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals("javax.ejb.SessionSynchronization")) {
                        oneFound = true;
                        break;
                    }
                }
            } while ((c = c.getSuperclass()) != null);
        } catch (ClassNotFoundException e) {
            Verifier.debug(e);
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName() + ".failedException1", "Error: [ {0} ] class not found.", new Object[] { descriptor.getEjbClassName() }));
            return result;
        }
        // Required, RequiresNew, Mandatory
        if (oneFound) {
            String transactionAttribute = "";
            ContainerTransaction containerTransaction = null;
            boolean oneFailed = false;
            if (!descriptor.getMethodContainerTransactions().isEmpty()) {
                for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements(); ) {
                    MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                    containerTransaction = (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor);
                    if (!(containerTransaction != null && properAttribDefined(containerTransaction))) {
                        transactionAttribute = containerTransaction.getTransactionAttribute();
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: TransactionAttribute [ {0} ] for method [ {1} ] is not valid.", new Object[] { transactionAttribute, methodDescriptor.getName() }));
                    }
                }
            }
        }
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "TransactionAttributes are defined properly for the bean"));
    }
    return result;
}
Also used : Enumeration(java.util.Enumeration) VerifierTestContext(com.sun.enterprise.tools.verifier.VerifierTestContext) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) Result(com.sun.enterprise.tools.verifier.Result) ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)

Example 15 with ContainerTransaction

use of org.glassfish.ejb.deployment.descriptor.ContainerTransaction in project Payara by payara.

the class TransactionDemarcationHomeInterface method commonToBothInterfaces.

/**
 * This method is responsible for the logic of the test. It is called for both local and remote interfaces.
 * @param descriptor the Enterprise Java Bean deployment descriptor
 * @param home for the Home interface of the Ejb.
 * @param methodIntf is the interface type
 * @return boolean the results for this assertion i.e if a test has failed or not
 */
private boolean commonToBothInterfaces(String home, EjbDescriptor descriptor, String methodIntf) {
    boolean oneFailed = false;
    try {
        Arrays.sort(EJBObjectMethods);
        Class c = Class.forName(home, false, getVerifierContext().getClassLoader());
        Method[] methods = c.getDeclaredMethods();
        boolean lookForIt = false;
        for (int i = 0; i < methods.length; i++) {
            if (Arrays.binarySearch(EJBObjectMethods, methods[i].getName()) < 0) {
                try {
                    ContainerTransaction containerTransaction = null;
                    boolean resolved = false;
                    if (!descriptor.getMethodContainerTransactions().isEmpty()) {
                        for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements(); ) {
                            lookForIt = false;
                            MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                            // style 1)
                            if (methodDescriptor.getName().equals(MethodDescriptor.ALL_METHODS)) {
                                // if Home - PASS
                                if (methodDescriptor.getEjbClassSymbol() == null) {
                                    lookForIt = true;
                                } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME)) {
                                    lookForIt = true;
                                // if empty String PASS
                                } else if (methodDescriptor.getEjbClassSymbol().equals("")) {
                                    lookForIt = true;
                                } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) {
                                    lookForIt = true;
                                } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE)) {
                                    lookForIt = false;
                                } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) {
                                    lookForIt = false;
                                // else (Bogus)
                                } else {
                                    // carry on & don't look for
                                    // container transaction
                                    lookForIt = false;
                                }
                            } else if (methodDescriptor.getParameterClassNames() == null) {
                                // if (getEjbClassSybol() is Home or is the empty String AND if methods[i].getName().equals(methodDescriptor.getName())
                                if (((methodDescriptor.getEjbClassSymbol() == null) || methodDescriptor.getEjbClassSymbol().equals("") || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME) || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) && (methods[i].getName().equals(methodDescriptor.getName()))) {
                                    // PASS
                                    lookForIt = true;
                                } else {
                                    // carry on
                                    lookForIt = false;
                                }
                            } else {
                                if (((methodDescriptor.getEjbClassSymbol() == null) || methodDescriptor.getEjbClassSymbol().equals("") || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME) || methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) && (methods[i].getName().equals(methodDescriptor.getName())) && (MethodUtils.stringArrayEquals(methodDescriptor.getParameterClassNames(), (new MethodDescriptor(methods[i], methodIntf)).getParameterClassNames()))) {
                                    // PASS
                                    lookForIt = true;
                                } else {
                                    // CARRY ON
                                    lookForIt = false;
                                }
                            }
                            if (lookForIt) {
                                containerTransaction = (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor);
                                if (containerTransaction != null) {
                                    String transactionAttribute = containerTransaction.getTransactionAttribute();
                                    // don't need this check here
                                    if (ContainerTransaction.NOT_SUPPORTED.equals(transactionAttribute) || ContainerTransaction.SUPPORTS.equals(transactionAttribute) || ContainerTransaction.REQUIRED.equals(transactionAttribute) || ContainerTransaction.REQUIRES_NEW.equals(transactionAttribute) || ContainerTransaction.MANDATORY.equals(transactionAttribute) || ContainerTransaction.NEVER.equals(transactionAttribute) || (!transactionAttribute.equals(""))) {
                                        addGoodDetails(result, compName);
                                        result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "Valid: [ {0} ] TransactionAttribute [ {1} ] for method [ {2} ] is valid.   Transaction attributes must be specified for all methods except getEJBMetaData and getHomeHandle methods of home interface [ {3} ]", new Object[] { methods[i].getName(), transactionAttribute, methodDescriptor.getName(), home }));
                                        resolved = true;
                                    } else {
                                        oneFailed = true;
                                        addErrorDetails(result, compName);
                                        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: [ {0} ] TransactionAttribute [ {1} ] for method [ {2} ] " + "is not valid.   Transaction attributes must be specified for " + "all methods except getEJBMetaData and getHomeHandle methods of " + "home interface [ {3} ]", new Object[] { methods[i].getName(), transactionAttribute, methodDescriptor.getName(), home }));
                                    }
                                } else {
                                    oneFailed = true;
                                    result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failedException", "Error: TransactionAttribute is null for method [ {0} ]", new Object[] { methodDescriptor.getName() }));
                                }
                            }
                        }
                        // did you resolve the last one okay?
                        if (!resolved) {
                            /*
                                // This if-stmt code is a workaround introduced by Harminder
                                // because currently methodDescriptor.getEjbClassSymbol() is
                                // returning NULL
                                //if (allMethods){
                                if (!wildCardWasPresent) {
*/
                            oneFailed = true;
                            addErrorDetails(result, compName);
                            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed1", "Error: Transaction attributes must be specified for the methods defined in the home interface [ {0} ].  Method [ {1} ] has no transaction attribute defined within this bean [ {2} ].", new Object[] { home, methods[i].getName(), descriptor.getName() }));
                        }
                    /*
                             else {
                                      result.addGoodDetails(smh.getLocalString
                                                                   ("tests.componentNameConstructor",
                                                                    "For [ {0} ]",
                                                                    new Object[] {compName.toString()}));
				      result.addGoodDetails(smh.getLocalString
						(getClass().getName() + ".passed",
					         "Valid: [ {0} ] TransactionAttribute [ {1} ] for method [ {2} ] is valid.   Transaction attributes must be specified for all methods except getEJBMetaData and getHomeHandle methods of home interface [ {3} ]",
						 new Object[] {methods[i].getName(),"*","*", home}));
//                              }
                              // End of workaround code. Note : this else also has to be removed once
                              // the original bug of methodDesc.getEjbClassSymbol() is fixed

                          }
*/
                    } else {
                        oneFailed = true;
                        addErrorDetails(result, compName);
                        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed2", "Error: There are no method container transactions within this bean [ {0} ].   Transaction attributes must be specified for the methods defined in the home interface [ {1} ].  Method [ {2} ] has no transaction attribute defined.", new Object[] { descriptor.getName(), home, methods[i].getName() }));
                    }
                    if (oneFailed == true && i == methods.length - 1)
                        return oneFailed;
                    else
                        continue;
                } catch (Exception e) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failedException1", "Error: Home interface [ {0} ] does not contain class [ {1} ] within bean [ {2} ]", new Object[] { home, e.getMessage(), descriptor.getName() }));
                    oneFailed = true;
                    return oneFailed;
                }
            } else // if found relevant Home interface method
            {
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failedExcep", "Error: Method [ {0} ] should not be assigned a transaction attribute.", new Object[] { methods[i].getName() }));
            }
        }
        // for all the methods within the home interface class, loop
        return oneFailed;
    } catch (ClassNotFoundException e) {
        Verifier.debug(e);
        addErrorDetails(result, compName);
        result.failed(smh.getLocalString(getClass().getName() + ".failedException2", "Error: Home interface [ {0} ] does not exist or is not loadable within bean [ {1} ]", new Object[] { home, descriptor.getName() }));
        oneFailed = true;
        return oneFailed;
    }
}
Also used : Enumeration(java.util.Enumeration) ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) Method(java.lang.reflect.Method) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Aggregations

ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)18 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)17 Enumeration (java.util.Enumeration)7 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)6 Result (com.sun.enterprise.tools.verifier.Result)5 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)5 Method (java.lang.reflect.Method)5 Iterator (java.util.Iterator)4 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)4 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)3 Set (java.util.Set)3 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)3 Collection (java.util.Collection)2 TransactionAttribute (javax.ejb.TransactionAttribute)2 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)1 LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)1 MethodPermission (com.sun.enterprise.deployment.MethodPermission)1 ResourceEnvReferenceDescriptor (com.sun.enterprise.deployment.ResourceEnvReferenceDescriptor)1 ResourceReferenceDescriptor (com.sun.enterprise.deployment.ResourceReferenceDescriptor)1 RoleReference (com.sun.enterprise.deployment.RoleReference)1