<chapter id="dynamic">

   <title>Dynamic AOP</title>

   <sect1 id="dynamic1" revision="1">
      <title>Hot Deployment</title>
      <para>
         Any joinpoint that has been aspectized by the <literal>aopc</literal> compiler or by a load time transformation
         is set up to be able to have advices/interceptors added or removed from it at runtime.  This is JBoss AOP's
         first definition of Dynamic AOP.  Using the <literal>prepare</literal> action allows you to aspectize
         any joinpoint in your application so that advices/interceptors can be applied later at runtime.  The over
         head of such a massaging of the bytecode is very minimal as it is just an extra boolean expression.  The benefits
         for search an architecture allow you to do things like deploy and undeploy metrics or statistic gathering
         on a needed basis.  If you are using AOP for testing (See "Testing with AOP"), it allows you to deploy/undeploy
         testing aspects as you run your automated tests on your live system.
      </para>
   </sect1>
   <sect1 id="dynamic2" revision="1">
      <title>Per Instance AOP</title>
      <para>
         JBoss AOP has the ability to apply interceptors on a per instance basis rather than having interceptors be
         applied entirely to the class.  This is very useful when you have instances of an object that need to behave
         differently in different circumstances.
      </para>
      <para>
         A perfect example of this is JBoss Cache AOP (TreeCacheAOP).  It uses AOP to <literal>prepare</literal>
         classes so that field access may be intercepted.  When an object is inserted into the cache, TreeCacheAOP
         adds field interceptors for that particular instance so that it can do automatic replication across a cluster
         or to automatically provide transaction properties to the object's state.  When the object is removed from
         cache, the field interceptors are removed from that particular instance.
      </para>
   </sect1>

</chapter>




