cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1345414 - in /cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm: blueprint/RMBPTxStoreBeanDefinitionParser.java persistence/jdbc/RMTxStore.java spring/RMTxStoreBeanDefinitionParser.java
Date Sat, 02 Jun 2012 01:54:08 GMT
Author: dkulp
Date: Sat Jun  2 01:54:07 2012
New Revision: 1345414

URL: http://svn.apache.org/viewvc?rev=1345414&view=rev
Log:
Close the connection on destroy. Use spring/bp methods to init/destroy

Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/spring/RMTxStoreBeanDefinitionParser.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java?rev=1345414&r1=1345413&r2=1345414&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
Sat Jun  2 01:54:07 2012
@@ -42,6 +42,7 @@ public class RMBPTxStoreBeanDefinitionPa
         super.parseChildElements(element, ctx, bean);
         
         bean.setInitMethod("init");
+        bean.setDestroyMethod("destroy");
     }
 
     @Override

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java?rev=1345414&r1=1345413&r2=1345414&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
Sat Jun  2 01:54:07 2012
@@ -43,10 +43,10 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.regex.Pattern;
 
-import javax.annotation.PostConstruct;
 import javax.sql.DataSource;
 
 import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
@@ -61,6 +61,7 @@ import org.apache.cxf.ws.rm.persistence.
 import org.apache.cxf.ws.rm.v200702.Identifier;
 import org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement;
 
+@NoJSR250Annotations
 public class RMTxStore implements RMStore {
     
     public static final String DEFAULT_DATABASE_NAME = "rmdb";
@@ -151,6 +152,7 @@ public class RMTxStore implements RMStor
     private static final Logger LOG = LogUtils.getL7dLogger(RMTxStore.class);
     
     private Connection connection;
+    private boolean createdConnection = true;
     private Lock writeLock = new ReentrantLock();
     
     private PreparedStatement createDestSequenceStmt;
@@ -180,6 +182,19 @@ public class RMTxStore implements RMStor
     private String tableExistsState = DERBY_TABLE_EXISTS_STATE;
     private int tableExistsCode = ORACLE_TABLE_EXISTS_CODE;
     
+    public RMTxStore() {
+    }
+    
+    public void destroy() {
+        if (connection != null && createdConnection) {
+            try {
+                connection.close();
+            } catch (SQLException e) {
+                //ignore
+            }
+        }
+    }
+    
     // configuration
     
     public void setDriverClassName(String dcn) {
@@ -252,6 +267,7 @@ public class RMTxStore implements RMStor
 
     public void setConnection(Connection c) {
         connection = c;
+        createdConnection = false; 
     }
     
     // RMStore interface  
@@ -825,10 +841,7 @@ public class RMTxStore implements RMStor
             MessageFormat.format(SELECT_MESSAGES_STMT_STR, OUTBOUND_MSGS_TABLE_NAME));
     }
 
-
-    @PostConstruct     
     public synchronized void init() {
-        
         if (null == connection) {
             LOG.log(Level.FINE, "Using derby.system.home: {0}", 
                     SystemPropertyAction.getProperty("derby.system.home"));
@@ -866,6 +879,7 @@ public class RMTxStore implements RMStor
             createTables();
             createStatements();
         } catch (SQLException ex) {
+            ex.printStackTrace();
             LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", ex);
             SQLException se = ex;
             while (se.getNextException() != null) {
@@ -873,6 +887,8 @@ public class RMTxStore implements RMStor
                 LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", se);
             }
             throw new RMStoreException(ex);
+        } catch (Throwable ex) {
+            ex.printStackTrace();
         } finally {
             try {
                 connection.setAutoCommit(false);                

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/spring/RMTxStoreBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/spring/RMTxStoreBeanDefinitionParser.java?rev=1345414&r1=1345413&r2=1345414&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/spring/RMTxStoreBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/spring/RMTxStoreBeanDefinitionParser.java
Sat Jun  2 01:54:07 2012
@@ -23,9 +23,15 @@ import org.w3c.dom.Element;
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
 
 public class RMTxStoreBeanDefinitionParser extends AbstractBeanDefinitionParser {
-
+    @Override
+    protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean)
{
+        super.doParse(element, ctx, bean);
+        bean.setInitMethodName("init");
+        bean.setDestroyMethodName("destroy");
+    }
     @Override
     protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String
val) {
         if ("dataSource".equals(name)) {



Mime
View raw message