001    /**
002     * Copyright (c) 2000-2010 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.aop;
016    
017    import com.liferay.portal.kernel.util.Validator;
018    
019    /**
020     * @author Shuyang Zhou
021     */
022    public class ChainableMethodAdviceInjector {
023    
024            public void afterPropertiesSet() {
025                    if (_injectCondition) {
026                            if (Validator.isNull(_newChainableMethodAdvice)) {
027                                    throw new IllegalArgumentException(
028                                            "New ChainableMethodAdvice is null");
029                            }
030    
031                            if (Validator.isNull(_parentChainableMethodAdvice)) {
032                                    throw new IllegalArgumentException(
033                                            "Parent ChainableMethodAdvice is null");
034                            }
035    
036                            _newChainableMethodAdvice.nextMethodInterceptor =
037                                    _parentChainableMethodAdvice.nextMethodInterceptor;
038                            _parentChainableMethodAdvice.nextMethodInterceptor =
039                                    _newChainableMethodAdvice;
040                    }
041            }
042    
043            public void setInjectCondition(boolean injectCondition) {
044                    _injectCondition = injectCondition;
045            }
046    
047            public void setNewChainableMethodAdvice(
048                    ChainableMethodAdvice newChainableMethodAdvice) {
049                    _newChainableMethodAdvice = newChainableMethodAdvice;
050            }
051    
052            public void setParentChainableMethodAdvice(
053                    ChainableMethodAdvice parentChainableMethodAdvice) {
054                    _parentChainableMethodAdvice = parentChainableMethodAdvice;
055            }
056    
057            private boolean _injectCondition;
058    
059            private ChainableMethodAdvice _newChainableMethodAdvice;
060    
061            private ChainableMethodAdvice _parentChainableMethodAdvice;
062    
063    }