KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > aop > PointcutsFactory


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Idea by Rachel Davies, Original code by various *
9  *****************************************************************************/

10 package org.nanocontainer.aop;
11
12 import java.lang.reflect.Method JavaDoc;
13
14 /**
15  * Produces pointcuts.
16  *
17  * @author Stephen Molitor
18  * @version $Revision: 3144 $
19  */

20 public interface PointcutsFactory {
21
22     /**
23      * Returns a component pointcut that picks one component key.
24      *
25      * @param componentKey the component key to match against.
26      * @return a <code>ComponentPointcut</code> that matches
27      * <code>componentKey</code>.
28      */

29     ComponentPointcut component(Object JavaDoc componentKey);
30
31     /**
32      * Returns a component pointcut that matches component keys with a regular
33      * expression. The regular expression must be an <a
34      * HREF="http://jakarta.apache.org/oro/index.html">ORO </a> Perl5 compatible
35      * regular expression.
36      *
37      * @param regex the regular expression to match against.
38      * @return a <code>ComponentPointcut</code> that matches the component key
39      * against <code>regex</code>.
40      * @throws MalformedRegularExpressionException
41      * if the regular expression is
42      * invalid.
43      */

44     ComponentPointcut componentName(String JavaDoc regex) throws MalformedRegularExpressionException;
45
46     /**
47      * Returns a class pointcut that picks all classes.
48      *
49      * @return a <code>ClassPointcut</code> that matches all classes.
50      */

51     ClassPointcut allClasses();
52
53     /**
54      * Returns a class pointcut that picks all instances of a given type.
55      *
56      * @param type the base interface or class.
57      * @return a <code>ClassPointcut</code> that matches instances of
58      * <code>type</code>.
59      */

60     ClassPointcut instancesOf(Class JavaDoc type);
61
62     /**
63      * Returns a class pointcut that matches class names with a regular
64      * expression. The regular expression must be an <a
65      * HREF="http://jakarta.apache.org/oro/index.html">ORO </a> Perl5 regular
66      * expression.
67      *
68      * @param regex the regular expression to match against.
69      * @return a <code>ClassPointcut</code> that matches the class name
70      * against <code>regex</code>.
71      * @throws org.nanocontainer.aop.MalformedRegularExpressionException
72      * if the regular expression is
73      * invalid.
74      */

75     ClassPointcut className(String JavaDoc regex) throws MalformedRegularExpressionException;
76
77     /**
78      * Returns a class pointcut that picks one class.
79      *
80      * @param clazz the class to match against.
81      * @return a <code>ClassPointcut</code> that matches <code>clazz</code>.
82      */

83     ClassPointcut oneClass(Class JavaDoc clazz);
84
85     /**
86      * Returns a class pointcut that picks all classes in a package. Note that
87      * the <code>packageName</code> argument is not a regular expression; the
88      * returned pointcut expects an exact match against the package name.
89      *
90      * @param packageName the package name to match against the package of the
91      * candidate component's class.
92      * @return a <code>ClassPointcut</code> that matches the class package
93      * with <code>packageName</code>.
94      */

95     ClassPointcut packageName(String JavaDoc packageName);
96
97     /**
98      * Returns a class pointcut that is the intersection of two class pointcuts.
99      *
100      * @param a the first <code>ClassPointcut</code>.
101      * @param b the second <code>ClassPointcut</code>.
102      * @return a <code>ClassPointcut</code> that is the intersection of
103      * <code>a</code> and <code>b</code>.
104      */

105     ClassPointcut intersection(ClassPointcut a, ClassPointcut b);
106
107     /**
108      * Returns a pointcut that is the union of two class pointcuts.
109      *
110      * @param a the first <code>ClassPointcut</code>.
111      * @param b the second <code>ClassPointcut</code>.
112      * @return a <code>ClassPointcut</code> that is the union of
113      * <code>a</code> and <code>b</code>.
114      */

115     ClassPointcut union(ClassPointcut a, ClassPointcut b);
116
117     /**
118      * Returns a class pointcut that inverts the original pointcut.
119      *
120      * @param classPointcut the pointcut to negate.
121      * @return a <code>ClassPointcut</code> that inverts
122      * <code>classPointcut</code>.
123      */

124     ClassPointcut not(ClassPointcut classPointcut);
125
126     /**
127      * Returns a pointcut that matches all methods.
128      *
129      * @return a <code>MethodPointcut</code> that matches all methods.
130      */

131     MethodPointcut allMethods();
132
133     /**
134      * Returns a pointcut that matches get methods. Note that this does not
135      * include 'is' methods.
136      *
137      * @return a <code>MethodPointcut</code> that matches get methods.
138      */

139     MethodPointcut getMethods();
140
141     /**
142      * Returns a pointcut that matches is methods.
143      *
144      * @return a <code>MethodPointcut</code> that matches is methods.
145      */

146     MethodPointcut isMethods();
147
148     /**
149      * Returns a method pointcut that matches set methods.
150      *
151      * @return a <code>MethodPointcut</code> that matches set methods.
152      */

153     MethodPointcut setMethods();
154
155     /**
156      * Returns a method pointcut that picks <code>equals</code>,
157      * <code>hashCode</code>, and <code>toString</code>.
158      *
159      * @return a <code>MethodPointcut</code> that matches methods declared by
160      * <code>java.lang.Object</code>.
161      */

162     MethodPointcut objectMethods();
163
164     /**
165      * Returns a method pointcut that matches the method signatures with a
166      * regular expression. Uses dynaop's signature pointcut. Method signatures
167      * follow this pattern:
168      * <p/>
169      * <pre>
170      * <p/>
171      * <p/>
172      * <p/>
173      * <p/>
174      * ReturnType methodName(ArgumentType, ArgumentType, ...)
175      * throws ExceptionType, ExceptionType
176      * <p/>
177      * <p/>
178      * <p/>
179      * <p/>
180      * </pre>
181      * <p/>
182      * Omits "java.lang." from classes in java.lang package. The regular
183      * expression must be an <a
184      * HREF="http://jakarta.apache.org/oro/index.html">ORO </a> Perl5 regular
185      * expression.
186      *
187      * @param regexp the method signature regular expression.
188      * @return a <code>MethodPointcut</code> that matches the method signature
189      * against a regular expression.
190      */

191     MethodPointcut signature(String JavaDoc regexp);
192
193     /**
194      * Returns a pointcut that matches one method.
195      *
196      * @param method the method to match against.
197      * @return a <code>MethodPointcut</code> that matches one method.
198      */

199     MethodPointcut oneMethod(Method JavaDoc method);
200
201     /**
202      * Returns a method pointcut that picks a method if the given class pointcut
203      * picks the method's return type.
204      *
205      * @param classPointcut the class pointcut to match against the method's
206      * return type.
207      * @return a <code>MethodPointcut</code> that matches
208      * <code>classPointcut</code> against the method's return type
209      */

210     MethodPointcut returnType(ClassPointcut classPointcut);
211
212     /**
213      * Returns a method pointcut that picks a method if the given class pointcut
214      * picks the method's declaring class.
215      *
216      * @param classPointcut the class pointcut to match against the method's
217      * declaring class.
218      * @return a <code>MethodPointcut</code> that matches
219      * <code>classPointcut</code> against the method's declaring
220      * class.
221      */

222     MethodPointcut declaringClass(ClassPointcut classPointcut);
223
224     /**
225      * Picks methods that are members of the given class (even if the method was
226      * declared in a super class of the given class).
227      *
228      * @param clazz the class that we will check to see if the method is a
229      * member of.
230      * @return a <code>MethodPointcut</code> that will check to see if the
231      * method is a member of <code>clazz</code>.
232      */

233     MethodPointcut membersOf(Class JavaDoc clazz);
234
235     /**
236      * Returns a method pointcut that is the intersection of two other method
237      * pointcuts.
238      *
239      * @param a the first method pointcut.
240      * @param b the second method pointcut.
241      * @return a <code>MethodPointcut</code> that is the intersection of
242      * <code>a</code> and <code>b</code>.
243      */

244     MethodPointcut intersection(MethodPointcut a, MethodPointcut b);
245
246     /**
247      * Returns a method pointcut that is the union of two other method
248      * pointcuts.
249      *
250      * @param a the first method pointcut.
251      * @param b the second method pointcut.
252      * @return a <code>MethodPointcut</code> that is the union of
253      * <code>a</code> and <code>b</code>.
254      */

255     MethodPointcut union(MethodPointcut a, MethodPointcut b);
256
257     /**
258      * Creates a method pointcut that inverts the original pointcut.
259      *
260      * @param methodPointcut the pointcut to negate.
261      * @return a new <code>MethodPointcut</code> that inverts
262      * <code>methodPointcut</code>.
263      */

264     MethodPointcut not(MethodPointcut methodPointcut);
265
266 }
Popular Tags