001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    @Deprecated
035    public class PortalTransactionAnnotationParser
036            implements TransactionAnnotationParser, Serializable {
037    
038            @Override
039            public TransactionAttribute parseTransactionAnnotation(
040                    AnnotatedElement annotatedElement) {
041    
042                    Transactional transactional = null;
043    
044                    if (annotatedElement instanceof Method) {
045                            Method method = (Method)annotatedElement;
046    
047                            transactional = AnnotationLocator.locate(
048                                    method, method.getDeclaringClass(), Transactional.class);
049                    }
050                    else {
051                            transactional = AnnotationLocator.locate(
052                                    (Class<?>)annotatedElement, Transactional.class);
053                    }
054    
055                    return TransactionAttributeBuilder.build(transactional);
056            }
057    
058    }