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   * @since 2.0.0
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  	public boolean isApplied(final Method targetMethod) {
72  		if (!ActionUtils.isActionMethod(targetMethod)) {
73  			return false;
74  		}
75  		return super.isApplied(targetMethod);
76  	}
77  
78  }