Remove old data.
authorGustavo Martin Morcuende <gustavo@supergusarapo.(none)>
Thu, 27 Jun 2013 00:09:38 +0000 (02:09 +0200)
committerGustavo Martin Morcuende <gustavo@supergusarapo.(none)>
Thu, 27 Jun 2013 00:09:38 +0000 (02:09 +0200)
SpringJava/SpringLTW/pom.xml
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/MyAdvice.java
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManager.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManagerN2A.java [deleted file]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/commitTransactional.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/commitTransactionalN2A.java [deleted file]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/initTransactional.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/initTransactionalN2A.java [deleted file]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/web/Gus.java [new file with mode: 0644]
SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/web/Test.java
SpringJava/SpringLTW/spring-ltw-example/src/main/resources/spring-config.xml

index 75bab27..d55d01f 100644 (file)
        </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>
index 5f61578..4704d0b 100644 (file)
@@ -3,23 +3,22 @@ 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(de.spring.example.annotation.initTransactionalN2A)")
-       public void initTransactionalN2A()
-       {
-               System.out.println("I am the Advice initTransaction.");
-               TransactionManagerN2A.getInstance().initTransaction();
-       }
-       
 
-       @After("@annotation(de.spring.example.annotation.commitTransactionalN2A)")
-       public void commitTransactionalN2A() {
-               System.out.println("I am the Advice commitTransaction.");
-               TransactionManagerN2A.getInstance().commitTransaction();        
-       }
+
+    @Before("execution(* de.spring.example.web.Gus.prueba())")
+    public void initTransactional()
+    {
+        System.out.println("I am the Advice initTransaction.");
+        TransactionManager.getInstance().initTransaction();
+    }
+
+
+    @After("@annotation(de.spring.example.annotation.commitTransactional)")
+    public void commitTransactional() {
+        System.out.println("I am the Advice commitTransaction.");
+        TransactionManager.getInstance().commitTransaction();
+    }
 }
diff --git a/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManager.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManager.java
new file mode 100644 (file)
index 0000000..d8657f2
--- /dev/null
@@ -0,0 +1,45 @@
+package de.spring.example;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.transaction.TransactionStatus;
+
+@Aspect
+public class TransactionManager {
+    private static TransactionManager instance = new TransactionManager();
+    private DataSourceTransactionManager transactionManager;
+    private TransactionStatus transactionStatus;
+
+    //Why could you want to extend this class?
+    private TransactionManager() {
+    }
+
+    public static TransactionManager 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/TransactionManagerN2A.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/TransactionManagerN2A.java
deleted file mode 100644 (file)
index 867b4bb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-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/commitTransactional.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/commitTransactional.java
new file mode 100644 (file)
index 0000000..1fda03f
--- /dev/null
@@ -0,0 +1,14 @@
+package de.spring.example.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.stereotype.Component;
+
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Component
+public @interface commitTransactional {
+}
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
deleted file mode 100644 (file)
index 950c319..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-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/initTransactional.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/annotation/initTransactional.java
new file mode 100644 (file)
index 0000000..dad0b3e
--- /dev/null
@@ -0,0 +1,14 @@
+package de.spring.example.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.stereotype.Component;
+
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Component
+public @interface initTransactional {
+}
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
deleted file mode 100644 (file)
index 7996478..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-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/Gus.java b/SpringJava/SpringLTW/spring-ltw-example/src/main/java/de/spring/example/web/Gus.java
new file mode 100644 (file)
index 0000000..2d11f75
--- /dev/null
@@ -0,0 +1,11 @@
+package de.spring.example.web;
+
+import de.spring.example.annotation.initTransactional;
+
+public class Gus {
+
+    @initTransactional
+    public void prueba() {
+        System.out.println("GUSOOK");
+    }
+}
index d17d3ef..cc21d8f 100644 (file)
@@ -1,23 +1,23 @@
 package de.spring.example.web;
 
-import de.spring.example.annotation.commitTransactionalN2A;
-import de.spring.example.annotation.initTransactionalN2A;
+import de.spring.example.annotation.commitTransactional;
+import de.spring.example.annotation.initTransactional;
 
 
 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. ");
-               }       
-       }
+    @initTransactional
+    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 {
+        @commitTransactional
+        public void innerMethod() {
+            System.out.println("I am the inner class. The Advice should be run after. ");
+        }
+    }
 }
index b358f70..0710eee 100644 (file)
@@ -43,8 +43,8 @@
                <property name="dataSource" ref="dataSource"/>
        </bean>
        
-       <bean id="transactionManagerN2A" 
-              class="de.spring.example.TransactionManagerN2A"
+       <bean id="myTransactionManager"
+              class="de.spring.example.TransactionManager"
               factory-method="getInstance">
         <property name="transactionManager">
             <ref bean="transactionManager" />