Package com.sun.enterprise.deployment

Examples of com.sun.enterprise.deployment.MethodDescriptor


            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_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

    String transactionType = descriptor.getTransactionType();
    if (EjbDescriptor.BEAN_TRANSACTION_TYPE.equals(transactionType)) {
        ContainerTransaction containerTransaction = null;
                    if (!descriptor.getMethodContainerTransactions().isEmpty()) {
                        for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
          MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                            containerTransaction =
                                                (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor);
         
          try {
        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(""))) {
            result.addErrorDetails(smh.getLocalString
                 ("tests.componentNameConstructor",
                  "For [ {0} ]",
                  new Object[] {compName.toString()}));
            result.failed(smh.getLocalString
              (getClass().getName() + ".failed",
               "Error: TransactionAttribute [ {0} ] for method [ {1} ] is not valid.   The Application Assembler must not define transaction attributes for an enterprise bean [ {2} ] with bean-managed transaction demarcation.",
               new Object[] {transactionAttribute, methodDescriptor.getName(),descriptor.getName()}));
        } else {
            result.addGoodDetails(smh.getLocalString
                ("tests.componentNameConstructor",
                 "For [ {0} ]",
                 new Object[] {compName.toString()}));
            result.passed(smh.getLocalString
              (getClass().getName() + ".passed",
               "Valid: TransactionAttribute [ {0} ] for method [ {1} ] is not defined for an enterprise bean [ {2} ] with bean-managed transaction demarcation.",
               new Object[] {transactionAttribute, methodDescriptor.getName(),descriptor.getName()}));
        }
          } catch (NullPointerException e) {
        result.addGoodDetails(smh.getLocalString
                  ("tests.componentNameConstructor",
                   "For [ {0} ]",
                   new Object[] {compName.toString()}));
        result.passed(smh.getLocalString
                (getClass().getName() + ".passed1",
                 "Valid: TransactionAttribute is null for method [ {0} ] in bean [ {1} ]",
                 new Object[] {methodDescriptor.getName(),descriptor.getName()}));
        return result;
          }
      }
        } else {
      result.addGoodDetails(smh.getLocalString
View Full Code Here

                                        descriptor.getAroundInvokeDescriptors();
           
            for (LifecycleCallbackDescriptor aiDesc : aiDescriptors) {
                try {
                    Method interceptorMethod = aiDesc.getLifecycleCallbackMethodObject(cl);
                    MethodDescriptor interceptorMD = new MethodDescriptor(interceptorMethod);
                    if(businessMethods.contains(interceptorMD)) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString
                                (getClass().getName() + ".failed",
                                "AroundInvoke method [ {0} ] is a business method.",
View Full Code Here

        for (Method method : methods) {
            if(isStyle2) {// for style 2 do only name comparison
                if(method.getName().equals(method1.getName()))
                    return true;
            } else if (method.getName().equals(method1.getName()) &&
                    Arrays.equals(new MethodDescriptor().getParameterClassNamesFor(method, method.getParameterTypes()),
                            method1.getParameterClassNames()))
                return true;
        }
        return false;
    }
View Full Code Here

                Set methods = descriptor.getMethodDescriptors();
//     Set methodPermissions = new HashSet();
                boolean noPermissions = false;
               
                for (Iterator i = methods.iterator(); i.hasNext();) {
                    MethodDescriptor md = (MethodDescriptor) i.next();
                    Set permissions = descriptor.getMethodPermissionsFor(md);
                    if (permissions.isEmpty() || (permissions == null)) {
                        result.addWarningDetails(smh.getLocalString
                                (getClass().getName() + ".failed",
                                        "Warning: Method [ {0} ] of EJB [ {1} ] does not have assigned security-permissions",
                                        new Object[] {md.getName(), descriptor.getName()}));
                        result.setStatus(result.WARNING);
                        noPermissions = true;
                    }
                }
               
View Full Code Here

      boolean na1 = false;
      boolean oneFailed = false;
            if (!descriptor.getMethodContainerTransactions().isEmpty()) {
                for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
 
        MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                    String methodIntf = methodDescriptor.getEjbClassSymbol();
                    if ( methodIntf == null ) { //|| methodIntf.equals("")
                        continue;
                    }
                    // The method-intf element must be one of the following
                    // Home Remote LocalHome Local ServiceEndpoint
                    if (!( (methodIntf.equals(MethodDescriptor.EJB_REMOTE)) ||
                        (methodIntf.equals(MethodDescriptor.EJB_HOME)) ||
                        (methodIntf.equals(MethodDescriptor.EJB_LOCALHOME)) ||
                        (methodIntf.equals(MethodDescriptor.EJB_LOCAL)) ||
                        (methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) ||
                        (methodIntf.length()==0))) {
                    // The method-intf element must be one of the following "Remote" or "Home"
//        if (!((methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE))  ||
//        (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME)) ||
//        (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) ||
//        (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) ||
//                          (methodDescriptor.getEjbClassSymbol().length()==0))) {
      oneFailed =true;
      result.addErrorDetails(smh.getLocalString
                 ("tests.componentNameConstructor",
            "For [ {0} ]",
            new Object[] {compName.toString()}));
      result.addErrorDetails
          (smh.getLocalString
           (getClass().getName() + ".failed",
            "Error: Container transaction method [ {0} ] method-intf element [ {1} ] must be one of the following: [ {2} ] or [ {3} ] or [ {4} ] or [ {5} ]  within bean [ {6} ]",
            new Object[] {methodDescriptor.getName(),methodDescriptor.getEjbClassSymbol(),
            MethodDescriptor.EJB_REMOTE.toString(), MethodDescriptor.EJB_HOME,
            MethodDescriptor.EJB_LOCAL, MethodDescriptor.EJB_LOCALHOME,
            descriptor.getName()}));
        } else {
      result.addGoodDetails(smh.getLocalString
                ("tests.componentNameConstructor",
                 "For [ {0} ]",
                 new Object[] {compName.toString()}));
      result.addGoodDetails
          (smh.getLocalString
           (getClass().getName() + ".passed",
            "Container Transaction method [ {0} ] method-intf element [ {1} ] is one of the following:  [ {2} ] or [ {3} ] or [ {4} ] or [ {5} ]  within bean [ {6} ]",
            new Object[] {methodDescriptor.getName(),methodDescriptor.getEjbClassSymbol(),
            MethodDescriptor.EJB_REMOTE, MethodDescriptor.EJB_HOME,
            MethodDescriptor.EJB_LOCAL, MethodDescriptor.EJB_LOCALHOME,
            descriptor.getName()}));
        }
    }
      } else {
                na = true;
      }

            Map permissionedMethods = descriptor.getPermissionedMethodsByPermission();
            if (permissionedMethods.size() >0) {
    for (Iterator e = permissionedMethods.keySet().iterator(); e.hasNext();) {           
        MethodPermission nextPermission = (MethodPermission) e.next();
        Set permissionedMethodsForRole = (HashSet) permissionedMethods.get(nextPermission);

        if (permissionedMethodsForRole != null) {
      Set convertedPermissionedMethods = new HashSet();
      for (Iterator itr = permissionedMethodsForRole.iterator(); itr.hasNext();) {
          MethodDescriptor methodDescriptor = (MethodDescriptor) itr.next();

                            String methodIntf = methodDescriptor.getEjbClassSymbol();
                            if ( methodIntf == null  ) { //|| methodIntf.equals("")
                                continue;
                            }
                            // The method-intf element must be one of the following
                            // Home Remote LocalHome Local ServiceEndpoint
                            if (!( (methodIntf.equals(MethodDescriptor.EJB_REMOTE)) ||
                                (methodIntf.equals(MethodDescriptor.EJB_HOME)) ||
                                (methodIntf.equals(MethodDescriptor.EJB_LOCALHOME)) ||
                                (methodIntf.equals(MethodDescriptor.EJB_LOCAL)) ||
                                (methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) ||
                                (methodIntf.length()==0))) {
 
          // The method-intf element must be one of the following "Remote" or "Home"
//          if (!((methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE))  ||
//          (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME)) ||
//                                (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) ||
//          (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) ||
//                                  (methodDescriptor.getEjbClassSymbol().length()==0))) {

        oneFailed =true;
        result.addErrorDetails(smh.getLocalString
                   ("tests.componentNameConstructor",
              "For [ {0} ]",
              new Object[] {compName.toString()}));
        result.addErrorDetails
            (smh.getLocalString
             (getClass().getName() + ".failed1",
              "Error: Method permissions method [ {0} ] method-intf element [ {1} ] must be one of the interfaces of the bean [ {2} ]",
              new Object[] {methodDescriptor.getName(),
              methodDescriptor.getEjbClassSymbol(),
              descriptor.getName()}));
          } else {
        result.addGoodDetails(smh.getLocalString
                  ("tests.componentNameConstructor",
                   "For [ {0} ]",
                   new Object[] {compName.toString()}));
        result.addGoodDetails
            (smh.getLocalString
             (getClass().getName() + ".passed1",
              "Method permissions method [ {0} ] method-intf element [ {1} ] is one of the interfaces of the  bean [ {2} ]",
              new Object[] {methodDescriptor.getName(),methodDescriptor.getEjbClassSymbol(), descriptor.getName()}));
          }
      }
        }
    }
      } else {
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_METHODS)) {
      foundWildCard++;
        }
    }

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

                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()}));

                        }
                    }
                }
            }
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_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

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.