cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1328266 - in /cxf/branches/2.5.x-fixes: ./ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/ rt/ws/rm/src/main/resources/schemas/configuration/ rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/
Date Fri, 20 Apr 2012 09:06:16 GMT
Author: ay
Date: Fri Apr 20 09:06:16 2012
New Revision: 1328266

URL: http://svn.apache.org/viewvc?rev=1328266&view=rev
Log:
Merged revisions 1327984 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1327984 | ay | 2012-04-19 17:13:29 +0200 (Thu, 19 Apr 2012) | 1 line
  
  [CXF-4249] Make RMTxStore's current schema name to be configurable
........

Added:
    cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java
      - copied, changed from r1327984, cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java
Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
    cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd
    cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java

Propchange: cxf/branches/2.5.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java?rev=1328266&r1=1328265&r2=1328266&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
Fri Apr 20 09:06:16 2012
@@ -37,6 +37,7 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.regex.Pattern;
 
 import javax.annotation.PostConstruct;
 
@@ -117,6 +118,9 @@ public class RMTxStore implements RMStor
     private static final String SELECT_MESSAGES_STMT_STR =
         "SELECT MSG_NO, SEND_TO, CONTENT FROM {0} WHERE SEQ_ID = ?";
     
+    private static final String CREATE_SCHEMA_STMT_STR = "CREATE SCHEMA {0}";
+    private static final String SET_CURRENT_SCHEMA_STMT_STR = "SET CURRENT SCHEMA {0}";
+    
     private static final String DERBY_TABLE_EXISTS_STATE = "X0Y32";
     private static final int ORACLE_TABLE_EXISTS_CODE = 955;
     
@@ -146,6 +150,7 @@ public class RMTxStore implements RMStor
     private String url = MessageFormat.format("jdbc:derby:{0};create=true", DEFAULT_DATABASE_NAME);
     private String userName;
     private String password;
+    private String schemaName;
     
     private String tableExistsState = DERBY_TABLE_EXISTS_STATE;
     private int tableExistsCode = ORACLE_TABLE_EXISTS_CODE;
@@ -184,6 +189,18 @@ public class RMTxStore implements RMStor
         return userName;
     }
     
+    public String getSchemaName() {
+        return schemaName;
+    }
+
+    public void setSchemaName(String sn) {
+        if (sn == null || Pattern.matches("[a-zA-Z\\d]{1,32}", sn)) {
+            schemaName = sn;
+        } else {
+            throw new IllegalArgumentException("Invalid schema name: " + sn);
+        }
+    }
+
     public String getTableExistsState() {
         return tableExistsState;
     }
@@ -666,6 +683,30 @@ public class RMTxStore implements RMStor
         }
     }
     
+    protected void setCurrentSchema() throws SQLException {
+        if (schemaName == null || connection == null) {
+            return;
+        }
+        
+        Statement stmt = connection.createStatement();
+        // schemaName has been verified at setSchemaName(String)
+        try {
+            stmt.executeUpdate(MessageFormat.format(CREATE_SCHEMA_STMT_STR, 
+                                                    schemaName));
+        } catch (SQLException ex) {
+            // pass through to assume it is already created
+        }
+        stmt.close();
+        stmt = connection.createStatement();
+        try {
+            stmt.executeUpdate(MessageFormat.format(SET_CURRENT_SCHEMA_STMT_STR, 
+                                                    schemaName));
+        } catch (SQLException ex) {
+            throw ex;
+        }
+        stmt.close();
+    }
+
     @PostConstruct     
     public synchronized void init() {
         
@@ -684,7 +725,6 @@ public class RMTxStore implements RMStor
             try {
                 LOG.log(Level.FINE, "Using url: " + url);
                 connection = DriverManager.getConnection(url, userName, password);
-    
             } catch (SQLException ex) {
                 LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", ex);
                 return;
@@ -693,6 +733,7 @@ public class RMTxStore implements RMStor
         
         try {
             connection.setAutoCommit(true);
+            setCurrentSchema();
             createTables();
         } catch (SQLException ex) {
             LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", ex);

Modified: cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd?rev=1328266&r1=1328265&r2=1328266&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd
Fri Apr 20 09:06:16 2012
@@ -168,6 +168,13 @@
               </xs:documentation>
             </xs:annotation>
           </xs:attribute>
+           <xs:attribute name="schemaName" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>
+                  The default schema name.          
+              </xs:documentation>
+            </xs:annotation>
+          </xs:attribute>
         </xs:extension>
       </xs:complexContent>
     </xs:complexType>

Modified: cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java?rev=1328266&r1=1328265&r2=1328266&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
Fri Apr 20 09:06:16 2012
@@ -46,6 +46,7 @@ public class RMTxStoreConfigurationTest 
         assertEquals("scott", store.getUserName());
         assertEquals("tiger", store.getPassword());
         assertEquals("jdbc:derby://localhost:1527/rmdb;create=true", store.getUrl());
+        assertNull("schema should be unset", store.getSchemaName());
     }
    
     @Test

Copied: cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java
(from r1327984, cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java?p2=cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java&p1=cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java&r1=1327984&r2=1328266&rev=1328266&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTwoSchemasTest.java
Fri Apr 20 09:06:16 2012
@@ -95,16 +95,17 @@ public class RMTxStoreTwoSchemasTest ext
         EasyMock.expect(seq.getExpires()).andReturn(null);
         EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
         EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
-        EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
+        // for 2.5.x, this is not called
+//        EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
         
         control.replay();
         store1.createSourceSequence(seq);   
         control.verify();        
         
-        SourceSequence rseq = store1.getSourceSequence(sid1);
+        SourceSequence rseq = store1.getSourceSequence(sid1, ProtocolVariation.RM10WSA200408);
         assertNotNull(rseq);
         
-        rseq = store2.getSourceSequence(sid1);
+        rseq = store2.getSourceSequence(sid1, ProtocolVariation.RM10WSA200408);
         assertNull(rseq);
         
         control.reset();
@@ -112,27 +113,28 @@ public class RMTxStoreTwoSchemasTest ext
         EasyMock.expect(seq.getExpires()).andReturn(null);
         EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
         EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
-        EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
+        // for 2.5.x, this is not called
+//        EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
         
         control.replay();
         store2.createSourceSequence(seq);   
         control.verify();
         
-        rseq = store2.getSourceSequence(sid1);
+        rseq = store2.getSourceSequence(sid1, ProtocolVariation.RM10WSA200408);
         assertNotNull(rseq);
  
         // create another store
         RMTxStore store3 = createStore(null);
         store3.init();
 
-        rseq = store3.getSourceSequence(sid1);
+        rseq = store3.getSourceSequence(sid1, ProtocolVariation.RM10WSA200408);
         assertNull(rseq);
 
         // switch to the store1's schema
         store3.setSchemaName(store1.getSchemaName());
         store3.init();
         
-        rseq = store3.getSourceSequence(sid1);
+        rseq = store3.getSourceSequence(sid1, ProtocolVariation.RM10WSA200408);
         assertNotNull(rseq);
     }
 }
\ No newline at end of file



Mime
View raw message