Package com.sun.enterprise.deployment

Examples of com.sun.enterprise.deployment.MethodDescriptor


            // Perform 2.x style TimedObject processing if the class
            // hasn't already been identified as a timed object. 
            if( !ejb.isTimedObject() ) {

                if( javax.ejb.TimedObject.class.isAssignableFrom(ejbClass) ) {
                    MethodDescriptor timedObjectMethod =
                        new MethodDescriptor("ejbTimeout",
                                             "TimedObject timeout method",
                                             new String[] {"javax.ejb.Timer"},
                                             MethodDescriptor.EJB_BEAN);
                    ejb.setEjbTimeoutMethod(timedObjectMethod);
                }
            } else {
                // If timeout-method was only processed from the descriptor,
                // we need to create a MethodDescriptor using the actual
                // Method object corresponding to the timeout method.  The
                // timeout method can have any access type and be anywhere
                // in the bean class hierarchy.
                String timeoutMethodName = ejb.getEjbTimeoutMethod().getName();
                MethodDescriptor timeoutMethodDesc = null;
                Class nextClass = ejbClass;
                while((nextClass != Object.class) && (nextClass != null)
                      && (timeoutMethodDesc == null) ) {
                    Method[] methods = nextClass.getDeclaredMethods();
                    for(Method m : methods) {
                        if( (m.getName().equals(timeoutMethodName)) ) {
                            Class[] params = m.getParameterTypes();
                            if( (params.length == 1) &&
                                (params[0] == javax.ejb.Timer.class) ) {
                                timeoutMethodDesc = new MethodDescriptor
                                    (m, MethodDescriptor.EJB_BEAN);
                                ejb.setEjbTimeoutMethod(timeoutMethodDesc);
                                break;
                            }
                        }
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

                                        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),
                            method1.getParameterClassNames()))
                return true;
        }
        return false;
    }
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

                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

        boolean hasError = false;
        String query = null;
        PersistenceDescriptor desc = ((EjbCMPEntityDescriptor)ejbDesc).getPersistenceDescriptor();
       
        for (Iterator it = desc.getQueriedMethods().iterator(); it.hasNext();) {
            MethodDescriptor method = (MethodDescriptor) it.next();
            try {
                QueryDescriptor qDesc = desc.getQueryFor(method);
                query = qDesc.getQuery();
               
                if (qDesc.getIsEjbQl()) {
                    Method m = method.getMethod(ejbDesc);

                    int retypeMapping = mapRetType(qDesc.getReturnTypeMapping());
       
                    boolean finder = false;

                    if ((method.getName()).startsWith("find")) {
                       finder = true;
                       retypeMapping = 2; /*QueryDescriptor.NO_RETURN_TYPE_MAPPING;*/
                    }

                    ejbqlDriver.compile(query, m, retypeMapping, finder, ejbDesc.getName());
View Full Code Here

      }

      Iterator iterator = methods.iterator();
      while(iterator.hasNext())
      {
        MethodDescriptor method = (MethodDescriptor) iterator.next();
        // if the MDB is also a TimedObject then don't check the
        // transaction attribute of ejbTimeout. The
        // timer/HasValidEjbTimeout test will check the transaction
        // attribute for ejbTimeout

        if( descriptor.isTimedObject() &&
            (method.getName()).equals("ejbTimeout") )
          continue;
        ContainerTransaction txAttr = descriptor.
          getContainerTransactionFor(method);
        if(txAttr == null)
        {
            if(getVerifierContext().getJavaEEVersion().compareTo(SpecVersionMapper.JavaEEVersion_5)<0) {
          // transaction attribute is not specified for method.
          addErrorDetails(result, compName);
          result.failed(smh.getLocalString
              (getClass().getName()+".failed4",
               "Error : Message-driven bean [ {0} ] method definition [ {1} ] does not have a valid container transaction descriptor.",
               new Object[] {descriptor.getName(), method.getName()}));                                
            } // default transaction attr in EJB 3.0 is REQUIRED
          continue;
        }
        String ta = txAttr.getTransactionAttribute();
        if (ContainerTransaction.REQUIRED.equals(ta) ||
            ContainerTransaction.NOT_SUPPORTED.equals(ta)) {
          addGoodDetails(result, compName);
          result.passed(smh.getLocalString
              (getClass().getName()+".passed",
               "Message-driven bean [ {0} ] method definition [ {1} ] in assembly-descriptor is correct",
               new Object[] {descriptor.getName(), method.getName()}));                                           
        } else {
          addErrorDetails(result, compName);
          result.failed(smh.getLocalString
              (getClass().getName()+".failed3",
               "Error : Message-driven bean [ {0} ] method definition [ {1} ] transaction attribute must be Required or NotSupported",
               new Object[] {descriptor.getName(), method.getName()}));                                
        }
      }
      return result;                   
    } else {
      addNaDetails(result, compName);
View Full Code Here

            // process each method
            String method = methodsTokenizer.nextToken().trim();
            if (method.length() == 0) {
                continue;
            }
            MethodDescriptor methodDescriptor =
                parseCheckpointedMethod(method);
            if (methodDescriptor != null) {
                checkpointMethodDescriptor.getMethodDescriptors().add(
                    methodDescriptor);
            }
View Full Code Here

                    }
                }
                if (paramTypeList.size() > 0) {
                    String[] paramTypeArray = (String[])paramTypeList.toArray(
                        new String[paramTypeList.size()]);
                    return new MethodDescriptor(methodName, null,
                        paramTypeArray, null);
                } else {
                    return new MethodDescriptor(methodName, null, null, null);
                }              
            } else {
                DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment_badformat_checkpointedmethods", new Object[] {method});
                return null;
            }
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.