cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1332956 - in /cxf/trunk/rt/ws/rm/src: main/java/org/apache/cxf/ws/rm/blueprint/ main/java/org/apache/cxf/ws/rm/spring/ main/resources/schemas/configuration/ test/java/org/apache/cxf/ws/rm/persistence/jdbc/
Date Wed, 02 May 2012 08:47:15 GMT
Author: ay
Date: Wed May  2 08:47:14 2012
New Revision: 1332956

URL: http://svn.apache.org/viewvc?rev=1332956&view=rev
Log:
[CXF-4282] Make additional properties of WS-RM's RMTxStore configurable using spring and bluepring
handlers

Added:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
  (with props)
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean2.xml
  (with props)
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-ds-bean2.xml
  (with props)
Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPHandler.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/spring/RMTxStoreBeanDefinitionParser.java
    cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPHandler.java?rev=1332956&r1=1332955&r2=1332956&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPHandler.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPHandler.java Wed May
 2 08:47:14 2012
@@ -25,10 +25,8 @@ import org.w3c.dom.Node;
 
 import org.apache.aries.blueprint.NamespaceHandler;
 import org.apache.aries.blueprint.ParserContext;
-import org.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser;
 import org.apache.cxf.ws.rm.RMManager;
 import org.apache.cxf.ws.rm.feature.RMFeature;
-import org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
 
@@ -60,7 +58,7 @@ public class RMBPHandler implements Name
         } else if ("rmManager".equals(s)) {
             return new RMBPBeanDefinitionParser(RMManager.class).parse(element, context);
         } else if ("jdbcStore".equals(s)) {
-            return new SimpleBPBeanDefinitionParser(RMTxStore.class).parse(element, context);
+            return new RMBPTxStoreBeanDefinitionParser().parse(element, context);
         }
 
         return null;

Added: 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=1332956&view=auto
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
(added)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
Wed May  2 08:47:14 2012
@@ -0,0 +1,52 @@
+/**
+ * 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.cxf.ws.rm.blueprint;
+
+import org.w3c.dom.Element;
+
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser;
+import org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore;
+
+/**
+ * This class provides some common functions used by the two BP TxStore bean definition parsers
+ * in this package. 
+ * 
+ */
+public class RMBPTxStoreBeanDefinitionParser extends SimpleBPBeanDefinitionParser {
+
+    public RMBPTxStoreBeanDefinitionParser() {
+        super(RMTxStore.class);
+    }
+    
+    @Override
+    protected void mapAttribute(MutableBeanMetadata bean, Element e, String name, String
val,
+                                ParserContext context) {
+        if ("dataSource".equals(name)) {
+            if (val != null && val.trim().length() > 0) {
+                bean.addProperty("dataSource", createRef(context, val));
+            }
+        } else {
+            super.mapAttribute(bean, e, name, val, context);    
+        }
+    }
+
+}

Propchange: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPTxStoreBeanDefinitionParser.java
------------------------------------------------------------------------------
    svn:executable = *

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=1332956&r1=1332955&r2=1332956&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
Wed May  2 08:47:14 2012
@@ -22,10 +22,22 @@ 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;
 
 public class RMTxStoreBeanDefinitionParser extends AbstractBeanDefinitionParser {
 
     @Override
+    protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String
val) {
+        if ("dataSource".equals(name)) {
+            if (val != null && val.trim().length() > 0) {
+                bean.addPropertyReference("dataSource", val);
+            }
+        } else {
+            super.mapAttribute(bean, e, name, val);    
+        }
+    }
+
+    @Override
     protected Class<?> getBeanClass(Element element) {
         return RMTxStore.class;
     }

Modified: cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd?rev=1332956&r1=1332955&r2=1332956&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd (original)
+++ cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd Wed May 
2 08:47:14 2012
@@ -147,6 +147,13 @@
               </xs:documentation>
             </xs:annotation>
           </xs:attribute>
+          <xs:attribute name="dataSource" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>
+                  The optional datasource reference to be used.          
+              </xs:documentation>
+            </xs:annotation>
+          </xs:attribute>
           <xs:attribute name="url" type="xs:string" default="jdbc:derby:rmdb;create=true">
             <xs:annotation>
               <xs:documentation>
@@ -154,24 +161,38 @@
               </xs:documentation>
             </xs:annotation>
           </xs:attribute>
-           <xs:attribute name="userName" type="xs:string">
+          <xs:attribute name="userName" type="xs:string">
             <xs:annotation>
               <xs:documentation>
-                  The username.          
+                  The username.
               </xs:documentation>
             </xs:annotation>
           </xs:attribute>
            <xs:attribute name="password" type="xs:string">
             <xs:annotation>
               <xs:documentation>
-                  The password.          
+                  The password.
+              </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:attribute name="tableExistsState" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>
+                  The SQL state to verify a vendor specific table-exists condition.
               </xs:documentation>
             </xs:annotation>
           </xs:attribute>
-           <xs:attribute name="schemaName" type="xs:string">
+          <xs:attribute name="tableExistsCode" type="xs:int">
             <xs:annotation>
               <xs:documentation>
-                  The default schema name.          
+                  The SQL error code to verify a vendor specific table-exists condition.
               </xs:documentation>
             </xs:annotation>
           </xs:attribute>

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java?rev=1332956&r1=1332955&r2=1332956&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
(original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
Wed May  2 08:47:14 2012
@@ -68,6 +68,19 @@ public class RMTxStoreConfigurationTest 
     }
 
     @Test
+    public void testSetCustomTableExistsState2() {
+        SpringBusFactory factory = new SpringBusFactory();
+        Bus bus = factory.createBus("org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean2.xml");
+        RMManager manager = bus.getExtension(RMManager.class);
+        assertNotNull(manager);
+        RMTxStore store = (RMTxStore)manager.getStore();
+                
+        assertTrue(store.isTableExistsError(new SQLException("Table exists", "I6000", 288)));
+        
+        assertFalse(store.isTableExistsError(new SQLException("Unknown error", "00000", -1)));
+    }
+
+    @Test
     public void testTxStoreWithDataSource() {
         SpringBusFactory factory = new SpringBusFactory();
         Bus bus = factory.createBus("org/apache/cxf/ws/rm/persistence/jdbc/txstore-ds-bean.xml");
@@ -80,6 +93,19 @@ public class RMTxStoreConfigurationTest 
         assertNull(store.getConnection());
     }
     
+    @Test
+    public void testTxStoreWithDataSource2() {
+        SpringBusFactory factory = new SpringBusFactory();
+        Bus bus = factory.createBus("org/apache/cxf/ws/rm/persistence/jdbc/txstore-ds-bean2.xml");
+        RMManager manager = bus.getExtension(RMManager.class);
+        assertNotNull(manager);
+        RMTxStore store = (RMTxStore)manager.getStore();
+                
+        assertNotNull(store.getDataSource());
+        
+        assertNull(store.getConnection());
+    }
+
     static class TestDataSource implements DataSource {
         public PrintWriter getLogWriter() throws SQLException {
             return null;

Added: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean2.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean2.xml?rev=1332956&view=auto
==============================================================================
Binary file - no diff available.

Propchange: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean2.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean2.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml

Added: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-ds-bean2.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-ds-bean2.xml?rev=1332956&view=auto
==============================================================================
Binary file - no diff available.

Propchange: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-ds-bean2.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-ds-bean2.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml



Mime
View raw message