KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > core > AspectComponent


1 /*
2   Copyright (C) 2001-2004 Renaud Pawlak <renaud@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.core;
20
21 import java.io.FileNotFoundException JavaDoc;
22 import java.io.Serializable JavaDoc;
23 import java.lang.reflect.InvocationTargetException JavaDoc;
24 import java.lang.reflect.Method JavaDoc;
25 import java.util.Arrays JavaDoc;
26 import java.util.Collection JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Map JavaDoc;
31 import java.util.Set JavaDoc;
32 import java.util.Vector JavaDoc;
33 import org.apache.log4j.Logger;
34 import org.objectweb.jac.core.rtti.*;
35 import org.objectweb.jac.util.WeakHashSet;
36 import org.objectweb.jac.util.WrappedThrowableException;
37
38 /**
39  * This class is the root class for the aspect components defined by a
40  * Jac application programmers.
41  *
42  * <p>When programming a new aspect, the programmer must extends this
43  * class and define new pointcuts to link a set of base method
44  * invocation to a wrapping method. If necessary, the programmer can
45  * also redefine the methods of the interface
46  * <code>BaseProgramListener</code> to be able to react on several
47  * events happenning in the base programm such as object
48  * (de)serialization, object instantiation, object naming, object
49  * cloning, or wrappers execution.
50  *
51  * @author <a HREF="mailto:pawlak@cnam.fr">Renaud Pawlak</a>
52  *
53  * @see Pointcut */

54
55 public class AspectComponent
56     implements Serializable JavaDoc, BaseProgramListener
57 {
58     static Logger logger = Logger.getLogger("aspects");
59     static Logger loggerConf = Logger.getLogger("aspects.config");
60     static Logger loggerWrap = Logger.getLogger("wrappers");
61     static Logger loggerWuni = Logger.getLogger("wuni");
62     static Logger loggerPerf = Logger.getLogger("perf");
63
64     protected static final boolean SHARED = false;
65     protected static final boolean NOT_SHARED = true;
66
67     protected static final ClassRepository cr = ClassRepository.get();
68
69     /**
70      * Returns true if the method is defined in the aspect component
71      * class.
72      *
73      * @param methodName the method to test
74      * @return true if aspect component method */

75
76     public static boolean defines(String JavaDoc methodName) {
77         if (ClassRepository.getDirectMethodAccess(AspectComponent.class,
78                                                   methodName )[0] != null)
79             return true;
80         return false;
81     }
82
83     /**
84      * A common configuration method that defines a timer and its
85      * callback.
86      *
87      * <p>The method <code>mi</code> is invoked every
88      * <code>period</code> ms. The method is defined in the aspect
89      * component.
90      *
91      * @param period the timer's period (in ms)
92      * @param callback the method that is called every period
93      * @param args the arguments the callback is called with */

94
95     public void defineTimer(final long period, final MethodItem callback,
96                             final Object JavaDoc[] args) {
97         final AspectComponent ac=this;
98         new Thread JavaDoc() {
99                 public void run() {
100                     while(true) {
101                         try {
102                             sleep(period);
103                         } catch(Exception JavaDoc e) {
104                             e.printStackTrace();
105                         }
106                         callback.invoke(ac,args);
107                     }
108                 }
109             }.start();
110     }
111
112     /**
113      * Tell if the aspect component is already woven to the base
114      * program.<br>
115      *
116      * @see #weave() */

117
118     // public boolean woven = false;
119

120     /**
121      * Memorize how many calls have been performed on
122      * <code>start_weaving_type.start_weaving_method</code>. The
123      * weaving will start when this number reaches
124      * <code>start_weaving_count</code>.<br>
125      *
126      * @see #weave() */

127
128     public int firstCall = -1;
129
130     /**
131      * The type where the weaving has to start.
132      *
133      * @see #weave() */

134    
135     public Class JavaDoc startWeavingType;
136
137     /**
138      * The method where the weaving has to start.<br>
139      *
140      * @see #weave()
141      */

142     public String JavaDoc startWeavingMethod;
143
144     /**
145      * The number of calls of
146      * <code>startWeavingType.startWeavingMethod</code> where the
147      * weaving has to start.<br>
148      *
149      * @see #weave()
150      */

151     public int startWeavingCount;
152
153     /**
154      * The number of instance of <code>startWeavingType</code> where
155      * the weaving has to start.<br>
156      *
157      * @see #weave()
158      */

159     public int startWeavingCCount;
160
161     /**
162      * The wrappers handled by this aspect component.<br>
163      *
164      * @see #getWrappers()
165      * @see #addWrapper(Wrapper)
166      */

167     protected transient WeakHashSet wrappers;
168
169     /**
170      * Tells if this aspect component is a system listener one so that
171      * it can receive events from the org.objectweb.jac.core objects.
172      */

173     protected boolean systemListener = false;
174
175     /**
176      * Sets this aspect component to be a system or non-system
177      * listener.
178      *
179      * @param systemListener if true, the component can receive events
180      * from the JAC core objects (e.g. whenUsingNewInstance) ; if
181      * false, these events are filtered
182      */

183     public void setSystemListener(boolean systemListener) {
184         this.systemListener = systemListener;
185     }
186
187     /**
188      * Tells if this aspect component is a system listener.
189      *
190      * @return true if system listener
191      * @see #setSystemListener(boolean)
192      */

193     public boolean isSystemListener() {
194         return systemListener;
195     }
196
197     /**
198      * The default constructor of the aspect component. By default,
199      * there is no start weaving type or method so that the
200      * <code>weave()</code> is called as the aspect component is
201      * registering to the aspect component manager<br>.
202      *
203      * @see #weave()
204      * @see ACManager#register(String,Object)
205      */

206     public AspectComponent() {
207         logger.debug("New AC: "+this);
208         wrappers = new WeakHashSet();
209         firstCall = -1;
210         startWeavingType = null;
211         startWeavingMethod = null;
212         startWeavingCount = 0;
213         startWeavingCCount = 0;
214         init();
215         // Collaboration.get().setCurAC(ACManager.get().getName(this));
216
}
217
218     /**
219      * Initializes the aspect component so that its state is resetted
220      * to the default state.<br>
221      */

222     public void init() {
223         //woven = false;
224
loggerWrap.debug("clearing wrappers (was "+wrappers+")");
225         wrappers.clear();
226     }
227
228     protected String JavaDoc application=null;
229
230     /**
231      * Gets the application that declares this aspect component.
232      *
233      * @return the application's name
234      * @see Application
235      * @see ApplicationRepository
236      */

237     public String JavaDoc getApplication() {
238         return application;
239     }
240
241     /**
242      * Gets the application that declares this aspect component.
243      *
244      * <p>This method is invoked by the system and should not be
245      * directly used.
246      *
247      * @param application the application's name
248      * @see Application
249      * @see ApplicationRepository */

250
251     public void setApplication(String JavaDoc application) {
252         this.application = application;
253     }
254
255     /**
256      * Returns the wrappers handled by this aspect component. When you
257      * have a reference on a wrapper, you can also know which aspect
258      * component is currently handling it by using
259      * <code>Wrapper.getAspectComponent()</code>.<br>
260      *
261      * @return a vector containing the handdled wrappers
262      * @see #addWrapper(Wrapper)
263      * @see Wrapper#getAspectComponent() */

264    
265     public Collection JavaDoc getWrappers() {
266         return wrappers;
267     }
268    
269     /**
270      * Add a wrapper to the wrappers handled by this aspect
271      * component.
272      *
273      * <p>The programmer should not call this method explicitly unless
274      * s/he really hnows what s/he is doing. In fact, this method is
275      * automatically upcalled when the aspect component wraps a base
276      * program object (see <code>Wrappee.wrap()</code>).<br>
277      *
278      * @param wrapper the wrapper to add to the handdled wrappers
279      * @see #getWrappers()
280      * @see Wrapping#wrap(Wrappee,Wrapper,AbstractMethodItem)
281      */

282
283     public void addWrapper(Wrapper wrapper) {
284         wrappers.add(wrapper);
285     }
286
287     /**
288      * The programmer should define this method to wrap all the
289      * currently instantiated Jac objects so that it plugs a given
290      * aspect. Since the objects might allready be wrapped by other
291      * weavers, the programmer should be careful that it does not wrap
292      * the same object with the same wrapper several times. This can
293      * be done in the weave function by using the
294      * <code>Wrappee.isExtendedBy()</code> method. When a new AC is
295      * registered the weave method is automatically called. In the
296      * jac.prop file, the time when it is called can be parametrized
297      * with the org.objectweb.jac.startWeavingPlaces property.
298      *
299      * <p>This method is only called once. For the objects that are
300      * created after the weaving, the programmer must define the
301      * <code>whenUsingNewInstance</code> method to wrap them.
302      *
303      * <p>The default implementation of the weave method is the
304      * following. In most of the case, it will work if the
305      * <code>whenUsingNewInstance()</code> is correctly defined (thus,
306      * the programer do not have to redefine the weave method).
307      *
308      * <ul><pre>
309      * for (int i=0; i < JacObject.objectCount(); i++) {
310      * simulateUsingNewInstance ( (Wrappee)JacObject.getObject(i) );
311      * }
312      * </pre></ul>
313      *
314      * <b>IMPORTANT NOTE</b>: this method is not deprecated but the
315      * programmer should not overload it since it is much cleaner to
316      * define the <code>whenUsingNewInstance()</code> to implement the
317      * weaving.<br>
318      *
319      * @see #whenUsingNewInstance(Interaction)
320      * @see #simulateUsingNewInstance(Wrappee)
321      * @see Wrapping#isExtendedBy(Wrappee,ClassItem,Class)
322      */

323
324     public void weave() {
325         Iterator JavaDoc it = ObjectRepository.getMemoryObjects().iterator();
326         while (it.hasNext()) {
327             simulateUsingNewInstance((Wrappee)it.next());
328         }
329     }
330
331     /**
332      * This method is called when a new instance (that has not been
333      * wrapped by the aspect component yet) is used by a peer
334      * object.
335      *
336      * <p>By default, this method check out all the pointcuts that have
337      * been defined within this aspect component and accordingly wraps
338      * the wrappee.
339      *
340      * <p>However, for performance or flexibility reasons, the
341      * programmer can also define it from scratch so that the aspects
342      * can dynamically apply while the base program creates new base
343      * objects. The aspect component is notified only once for each new
344      * instance.
345      *
346      * <p>Here is a typical implementation of this method for a
347      * many-to-one wrappees-wrapper relationship:
348      *
349      * <ul><pre>
350      * public class MyAC extends AspectComponent {
351      * public MyWrapper myWrapper = null;
352      * public void whenUsingNewInstance() {
353      * // creates the sole instance of MyWrapper
354      * if ( myWrapper == null ) myWrapper = new MyWrapper();
355      * // make sure we do not wrap an object several times
356      * // (this is usually not useful!!)
357      * if ( wrappee().isExtendedBy( MyWrapper.class ) ) return;
358      * // Do not wrap system or aspect objects
359      * if ( wrappee().getClass().getName().startsWith( "org.objectweb.jac.core." ) ||
360      * wrappee().getClass().getName().startsWith( "org.objectweb.jac.aspects." ) )
361      * return;
362      * // wrap it...
363      * wrappee().wrapAll( myWrapper, "myWrappingMethod" );
364      * }
365      * }
366      * </pre></ul>
367      *
368      * <p>The same but with one-to-one wrappees-wrappers
369      * relationship:
370      *
371      * <ul><pre>
372      * public class MyAC extends AspectComponent {
373      * public void whenUsingNewInstance() {
374      * // make sure we do not wrap an object several times
375      * // (this is usually not useful!!)
376      * if ( wrappee().isExtendedBy( MyWrapper.class ) ) return;
377      * // Do not wrap system or aspect objects
378      * if ( wrappee().getClass().getName().startsWith( "org.objectweb.jac.core." ) ||
379      * wrappee().getClass().getName().startsWith( "org.objectweb.jac.aspects." ) )
380      * return;
381      * // one wrapper for each new instance
382      * MyWrapper myWrapper = new MyWrapper();
383      * // wrap it...
384      * wrappee().wrapAll( myWrapper, "myWrappingMethod" );
385      * }
386      * }
387      * </pre></ul>
388      *
389      * <b>NOTE</b>: this method is not upcalled until the aspect component
390      * is woven.<br>
391      *
392      * @see #weave()
393      */

394     public void whenUsingNewInstance(Interaction interaction) {
395         //if(treatedInstances.contains(wrappee())) return;
396
//treatedInstances.add(wrappee());
397
ClassItem cli = interaction.getClassItem();
398         //Log.trace("wuni",this+": "+method());
399
AbstractMethodItem method = interaction.method;
400
401         loggerWuni.debug("whenUsingNewInstance("+interaction+"); pointcuts: "+pointcuts.size());
402         int i = 0;
403         Iterator JavaDoc it = pointcuts.iterator();
404         while (it.hasNext()) {
405             loggerWuni.debug(" pointcut "+i++);
406             ((Pointcut)it.next()).applyTo(interaction.wrappee, cli);
407         }
408     }
409
410     public void whenUsingNewClass(ClassItem cli) {
411         Iterator JavaDoc it = pointcuts.iterator();
412         int i = 0;
413         loggerWuni.debug(this+".whenUsingNewClass"+cli);
414         while (it.hasNext()) {
415             ((Pointcut)it.next()).applyTo(null, cli);
416         }
417     }
418
419     /**
420      * This method simulates an instance first use so that the system
421      * upcalls <code>whenUsingNewInstance()</code> with a fake
422      * collaboration point (<code>method()</code> is null and
423      * <code>args</code> is null too).
424      *
425      * @param wrappee the wrappe on which the call is simulated.
426      * @see #whenUsingNewInstance(Interaction) */

427
428     protected void simulateUsingNewInstance(Wrappee wrappee) {
429         /** simulates a new interaction */
430         // Log.trace("core","simulateUsingNewInstance "+this);
431
Collaboration collab = Collaboration.get();
432         //collab.newInteraction();
433
whenUsingNewInstance(new Interaction(null,wrappee,null,null));
434         /** end of simulated interaction */
435         //collab.endOfInteraction();
436
}
437
438     /**
439      * This method is called when a new instance is created.
440      *
441      * <p>Since the instance is not initialized yet, the aspect
442      * component must not wrap it at this stage. To wrap a new
443      * instance, the aspect component must use the
444      * <code>whenUsingNewInstance()</code> method. This method is not
445      * upcalled when the instantiation is remotly performed (from a
446      * deployer site), see the <code>whenRemoteInstantiation()</code>
447      * method.<br>
448      *
449      * @param newInstance the newly created instance
450      * @see #whenUsingNewInstance(Interaction)
451      * @see #whenRemoteInstantiation(Wrappee,String) */

452
453     //public void whenNewInstance( Wrappee newInstance ) {}
454

455     /**
456      * This method is upcalled when a new object is instanciated from a
457      * remote site.
458      *
459      * <p>The name that is passed is the name of the remote
460      * reference that has been used to create the object. Typically, it
461      * is the name that will be used by the naming aspect to name the
462      * new object.
463      *
464      * @param newInstance the instance that have been created by a
465      * remote host
466      * @param name the name of the new instance
467      * @see org.objectweb.jac.aspects.naming.NamingAC#whenRemoteInstantiation(Wrappee,String)
468      */

469     public void whenRemoteInstantiation(Wrappee newInstance,
470                                         String JavaDoc name) {}
471
472     /**
473      * This method unwraps all the instances that have been wrapped by
474      * the aspect component.
475      *
476      * <p>This is done in a generic way that is not very efficient. To
477      * optimize this process, the user may overload the
478      * <code>unweave()</code> method to change its default
479      * behavior.<br>
480      *
481      * @see #unweave()
482      */

483     protected final void unwrapAll() {
484         loggerWrap.debug("unwrap all");
485         loggerWrap.debug(wrappers.size()+" wrappers: " + wrappers);
486         Iterator JavaDoc it = ObjectRepository.getMemoryObjects().iterator();
487         while (it.hasNext()) {
488             Object JavaDoc o = it.next();
489             if (o instanceof Wrappee) {
490                 Wrappee wrappee = (Wrappee)o;
491                 ClassItem wrappeeClass = cr.getClass(wrappee);
492                 loggerWrap.debug("testing wrappee " + wrappee);
493                 Wrapping.unwrap(wrappee,wrappeeClass,wrappers);
494                 Wrapping.unwrap(null,wrappeeClass,wrappers);
495             }
496         }
497         wrappers.clear();
498     }
499
500     /**
501      * The programmer should overload this method to unwrap all the
502      * currently wrapped Jac objects so that it unplugs a given aspect.
503      *
504      * <p>By default, calls the <code>unwrapAll</code> method but the
505      * programmer can implement the unveaving process in a more
506      * efficient way.<br>
507      *
508      * @see #unwrapAll() */

509
510     public void unweave() {
511         logger.info("--- unweaving "+this+" ---");
512         long start = System.currentTimeMillis();
513         unwrapAll();
514         pointcuts.clear();
515         loggerPerf.info("unweaved "+this+" in "+(System.currentTimeMillis()-start)+"ms");
516     }
517
518     /**
519      * This method is automatically called when a Jac Object is
520      * cloned. */

521
522     public void whenClone(Wrappee cloned, Wrappee clone) {}
523
524     /**
525      * This method is called when a JAC object is serialized and can
526      * parametrize the serialization by filling the <code>finalObject</code>
527      * parameter.
528      *
529      * <p><b>IMPORTANT</b>: this method is upcalled only if the
530      * serialization is done with a
531      * <code>JacObjectOutputStream</code>. To ensure the correct use of
532      * this class, only use <code>JacObject.serialize()</code> to
533      * serialize an object.</p>
534      *
535      * @param orgObject the object being serialized
536      * @param finalObject the corresponding serialized structure
537      * @return the object being serialized (usually orgObject, but not
538      * necessarily).
539      * @see SerializedJacObject
540      * @see JacObjectOutputStream */

541
542     public Wrappee whenSerialized(Wrappee orgObject,
543                                   SerializedJacObject finalObject) {
544         return orgObject;
545     }
546
547     /**
548      * This method is called when a base object is deserialized and can
549      * parametrize the deserialization by reading the
550      * SerializedJacObject instance to get some extra infos on the
551      * aspects.
552      *
553      * <p><b>IMPORTANT</b>: this method is upcalled only if the
554      * deserialization is done with a
555      * <code>JacObjectInputStream</code>. To ensure the correct use of
556      * this class, only use <code>JacObject.deserialize()</code> to
557      * deserialize an object.
558      *
559      * @param orgObject the corresponding serialized structure
560      * @param finalObject the object being deserialized
561      * @return the object being deserialized (usually finalObject but
562      * not necessarily)
563      * @see SerializedJacObject
564      * @see JacObjectInputStream */

565
566     public Wrappee whenDeserialized(SerializedJacObject orgObject,
567                                     Wrappee finalObject) {
568         return finalObject;
569     }
570
571
572     public void onExit() {}
573
574     /**
575      * This method is called when a wrapper is going to be applied to a
576      * wrappee.
577      *
578      * <p>By overloading this method, the aspect component can skip the
579      * wrapper, for instance if the current collaboration shows that
580      * the wrapper has allready been applied.<br>
581      *
582      * <p>If the method returns true, then the wrapper is run, else it
583      * is skipped. Default: return true.<br>
584      *
585      * @param wrapper the wrapper that is going to be runned
586      * @param wrappingMethod the name of the may-be runned wrapping
587      * method
588      * @return a boolean that tells if the wrapper has to be runned
589      * (true) or not (false)
590      * @see Wrappee
591      * @see Wrapping#wrap(Wrappee,Wrapper,AbstractMethodItem)
592      * @see Wrapper
593      * @see Wrapper#proceed(Invocation)
594      */

595     public boolean beforeRunningWrapper(Wrapper wrapper,
596                                         String JavaDoc wrappingMethod) {
597         return true;
598     }
599    
600     /**
601      * This method is called after the application of the
602      * wrapper.
603      *
604      * <p>Typically, the aspect component can set an attribute to
605      * the collaboration that indicates that the wrapper has been
606      * applied (and that can be used by the beforeRunningWrapper
607      * method).
608      *
609      * @param wrapper the wrapper that has just been runned
610      * @param wrappingMethod the name of the runned wrapping method
611      * @see Wrappee
612      * @see Wrapping#wrap(Wrappee,Wrapper,AbstractMethodItem)
613      * @see Wrapper
614      * @see Wrapper#proceed(Invocation)
615      */

616     public void afterRunningWrapper(Wrapper wrapper,
617                                     String JavaDoc wrappingMethod) {}
618
619     /**
620      * This method is called after a new wrapper wraps a wrappee.
621      */

622
623     public void afterWrap(Wrappee wrappee, Wrapper wrapper,
624                           String JavaDoc[] wrapping_methods,
625                           String JavaDoc[][] wrapped_methods) {}
626    
627     /**
628      * This method is called when a program gets a set of object from
629      * the object repository.
630      *
631      * <p>At this step, the aspect can change the returned list so that
632      * the program will see the right set of objects (for instance a
633      * security aspect may filter this set so that the user will not
634      * see the objects s/he is not allowed to see or a persistance
635      * aspect may force the load of a set of objects from the storage
636      * and add them to the list).
637      *
638      * @param objects the returned list (can be modified)
639      * @param cl the class that was used by the program to filter its
640      * instances (can be null for all the objects)
641      * @see ObjectRepository */

642
643     public void whenGetObjects(Collection JavaDoc objects, ClassItem cl) {}
644
645     public String JavaDoc whenNameObject(Object JavaDoc object,String JavaDoc name) {
646         return name;
647     }
648
649     public void getNameCounters(Map JavaDoc counters) {
650     }
651
652     public void updateNameCounters(Map JavaDoc counters) {
653     }
654
655     /**
656      * This method is upcalled by JAC when an object was seeked into
657      * the name repository and was not found.
658      *
659      * <p>The reason of this miss can be multiple. For instance, the
660      * persistence aspect may have not already load the object from the
661      * storage, or the distribution aspect may need to bind to a remote
662      * object. Thus, this method allows the aspects to resolve the
663      * object.
664      *
665      * <p>By default, this method does nothing.
666      *
667      * <p>The final choosen name is a contextual attribute called
668      * FOUND_OBJECT.
669      *
670      * @param name the name of the object
671      * @see BaseProgramListener#FOUND_OBJECT
672      */

673    
674     public void whenObjectMiss(String JavaDoc name) {}
675
676     public void whenDeleted(Wrappee object) {}
677
678     public void whenFree(Wrappee object) {}
679
680     public void afterApplicationStarted() {}
681
682     public void whenCloseDisplay(Display display) {}
683
684     public void whenTopologyChanged() {}
685
686     /**
687      * Called when the aspect's configuration is reloaded
688      */

689     public void whenReload() {}
690     public void beforeReload() {}
691
692     /**
693      * This method should be defined by the programmer when specific
694      * actions are needed once the aspect component has be
695      * configured. */

696
697     public void whenConfigured() {}
698
699     /**
700      * To overload in order to perform some treatements before the
701      * configuration. */

702     public void beforeConfiguration() throws Exception JavaDoc {
703     }
704
705     public String JavaDoc getName() {
706         return ACManager.getACM().getName(this);
707     }
708
709     /**
710      * This method is upcalled by the system when the aspect is
711      * actually registered in the AC manager.
712      *
713      * <p>Here it does nothing. */

714     public void doRegister() {
715     }
716
717     /**
718      * This method is upcalled by the system when the aspect is
719      * actually registered in the AC manager.
720      *
721      * <p>Here it does nothing. */

722     public void doUnregister() {
723     }
724
725     /** Store the pointcuts. */
726     Vector JavaDoc pointcuts = new Vector JavaDoc();
727
728     /**
729      * Defines and adds a new method pointcut.
730      *
731      * <p>For more details on how to use pointcuts, see the
732      * <code>MethodPointcut</code> class.
733      *
734      * @param wrappeeExpr the wrappee definition that matches the names
735      * as defined by the naming aspect
736      * @param wrappeeClassExpr the wrappee class expression (matches
737      * the fully qualified class name)
738      * @param wrappeeMethodExpr the wrappee method expression (matches
739      * the full method name as defined by the rtti)
740      * @param wrappingClassName the name of the wrapper class
741      * @param one2one true if each new wrapped instance corresponds to
742      * one different wrapper
743      * @see MethodPointcut
744      */

745     public Pointcut pointcut(String JavaDoc wrappeeExpr,
746                              String JavaDoc wrappeeClassExpr,
747                              String JavaDoc wrappeeMethodExpr,
748                              String JavaDoc wrappingClassName,
749                              String JavaDoc exceptionHandler,
750                              boolean one2one) {
751
752         MethodPointcut pc = new MethodPointcut( this,
753                                                 wrappeeExpr,
754                                                 wrappeeClassExpr,
755                                                 wrappeeMethodExpr,
756                                                 null,
757                                                 wrappingClassName,
758                                                 null,
759                                                 null,
760                                                 "ALL",
761                                                 exceptionHandler,
762                                                 one2one );
763         pointcuts.add(pc);
764         return pc;
765     }
766
767     /**
768      * Defines and adds a new method pointcut.
769      *
770      * <p>For more details on how to use pointcuts, see the
771      * <code>MethodPointcut</code> class.
772      *
773      * @param wrappeeExpr the wrappee definition that matches the names
774      * as defined by the naming aspect
775      * @param wrappeeClassExpr the wrappee class expression (matches
776      * the fully qualified class name)
777      * @param wrappeeMethodExpr the wrappee method expression (matches
778      * the full method name as defined by the rtti)
779      * @param wrappingClassName the name of the wrapper class
780      * @param initParameters the initialization parameters of the
781      * wrapper (passed to the wrappers constructor that matches the
782      * parameters types)
783      * @param one2One true if each new wrapped instance corresponds to
784      * one different wrapper
785      * @see MethodPointcut
786      */

787     public Pointcut pointcut(String JavaDoc wrappeeExpr,
788                              String JavaDoc wrappeeClassExpr,
789                              String JavaDoc wrappeeMethodExpr,
790                              String JavaDoc wrappingClassName,
791                              Object JavaDoc[] initParameters,
792                              String JavaDoc exceptionHandler,
793                              boolean one2One) {
794
795         MethodPointcut pc = new MethodPointcut( this,
796                                                 wrappeeExpr,
797                                                 wrappeeClassExpr,
798                                                 wrappeeMethodExpr,
799                                                 null,
800                                                 wrappingClassName,
801                                                 null,
802                                                 initParameters,
803                                                 "ALL",
804                                                 exceptionHandler,
805                                                 one2One );
806         pointcuts.add(pc);
807         return pc;
808     }
809
810     /**
811      * Defines and adds a new localized method pointcut.
812      *
813      * <p>For more details on how to use pointcuts, see the
814      * <code>MethodPointcut</code> class.
815      *
816      * @param wrappeeExpr the wrappee definition that matches the names
817      * as defined by the naming aspect
818      * @param wrappeeClassExpr the wrappee class expression (matches
819      * the fully qualified class name)
820      * @param wrappeeMethodExpr the wrappee method expression (matches
821      * the full method name as defined by the rtti)
822      * @param wrappingClassName the name of the wrapper class
823      * @param hostExpr a regular expression that macthes the hosts
824      * where the pointcut has to be applied (if null or empty string,
825      * default is ".*" which means that the pointcut will be applied on
826      * all the hosts)
827      * @param one2One true if each new wrapped instance corresponds to
828      * one different wrapper
829      * @see MethodPointcut */

830
831     public Pointcut pointcut(String JavaDoc wrappeeExpr,
832                              String JavaDoc wrappeeClassExpr,
833                              String JavaDoc wrappeeMethodExpr,
834                              String JavaDoc wrappingClassName,
835                              String JavaDoc hostExpr,
836                              String JavaDoc exceptionHandler,
837                              boolean one2One) {
838
839         MethodPointcut pc = new MethodPointcut(this,
840                                                wrappeeExpr,
841                                                wrappeeClassExpr,
842                                                wrappeeMethodExpr,
843                                                null,
844                                                wrappingClassName,
845                                                null,
846                                                null,
847                                                hostExpr,
848                                                exceptionHandler,
849                                                one2One);
850         pointcuts.add(pc);
851         return pc;
852     }
853
854     /**
855      * Defines and adds a new localized method pointcut.
856      *
857      * <p>For more details on how to use pointcuts, see the
858      * <code>MethodPointcut</code> class.
859      *
860      * @param wrappeeExpr the wrappee definition that matches the names
861      * as defined by the naming aspect
862      * @param wrappeeClassExpr the wrappee class expression (matches
863      * the fully qualified class name)
864      * @param wrappeeMethodExpr the wrappee method expression (matches
865      * the full method name as defined by the rtti)
866      * @param wrappingClassName the name of the wrapper class
867      * @param initParameters the initialization parameters of the
868      * wrapper (passed to the wrappers constructor that matches the
869      * parameters types)
870      * @param hostExpr a regular expression that macthes the hosts
871      * where the pointcut has to be applied (if null or empty string,
872      * default is ".*" which means that the pointcut will be applied on
873      * all the hosts)
874      * @param one2One true if each new wrapped instance corresponds to
875      * one different wrapper
876      * @see MethodPointcut
877      */

878     public Pointcut pointcut(String JavaDoc wrappeeExpr,
879                              String JavaDoc wrappeeClassExpr,
880                              String JavaDoc wrappeeMethodExpr,
881                              String JavaDoc wrappingClassName,
882                              Object JavaDoc[] initParameters,
883                              String JavaDoc hostExpr,
884                              String JavaDoc exceptionHandler,
885                              boolean one2One) {
886