summaryrefslogtreecommitdiff
path: root/myapp/src
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-08-01 22:26:13 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-08-01 22:26:13 +0200
commit6ba3b6fc452265fb595b7f32055423c606ed77fd (patch)
tree14ae8915ef9cb9dc28667a10f9303f12672c12ba /myapp/src
downloadcontainer-playground-6ba3b6fc452265fb595b7f32055423c606ed77fd.tar.gz
container-playground-6ba3b6fc452265fb595b7f32055423c606ed77fd.tar.bz2
container-playground-6ba3b6fc452265fb595b7f32055423c606ed77fd.tar.xz
container-playground-6ba3b6fc452265fb595b7f32055423c606ed77fd.zip
o Initial import.
Diffstat (limited to 'myapp/src')
-rw-r--r--myapp/src/main/java/io/trygvis/container/myapp/MyComponent.java40
-rw-r--r--myapp/src/main/java/io/trygvis/container/myapp/MyComponent_Tx.java26
-rw-r--r--myapp/src/main/java/io/trygvis/container/myapp/MyMain.java10
3 files changed, 76 insertions, 0 deletions
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<Object>() {
+ @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");
+ }
+}