aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1696456 [2/2] - in /aries/trunk/transaction: transaction-blueprint/ transaction-blueprint/src/main/java/org/apache/aries/transaction/ transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/ transaction-blueprint/src/m...
Date Tue, 18 Aug 2015 16:40:51 GMT
Copied: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/Counter.java
(from r1696014, aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/TransactionPropagationType.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/Counter.java?p2=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/Counter.java&p1=aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/TransactionPropagationType.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/TransactionPropagationType.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/Counter.java
Tue Aug 18 16:40:50 2015
@@ -1,23 +1,26 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.aries.transaction.annotations;
-
-public enum TransactionPropagationType {
-	Mandatory, Never, NotSupported, Required, RequiresNew, Supports
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.transaction.test;
+
+/**
+ * Allows to count the rows in the test table
+ */
+public interface Counter {
+    int countRows();
+}

Modified: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/TestBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/TestBean.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/TestBean.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/TestBean.java
Tue Aug 18 16:40:50 2015
@@ -25,15 +25,8 @@ import java.sql.SQLException;
  *
  */
 public interface TestBean {
-    public void insertRow(String name, int value) throws SQLException;
-    
-    public void delegateInsertRow(String name, int value) throws SQLException;
-    
-    public void insertRow(String name, int value, Exception e) throws SQLException;
-
-    public int countRows() throws SQLException;
-    
-    public void throwApplicationException() throws SQLException;
-    
-    public void throwRuntimeException();
+    void delegateInsertRow(String name, int value) throws SQLException;
+    void insertRow(String name, int value, Exception e) throws SQLException;
+    void throwApplicationException() throws SQLException;
+    void throwRuntimeException();
 }

Modified: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/Connector.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/Connector.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/Connector.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/Connector.java
Tue Aug 18 16:40:50 2015
@@ -19,82 +19,134 @@
 package org.apache.aries.transaction.test.impl;
 
 import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
 import javax.sql.DataSource;
 
-public class Connector {
+import org.apache.aries.transaction.test.Counter;
+
+public class Connector implements Counter {
     private DataSource xads;
     private String user;
     private String password;
+    private Connection conn;
 
     public void setXads(DataSource xads) {
         this.xads = xads;
     }
+
     public void setUser(String user) {
         this.user = user;
     }
+
     public void setPassword(String password) {
         this.password = password;
     }
-    
-    public Connection connect() throws SQLException {
+
+    private Connection connect() throws SQLException {
         return xads.getConnection(user, password);
     }
     
-    public void initialize() {
-        Connection conn = null;
-        Statement stmt = null;
+    public Connection getConn() {
+        return conn;
+    }
 
+    public void initialize() throws SQLException {
+        conn = connect();
+        DatabaseMetaData dbmd = conn.getMetaData();
+        ResultSet rs = dbmd.getTables(null, "", "TESTTABLE", null);
+        if (!rs.next()) {
+            executeUpdate("CREATE TABLE TESTTABLE (NAME VARCHAR(64), VALUE INTEGER, PRIMARY
KEY(NAME, VALUE))");
+        }
+    }
+    
+    public void executeUpdate(String sql) {
+        Statement stmt = null;
         try {
-            conn = connect();
-            conn.setAutoCommit(true);
             stmt = conn.createStatement();
-            stmt.executeUpdate("DROP TABLE TESTTABLE");
-        }
-        catch (Exception e) {
+            stmt.executeUpdate(sql);
+            conn.commit();
+        } catch (Exception e) {
             // Ignore
+        } finally {
+            safeClose(stmt);
+        }
+    }
+    
+    public int countRows() {
+        PreparedStatement stmt = null;
+        ResultSet rs = null;
+        int count = -1;
+        try {
+            stmt = conn.prepareStatement("SELECT * FROM TESTTABLE", ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
+            rs = stmt.executeQuery();
+            rs.last();
+            count = rs.getRow();
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage(), e);
         }
         finally {
+            safeClose(rs);
             safeClose(stmt);
-            safeClose(conn);
         }
 
+        return count;
+    }
+
+    
+    public void insertRow(String name, int value) throws SQLException {
+        PreparedStatement stmt = null;
+        Connection con2 = null;
         try {
-            conn = connect();
-            conn.setAutoCommit(true);
-            stmt = conn.createStatement();
-            stmt.executeUpdate("CREATE TABLE TESTTABLE (NAME VARCHAR(64), VALUE INTEGER,
PRIMARY KEY(NAME, VALUE))");
-        }
-        catch (Exception e) {
-            // Ignore
+            // Need to create a new connection to participate in transaction
+            con2 = connect();
+            stmt = con2.prepareStatement("INSERT INTO TESTTABLE VALUES (?, ?)");
+            stmt.setString(1, name);
+            stmt.setInt(2, value);
+            stmt.executeUpdate();
         }
         finally {
             safeClose(stmt);
-            safeClose(conn);
+            safeClose(con2);
         }
     }
+    
+    public void close() {
+        safeClose(conn);
+    }
 
     public void safeClose(Connection conn) {
-        if (conn == null) {
-            return;
-        }
-        try {
-            conn.close();
-        } catch (SQLException e) {
-            // Ignore
+        if (conn != null) {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+                // Ignore
+            }
         }
     }
 
     public void safeClose(Statement stmt) {
-        if (stmt == null) {
-            return;
+        if (stmt != null) {
+            try {
+                stmt.close();
+            } catch (SQLException e) {
+                // Ignore
+            }
         }
-        try {
-            stmt.close();
-        } catch (SQLException e) {
-            // Ignore
+    }
+    
+
+    private void safeClose(ResultSet rs) {
+        if (rs != null) {
+            try {
+                rs.close();
+            } catch (SQLException e) {
+                // Ignore
+            }
         }
     }
 }

Copied: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/MandatoryTestBeanImpl.java
(from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/MandatoryTestBeanImpl.java?p2=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/MandatoryTestBeanImpl.java&p1=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/MandatoryTestBeanImpl.java
Tue Aug 18 16:40:50 2015
@@ -21,13 +21,7 @@ package org.apache.aries.transaction.tes
 import javax.transaction.Transactional;
 import java.sql.SQLException;
 
-public class JtaAnnotatedTestBeanImpl extends TestBeanImpl {
-
-    @Override
-    @Transactional(Transactional.TxType.MANDATORY)
-    public void insertRow(String name, int value) throws SQLException {
-        super.insertRow(name, value);
-    }
+public class MandatoryTestBeanImpl extends TestBeanImpl {
 
     @Override
     @Transactional(Transactional.TxType.MANDATORY)
@@ -41,9 +35,4 @@ public class JtaAnnotatedTestBeanImpl ex
         super.delegateInsertRow(name, value);
     }
 
-    @Override
-    @Transactional(Transactional.TxType.NOT_SUPPORTED)
-    public int countRows() throws SQLException {
-        return super.countRows();
-    }
 }

Copied: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NeverTestBeanImpl.java
(from r1696014, aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/JtaAnnotatedPojo.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NeverTestBeanImpl.java?p2=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NeverTestBeanImpl.java&p1=aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/JtaAnnotatedPojo.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/JtaAnnotatedPojo.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NeverTestBeanImpl.java
Tue Aug 18 16:40:50 2015
@@ -1,39 +1,40 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.aries.transaction.pojo;
-
-import javax.transaction.Transactional;
-import javax.transaction.Transactional.TxType;
-
-@Transactional(TxType.REQUIRED)
-public class JtaAnnotatedPojo {
-
-    public void increment(String key) {
-    }
-
-    @Transactional(TxType.SUPPORTS)
-    protected int checkValue(String key) {
-        return 0;
-    }
-
-    @Transactional(TxType.MANDATORY)
-    Object getRealObject(String key) {
-        return null;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.transaction.test.impl;
+
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+import java.sql.SQLException;
+
+public class NeverTestBeanImpl extends TestBeanImpl {
+
+    @Override
+    @Transactional(value=TxType.NEVER)
+    public void insertRow(String name, int value, Exception e) throws SQLException {
+        super.insertRow(name, value, e);
+    }
+
+    @Override
+    @Transactional(value=TxType.NEVER)
+    public void delegateInsertRow(String name, int value) throws SQLException {
+        super.delegateInsertRow(name, value);
+    }
+
+}

Copied: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NotSupportedTestBeanImpl.java
(from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NotSupportedTestBeanImpl.java?p2=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NotSupportedTestBeanImpl.java&p1=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NotSupportedTestBeanImpl.java
Tue Aug 18 16:40:50 2015
@@ -18,32 +18,32 @@
  */
 package org.apache.aries.transaction.test.impl;
 
-import javax.transaction.Transactional;
 import java.sql.SQLException;
 
-public class JtaAnnotatedTestBeanImpl extends TestBeanImpl {
-
-    @Override
-    @Transactional(Transactional.TxType.MANDATORY)
-    public void insertRow(String name, int value) throws SQLException {
-        super.insertRow(name, value);
-    }
+import javax.transaction.Transactional;
 
-    @Override
-    @Transactional(Transactional.TxType.MANDATORY)
-    public void insertRow(String name, int value, Exception e) throws SQLException {
-        super.insertRow(name, value, e);
-    }
+@Transactional(Transactional.TxType.NOT_SUPPORTED)
+public class NotSupportedTestBeanImpl extends TestBeanImpl {
 
+    @Transactional(Transactional.TxType.NOT_SUPPORTED)
     @Override
-    @Transactional(Transactional.TxType.MANDATORY)
     public void delegateInsertRow(String name, int value) throws SQLException {
+        // TODO Auto-generated method stub
         super.delegateInsertRow(name, value);
     }
 
+    @Transactional(Transactional.TxType.NOT_SUPPORTED)
     @Override
+    public void throwApplicationException() throws SQLException {
+        // TODO Auto-generated method stub
+        super.throwApplicationException();
+    }
+
     @Transactional(Transactional.TxType.NOT_SUPPORTED)
-    public int countRows() throws SQLException {
-        return super.countRows();
+    @Override
+    public void throwRuntimeException() {
+        // TODO Auto-generated method stub
+        super.throwRuntimeException();
     }
+
 }

Copied: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiredTestBeanImpl.java
(from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/AnnotatedTestBeanImpl.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiredTestBeanImpl.java?p2=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiredTestBeanImpl.java&p1=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/AnnotatedTestBeanImpl.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/AnnotatedTestBeanImpl.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiredTestBeanImpl.java
Tue Aug 18 16:40:50 2015
@@ -18,34 +18,22 @@
  */
 package org.apache.aries.transaction.test.impl;
 
-import org.apache.aries.transaction.annotations.Transaction;
-import org.apache.aries.transaction.annotations.TransactionPropagationType;
-
 import java.sql.SQLException;
 
-public class AnnotatedTestBeanImpl extends TestBeanImpl {
+import javax.transaction.Transactional;
 
-    @Override
-    @Transaction(TransactionPropagationType.Mandatory)
-    public void insertRow(String name, int value) throws SQLException {
-        super.insertRow(name, value);
-    }
+public class RequiredTestBeanImpl extends TestBeanImpl {
 
     @Override
-    @Transaction(TransactionPropagationType.Mandatory)
+    @Transactional(Transactional.TxType.REQUIRED)
     public void insertRow(String name, int value, Exception e) throws SQLException {
         super.insertRow(name, value, e);
     }
 
     @Override
-    @Transaction(TransactionPropagationType.Mandatory)
+    @Transactional(Transactional.TxType.REQUIRED)
     public void delegateInsertRow(String name, int value) throws SQLException {
         super.delegateInsertRow(name, value);
     }
 
-    @Override
-    @Transaction(TransactionPropagationType.NotSupported)
-    public int countRows() throws SQLException {
-        return super.countRows();
-    }
 }

Copied: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiresNewTestBeanImpl.java
(from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiresNewTestBeanImpl.java?p2=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiresNewTestBeanImpl.java&p1=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiresNewTestBeanImpl.java
Tue Aug 18 16:40:50 2015
@@ -19,31 +19,22 @@
 package org.apache.aries.transaction.test.impl;
 
 import javax.transaction.Transactional;
-import java.sql.SQLException;
+import javax.transaction.Transactional.TxType;
 
-public class JtaAnnotatedTestBeanImpl extends TestBeanImpl {
+import java.sql.SQLException;
 
-    @Override
-    @Transactional(Transactional.TxType.MANDATORY)
-    public void insertRow(String name, int value) throws SQLException {
-        super.insertRow(name, value);
-    }
+public class RequiresNewTestBeanImpl extends TestBeanImpl {
 
     @Override
-    @Transactional(Transactional.TxType.MANDATORY)
+    @Transactional(value=TxType.REQUIRES_NEW)
     public void insertRow(String name, int value, Exception e) throws SQLException {
         super.insertRow(name, value, e);
     }
 
     @Override
-    @Transactional(Transactional.TxType.MANDATORY)
+    @Transactional(value=TxType.REQUIRES_NEW)
     public void delegateInsertRow(String name, int value) throws SQLException {
         super.delegateInsertRow(name, value);
     }
 
-    @Override
-    @Transactional(Transactional.TxType.NOT_SUPPORTED)
-    public int countRows() throws SQLException {
-        return super.countRows();
-    }
 }

Copied: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/SupportsTestBeanImpl.java
(from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/SupportsTestBeanImpl.java?p2=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/SupportsTestBeanImpl.java&p1=aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/SupportsTestBeanImpl.java
Tue Aug 18 16:40:50 2015
@@ -19,31 +19,22 @@
 package org.apache.aries.transaction.test.impl;
 
 import javax.transaction.Transactional;
-import java.sql.SQLException;
+import javax.transaction.Transactional.TxType;
 
-public class JtaAnnotatedTestBeanImpl extends TestBeanImpl {
+import java.sql.SQLException;
 
-    @Override
-    @Transactional(Transactional.TxType.MANDATORY)
-    public void insertRow(String name, int value) throws SQLException {
-        super.insertRow(name, value);
-    }
+public class SupportsTestBeanImpl extends TestBeanImpl {
 
     @Override
-    @Transactional(Transactional.TxType.MANDATORY)
+    @Transactional(value=TxType.SUPPORTS)
     public void insertRow(String name, int value, Exception e) throws SQLException {
         super.insertRow(name, value, e);
     }
 
     @Override
-    @Transactional(Transactional.TxType.MANDATORY)
+    @Transactional(value=TxType.SUPPORTS)
     public void delegateInsertRow(String name, int value) throws SQLException {
         super.delegateInsertRow(name, value);
     }
 
-    @Override
-    @Transactional(Transactional.TxType.NOT_SUPPORTED)
-    public int countRows() throws SQLException {
-        return super.countRows();
-    }
 }

Modified: aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/TestBeanImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/TestBeanImpl.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/TestBeanImpl.java
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/TestBeanImpl.java
Tue Aug 18 16:40:50 2015
@@ -18,9 +18,6 @@
  */
 package org.apache.aries.transaction.test.impl;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
 import java.sql.SQLException;
 
 import org.apache.aries.transaction.test.TestBean;
@@ -32,57 +29,17 @@ public class TestBeanImpl implements Tes
     public TestBeanImpl() {
     }
 
-    public void insertRow(String name, int value) throws SQLException {
-        Connection conn = null;
-        PreparedStatement stmt = null;
-
-        try {
-            conn = connector.connect();
-            stmt = conn.prepareStatement("INSERT INTO TESTTABLE VALUES (?, ?)");
-            stmt.setString(1, name);
-            stmt.setInt(2, value);
-            stmt.executeUpdate();
-        }
-        finally {
-            connector.safeClose(stmt);
-            connector.safeClose(conn);
-        }
-    }
-
     public void insertRow(String name, int value, Exception e) throws SQLException {
-        insertRow(name, value);
-        
-        if (e instanceof SQLException)
+        connector.insertRow(name, value);
+        if (e instanceof SQLException) { 
             throw (SQLException) e;
-        else if (e instanceof RuntimeException)
+        } else if (e instanceof RuntimeException) {
             throw (RuntimeException) e;
+        }
     }
 
     public void delegateInsertRow(String name, int value) throws SQLException {
-        bean.insertRow(name, value);
-    }
-
-    public int countRows() throws SQLException {
-        Connection conn = null;
-        PreparedStatement stmt = null;
-        ResultSet rs = null;
-        int count = -1;
-
-        try {
-            conn = connector.connect();
-            stmt = conn.prepareStatement("SELECT * FROM TESTTABLE", ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
-            rs = stmt.executeQuery();
-            rs.last();
-            count = rs.getRow();
-        }
-        finally {
-            if (rs != null)
-                rs.close();
-            connector.safeClose(stmt);
-            connector.safeClose(conn);
-        }
-
-        return count;
+        bean.insertRow(name, value, null);
     }
 
     public void throwApplicationException() throws SQLException {

Modified: aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
(original)
+++ aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
Tue Aug 18 16:40:50 2015
@@ -1,140 +1,82 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0"
-           default-activation="lazy">
-
-   <tx:enable-annotations/>
-
-   <bean id="connector" class="org.apache.aries.transaction.test.impl.Connector" init-method="initialize">
-       <property name="xads" ref="enlistingDataSource"/>
-       <property name="user" value="user"/>
-       <property name="password" value="password"/>
-   </bean>
-
-   <bean id="notSupportedBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl">
-       <tx:transaction method="*" value="NotSupported"/>
-       <property name="testBean" ref="mandatoryBeanImpl"/>
-       <property name="connector" ref="connector"/>
-   </bean>
-   
-   <service id="notSupportedBean" ref="notSupportedBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
-       <service-properties>
-           <entry key="tranAttribute" value="NotSupported"/>
-       </service-properties>
-   </service>
-
-   <bean id="requiredBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl">
-       <tx:transaction method="insertRow throw*" value="Required"/>
-       <tx:transaction method="countRows" value="NotSupported"/>
-       <property name="connector" ref="connector"/>
-   </bean>
-   
-   <service id="requiredBean" ref="requiredBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
-       <service-properties>
-           <entry key="tranAttribute" value="Required"/>
-       </service-properties>
-   </service>
-
-   <bean id="supportsBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl">
-       <tx:transaction method="*" value="Supports"/>
-       <tx:transaction method="countRows" value="NotSupported"/>
-       <property name="testBean" ref="mandatoryBeanImpl"/>
-       <property name="connector" ref="connector"/>
-   </bean>
-   
-   <service id="supportsBean" ref="supportsBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
-       <service-properties>
-           <entry key="tranAttribute" value="Supports"/>
-       </service-properties>
-   </service>
-
-   <service id="requiresNewBean" interface="org.apache.aries.transaction.test.TestBean">
-       <service-properties>
-           <entry key="tranAttribute" value="RequiresNew"/>
-       </service-properties>
-       <bean class="org.apache.aries.transaction.test.impl.TestBeanImpl">
-           <tx:transaction method="insertRow throw*" value="RequiresNew"/>
-           <tx:transaction method="countRows" value="NotSupported"/>
-           <property name="connector" ref="connector"/>
-       </bean>
-   </service>
-
-   <bean id="mandatoryBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl">
-       <tx:transaction method="insertRow throw*" value="Mandatory"/>
-       <tx:transaction method="countRows" value="NotSupported"/>
-       <property name="connector" ref="connector"/>
-   </bean>
-
-   <service id="mandatoryBean" ref="mandatoryBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
-       <service-properties>
-           <entry key="tranAttribute" value="Mandatory"/>
-       </service-properties>
-   </service>
-
-   <bean id="neverBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl">
-       <tx:transaction method="insertRow" value="Never"/>
-       <tx:transaction method="countRows" value="NotSupported"/>
-       <property name="testBean" ref="mandatoryBeanImpl"/>
-       <property name="connector" ref="connector"/>
-   </bean>
-   
-   <service id="neverBean" ref="neverBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
-       <service-properties>
-           <entry key="tranAttribute" value="Never"/>
-       </service-properties>
-   </service>
-
-   <bean id="invalidBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl">
-       <tx:transaction method="ins*" value="Never"/>
-       <tx:transaction method="*Row" value="NotSupported"/>
-       <property name="connector" ref="connector"/>
-   </bean>
-
-   <service id="invalidBean" ref="invalidBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
-       <service-properties>
-           <entry key="tranAttribute" value="Invalid"/>
-       </service-properties>
-   </service>
-
-    <bean id="mandatoryAnnotatedBeanImpl" class="org.apache.aries.transaction.test.impl.AnnotatedTestBeanImpl">
-        <property name="connector" ref="connector"/>
-    </bean>
-
-    <service id="mandatoryAnnotatedBean" ref="mandatoryAnnotatedBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
-        <service-properties>
-            <entry key="tranAttribute" value="MandatoryAnnotated"/>
-        </service-properties>
-    </service>
-
-    <bean id="mandatoryJtaAnnotatedBeanImpl" class="org.apache.aries.transaction.test.impl.JtaAnnotatedTestBeanImpl">
-        <property name="connector" ref="connector"/>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements. See the NOTICE file distributed 
+    with this work for additional information regarding copyright ownership. The ASF licenses
this file to you under the Apache License, 
+    Version 2.0 (the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License 
+    at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed
to in writing, software distributed under 
+    the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License 
+    for the specific language governing permissions and limitations under the License. -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0"
+    default-activation="lazy">
+
+    <tx:enable-annotations />
+
+    <reference id="enlistingDataSource" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=jdbc/xads)"
/>
+
+    <bean id="connector" class="org.apache.aries.transaction.test.impl.Connector" init-method="initialize"
destroy-method="close">
+        <property name="xads" ref="enlistingDataSource" />
+        <property name="user" value="" />
+        <property name="password" value="" />
     </bean>
 
-    <service id="mandatoryJtaAnnotatedBean" ref="mandatoryJtaAnnotatedBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
+    <service id="counter" ref="connector" interface="org.apache.aries.transaction.test.Counter">
+    </service>
+
+    <bean id="mandatoryBeanImpl" class="org.apache.aries.transaction.test.impl.MandatoryTestBeanImpl">
+        <property name="connector" ref="connector" />
+    </bean>
+    <service id="mandatoryBean" ref="mandatoryBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
+        <service-properties>
+            <entry key="tranAttribute" value="Mandatory" />
+        </service-properties>
+    </service>
+
+    <bean id="notSupportedBeanImpl" class="org.apache.aries.transaction.test.impl.NotSupportedTestBeanImpl">
+        <property name="testBean" ref="mandatoryBeanImpl" />
+        <property name="connector" ref="connector" />
+    </bean>
+    <service id="notSupportedBean" ref="notSupportedBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
         <service-properties>
-            <entry key="tranAttribute" value="MandatoryJtaAnnotated"/>
+            <entry key="tranAttribute" value="NotSupported" />
         </service-properties>
     </service>
-    
-    <reference id="enlistingDataSource" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=jdbc/xads)"/>
+
+    <bean id="requiredBeanImpl" class="org.apache.aries.transaction.test.impl.RequiredTestBeanImpl">
+        <property name="connector" ref="connector" />
+    </bean>
+    <service id="requiredBean" ref="requiredBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
+        <service-properties>
+            <entry key="tranAttribute" value="Required" />
+        </service-properties>
+    </service>
+
+    <bean id="supportsBeanImpl" class="org.apache.aries.transaction.test.impl.SupportsTestBeanImpl">
+        <property name="testBean" ref="mandatoryBeanImpl" />
+        <property name="connector" ref="connector" />
+    </bean>
+    <service id="supportsBean" ref="supportsBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
+        <service-properties>
+            <entry key="tranAttribute" value="Supports" />
+        </service-properties>
+    </service>
+
+    <bean id="requiresNewBeanImpl" class="org.apache.aries.transaction.test.impl.RequiresNewTestBeanImpl">
+        <property name="connector" ref="connector" />
+    </bean>
+    <service id="requiresNewBean" ref="requiresNewBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
+        <service-properties>
+            <entry key="tranAttribute" value="RequiresNew" />
+        </service-properties>
+    </service>
+
+    <bean id="neverBeanImpl" class="org.apache.aries.transaction.test.impl.NeverTestBeanImpl">
+        <property name="testBean" ref="mandatoryBeanImpl" />
+        <property name="connector" ref="connector" />
+    </bean>
+    <service id="neverBean" ref="neverBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
+        <service-properties>
+            <entry key="tranAttribute" value="Never" />
+        </service-properties>
+    </service>
+
 </blueprint>



Mime
View raw message