Friday, June 12, 2009

I want my AOP (Spring 3 AOP) that is...

Spring 3 still maintains a great Aspect Oriented Programming (AOP) environment.
AOP Guide HERE. (and for Java 5 HERE)

What dependencies are required?

Library Dependencies:
  • antlr-3.0.1
  • aopalliance-1.0
  • aspectjrt-1.5.0
  • aspectjweaver-1.6.1 (not certain about this, but the documentation says it is needed)
  • cglib-2.1_3 (if using proxied classes, as opposed to JDK dynamic proxies)
  • commons-logging0-1.1.1
  • jsr250-api-1.0 (if you want JSR25o annotations)
  • org.springframework.asm-3.0.0.M3
  • org.springframework.beans-3.0.0.M3
  • org.springframework.core-3.0.0.M3
  • org.springframework.context-3.0.0.M3
  • org.springframework.expression-3.0.0.M3 (if you need SpEL)
Pointcuts from the docs:

pointcuts determine join points of interest, and thus enable us to control when advice executes.

think of a pointcut as matching the execution of methods on Spring beans. A pointcut declaration has two parts: a signature

comprising a name and any parameters, and a pointcut expression that determines exactly which method executions we are interested in.


Maven:


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.jgk.spring3</groupId>

<artifactId>jgkspring3</artifactId>

<packaging>jar</packaging>

<version>0.0.1-SNAPSHOT</version>

<properties>

<spring.version>3.0.0.M3</spring.version>

</properties>

<name>Playing with Spring Framework 3</name>

<url>http://maven.apache.org</url>

<dependencies>

<dependency>

<groupId>javax.annotation</groupId>

<artifactId>jsr250-api</artifactId>

<version>1.0</version>

<optional>true</optional>

</dependency>

<dependency>

<groupId>aopalliance</groupId>

<artifactId>aopalliance</artifactId>

<version>1.0</version>

</dependency>

<dependency>

<groupId>aspectj</groupId>

<artifactId>aspectjrt</artifactId>

<version>1.5.0</version>

</dependency>

<dependency>

<groupId>commons-logging</groupId>

<artifactId>commons-logging</artifactId>

<version>1.1.1</version>

</dependency>

<dependency>

<groupId>org.antlr</groupId>

<artifactId>antlr</artifactId>

<version>3.0.1</version>

<scope>compile</scope>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.asm</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.aop</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.aspects</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.beans</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.core</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.context</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.context.support</artifactId>

<version>${spring.version}</version>

</dependency>


<dependency>

<groupId>org.springframework</groupId>

<artifactId>org.springframework.expression</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>log4j</groupId>

<artifactId>log4j</artifactId>

<version>1.2.14</version>

<optional>true</optional>

</dependency>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>3.8.1</version>

<scope>test</scope>

</dependency>

</dependencies>


</project>



2 comments:

LiNk said...

Which repository resolves the spring jars with org.springframework.core in the artifactId tag?


*I have a project where someone put these exact jars in the pom but has left out the repository and therefore I can't compile.

Thanks.

javapda blog said...

Snapshots:

<repository>
<id>spring-snapshot</id>
<name>Spring Portfolio Snapshot Repository</name>
<url>http://s3.amazonaws.com/maven.springframework.org/snapshot</url>
</repository>