## Running and packaging in JBoss

This example is exactly the same as the XML example. Please see that for a description of the application, and how the different examples are built up. The differences are outlined below

To run these examples you must edit build.xml and set the jboss.dir to where JBoss is. The server configuration used in this example is 'all', so you must start JBoss with 'run -c all'.

### JDK 1.5

JDK 1.5 must be used for this example, this involves:

- deleting JBOSS_HOME/server/all/jboss-aop.deployer
- copying jboss-40-install/jboss-aop-jdk50.deployer from the AOP distribution into the JBOSS_HOME/server/all/ folder
- using JDK 5.0 when you run JBoss
- building the example with JDK 1.5

### Interceptors and bindings

Instead of defining out interceptors and bindings via XML, they are defined via annotations in the `SimpleInterceptor` class. (For the long @Bind annotation newlines have been added to the pointcut string for readability)

    @InterceptorDef
    @Bind (pointcut="org.jboss.injbossaop.lib.SimpleInterceptor.valueConstructors OR
    	org.jboss.injbossaop.lib.SimpleInterceptor.valueMessage OR
    	org.jboss.injbossaop.lib.SimpleInterceptor.service OR
    	org.jboss.injbossaop.lib.SimpleInterceptor.sessionValue OR
    	org.jboss.injbossaop.lib.SimpleInterceptor.mbeans")
    public class SimpleInterceptor implements Interceptor
    {
       @PointcutDef ("execution(org.jboss.injbossaop.lib.ExampleValue->new(..))")
       public static Pointcut valueConstructors;

       @PointcutDef ("execution(* org.jboss.injbossaop.lib.ExampleValue->getMessage())")
       public static Pointcut valueMessage;

       @TypeDef ("class($instanceof{javax.servlet.http.HttpServlet}) AND class(org.jboss.injbossaop.web.*)")
       public static Typedef servlets;

       @PointcutDef ("execution(* $typedef{org.jboss.injbossaop.lib.SimpleInterceptor.servlets}->service(..))")
       public static Pointcut service;

       @TypeDef ("class($instanceof{javax.ejb.SessionBean}) AND class(org.jboss.injbossaop.ejb.*)")
       public static Typedef sessionBeans;

       @PointcutDef ("execution(* $typedef{org.jboss.injbossaop.lib.SimpleInterceptor.sessionBeans}->getValue(..))")
       public static Pointcut sessionValue;

       @PointcutDef ("all(org.jboss.injbossaop.mbean.*)")
       public static Pointcut mbeans;

       public String getName() { return "SimpleInterceptor"; }

       ...
    }

### Bye bye XML

For JBoss AOP to look for annotations in a deployed application, it must be packaged in a `.aop` file, so the only configurations from the original XML example that work for annotations are:

- deploy-basic-lt-war-in-sar
- deploy-ear-aop
- deploy-example-lt-sar

Please see the original example for details of how these are packaged. The other configurations in the original example did not use `.aop` files, and they had a standalone XML file containing the bind info, which is not what we are demonstrating in this example.

One quirk of the `.aop` format is that the file must contain a `META-INF/jboss-aop.xml` file in order to be valid. So this file is used for the examples, although it is empty and so contains no binding information.