[teiid-commits] teiid SVN: r3125 - in trunk: connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce and 3 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Apr 27 15:38:40 EDT 2011


Author: rareddy
Date: 2011-04-27 15:38:39 -0400 (Wed, 27 Apr 2011)
New Revision: 3125

Modified:
   trunk/connectors/connector-salesforce/pom.xml
   trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
   trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
   trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
   trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
TEIID-1432: Adding CXF configuration option for Saleforce connection. Also updated the document for this change.

Modified: trunk/connectors/connector-salesforce/pom.xml
===================================================================
--- trunk/connectors/connector-salesforce/pom.xml	2011-04-27 14:54:53 UTC (rev 3124)
+++ trunk/connectors/connector-salesforce/pom.xml	2011-04-27 19:38:39 UTC (rev 3125)
@@ -39,6 +39,30 @@
             <artifactId>connector-api</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>2.2.2</version>
+            <scope>provided</scope>        
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>2.2.2</version>
+            <scope>provided</scope>        
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-ws-security</artifactId>
+            <version>2.2.2</version>
+            <scope>provided</scope>        
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-ws-policy</artifactId>
+            <version>2.2.2</version>
+            <scope>provided</scope>        
+        </dependency>        
     </dependencies>
 
     <build>

Modified: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java	2011-04-27 14:54:53 UTC (rev 3124)
+++ trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java	2011-04-27 19:38:39 UTC (rev 3125)
@@ -25,18 +25,29 @@
 import java.net.URL;
 
 import javax.resource.ResourceException;
+import javax.xml.namespace.QName;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
 import org.teiid.core.TeiidRuntimeException;
 import org.teiid.resource.spi.BasicConnectionFactory;
 import org.teiid.resource.spi.BasicManagedConnectionFactory;
 
+import com.sforce.soap.partner.SforceService;
 
+
 public class SalesForceManagedConnectionFactory extends BasicManagedConnectionFactory {
 	private static final long serialVersionUID = 5298591275313314698L;
 	
 	private String username;
 	private String password;
-	private URL URL;
+	private URL URL; //sf url
+	private String configFile; // path to the "jbossws-cxf.xml" file
+
+	//cxf bus
+	private Bus bus;
 	
 	public String getUsername() {
 		return username;
@@ -66,15 +77,37 @@
 		}
 	}
 	
+	public String getConfigFile() {
+		return configFile;
+	}
+
+	public void setConfigFile(String config) {
+		this.configFile = config;
+	}
+	
 	@Override
 	public BasicConnectionFactory createConnectionFactory() throws ResourceException {
+		QName portQName = SforceService.SERVICE;
+		if (this.configFile != null) {
+			this.bus = new SpringBusFactory().createBus(this.configFile);
+			JaxWsClientFactoryBean instance = new JaxWsClientFactoryBean();
+			Configurer configurer = this.bus.getExtension(Configurer.class);
+	        if (null != configurer) {
+	            configurer.configureBean(portQName.toString() + ".jaxws-client.proxyFactory", instance); //$NON-NLS-1$
+	        }
+		}
+		
 		return new BasicConnectionFactory() {
 			private static final long serialVersionUID = 5028356110047329135L;
 
 			@Override
 			public SalesforceConnectionImpl getConnection() throws ResourceException {
-				return new SalesforceConnectionImpl(getUsername(), getPassword(), getURL());
+				return new SalesforceConnectionImpl(getUsername(), getPassword(), getURL(), SalesForceManagedConnectionFactory.this);
 			}
 		};
 	}
+	
+	public Bus getBus() {
+		return bus;
+	}
 }

Modified: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java	2011-04-27 14:54:53 UTC (rev 3124)
+++ trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java	2011-04-27 19:38:39 UTC (rev 3125)
@@ -30,6 +30,8 @@
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.ws.BindingProvider;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.resource.spi.BasicConnection;
@@ -67,12 +69,14 @@
 	private Soap sfSoap;
 	private SessionHeader sh;
 	private CallOptions co;
+	private SalesForceManagedConnectionFactory mcf;
 	
 	private ObjectFactory partnerFactory = new ObjectFactory();
 	
 	PackageVersionHeader pvHeader = partnerFactory.createPackageVersionHeader();
 	
-	public SalesforceConnectionImpl(String username, String password, URL url) throws ResourceException {
+	public SalesforceConnectionImpl(String username, String password, URL url, SalesForceManagedConnectionFactory mcf) throws ResourceException {
+		this.mcf = mcf;
 		login(username, password, url);
 	}
 	
@@ -102,6 +106,8 @@
 				throw new ResourceException("SalesForce URL is not specified, please provide a valid URL"); //$NON-NLS-1$
 			}
 
+			Bus bus = BusFactory.getThreadDefaultBus();
+			BusFactory.setThreadDefaultBus(mcf.getBus());
 			try {
 				sfService = new SforceService();
 				sfSoap = sfService.getSoap();
@@ -113,6 +119,8 @@
 				throw new ResourceException(e);
 			} catch (com.sforce.soap.partner.UnexpectedErrorFault e) {
 				throw new ResourceException(e);
+			} finally {
+				BusFactory.setThreadDefaultBus(bus);
 			}
 			LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Login was successful for username " + username); //$NON-NLS-1$
 

Modified: trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml	2011-04-27 14:54:53 UTC (rev 3124)
+++ trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml	2011-04-27 19:38:39 UTC (rev 3125)
@@ -57,8 +57,14 @@
                <config-property-name>URL</config-property-name>
                <config-property-type>java.lang.String</config-property-type>
                <config-property-value>https://www.salesforce.com/services/Soap/u/17.0</config-property-value>
-            </config-property>     
+            </config-property> 
             
+            <config-property>
+                <description>{$display:"CXF Configuration File",$description:"CXF client configuration File or URL"}</description>
+                <config-property-name>ConfigFile</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+            </config-property>
+            
             <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
             <connectionfactory-impl-class>org.teiid.resource.spi.WrappedConnectionFactory</connectionfactory-impl-class>
             <connection-interface>javax.resource.cci.Connection</connection-interface>

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml	2011-04-27 14:54:53 UTC (rev 3124)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml	2011-04-27 19:38:39 UTC (rev 3125)
@@ -117,7 +117,9 @@
 </datasources>]]></programlisting>     
                 </listitem>
             </orderedlist>
-            
+            <para>Template files [xxx-ds.xml] for different databases can found at {jboss-as}/docs/examples/jca, and also
+            additional  sources like ingres, mondrian, intersystems-cache etc that Teiid suports can be found at
+            {jboss-as}/server/{profile}/teiid-examples/jca directory. </para>
         </section>        
         <section>
             <title>File Data Sources</title>
@@ -136,7 +138,7 @@
 </connection-factories>]]></programlisting></example>             
         </section>
         
-        <section>
+        <section id="ws-ds">
         	<title>Web Service Data Sources</title>
         	<para>Web service data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the 
             "&lt;jboss-install&gt;/server/&lt;profile&gt;/deploy" directory.</para>
@@ -296,6 +298,24 @@
       <config-property name="password">password</config-property>
    </no-tx-connection-factory>
 </connection-factories>]]></programlisting></example>
+
+            <section>
+                <title>CXF Configuration</title>
+                <para>Salesforce service data source may choose a particular CXF config file and port configuration. 
+                The <code>ConfigFile</code> config property specifies the Spring XML configuration 
+                file for the CXF Bus and port configuration to be used by connections.  
+                If no config file is specified then the system default configuration will be used.</para>
+                
+                <para>Only 1 port configuration can be used by this data source.  The namespace URI for the QName in your 
+                 config file should be "urn:partner.soap.sforce.com", with configuration name "SforceService". For sample
+                 cxf configuration file and details on configuration see <link linkend="ws-ds">Web Service Data Sources</link>
+                 </para>
+                 
+                <para>See the <ulink url="http://cxf.apache.org/docs/">CXF documentation</ulink> for all possible configuration options.</para>
+                
+                <note><para>The CXF configuration in Salesforce data source is only used for http bus configuration not for purposes of 
+                ws-security, Salesforce has its own security authentication.</para></note>
+            </section>
         </section>
         
         <section>

Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml	2011-04-27 14:54:53 UTC (rev 3124)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml	2011-04-27 19:38:39 UTC (rev 3125)
@@ -197,6 +197,12 @@
                 getTextFiles, and saveFile procedures.
                 </para>
             </section>
+            
+            <section>
+                <title>JCA Resource Adapter</title>
+                <para>The resource adapter for this translator provided through "File Data Source", Refer to Admin Guide for 
+                configuration information.</para>
+            </section>            
 
         </section>
         
@@ -490,6 +496,12 @@
             </para>
         </section>
         
+        <section>
+            <title>JCA Resource Adapter</title>
+            <para>The resource adapter for this translator provided through data source in JBoss AS, 
+            Refer to Admin Guide for "JDBC Data Sources" configuration section.</para>
+        </section>          
+        
     </section>
     
     <section>
@@ -542,6 +554,13 @@
 	        any value may be returned.  
 	        </para>        
         </section>
+        
+        <section>
+            <title>JCA Resource Adapter</title>
+            <para>The resource adapter for this translator provided through "LDAP Data Source", 
+            Refer to Admin Guide for configuration.</para>
+        </section> 
+                
     </section>
 
     <section>
@@ -595,6 +614,11 @@
         provide metadata - it should be used as a testing stub.
         </para>
         
+        <section>
+            <title>JCA Resource Adapter</title>
+            <para>The source connection is required for this translator</para>
+        </section>         
+        
     </section>
     
     <section>
@@ -942,6 +966,13 @@
                 </section>
                 
             </section>
+            
+        <section>
+            <title>JCA Resource Adapter</title>
+            <para>The resource adapter for this translator provided through "Salesforce Data Source", 
+            Refer to Admin Guide for configuration.</para>
+        </section> 
+                    
         </section>
         
         <section>
@@ -1061,6 +1092,11 @@
                     </para>
                 </section>
             </section>
+            <section>
+                <title>JCA Resource Adapter</title>
+                <para>Theresource adapter for this translator provided through "Web Service Data Source", 
+                Refer to Admin Guide for configuration.</para>
+            </section>             
         </section>
         
         <section>
@@ -1098,13 +1134,18 @@
                     </para>
                     <note><para>The use of <xref linkend="dataroles"/> should be considered to prevent arbitrary MDX from being submitted to the invokeMDX procedure.</para></note>
                     <para>
-                    This translator requires a data source to be configured to the OLAP cube using OLAP4J JDBC driver. Two sample
-                    -ds.xml files provided for accessing OLAP servers in teiid-examples section. One is Mondrian specific, when Mondrian server is deloyed
-                    in the same JBoss AS as Teiid (mondrian-ds.xml). To access any other OLAP servers using XMLA interface, 
-                    the data source for them can be created using them example template olap-xmla-ds.xml
                     </para>
                 </section>
             </section>
+            <section>
+                <title>JCA Resource Adapter</title>
+                <para>The resource adapter for this translator provided through data source in JBoss AS, 
+                     Refer to Admin Guide for "JDBC Data Sources" configuration section. Two sample
+                    -ds.xml files provided for accessing OLAP servers in teiid-examples section. One is Mondrian specific, 
+                    when Mondrian server is deloyed
+                    in the same JBoss AS as Teiid (mondrian-ds.xml). To access any other OLAP servers using XMLA interface, 
+                    the data source for them can be created using them example template olap-xmla-ds.xml</para>
+            </section>              
         </section>        
         
         <section>



More information about the teiid-commits mailing list