diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-01 22:26:13 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-01 22:26:13 +0200 |
commit | 6ba3b6fc452265fb595b7f32055423c606ed77fd (patch) | |
tree | 14ae8915ef9cb9dc28667a10f9303f12672c12ba /myapp | |
download | container-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')
-rw-r--r-- | myapp/pom.xml | 36 | ||||
-rw-r--r-- | myapp/src/main/java/io/trygvis/container/myapp/MyComponent.java | 40 | ||||
-rw-r--r-- | myapp/src/main/java/io/trygvis/container/myapp/MyComponent_Tx.java | 26 | ||||
-rw-r--r-- | myapp/src/main/java/io/trygvis/container/myapp/MyMain.java | 10 |
4 files changed, 112 insertions, 0 deletions
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 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>container-playground</artifactId> + <groupId>io.trygvis.container</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>myapp</artifactId> + <dependencies> + <dependency> + <groupId>io.trygvis.container</groupId> + <artifactId>container-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.trygvis.container</groupId> + <artifactId>container-compiler-plugin</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <compilerArguments> + <processor>io.trygvis.container.compiler.MyProcessor</processor> + </compilerArguments> + </configuration> + </plugin> + </plugins> + </build> +</project> 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"); + } +} |