JavaxEjbTransactionAttributeVisitor.java :  » J2EE » ow2-easybeans » org » ow2 » easybeans » deployment » annotations » analyzer » Java Open Source

Java Open Source » J2EE » ow2 easybeans 
ow2 easybeans » org » ow2 » easybeans » deployment » annotations » analyzer » JavaxEjbTransactionAttributeVisitor.java
/**
 * EasyBeans
 * Copyright (C) 2006 Bull S.A.S.
 * Contact: easybeans@ow2.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id: JavaxEjbTransactionAttributeVisitor.java 2059 2007-11-22 17:22:33Z benoitf $
 * --------------------------------------------------------------------------
 */

package org.ow2.easybeans.deployment.annotations.analyzer;

import static javax.ejb.TransactionAttributeType.MANDATORY;
import static javax.ejb.TransactionAttributeType.REQUIRED;
import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
import static javax.ejb.TransactionAttributeType.SUPPORTS;
import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
import static javax.ejb.TransactionAttributeType.NEVER;

import org.ow2.easybeans.deployment.annotations.metadata.interfaces.ITransactionAttribute;

/**
 * This class manages the handling of @{@link javax.ejb.TransactionAttribute} annotation.
 * @param <T> An implementation of ITransactionAttribute interface.
 * @author Florent Benoit
 */
public class JavaxEjbTransactionAttributeVisitor<T extends ITransactionAttribute>
          extends EnumAnnotationVisitor<T> implements AnnotationType {

    /**
     * Type of annotation.
     */
    public static final String TYPE = "Ljavax/ejb/TransactionAttribute;";

    /**
     * Constructor.
     * @param annotationMetadata linked to a class or method metadata
     */
    public JavaxEjbTransactionAttributeVisitor(final T annotationMetadata) {
        super(annotationMetadata);
    }

    /**
     * Visits the end of the annotation. <br>
     * Creates the object and store it.
     */
    @Override
    public void visitEnd() {
        String s = getValue();
        // TYPE annotation
        if (getAnnotationMetadata() != null) {
            if (MANDATORY.name().equals(s)) {
                getAnnotationMetadata().setTransactionAttributeType(MANDATORY);
            } else if (REQUIRED.name().equals(s)) {
                getAnnotationMetadata().setTransactionAttributeType(REQUIRED);
            } else if (REQUIRES_NEW.name().equals(s)) {
                getAnnotationMetadata().setTransactionAttributeType(REQUIRES_NEW);
            } else if (SUPPORTS.name().equals(s)) {
                getAnnotationMetadata().setTransactionAttributeType(SUPPORTS);
            } else if (NOT_SUPPORTED.name().equals(s)) {
                getAnnotationMetadata().setTransactionAttributeType(NOT_SUPPORTED);
            } else if (NEVER.name().equals(s)) {
                getAnnotationMetadata().setTransactionAttributeType(NEVER);
            } else {
                // set default
                getAnnotationMetadata().setTransactionAttributeType(REQUIRED);
            }
        }
    }

    /**
     * @return type of the annotation (its description)
     */
    public String getType() {
        return TYPE;
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.