Weaving with ASPECTJ libraries.
authorgumartinm <gu.martinm@gmail.com>
Thu, 10 Nov 2011 22:45:44 +0000 (23:45 +0100)
committergumartinm <gu.martinm@gmail.com>
Thu, 10 Nov 2011 22:45:44 +0000 (23:45 +0100)
With this configuration we are not relying on the SPRING AOP
libraries. So, I guess, this is the SPRING ASPECTJ configuration,
the rest of them are SPRING AOP 2.0/1.2 with Aspects.

SpringJava/SpringLTW/pom.xml [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/pom.xml [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/MyAdvice.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/SpringContextLocator.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/SpringStart.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManagerN2A.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/commitTransactionalN2A.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/initTransactionalN2A.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/web/Test.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/resources/META-INF/aop.xml [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/resources/spring-config.xml [new file with mode: 0644]

diff --git a/SpringJava/SpringLTW/pom.xml b/SpringJava/SpringLTW/pom.xml
new file mode 100644 (file)
index 0000000..75bab27
--- /dev/null
@@ -0,0 +1,663 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>de.spring.example</groupId>
+       <artifactId>spring-ltw</artifactId>
+       <version>2.0-SNAPSHOT</version>
+       <name>spring-ltw</name>
+       <url>http://www.myorganization.de</url>
+       <description>Spring AspectJ with Spring Libraries</description>
+       <organization>
+               <name>MyOrganization</name>
+               <url>http://www.myorganization.de</url>
+       </organization>
+       <packaging>pom</packaging>
+       <issueManagement>
+               <system>trac</system>
+               <url>http://noserver/</url>
+       </issueManagement>
+       <ciManagement>
+               <system>jenkins</system>
+               <url>http://noserver/jenkins/</url>
+       </ciManagement>
+       <scm>
+               <developerConnection>scm:svn:http://noserver</developerConnection>
+               <url>http://noserver</url>
+       </scm>
+       <dependencies>
+               <dependency>
+                       <groupId>com.sun.jdmk</groupId>
+                       <artifactId>jmxtools</artifactId>
+                       <version>1.2.1</version>
+               </dependency>
+               <dependency>
+                       <groupId>javax.activation</groupId>
+                       <artifactId>activation</artifactId>
+                       <version>1.1</version>
+               </dependency>
+               <dependency>
+                       <groupId>log4j</groupId>
+                       <artifactId>log4j</artifactId>
+                       <version>1.2.15</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>com.sun.jdmk</groupId>
+                                       <artifactId>jmxtools</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>com.sun.jmx</groupId>
+                                       <artifactId>jmxri</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>javax.mail</groupId>
+                                       <artifactId>mail</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>javax.jms</groupId>
+                                       <artifactId>jms</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.4</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+       <dependencyManagement>
+               <dependencies>
+                       <dependency>
+                               <groupId>c3p0</groupId>
+                               <artifactId>c3p0</artifactId>
+                               <version>0.9.1.2</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>cglib</groupId>
+                               <artifactId>cglib-nodep</artifactId>
+                               <version>2.1_3</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>commons-collections</groupId>
+                               <artifactId>commons-collections</artifactId>
+                               <version>3.2.1</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>commons-configuration</groupId>
+                               <artifactId>commons-configuration</artifactId>
+                               <version>1.6</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>commons-dbcp</groupId>
+                               <artifactId>commons-dbcp</artifactId>
+                               <version>1.2.2</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>commons-io</groupId>
+                               <artifactId>commons-io</artifactId>
+                               <version>1.4</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>commons-lang</groupId>
+                               <artifactId>commons-lang</artifactId>
+                               <version>2.4</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                               <version>1.1.1</version>
+                       </dependency>
+                        <dependency>
+                               <groupId>commons-net</groupId>
+                                <artifactId>commons-net</artifactId>
+                               <version>2.0</version>
+                        </dependency>
+                       <dependency>
+                               <groupId>commons-pool</groupId>
+                               <artifactId>commons-pool</artifactId>
+                               <version>1.3</version>
+                       </dependency> 
+                       <dependency>
+                               <groupId>com.h2database</groupId>
+                               <artifactId>h2</artifactId>
+                               <version>1.2.130</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>dom4j</groupId>
+                               <artifactId>dom4j</artifactId>
+                               <version>1.6.1</version>
+                               <exclusions>
+                                       <exclusion>
+                                               <groupId>xml-apis</groupId>
+                                               <artifactId>xml-apis</artifactId>
+                                       </exclusion>
+                               </exclusions>
+                       </dependency>
+                       <dependency>
+                               <groupId>hsqldb</groupId>
+                               <artifactId>hsqldb</artifactId>
+                               <version>1.8.0.7</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>javatar</groupId>
+                               <artifactId>javatar</artifactId>
+                               <version>2.5</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>jpos</groupId>
+                               <artifactId>jpos</artifactId>
+                               <version>1.12.2</version>
+                               <scope>provided</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>jpos</groupId>
+                               <artifactId>jpos-controls</artifactId>
+                               <version>1.12.2</version>
+                               <scope>provided</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.python</groupId>
+                               <artifactId>jython</artifactId>
+                               <version>2.5.2b2</version>
+                       </dependency>           
+                       <dependency>
+                               <groupId>urbanophile</groupId>
+                               <artifactId>java-getopt</artifactId>
+                               <version>1.0.13</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>mysql</groupId>
+                               <artifactId>mysql-connector-java</artifactId>
+                               <version>5.1.6</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.apache.ibatis</groupId>
+                               <artifactId>ibatis-sqlmap</artifactId>
+                               <version>2.3.4.726</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.apache.mina</groupId>
+                               <artifactId>mina-core</artifactId>
+                               <version>2.0.0-M6</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.aspectj</groupId>
+                               <artifactId>aspectjrt</artifactId>
+                               <version>1.6.5</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.aspectj</groupId>
+                               <artifactId>aspectjweaver</artifactId>
+                               <version>1.6.5</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.dbunit</groupId>
+                               <artifactId>dbunit</artifactId>
+                               <version>2.4.4</version>
+                               <scope>test</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-continuation</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-http</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-io</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-security</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-server</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-servlet</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-webapp</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-util</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-xml</artifactId>
+                               <version>7.0.0.v20091005</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.slf4j</groupId>
+                               <artifactId>slf4j-api</artifactId>
+                               <version>1.5.2</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.slf4j</groupId>
+                               <artifactId>slf4j-log4j12</artifactId>
+                               <version>1.5.2</version>
+                               <exclusions>
+                                       <exclusion>
+                                               <groupId>log4j</groupId>
+                                               <artifactId>log4j</artifactId>
+                                       </exclusion>
+                               </exclusions>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-aop</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-beans</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-core</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-context</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-jdbc</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-tx</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-web</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-webmvc</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                                       <artifactId>spring-context-support</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-test</artifactId>
+                               <version>${spring.version}</version>
+                               <scope>test</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework.batch</groupId>
+                               <artifactId>spring-batch-test</artifactId>
+                               <version>2.0.4.RELEASE</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework.batch</groupId>
+                               <artifactId>spring-batch-core</artifactId>
+                               <version>2.0.4.RELEASE</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework.batch</groupId>
+                               <artifactId>spring-batch-infrastructure</artifactId>
+                               <version>2.0.4.RELEASE</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-orm</artifactId>
+                               <version>${spring.version}</version>
+                       </dependency>
+                       <dependency>
+                           <groupId>net.sf.ehcache</groupId>
+                           <artifactId>ehcache</artifactId>
+                           <version>1.6.2</version>
+                       </dependency>
+                       <dependency>
+                           <groupId>org.springmodules</groupId>
+                           <artifactId>spring-modules-cache</artifactId>
+                           <version>0.9</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>p6spy</groupId>
+                               <artifactId>p6spy</artifactId>
+                               <version>1.3</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>javax.transaction</groupId>
+                               <artifactId>jta</artifactId>
+                               <version>1.0.1B</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>javax.servlet</groupId>
+                               <artifactId>servlet-api</artifactId>
+                               <version>2.5</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>com.caucho</groupId>
+                               <artifactId>hessian</artifactId>
+                               <version>3.1.6</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.codehaus.jettison</groupId>
+                               <artifactId>jettison</artifactId>
+                               <version>1.0</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>com.thoughtworks.xstream</groupId>
+                               <artifactId>xstream</artifactId>
+                               <version>1.3</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.ini4j</groupId>
+                               <artifactId>ini4j</artifactId>
+                               <version>0.5.1</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.easymock</groupId>
+                               <artifactId>easymock</artifactId>
+                               <version>2.4</version>
+                               <scope>test</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.easymock</groupId>
+                               <artifactId>easymockclassextension</artifactId>
+                               <version>2.4</version>
+                               <scope>test</scope>
+                       </dependency>
+
+                       <dependency>
+                               <groupId>org.apache.commons</groupId>
+                               <artifactId>commons-compress</artifactId>
+                               <version>1.0</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.apache.commons</groupId>
+                               <artifactId>commons-math</artifactId>
+                               <version>2.0</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>dtgjpos_forms</groupId>
+                               <artifactId>dtgjpos_forms</artifactId>
+                               <version>1.4.12</version>
+                               <scope>provided</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.codehaus.castor</groupId>
+                               <artifactId>castor-xml</artifactId>
+                               <version>1.3.1</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.apache.xmlbeans</groupId>
+                               <artifactId>xmlbeans</artifactId>
+                               <version>2.5.0</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.apache.velocity.tools</groupId>
+                               <artifactId>velocity-tools-generic</artifactId>
+                               <version>1.4</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.apache.velocity</groupId>
+                               <artifactId>velocity</artifactId>
+                               <version>1.6.2</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.tmatesoft.svnkit</groupId>
+                               <artifactId>svnkit</artifactId>
+                               <version>1.3.1</version>
+                       </dependency>
+               </dependencies>
+       </dependencyManagement>
+       <modules>
+               <module>spring-ltw-example</module>
+       </modules>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>2.0.2</version>
+                               <configuration>
+                                       <source>1.6</source>
+                                       <target>1.6</target>
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+                               </configuration>
+                       </plugin>
+                       <!-- Usually you will not need this plugin
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-resources-plugin</artifactId>
+                               <version>2.2</version>
+                               <configuration>
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+                               </configuration>
+                       </plugin>
+                       -->
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-javadoc-plugin</artifactId>
+                               <version>2.6</version>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <version>2.4.2</version>
+                               <configuration>
+                                       <testFailureIgnore>true</testFailureIgnore>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>jdepend-maven-plugin</artifactId>
+                               <version>2.0-beta-2</version>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                               <version>2.3.1</version>
+                               <configuration>
+                                       <archive>
+                                               <manifestEntries>
+                                                       <Specification-Title>${project.description}</Specification-Title>
+                                                       <Specification-Version>${project.version}</Specification-Version>
+                                                       <Specification-Vendor>${project.organization.name}</Specification-Vendor>
+                                                       <Implementation-Title>${project.description}</Implementation-Title>
+                                                       <Implementation-Version>${project.version}</Implementation-Version>
+                                                       <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
+                                                       <Implementation-Build>${BUILD_TAG}</Implementation-Build>
+                                                       <Implementation-Build-id>${BUILD_ID}</Implementation-Build-id>
+                                                       <Implementation-Build-number>${BUILD_NUMBER}</Implementation-Build-number>
+                                                       <scm-committed-revision>${prefix.committedRevision}</scm-committed-revision>
+                                                       <scm-repository>${prefix.repository}</scm-repository>
+                                                       <scm-path>${prefix.path}</scm-path>                                                           
+                                               </manifestEntries>
+                                       </archive>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
+                               <artifactId>maven-svn-revision-number-plugin</artifactId>
+                               <version>1.6</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>revision</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                               <configuration>
+                                       <entries>
+                                               <entry>
+                                                       <prefix>prefix</prefix>
+                                               </entry>
+                                       </entries>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <!--We need this for the javadoc and reporting maven plugin -->
+       <distributionManagement>
+               <repository>
+                       <id>releases</id>
+                       <name>releases</name>
+                       <url>http://noserver/artifactory/custom-annotations-libs-releases-local</url>
+               </repository>
+               <snapshotRepository>
+                       <id>snapshots-releases</id>
+                       <name>snapshots-releases</name>
+                       <url>http://noserver/artifactory/custom-annotations-libs-snapshots-local</url>
+               </snapshotRepository>
+               <site>
+                       <id>noserver</id>
+                       <url>file:///mnt/sdb1/data/downloads/jenkins/</url>
+               </site>
+
+       </distributionManagement>
+       <reporting>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-project-info-reports-plugin</artifactId>
+                               <version>2.1.2</version>
+                               <reportSets>
+                                       <reportSet>
+                                               <reports>
+                                                       <report>index</report>
+                                                       <report>dependencies</report>
+                                                       <report>cim</report>
+                                                       <report>issue-tracking</report>
+                                                       <report>scm</report>
+                                                       <report>summary</report>
+                                                       <report>project-team</report>
+                                               </reports>
+                                       </reportSet>
+                               </reportSets>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-javadoc-plugin</artifactId>
+                               <version>2.6.1</version>
+                               <reportSets>
+                                       <reportSet>
+                                               <id>html</id>
+                                               <configuration>
+                                                       <doctitle>MYPROJECT API for ${project.name} ${project.version}</doctitle>
+                                                       <windowtitle>MYPROJECT API for ${project.name} ${project.version}</windowtitle>
+                                               </configuration>
+                                               <reports>
+                                                       <report>javadoc</report>
+                                                       <report>aggregate</report>
+                                               </reports>
+                                       </reportSet>
+                               </reportSets>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>taglist-maven-plugin</artifactId>
+                               <version>2.3</version>
+                               <configuration>
+                                       <tags>
+                                               <tag>TODO</tag>
+                                               <tag>@todo</tag>
+                                               <tag>FIXME</tag>
+                                               <tag>XXX</tag>
+                                       </tags>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-report-plugin</artifactId>
+                               <version>2.4.3</version>
+                               <reportSets>
+                                       <reportSet>
+                                               <id>integration-tests</id>
+                                               <reports>
+                                                       <report>report-only</report>
+                                               </reports>
+                                               <configuration>
+                                                       <outputName>failsafe-report</outputName>
+                                                       <reportsDirectories>
+                                                               <reportsDirectory>target/failsafe-reports</reportsDirectory>
+                                                       </reportsDirectories>
+                                               </configuration>
+                                       </reportSet>
+                                       <reportSet>
+                                               <id>junit-tests</id>
+                                               <reports>
+                                                       <report>report-only</report>
+                                               </reports>
+                                               <configuration>
+                                                       <outputName>surefire-report</outputName>
+                                                       <reportsDirectories>
+                                                               <reportsDirectory>target/surefire-reports</reportsDirectory>
+                                                       </reportsDirectories>
+                                               </configuration>
+                                       </reportSet>
+                               </reportSets>
+                       </plugin>
+               </plugins>
+       </reporting>
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <spring.version>2.5.6</spring.version>
+       </properties>
+       <repositories>
+               <!--
+               <repository>
+                       <id>central-myproject-repo</id>
+                       <name>Internal repository</name>
+                       <url>http://noserver/artifactory/my-repo</url>
+                       <snapshots>
+                               <enabled>false</enabled>
+                       </snapshots>
+               </repository>
+               <repository>
+                       <id>snapshots-releases</id>
+                       <name>snapshots-releases</name>
+                       <url>http://noserver/artifactory/custom-annotations-libs-snapshots-local</url>
+                       <snapshots>
+                               <enabled>true</enabled>
+                       </snapshots>
+               </repository>
+               -->
+       </repositories>
+       <pluginRepositories>
+               <!--
+               <pluginRepository>
+                       <id>central-myproject-plugins-repo</id>
+                       <name>Plugins internal repository</name>
+                       <url>http://noserver/artifactory/plugins-repo</url>
+                       <snapshots>
+                               <enabled>true</enabled>
+                       </snapshots>
+                       <releases>
+                               <enabled>true</enabled>
+                       </releases>
+               </pluginRepository>
+               -->
+       </pluginRepositories>
+</project>
diff --git a/SpringJava/SpringLTW/spring-ltw-example/pom.xml b/SpringJava/SpringLTW/spring-ltw-example/pom.xml
new file mode 100644 (file)
index 0000000..03f917f
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+       xmlns="http://maven.apache.org/POM/4.0.0" 
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+       
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <artifactId>spring-ltw</artifactId>
+               <groupId>de.spring.example</groupId>
+               <version>2.0-SNAPSHOT</version>
+       </parent>
+
+       <artifactId>spring-ltw-example</artifactId>
+       <name>spring-ltw-example</name>
+       <url>http://maven.apache.org</url>
+
+       <dependencies>
+               <dependency>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-aspects</artifactId>
+               <version>2.5.6</version>
+               </dependency>
+               <dependency>
+            <groupId>org.springframework</groupId>
+                       <artifactId>spring-context</artifactId>
+        </dependency>
+               <dependency>
+                       <groupId>cglib</groupId>
+                       <artifactId>cglib-nodep</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-aop</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-jdbc</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>c3p0</groupId>
+                       <artifactId>c3p0</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>mysql</groupId>
+                       <artifactId>mysql-connector-java</artifactId>
+               </dependency>
+       </dependencies>
+</project>
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/MyAdvice.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/MyAdvice.java
new file mode 100644 (file)
index 0000000..5a5e2a3
--- /dev/null
@@ -0,0 +1,25 @@
+package de.spring.example;
+
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import de.spring.example.TransactionManagerN2A;
+
+@Aspect
+public class MyAdvice {
+       
+       
+       @Before("@annotation(es.dia.pos.n2a.spring.example.annotation.initTransactionalN2A)")
+       public void initTransactionalN2A()
+       {
+               System.out.println("I am the Advice initTransaction.");
+               TransactionManagerN2A.getInstance().initTransaction();
+       }
+       
+
+       @After("@annotation(es.dia.pos.n2a.spring.example.annotation.commitTransactionalN2A)")
+       public void commitTransactionalN2A() {
+               System.out.println("I am the Advice commitTransaction.");
+               TransactionManagerN2A.getInstance().commitTransaction();        
+       }
+}
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/SpringContextLocator.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/SpringContextLocator.java
new file mode 100644 (file)
index 0000000..2ece260
--- /dev/null
@@ -0,0 +1,53 @@
+package de.spring.example;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+/**
+ *
+ */
+public final class SpringContextLocator {
+
+        // Singleton Pattern
+        private static SpringContextLocator instance;
+
+        // Spring ApplicationContext
+        private static ApplicationContext context;
+
+        // Spring Context
+        private static final String SPRING_CONFIG_CONTEXT="/spring-config.xml";
+
+
+        /**
+         * Private constructor. Singleton pattern.
+         */
+        private SpringContextLocator() {
+                String[] factoryFiles = null;
+                System.out.println("Loading context files: " + SpringContextLocator.SPRING_CONFIG_CONTEXT);
+
+                factoryFiles = new String[] { SPRING_CONFIG_CONTEXT };
+
+                SpringContextLocator.context = new ClassPathXmlApplicationContext(factoryFiles);
+
+                System.out.println("The context has been loaded successfully!! ");
+        }
+
+        /**
+         * Singleton pattern not thread safety. To use SingletoHolder pattern as the best approximation 
+         * otherwise to use an Enum class (see Effective Java Second Edition and ) if we need serialization.
+         */
+        public static SpringContextLocator getInstance() {
+                if (SpringContextLocator.instance == null) {
+                        SpringContextLocator.instance = new SpringContextLocator();
+                }
+                return SpringContextLocator.instance;
+        }
+
+        /**
+         * Return bean from application context.
+         */
+        public Object getBean(final String name) {
+                return SpringContextLocator.context.getBean(name);
+        }
+}
\ No newline at end of file
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/SpringStart.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/SpringStart.java
new file mode 100644 (file)
index 0000000..a9da7cb
--- /dev/null
@@ -0,0 +1,20 @@
+package de.spring.example;
+
+import de.spring.example.web.Test;
+
+public class SpringStart {
+
+       /**
+        * @param args
+        */
+       public static void main(String[] args) {
+               System.out.println("Starting application");
+               SpringContextLocator.getInstance();
+               
+               Test test = (Test) SpringContextLocator.getInstance().getBean("testOuter");
+               test.myMethod();
+               
+               Test.InnerTest testInner = (Test.InnerTest) SpringContextLocator.getInstance().getBean("testInner");
+               testInner.innerMethod();
+       }
+}
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManagerN2A.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManagerN2A.java
new file mode 100644 (file)
index 0000000..867b4bb
--- /dev/null
@@ -0,0 +1,44 @@
+package de.spring.example;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.transaction.TransactionStatus;
+
+@Aspect
+public class TransactionManagerN2A {
+       private static TransactionManagerN2A instance = new TransactionManagerN2A();
+       private DataSourceTransactionManager transactionManager;
+       private TransactionStatus transactionStatus;
+
+       //Why could you want to extend this class?
+       private TransactionManagerN2A() {}
+       
+       public static TransactionManagerN2A getInstance() {
+        return instance;
+       }
+       
+       public void initTransaction()
+       {
+               System.out.println("initTRANSACTION");
+               transactionStatus = this.transactionManager.getTransaction(null);
+       }
+       
+       public void rollbackTransaction()
+       {
+               this.transactionManager.rollback(this.transactionStatus);
+       }
+       
+       
+       public void commitTransaction()
+       {
+               System.out.println("commitTRANSACTION");
+               this.transactionManager.commit(this.transactionStatus);
+       }
+       
+       
+       /************************* Setters and getters *******************************************/
+       public void setTransactionManager(final DataSourceTransactionManager  transactionManager) 
+       {
+               this.transactionManager = transactionManager;
+       }
+}
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/commitTransactionalN2A.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/commitTransactionalN2A.java
new file mode 100644 (file)
index 0000000..950c319
--- /dev/null
@@ -0,0 +1,13 @@
+package de.spring.example.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import org.springframework.stereotype.Component;
+
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Component
+public @interface commitTransactionalN2A {
+}
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/initTransactionalN2A.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/initTransactionalN2A.java
new file mode 100644 (file)
index 0000000..7996478
--- /dev/null
@@ -0,0 +1,13 @@
+package de.spring.example.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import org.springframework.stereotype.Component;
+
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Component
+public @interface initTransactionalN2A {
+}
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/web/Test.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/web/Test.java
new file mode 100644 (file)
index 0000000..d17d3ef
--- /dev/null
@@ -0,0 +1,23 @@
+package de.spring.example.web;
+
+import de.spring.example.annotation.commitTransactionalN2A;
+import de.spring.example.annotation.initTransactionalN2A;
+
+
+public class Test {
+       @initTransactionalN2A
+       public int myMethod()
+       {
+               System.out.println("The Advice should be run before.");
+               
+               //This value will be caught by the Advice with the @AfterReturning annotation.
+               return 666;
+       }
+       
+       public class InnerTest {
+               @commitTransactionalN2A
+               public void innerMethod() {
+                       System.out.println("I am the inner class. The Advice should be run after. ");
+               }       
+       }
+}
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/resources/META-INF/aop.xml b/SpringJava/SpringLTW/spring-ltw-example/src/main/resources/META-INF/aop.xml
new file mode 100644 (file)
index 0000000..9f6ee4b
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE aspectj PUBLIC
+        "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
+
+<aspectj>
+       <!--
+               With or without logs
+               <weaver options="-verbose -showWeaveInfo">
+       -->     
+       <weaver>
+               <!-- only weave classes in our application-specific packages -->
+                       <include within="de.spring..*"/>
+               <!--
+                       Dump all types within the "somepack" package before they are woven
+                       to the "./_ajdump" folder on disk
+               <dump within="de.spring..*"/>
+               -->
+       </weaver>
+       <aspects>
+               <aspect name="de.spring.example.MyAdvice"/>        
+       </aspects>
+</aspectj>
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/resources/spring-config.xml b/SpringJava/SpringLTW/spring-ltw-example/src/main/resources/spring-config.xml
new file mode 100644 (file)
index 0000000..c6b5893
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context" 
+       xsi:schemaLocation="http://www.springframework.org/schema/beans 
+                                                  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+                                                  http://www.springframework.org/schema/context 
+                                                  http://www.springframework.org/schema/context/spring-context-2.5.xsd">
+
+       <!-- 
+                       We have to use SPRING ASPECTJ (no SPRING AOP 2.0/1.2) because we want to use
+               annotations with inner classes.
+                       AspectJ under this configuration requires at least one 'META-INF/aop.xml' file
+               with the configuration about the Advices.
+                       
+               This switches on the load-time weaving 
+           See: http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/aop.html#aop-aj-ltw-spring
+       -->
+    <context:load-time-weaver  weaver-class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"
+                                                  aspectj-weaving="autodetect"/>
+    
+       
+       <bean id="myAdvice" class="es.dia.pos.n2a.spring.example.MyAdvice">
+       
+    </bean>
+
+       <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
+                <property name="user" value="root"/>
+                <property name="password" value=""/>
+                <property name="driverClass" value="com.mysql.jdbc.Driver"/>
+                <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/n2a?autoReconnect=true"/>
+                <property name="initialPoolSize" value="5"/>
+                <property name="maxPoolSize" value="20"/>
+                <property name="minPoolSize" value="10"/>
+                <property name="acquireIncrement" value="1"/>
+                <property name="acquireRetryAttempts" value="5"/>
+                <property name="acquireRetryDelay" value="1000"/>
+                <property name="automaticTestTable" value="con_test"/>
+                <property name="checkoutTimeout" value="5000"/>
+    </bean>
+    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+               <property name="dataSource" ref="dataSource"/>
+       </bean>
+       
+       <bean id="transactionManagerN2A" 
+              class="es.dia.pos.n2a.spring.example.TransactionManagerN2A"
+              factory-method="getInstance">
+        <property name="transactionManager">
+            <ref bean="transactionManager" />
+        </property>
+    </bean>
+       
+       <!-- 
+               In order to find annotations in inner classes we have to create Spring 
+       beans of them.
+    -->
+    <bean id="testOuter" class="es.dia.pos.n2a.spring.example.web.Test"/> 
+    <bean id="testInner" class="es.dia.pos.n2a.spring.example.web.Test$InnerTest">
+        <constructor-arg ref="testOuter"/>
+    
+    </bean>
+    
+</beans>