View Javadoc

1   package org.seasar.cubby.customizer;
2   
3   import java.lang.reflect.Method;
4   
5   import org.seasar.cubby.aop.ActionMethodPointcutImpl;
6   import org.seasar.framework.aop.Pointcut;
7   import org.seasar.framework.util.StringUtil;
8   
9   /**
10   * {@link org.seasar.framework.aop.Pointcut ポイントカット}を構築するためのファクトリクラスです。
11   * 
12   * @author baba
13   */
14  class PointcutFactory {
15  
16      /**
17       * 指定されたポイントカットを表す文字列から、 {@link org.seasar.framework.aop.Pointcut ポイントカット}を構築して返します。
18       * 
19       * @param pointcutStr
20       *            ポイントカットを表す文字列
21       * @return ポイントカット
22       */
23      public static Pointcut createPointcut(final String pointcutStr) {
24          if (!StringUtil.isEmpty(pointcutStr)) {
25              String[] methodNames = StringUtil.split(pointcutStr, ", \n");
26              return new ActionMethodPointcutImpl(methodNames);
27          }
28          return null;
29      }
30  
31      /**
32       * 指定された{@link Class クラス}から、
33       * {@link org.seasar.framework.aop.Pointcut ポイントカット}を構築して返します。
34       * 
35       * @param clazz
36       *            クラス
37       * @return ポイントカット
38       */
39      public static Pointcut createPointcut(final Class<?> clazz) {
40          return new ActionMethodPointcutImpl(clazz);
41      }
42  
43      /**
44       * 指定された{@link java.lang.reflect.Method メソッド}から、
45       * {@link org.seasar.framework.aop.Pointcut ポイントカット}を構築して返します。
46       * 
47       * @param method
48       *            メソッド
49       * @return ポイントカット
50       */
51      public static Pointcut createPointcut(final Method method) {
52          if (method != null) {
53              return new ActionMethodPointcutImpl(method);
54          }
55          return null;
56      }
57  
58  }