View Javadoc

1   /*
2    * Copyright 2004-2009 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  package org.seasar.cubby.plugins.s2.aop;
17  
18  import java.io.Serializable;
19  import java.lang.reflect.Method;
20  
21  import org.seasar.cubby.util.ActionUtils;
22  import org.seasar.framework.aop.Pointcut;
23  import org.seasar.framework.aop.impl.PointcutImpl;
24  import org.seasar.framework.exception.EmptyRuntimeException;
25  
26  /**
27   * アクションメソッドに適用される {@link Pointcut}。
28   * 
29   * @author baba
30   */
31  public class ActionMethodPointcutImpl extends PointcutImpl implements
32  		Serializable {
33  
34  	/** シリアルバージョン UID。 */
35  	private static final long serialVersionUID = 1L;
36  
37  	/**
38  	 * {@link ActionMethodPointcutImpl}を作成します。
39  	 * 
40  	 * @param targetClass
41  	 *            対象のクラス
42  	 * @throws EmptyRuntimeException
43  	 *             対象のクラスが <code>null</code> の場合
44  	 */
45  	public ActionMethodPointcutImpl(final Class<?> targetClass)
46  			throws EmptyRuntimeException {
47  		super(targetClass);
48  	}
49  
50  	/**
51  	 * {@link ActionMethodPointcutImpl}を作成します。
52  	 * 
53  	 * @param methodNames
54  	 *            メソッド名
55  	 * @throws EmptyRuntimeException
56  	 *             メソッド名が <code>null</code> または空文字の場合
57  	 */
58  	public ActionMethodPointcutImpl(final String[] methodNames)
59  			throws EmptyRuntimeException {
60  		super(methodNames);
61  	}
62  
63  	/**
64  	 * {@inheritDoc}
65  	 * <p>
66  	 * 対象メソッドがアクションメソッドでない場合は <code>false</code> を返します。
67  	 * そうでない場合はスーパークラスに処理を移譲します。
68  	 * </p>
69  	 */
70  	@Override
71  	public boolean isApplied(final Method targetMethod) {
72  		if (!ActionUtils.isActionMethod(targetMethod)) {
73  			return false;
74  		}
75  		return super.isApplied(targetMethod);
76  	}
77  
78  }