From 6ba3b6fc452265fb595b7f32055423c606ed77fd Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 1 Aug 2013 22:26:13 +0200 Subject: o Initial import. --- myapp/pom.xml | 36 +++++++++++++++++++ .../io/trygvis/container/myapp/MyComponent.java | 40 ++++++++++++++++++++++ .../io/trygvis/container/myapp/MyComponent_Tx.java | 26 ++++++++++++++ .../java/io/trygvis/container/myapp/MyMain.java | 10 ++++++ 4 files changed, 112 insertions(+) create mode 100644 myapp/pom.xml create mode 100644 myapp/src/main/java/io/trygvis/container/myapp/MyComponent.java create mode 100644 myapp/src/main/java/io/trygvis/container/myapp/MyComponent_Tx.java create mode 100644 myapp/src/main/java/io/trygvis/container/myapp/MyMain.java (limited to 'myapp') diff --git a/myapp/pom.xml b/myapp/pom.xml new file mode 100644 index 0000000..7253422 --- /dev/null +++ b/myapp/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + container-playground + io.trygvis.container + 1.0-SNAPSHOT + + myapp + + + io.trygvis.container + container-core + ${project.version} + + + io.trygvis.container + container-compiler-plugin + ${project.version} + + + + + + maven-compiler-plugin + + + io.trygvis.container.compiler.MyProcessor + + + + + + diff --git a/myapp/src/main/java/io/trygvis/container/myapp/MyComponent.java b/myapp/src/main/java/io/trygvis/container/myapp/MyComponent.java new file mode 100644 index 0000000..cf30c3b --- /dev/null +++ b/myapp/src/main/java/io/trygvis/container/myapp/MyComponent.java @@ -0,0 +1,40 @@ +package io.trygvis.container.myapp; + +import io.trygvis.container.log.Log; +import io.trygvis.container.tx.Tx; +import org.springframework.transaction.annotation.Transactional; + +import static io.trygvis.container.tx.TransactionHolder.currentTx; + +@Transactional +@Log +public class MyComponent { + private final String myString = "123"; + private String myVar; + + public static class Person { + public final String name; + + public Person(String name) { + this.name = name; + } + } + + protected MyComponent() { + } + + public MyComponent(String myVar) { + this.myVar = myVar; + } + + public void doProcessing(int x) { + Tx tx = currentTx(); + } + + public Person addPerson(String name) { + return new Person(name); + } + + public void deletePerson(int a, int b) { + } +} diff --git a/myapp/src/main/java/io/trygvis/container/myapp/MyComponent_Tx.java b/myapp/src/main/java/io/trygvis/container/myapp/MyComponent_Tx.java new file mode 100644 index 0000000..445d236 --- /dev/null +++ b/myapp/src/main/java/io/trygvis/container/myapp/MyComponent_Tx.java @@ -0,0 +1,26 @@ +package io.trygvis.container.myapp; + +import io.trygvis.container.tx.PlatformTransactionManager; + +public class MyComponent_Tx extends MyComponent { + private final PlatformTransactionManager transactionManager; + private final MyComponent target; + + public MyComponent_Tx(PlatformTransactionManager tm) { + this.transactionManager = tm; + this.target = new MyComponent(); + } + + public void doProcessing(final int x) { + transactionManager.doInTransaction( + PlatformTransactionManager.TransactionIsolation.ISOLATION_DEFAULT, + PlatformTransactionManager.TransactionPropagation.PROPAGATION_REQUIRED, + new PlatformTransactionManager.TransactionTemplate() { + @Override + public Object doInTransaction() { + target.doProcessing(x); + return null; + } + }); + } +} diff --git a/myapp/src/main/java/io/trygvis/container/myapp/MyMain.java b/myapp/src/main/java/io/trygvis/container/myapp/MyMain.java new file mode 100644 index 0000000..a54e486 --- /dev/null +++ b/myapp/src/main/java/io/trygvis/container/myapp/MyMain.java @@ -0,0 +1,10 @@ +package io.trygvis.container.myapp; + +import org.springframework.transaction.annotation.Transactional; + +public class MyMain { + + public static void main(String[] args) { + System.out.println("io.trygvis.container.myapp.MyMain.main"); + } +} -- cgit v1.2.3