Package org.glassfish.ejb.deployment.descriptor

Examples of org.glassfish.ejb.deployment.descriptor.ContainerTransaction


            // interface, the Application Assembler can specify only the following
            // values for the transaction attributes of the bean's methods:
            //   Required, RequiresNew, Mandatory
            if (oneFound) {
                String transactionAttribute = "";
                ContainerTransaction containerTransaction = null;
                boolean oneFailed = false;
                if (!descriptor.getMethodContainerTransactions().isEmpty()) {
                    for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
                        MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                        containerTransaction =
                                (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor);

                        if (!(containerTransaction != null && properAttribDefined(containerTransaction))) {
                            transactionAttribute  =
                                    containerTransaction.getTransactionAttribute();
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString
                                    (getClass().getName() + ".failed",
                                            "Error: TransactionAttribute [ {0} ] for method [ {1} ] is not valid.",
                                            new Object[] {transactionAttribute, methodDescriptor.getName()}));
View Full Code Here


      Class c = Class.forName(home, false, getVerifierContext().getClassLoader());
      Method methods[] = c.getDeclaredMethods();
      boolean lookForIt = false;
      for (int i=0; i< methods.length; i++) {
    try  {
        ContainerTransaction containerTransaction = null;
        boolean resolved = true;
/*
                     // This flag is a workaround introduced by Harminder
                     // because currently methodDescriptor.getEjbClassSymbol() is
                     // returning NULL
                     //boolean allMethods = false;
                     boolean wildCardWasPresent = false;
*/

        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
View Full Code Here

        if(descriptor.isTimedObject()) {

            if (descriptor.getTransactionType().equals
                    (EjbDescriptor.CONTAINER_TRANSACTION_TYPE)) {
                MethodDescriptor methodDesc = descriptor.getEjbTimeoutMethod();
                ContainerTransaction txAttr =
                        descriptor.getContainerTransactionFor(methodDesc);
                String version = getVerifierContext().getJavaEEVersion();
                if(txAttr != null) {
                    String ta = txAttr.getTransactionAttribute();
                    if ((version.compareTo(SpecVersionMapper.JavaEEVersion_5) >= 0) &&
                            !(ContainerTransaction.REQUIRES_NEW.equals(ta)
                            || ContainerTransaction.NOT_SUPPORTED.equals(ta)
                            || ContainerTransaction.REQUIRED.equals(ta))) {
                        addErrorDetails(result, compName);
View Full Code Here

      boolean lookForIt = false;
      for (int i = 0; i < componentInterfaceMethods.length; i++) {
    if (Arrays.binarySearch(EJBObjectMethods, componentInterfaceMethods[i].getName()) < 0) {
       
        try  {
      ContainerTransaction containerTransaction = null;
      boolean resolved = false;
/*
                        // This flag is a workaround introduced by Harminder
                        // because currently methodDescriptor.getEjbClassSymbol() is
                        // returning NULL
                        //boolean allMethods = false;
                        boolean wildCardWasPresent = false;
*/
                       
      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_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
View Full Code Here

        TransactionAttribute taAn =
            (TransactionAttribute) ainfo.getAnnotation();

        for (EjbContext ejbContext : ejbContexts) {
            EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
            ContainerTransaction containerTransaction =
                getContainerTransaction(taAn.value());

            if (ElementType.TYPE.equals(ainfo.getElementType())) {
                ejbContext.addPostProcessInfo(ainfo, this);
            } else {
View Full Code Here

    private ContainerTransaction getContainerTransaction(
            TransactionAttributeType taType) {
        switch(taType) {
            case MANDATORY:
                return new ContainerTransaction(
                        ContainerTransaction.MANDATORY,
                        ContainerTransaction.MANDATORY);
            case REQUIRED:
                return new ContainerTransaction(
                        ContainerTransaction.REQUIRED,
                        ContainerTransaction.REQUIRED);
            case REQUIRES_NEW:
                return new ContainerTransaction(
                        ContainerTransaction.REQUIRES_NEW,
                        ContainerTransaction.REQUIRES_NEW);
            case SUPPORTS:
                return new ContainerTransaction(
                        ContainerTransaction.SUPPORTS,
                        ContainerTransaction.SUPPORTS);
            case NOT_SUPPORTED:
                return new ContainerTransaction(
                        ContainerTransaction.NOT_SUPPORTED,
                        ContainerTransaction.NOT_SUPPORTED);
            default: // NEVER
                return new ContainerTransaction(
                        ContainerTransaction.NEVER,
                        ContainerTransaction.NEVER);
        }
    }
View Full Code Here

    public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext)
            throws AnnotationProcessorException {
        EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
        TransactionAttribute taAn =
            (TransactionAttribute) ainfo.getAnnotation();
        ContainerTransaction containerTransaction =
            getContainerTransaction(taAn.value());
        Class classAn = (Class)ainfo.getAnnotatedElement();

        Set txBusMethods = ejbDesc.getTxBusinessMethodDescriptors();
        for (Object mdObj : txBusMethods) {
View Full Code Here

    @Override
    public boolean endElement(XMLElement element) {
        boolean doneWithNode = super.endElement(element);
       
        if (doneWithNode) {
            ContainerTransaction ct =  new ContainerTransaction(trans_attribute, description);
            for (Iterator methodsIterator = methods.iterator();methodsIterator.hasNext();) {
                MethodDescriptor md = (MethodDescriptor) methodsIterator.next();
                EjbBundleDescriptorImpl bundle = (EjbBundleDescriptorImpl) getParentNode().getDescriptor();
                EjbDescriptor ejb = bundle.getEjbByName(md.getEjbName(), true);
                ejb.getMethodContainerTransactions().put(md, ct);
View Full Code Here

        MethodNode mn = new MethodNode();
        for (Object o : methodToTransactions.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            MethodDescriptor md = (MethodDescriptor) entry.getKey();
            Node ctNode = super.writeDescriptor(parent, nodeName, ejb);           
            ContainerTransaction ct = (ContainerTransaction) entry.getValue();
            appendTextChild(ctNode, EjbTagNames.DESCRIPTION, ct.getDescription());
            mn.writeDescriptor(ctNode, EjbTagNames.METHOD, md, ejb.getName());
            appendTextChild(ctNode, EjbTagNames.TRANSACTION_ATTRIBUTE, ct.getTransactionAttribute());
        }
        return null;
    }
View Full Code Here

            accept(roleRef);
        }

        for (Iterator e = ejb.getMethodContainerTransactions().keySet().iterator(); e.hasNext();) {
            MethodDescriptor md = (MethodDescriptor) e.next();
            ContainerTransaction ct = (ContainerTransaction) ejb.getMethodContainerTransactions().get(md);
            accept(md, ct);
        }

        for (EnvironmentProperty envProp : ejb.getEnvironmentProperties()) {
            accept(envProp);
View Full Code Here

TOP

Related Classes of org.glassfish.ejb.deployment.descriptor.ContainerTransaction

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.