001    /**
002     * Copyright (c) 2000-2012 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
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    }