View Javadoc

1   /*
2    * Copyright 2004-2010 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  
17  package org.seasar.cubby.plugins.s2.aop;
18  
19  import java.io.Serializable;
20  import java.lang.reflect.Method;
21  
22  import org.seasar.cubby.util.ActionUtils;
23  import org.seasar.framework.aop.Pointcut;
24  import org.seasar.framework.aop.impl.PointcutImpl;
25  import org.seasar.framework.exception.EmptyRuntimeException;
26  
27  /**
28   * アクションメソッドに適用される {@link Pointcut}。
29   * 
30   * @author baba
31   */
32  public class ActionMethodPointcutImpl extends PointcutImpl implements
33  		Serializable {
34  
35  	/** シリアルバージョン UID。 */
36  	private static final long serialVersionUID = 1L;
37  
38  	/**
39  	 * {@link ActionMethodPointcutImpl}を作成します。
40  	 * 
41  	 * @param targetClass
42  	 *            対象のクラス
43  	 * @throws EmptyRuntimeException
44  	 *             対象のクラスが <code>null</code> の場合
45  	 */
46  	public ActionMethodPointcutImpl(final Class<?> targetClass)
47  			throws EmptyRuntimeException {
48  		super(targetClass);
49  	}
50  
51  	/**
52  	 * {@link ActionMethodPointcutImpl}を作成します。
53  	 * 
54  	 * @param methodNames
55  	 *            メソッド名
56  	 * @throws EmptyRuntimeException
57  	 *             メソッド名が <code>null</code> または空文字の場合
58  	 */
59  	public ActionMethodPointcutImpl(final String[] methodNames)
60  			throws EmptyRuntimeException {
61  		super(methodNames);
62  	}
63  
64  	/**
65  	 * {@inheritDoc}
66  	 * <p>
67  	 * 対象メソッドがアクションメソッドでない場合は <code>false</code> を返します。
68  	 * そうでない場合はスーパークラスに処理を移譲します。
69  	 * </p>
70  	 */
71  	@Override
72  	public boolean isApplied(final Method targetMethod) {
73  		if (!ActionUtils.isActionMethod(targetMethod)) {
74  			return false;
75  		}
76  		return super.isApplied(targetMethod);
77  	}
78  
79  }