001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.spring.annotation;
016    
017    import com.liferay.portal.kernel.annotation.AnnotationLocator;
018    import com.liferay.portal.kernel.transaction.Transactional;
019    import com.liferay.portal.spring.transaction.TransactionAttributeBuilder;
020    
021    import java.io.Serializable;
022    
023    import java.lang.reflect.AnnotatedElement;
024    import java.lang.reflect.Method;
025    
026    import org.springframework.transaction.annotation.TransactionAnnotationParser;
027    import org.springframework.transaction.interceptor.TransactionAttribute;
028    
029    /**
030     * @author     Michael Young
031     * @author     Shuyang Zhou
032     * @deprecated As of 6.1.0
033     */
034    public class PortalTransactionAnnotationParser
035            implements TransactionAnnotationParser, Serializable {
036    
037            @Override
038            public TransactionAttribute parseTransactionAnnotation(
039                    AnnotatedElement annotatedElement) {
040    
041                    Transactional transactional = null;
042    
043                    if (annotatedElement instanceof Method) {
044                            Method method = (Method)annotatedElement;
045    
046                            transactional = AnnotationLocator.locate(
047                                    method, method.getDeclaringClass(), Transactional.class);
048                    }
049                    else {
050                            transactional = AnnotationLocator.locate(
051                                    (Class<?>)annotatedElement, Transactional.class);
052                    }
053    
054                    return TransactionAttributeBuilder.build(transactional);
055            }
056    
057    }