001    /**
002     * Copyright (c) 2000-2011 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
033     */
034    public class PortalTransactionAnnotationParser
035            implements TransactionAnnotationParser, Serializable {
036    
037            public TransactionAttribute parseTransactionAnnotation(
038                    AnnotatedElement annotatedElement) {
039    
040                    Transactional transactional = null;
041    
042                    if (annotatedElement instanceof Method) {
043                            Method method = (Method)annotatedElement;
044    
045                            transactional = AnnotationLocator.locate(
046                                    method, method.getDeclaringClass(), Transactional.class);
047                    }
048                    else {
049                            transactional = AnnotationLocator.locate(
050                                    (Class<?>)annotatedElement, Transactional.class);
051                    }
052    
053                    return TransactionAttributeBuilder.build(transactional);
054            }
055    
056    }