1 /* 2 * Copyright 2004-2008 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.customizer; 17 18 import org.seasar.framework.aop.Pointcut; 19 import org.seasar.framework.container.customizer.AspectCustomizer; 20 import org.seasar.framework.util.StringUtil; 21 22 /** 23 * {@link org.seasar.framework.container.ComponentDef コンポーネント定義}に 24 * {@link org.seasar.framework.container.AspectDef アスペクト定義}を 25 * 登録するコンポーネントカスタマイザです。 26 * <p> 27 * カスタマイザには、ポイントカットとインターセプタを設定します。 インターセプタはコンポーネント名で指定し、複数のインターセプタ名を設定することができます。 28 * インターセプタ名が複数設定された場合は、設定された順にアスペクト定義をコンポーネント定義に登録します。 29 * 最初に設定された名前を持つインターセプタが、後に設定された名前を持つインターセプタよりも先に呼び出されることになります。 30 * </p> 31 * <p> 32 * コンポーネントに適用するインターセプタのインスタンス属性が<code>singleton</code>以外の場合は、 33 * {@link #setUseLookupAdapter(boolean) useLookupAdapter}プロパティを<code>true</code>に設定します。 34 * これにより、コンポーネントのメソッドが呼び出される度に、コンテナからインターセプタのインスタンスをルックアップするようになります。 35 * </p> 36 * 37 * @author baba 38 * @since 1.0.0 39 */ 40 public class ActionMethodCustomizer extends AspectCustomizer { 41 42 private String pointcut; 43 44 /** 45 * コンポーネント定義に登録するアスペクト定義のポイントカットを設定します。 46 * 47 * @param pointcut 48 * ポイントカット 49 */ 50 @Override 51 public void setPointcut(final String pointcut) { 52 super.setPointcut(pointcut); 53 this.pointcut = pointcut; 54 } 55 56 /** 57 * ポイントカットを作成して返します。 58 * <p> 59 * <code>pointcut</code>プロパティが指定されている場合は、その文字列からポイントカットを作成します。 60 * <code>targetInterface</code>プロパティが指定されている場合は、そのインターフェースからポイントカットを作成します。 61 * それ以外の場合は<code>null</code>を返します。 62 * </p> 63 * 64 * @return ポイントカット 65 */ 66 @Override 67 protected Pointcut createPointcut() { 68 if (!StringUtil.isEmpty(pointcut)) { 69 return PointcutFactory.createPointcut(pointcut); 70 } 71 if (targetInterface != null) { 72 return PointcutFactory.createPointcut(targetInterface); 73 } 74 return null; 75 } 76 77 }