dynaop.bsh
Class BshAspects

java.lang.Object
  extended by dynaop.Aspects
      extended by dynaop.bsh.BshAspects

public class BshAspects
extends Aspects

Executes BeanShell script on the classpath at "/dynaop.bsh". Script implicitly supports methods from Aspects and static methods and fields from Pointcuts.

You can use a Class or class name regular expression in place of ClassPointcut. You can use a Method or method signature regular expression in place of MethodPointcut.

Example script:

 // Create pointcut - instances of Person.
 people = instancesOf(Person.class);
 
 // Create pointcut - instances of Book (uses Class in 
 // place of ClassPointcut).
 books = Book.class; 
 
 // Apply IdentifiableMixin to people and books. IdentifiableMixin should
 // implement Object methods as well.
 mixin(
   union(people, books), 
   new Class[] { Identifiable.class, Object.class }, 
   IdentifiableMixin.class
 );
 
 // Apply AuthorMixin to people. Automatically adds Author interface. 
 mixin(people, AuthorMixin.class);

 // Add PersonProxy interface to people. PersonProxy extends all of the
 // added interfaces and helps reduce casting. 
 mixin(people, new Class[] { PersonProxy.class });

 // Apply transaction interceptor to Person.setName(String) using a 
 // regular expression.
 interceptor(people, ".*setName.*", new TransactionInterceptor());
 
 // Apply a per-instance interceptor to all methods.
 interceptor(people, ALL_METHODS, PerInstanceInterceptor.class,
   new Closure() {
     execute(interceptor) {
       // BeanShell syntactic sugar, calls PerInstanceInterceptor.setName().
       interceptor.name = "per-instance interceptor";
       interceptor.foo = 5;
     }
   } 
 );
 
 // Apply a counter mixin to books that will be used to count sales. 
 // Use a custom mixin factory implementation that loads the mixin from a 
 // persistent store. 
 mixin(
   books, 
   new Class[] { Counter.class }, 
   new MyMixinFactory(CounterMixin.java)
 );
 

Author:
Bob Lee (crazybob@crazybob.org)

Constructor Summary
BshAspects()
           
BshAspects(java.net.URL url)
           
 
Method Summary
 
Methods inherited from class dynaop.Aspects
getInstance, interceptor, interceptor, interceptor, interfaces, mixin, mixin, mixin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BshAspects

public BshAspects(java.net.URL url)

BshAspects

public BshAspects()