Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ActionMethodCustomizer |
|
| 3.0;3 |
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.customizer; | |
18 | ||
19 | import org.seasar.framework.aop.Pointcut; | |
20 | import org.seasar.framework.container.customizer.AspectCustomizer; | |
21 | import org.seasar.framework.util.StringUtil; | |
22 | ||
23 | /** | |
24 | * {@link org.seasar.framework.container.ComponentDef コンポーネント定義}に | |
25 | * {@link org.seasar.framework.container.AspectDef アスペクト定義}を | |
26 | * 登録するコンポーネントカスタマイザです。 | |
27 | * <p> | |
28 | * カスタマイザには、ポイントカットとインターセプタを設定します。 インターセプタはコンポーネント名で指定し、複数のインターセプタ名を設定することができます。 | |
29 | * インターセプタ名が複数設定された場合は、設定された順にアスペクト定義をコンポーネント定義に登録します。 | |
30 | * 最初に設定された名前を持つインターセプタが、後に設定された名前を持つインターセプタよりも先に呼び出されることになります。 | |
31 | * </p> | |
32 | * <p> | |
33 | * コンポーネントに適用するインターセプタのインスタンス属性が<code>singleton</code>以外の場合は、 | |
34 | * {@link #setUseLookupAdapter(boolean) useLookupAdapter}プロパティを<code>true</code> | |
35 | * に設定します。 これにより、コンポーネントのメソッドが呼び出される度に、コンテナからインターセプタのインスタンスをルックアップするようになります。 | |
36 | * </p> | |
37 | * | |
38 | * @author baba | |
39 | */ | |
40 | 0 | 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 | 0 | super.setPointcut(pointcut); |
53 | 0 | this.pointcut = pointcut; |
54 | 0 | } |
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 | 0 | if (!StringUtil.isEmpty(pointcut)) { |
69 | 0 | return PointcutFactory.createPointcut(pointcut); |
70 | } | |
71 | 0 | if (targetInterface != null) { |
72 | 0 | return PointcutFactory.createPointcut(targetInterface); |
73 | } | |
74 | 0 | return null; |
75 | } | |
76 | ||
77 | } |