Package com.sun.enterprise.deployment

Examples of com.sun.enterprise.deployment.MethodDescriptor


      */
     private void transformAndAdd(Collection methods, String methodIntf, Vector globalList) {
        
         for (Iterator itr = methods.iterator();itr.hasNext();) {
             Method m = (Method) itr.next();                                                
             MethodDescriptor md = new MethodDescriptor(m, methodIntf);
             globalList.add(md);
         }
     }
View Full Code Here


            isTimedObject = javax.ejb.TimedObject.class.isAssignableFrom(beanClass);
        } catch (ClassNotFoundException e) {} //continue
       
        initializeMethods();
        for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
            MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
           
            if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS) ||
                    methodDescriptor.getParameterClassNames() == null) // style 1 and 2
                continue;
           
            if(isTimedObject &&
                    MethodDescriptor.EJB_BEAN.equals(methodDescriptor.getEjbClassSymbol()) &&
                    methodDescriptor.getName().equals("ejbTimeout")) {
                String[] params=methodDescriptor.getJavaParameterClassNames();
                if(params.length==1 && params[0].trim().equals("javax.ejb.Timer"))
                    continue;//found a match
            }//if implements timer
           
            Set<Method> methods = getAllInterfaceMethods(methodDescriptor);
           
            if(!isMethodContained(methods, methodDescriptor)) { // report failure
                String ejbClassSymbol = methodDescriptor.getEjbClassSymbol();
                String intf = ejbClassSymbol;
                if(ejbClassSymbol == null) {
                    intf = smh.getLocalString(getClass().getName() + ".msg", "any of bean");
                } else if(ejbClassSymbol.equals(MethodDescriptor.EJB_REMOTE)) {
                    intf = "Remote or RemoteBusiness";
                } else if(ejbClassSymbol.equals(MethodDescriptor.EJB_LOCAL)) {
                    intf = "Local or LocalBusiness";
                }

                addErrorDetails(result, compName);
                result.failed(smh.getLocalString
                        (getClass().getName() + ".failed",
                        "Error: Container Transaction method name [ {0} ] not " +
                        "defined in [ {1} ] interface(s).",
                        new Object[] {methodDescriptor.getName(), intf}));
            }
        }
    }
View Full Code Here

    private boolean isMethodContained(Set<Method> methods, MethodDescriptor methodDescriptor) {
        boolean foundIt = false;
        for (Method method : methods) {
            if(method.getName().equals(methodDescriptor.getName()) && 
                    MethodUtils.stringArrayEquals(methodDescriptor.getParameterClassNames(),
                            (new MethodDescriptor(method)).getParameterClassNames())) {
                foundIt = true;
                break;
            }
        }
        return foundIt;
View Full Code Here

*/
                        
       if (!descriptor.getMethodContainerTransactions().isEmpty()) {
           for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
        lookForIt = false;
        MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();

    /*** Fixed the bug: 4883730. ejbClassSymbol is null when method-intf is not
     * defined in the xml, since it is an optional field. Removed the earlier
     * checks. A null method-intf indicates that the method is supposed to be
     * in both Local & Home interfaces. ***/                   
/*
                                // This code is a workaround introduced by Harminder
                                // because currently methodDescriptor.getEjbClassSymbol() is
                                // returning NULL
                                String methodIntf = null;
                                try {
                                    methodIntf = methodDescriptor.getEjbClassSymbol();
                                } catch ( Exception ex ) {}
                                if ( methodIntf == null ) { //|| methodIntf.equals("")
                                    //probably a wildcard was there
                                    wildCardWasPresent = true;
                                    continue;
                                }
                                 //allMethods = true;
                                 // end of workaround
*/
                                
         // here we have to check that each method descriptor
         // corresponds to a or some methods on the component interface
         // according to the six styles
         // style 1)
                 if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS)) {
             // if getEjbClassName() is Remote -> CARRY ON
             // if Remote - PASS
                     if (methodDescriptor.getEjbClassSymbol() == null) {
           lookForIt = true;
                     } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE)) {
           lookForIt = true;
           // if empty String PASS
             } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) {
           lookForIt = true;
             }else if (methodDescriptor.getEjbClassSymbol().equals("")) {
           lookForIt = true;
             } else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME)) {
           lookForIt = false;
             else if (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) {
           lookForIt = false;
             }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 (getEjbClassSybol() is Remote or is the empty String AND if componentInterfaceMethods[i].getName().equals(methodDescriptor.getName()) AND
             // the parameters of the method[i] are the same as the parameters of the method descriptor )
            
             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();
          
           // danny is doing this in the DOL, but is it possible to not have
           // any value for containerTransaction.getTransactionAttribute()
           // in the DOL? if it is possible to have blank value for this,
           // then this check is needed here, otherwise we are done and we
           // 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 defined for all methods except getEJBHome, getHandle, getPrimaryKey, and isIdentical methods of component interface [ {3} ].",
                    new Object[] {componentInterfaceMethods[i].getName(), transactionAttribute, methodDescriptor.getName(),component}));
               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 defined for all methods except getEJBHome, getHandle, getPrimaryKey, and isIdentical methods of component interface [ {3} ]",
                     new Object[] {componentInterfaceMethods[i].getName(), transactionAttribute, methodDescriptor.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()}));
             }      
         }
           }
           // before you go on to the next method,
           // did you resolve the last one okay?
View Full Code Here

      if (!descriptor.getMethodContainerTransactions().isEmpty()) {
          for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
        lookForIt = false;
       
        MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
    /*** Fixed the bug: 4883730. ejbClassSymbol is null when method-intf is not
     * defined in the xml, since it is an optional field. Removed the earlier
     * checks. A null method-intf indicates that the method is supposed to be
     * in both Local & Home interfaces. ***/                   
/*
                                // This code is a workaround introduced by Harminder
                                // because currently methodDescriptor.getEjbClassSymbol() is
                                // returning NULL
                                String methodIntf = null;
                                try {
                                    methodIntf = methodDescriptor.getEjbClassSymbol();
                                } catch ( Exception ex ) {}
                                if ( methodIntf == null ) { //|| methodIntf.equals("")
                                    //probably a wildcard was there
                                    wildCardWasPresent = true;
                                    continue;
                                }
                                 //allMethods = true;
                                 // end of workaround
*/
                               
       
        // here we have to check that each method descriptor
        // corresponds to a or some methods on the home interface
        // according to the six styles
        // style 1)
                 if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS)) {
            // if getEjbClassName() is Remote -> CARRY ON
            // 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 (getEjbClassSybol() is Home or is the empty String AND if methods[i].getName().equals(methodDescriptor.getName()) AND
            // the parameters of the method[i] are the same as the parameters of the method descriptor )
           
            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();
         
          // danny is doing this in the DOL, but is it possible to not have
          // any value for containerTransaction.getTransactionAttribute()
          // in the DOL? if it is possible to have blank value for this,
          // then this check is needed here, otherwise we are done and we
          // 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()}));
            }
        }
          }   
          // before you go on to the next method,
          // did you resolve the last one okay?
View Full Code Here

      boolean oneFailed = false;
      boolean na = false;
      int foundWildCard = 0;
            if (!descriptor.getMethodContainerTransactions().isEmpty()) {
    for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
        MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
 
        if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS)) {
      foundWildCard++;
        }
    }

    // report for this particular set of Container tx's
View Full Code Here

      if (!descriptor.getMethodContainerTransactions().isEmpty()) {
         
          for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
        lookForIt = false;
                               
        MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();

    /*** Fixed the bug: 4883730. ejbClassSymbol is null when method-intf is not
     * defined in the xml, since it is an optional field. Removed the earlier
     * checks. A null method-intf indicates that the method is supposed to be
     * in both Local & Home interfaces. ***/                   
/*
                                String methodIntf = null;
                                try {
                                    methodIntf = methodDescriptor.getEjbClassSymbol();
                                } catch ( Exception ex ) {}
                                if ( methodIntf == null ) { //|| methodIntf.equals("")
                                    //probably a wildcard was there
                                    wildCardWasPresent = true;
                                    continue;
                                }
                                //allMethods = true;
                                // end of workaround
*/
                               
        // here we have to check that each method descriptor
        // corresponds to a or some methods on the component interface
        // according to the six styles
        // style 1)
        if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS)) {
            // if getEjbClassName() is Remote -> CARRY ON
            // 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 (getEjbClassSybol() is Remote or is the empty String AND if componentInterfaceMethods[i].getName().equals(methodDescriptor.getName()) AND
            // the parameters of the method[i] are the same as the parameters of the method descriptor )
           
            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();
         
          // danny is doing this in the DOL, but is it possible to not have
          // any value for containerTransaction.getTransactionAttribute()
          // in the DOL? if it is possible to have blank value for this,
          // then this check is needed here, otherwise we are done and we
          // 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()}));
            }
        }
          }
          // before you go on to the next method,
          // 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;
        }
    } // if you found a business method
    else // 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;
                }
            }
        }
    }
View Full Code Here

*/

        if (!descriptor.getMethodContainerTransactions().isEmpty()) {
      for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
          lookForIt = false;
          MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();

    /*** Fixed the bug: 4883730. ejbClassSymbol is null when method-intf is not
     * defined in the xml, since it is an optional field. Removed the earlier
     * checks. A null method-intf indicates that the method is supposed to be
     * in both Local & Home interfaces. ***/                   
/*
                            String methodIntf = null;
                            try {
                                methodIntf = methodDescriptor.getEjbClassSymbol();
                            } catch ( Exception ex ) {}
                            if ( methodIntf == null ) { //|| methodIntf.equals("")
                                //probably a wildcard was there
                                wildCardWasPresent = true;
                                continue;
                            }
                            //allMethods = true;
                            // end of workaround
*/

                           
          // here we have to check that each method descriptor
          // corresponds to a or some methods on the home interface
          // according to the six styles
          // style 1)
          if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS)) {
        // if getEjbClassName() is Remote -> CARRY ON
        // 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_REMOTE)) {
            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 (getEjbClassSybol() is Home or is the empty String AND if methods[i].getName().equals(methodDescriptor.getName()) AND
        // the parameters of the method[i] are the same as the parameters of the method descriptor )        
        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();
           
            // danny is doing this in the DOL, but is it possible to not have
            // any value for containerTransaction.getTransactionAttribute()
            // in the DOL? if it is possible to have blank value for this,
            // then this check is needed here, otherwise we are done and we
            // 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(""))) {
          // if "*" ignore, test N/A
          if (!methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME)&&
              !methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) {
              result.addGoodDetails(smh.getLocalString
                  (getClass().getName() + ".passed",
                   "Valid: TransactionAttribute [ {0} ] for method [ {1} ] is not defined for home interface [ {2} ]",
                   new Object[] {transactionAttribute, methods[i].getName(),home}));
          } 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 not be specified for all methods of session bean home interface [ {2} ].",
                    new Object[] {transactionAttribute, methods[i].getName(),home}));
              resolved = false;
          }
            } else {
          addGoodDetails(result, compName);
          result.addGoodDetails(smh.getLocalString
                    (getClass().getName() + ".passed",
                     "Valid: TransactionAttribute [ {0} ] for method [ {1} ] is not defined for home interface [ {2} ]",
                     new Object[] {transactionAttribute, methods[i].getName(),home}));
            }
        } else {
            addGoodDetails(result, compName);
            result.addGoodDetails(smh.getLocalString
                (getClass().getName() + ".passedException",
                 "Valid: TransactionAttribute is null for method [ {0} ]",
                 new Object[] {methodDescriptor.getName()}));
        }
          }
      }
      // before you go on to the next method,
      // did you resolve the last one okay?
View Full Code Here

        try  {
                        Arrays.sort(EJBObjectMethods);
      ContainerTransaction containerTransaction = null;
                        if (!descriptor.getMethodContainerTransactions().isEmpty()) {
                            for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
                                MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
        if (Arrays.binarySearch(EJBObjectMethods, methodDescriptor.getName()) < 0) {
            containerTransaction =
                                                (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor);
               
                    if (containerTransaction != null &&
                            containerTransaction.getTransactionAttribute()!=null) {
              String transactionAttribute  =
                  containerTransaction.getTransactionAttribute();
         
              // danny is doing this in the DOL, but is it possible to not have
              // any value for containerTransaction.getTransactionAttribute()
              // in the DOL? if it is possible to have blank value for this,
              // then this check is needed here, otherwise we are done and we
              // 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)) {
            addGoodDetails(result, compName);
            result.addGoodDetails(smh.getLocalString
                      (getClass().getName() + ".passed",
                       "TransactionAttribute [ {0} ] for method [ {1} ] is valid.",
                       new Object[] {transactionAttribute, methodDescriptor.getName()}));
              } else {
            oneFailed = true;
            addErrorDetails(result, compName);
            result.addErrorDetails(smh.getLocalString
                       (getClass().getName() + ".failed",
                        "Error: TransactionAttribute [ {0} ] for method [ {1} ] is not valid.",
                        new Object[] {transactionAttribute, methodDescriptor.getName()}));
              }
                } else {
                        // Null transaction attributes are allowed in EJB 3. Default is REQUIRED.
                        if(getVerifierContext().getJavaEEVersion().compareTo(SpecVersionMapper.JavaEEVersion_5)<0) {
              oneFailed = true;
              addErrorDetails(result, compName);
              result.addErrorDetails(smh.getLocalString
                         (getClass().getName() + ".failedException",
                    "Error: TransactionAttribute is null for method [ {0} ]",
                    new Object[] {methodDescriptor.getName()}));
                        }
             
                        }
                                } // if you found a business method
        else {
            //check if the ejb is a session bean
            //and the method with transaction attribute belongs
                                //to home/local home interface
            String ejbClass = methodDescriptor.getEjbClassSymbol();

    /*** Fixed the bug: 4883730. ejbClassSymbol is null when method-intf is not
     * defined in the xml, since it is an optional field. Removed the earlier
     * checks. A null method-intf indicates that the method is supposed to be
     * in both Local & Home interfaces. ***/                   
/*
                                    String methodIntf = null;
                                    try {
                                        methodIntf = methodDescriptor.getEjbClassSymbol();
                                    } catch ( Exception ex ) {}
                                    if ( methodIntf == null ) { //|| methodIntf.equals("")
                                        continue;
                                    }

*/
                    boolean session = descriptor instanceof EjbSessionDescriptor;
            boolean entity = descriptor instanceof EjbEntityDescriptor;
            if (((ejbClass == null)
           || ejbClass.equals(MethodDescriptor.EJB_HOME)
           || ejbClass.equals(MethodDescriptor.EJB_LOCALHOME))
          && session) {
          oneFailed = true;
          addErrorDetails(result, compName);
          result.addErrorDetails(smh.getLocalString
                     (getClass().getName() + ".failedHome",
                "Error: TransactionAttribute for method [ {0} ] is not valid. Home or Local Home interface methods of a session bean must not hvae a transaction attribute.",
                new Object[] {methodDescriptor.getName()}));
            }
            //check if it is a session bean with remote/local interface
            //and method with Tx attribute is "remove"
            else if (((ejbClass == null)
                          || ejbClass.equals(MethodDescriptor.EJB_REMOTE)
                || ejbClass.equals(MethodDescriptor.EJB_LOCAL))
               && session && methodDescriptor.getName().equals("remove")) {
          //check for style 3
          //if remove method defined has parameters then pass else fail
          if (methodDescriptor.getParameterClassNames() == null
              || methodDescriptor.getParameterClassNames().length == 0 ) {
              //style 2
              oneFailed = true;
              addErrorDetails(result, compName);
              result.addErrorDetails(smh.getLocalString
                   (getClass().getName() + ".failedComp",
                    "Error: TransactionAttribute for method [ {0} ] is not valid. 'remove' method in Remote/Local interface of a session bean must not have a transaction attribute.",
                    new Object[] {methodDescriptor.getName()}));
          } else {
              addGoodDetails(result, compName);
              result.addGoodDetails(smh.getLocalString
                  (getClass().getName() + ".passedTest",
                   "TransactionAttribute for method [ {0} ] is valid.",
                   new Object[] {methodDescriptor.getName()}));
          }
            }
            else if (((ejbClass == null)
                          || ejbClass.equals(MethodDescriptor.EJB_HOME)
                || ejbClass.equals(MethodDescriptor.EJB_LOCALHOME))
               && entity) {
          if (methodDescriptor.getParameterClassNames() == null
              || methodDescriptor.getParameterClassNames().length == 0) {
              //style 2
              oneFailed = true;
              addErrorDetails(result, compName);
              result.addErrorDetails(smh.getLocalString
                   (getClass().getName() + ".failed1",
                    "Error: TransactionAttribute for method [ {0} ] is not valid. ",
                    new Object[] {methodDescriptor.getName()}));
          } else {
              addGoodDetails(result, compName);
              result.addGoodDetails(smh.getLocalString
                  (getClass().getName() + ".passedTest",
                   "TransactionAttribute for method [ {0} ] is valid.",
                   new Object[] { methodDescriptor.getName()}));
          }
            }
            else if (((ejbClass == null)
           || ejbClass.equals(MethodDescriptor.EJB_REMOTE)
           || ejbClass.equals(MethodDescriptor.EJB_LOCAL))
          && entity) {
          if ((methodDescriptor.getName()).equals("isIdentical")) {
              if(methodDescriptor.getParameterClassNames() == null
                 || methodDescriptor.getParameterClassNames().length == 0 ) {
            addGoodDetails(result, compName);
            result.addGoodDetails(smh.getLocalString
                      (getClass().getName() + ".passedTest",
                       "TransactionAttribute for method [ {0} ] is valid.",
                       new Object[] {methodDescriptor.getName()}));
              } else {
            String[] paramList = methodDescriptor.getParameterClassNames();
            if(Array.getLength(paramList) == 1) {
                if (paramList[0].equals("javax.ejb.EJBObject")) {
              //style 3
              oneFailed = true;
              addErrorDetails(result, compName);
              result.addErrorDetails(smh.getLocalString
                         (getClass().getName() + ".failed1",
                    "Error: TransactionAttribute for method [ {0} ] is not valid.",
                    new Object[] { methodDescriptor.getName()}));
                }
                else {
              addGoodDetails(result, compName);
              result.addGoodDetails(smh.getLocalString
                        (getClass().getName() + ".passedTest",
                         "TransactionAttribute for method [ {0} ] is valid.",
                         new Object[] { methodDescriptor.getName()}));
                }
            } else {
                addGoodDetails(result, compName);
                result.addGoodDetails(smh.getLocalString
                    (getClass().getName() + ".passedTest",
                     "TransactionAttribute for method [ {0} ] is valid.",
                     new Object[] { methodDescriptor.getName()}));
            }
              }
          }
          else { //for all other methods in entity bean
              if ((methodDescriptor.getName()).equals("remove")) {
            addGoodDetails(result, compName);
            result.addGoodDetails(smh.getLocalString
                      (getClass().getName() + ".passedTest",
                       "TransactionAttribute for method [ {0} ] is valid.",
                       new Object[] { methodDescriptor.getName()}));
              }
              else {
            if (methodDescriptor.getParameterClassNames() == null
                || methodDescriptor.getParameterClassNames().length == 0) {
                //style 2
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString
                  (getClass().getName() + ".failedException1",
                   "Error: [ {0} ] should not have a Transaction Attribute",
                   new Object[] {methodDescriptor.getName()}));
            }
              }
          }
            }
        }
View Full Code Here

             }

             Iterator it = txMethDescs.iterator();
             while (it.hasNext()) {
               // need to check if this method is part of SEI
               MethodDescriptor methdesc =(MethodDescriptor)it.next();
              if (isSEIMethod(methdesc, descriptor, sei, cl)) {
                  ctx = descriptor.getContainerTransactionFor(methdesc);
                  if ((ctx != null) &&
                     (ContainerTransaction.MANDATORY.equals(ctx.getTransactionAttribute()))) {
                     // Call result.failed here with Method details here
                     result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
                     result.failed(smh.getLocalString (getClass().getName() + ".failed",
                     "[{0}] of this WebService [{1}] have Mandatory Transaction Attribute.",
                     new Object[] {methdesc.getName(), compName.toString()}));
                     pass = false;
                   }
               }
             }
           } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.MethodDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.