[teiid-commits] teiid SVN: r2769 - in branches/7.1.x/connectors/connector-salesforce/src/main: rar/META-INF and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Mon Dec 13 12:55:27 EST 2010


Author: rareddy
Date: 2010-12-13 12:55:26 -0500 (Mon, 13 Dec 2010)
New Revision: 2769

Modified:
   branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
   branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
   branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
Log:
TEIID-1388: The CXF resolution of endpoint address from salesforce WSDL is different from that of the JDK impl of JAX-WS, thus connection was resolving to wrong endpoint when CXF is used. However using CXF if you set the "endpoint" address explicitly it will resolve correctly. The changes here make use of user supplied URL as the endpoint, if in case user did not supply the endpoint then a default endpoint is defined in the ra.xml will be used. Also, cleaned up some unused properties and added isAlive call to actually check if the connection is alive.

Modified: branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java	2010-12-13 15:31:33 UTC (rev 2768)
+++ branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java	2010-12-13 17:55:26 UTC (rev 2769)
@@ -35,28 +35,19 @@
 	private static final long serialVersionUID = 5298591275313314698L;
 	
 	private String username;
-	private String connectorStateClass;
 	private String password;
 	private URL URL;
-	private long sourceConnectionTestInterval = -1;
-	private int sourceConnectionTimeout = -1;
-	private boolean auditModelFields = false;
 	
 	public String getUsername() {
 		return username;
 	}
 	public void setUsername(String username) {
 		if (username.trim().length() == 0) {
-			throw new TeiidRuntimeException("Name can not be null");
+			throw new TeiidRuntimeException("Name can not be null"); //$NON-NLS-1$
 		}
 		this.username = username;
 	}
-	public String getConnectorStateClass() {
-		return this.connectorStateClass;
-	}
-	public void setConnectorStateClass(String connectorStateClass) {
-		this.connectorStateClass = connectorStateClass;
-	}
+
 	public String getPassword() {
 		return this.password;
 	}
@@ -71,35 +62,18 @@
 		try {
 			this.URL = new URL(uRL);
 		} catch (MalformedURLException e) {
-			throw new TeiidRuntimeException("URL Supplied is not valid URL"+ e.getMessage());
+			throw new TeiidRuntimeException("URL Supplied is not valid URL"+ e.getMessage());//$NON-NLS-1$
 		}
 	}
 	
-	public long getSourceConnectionTestInterval() {
-		return sourceConnectionTestInterval;
-	}
-	public void setSourceConnectionTestInterval(Long sourceConnectionTestInterval) {
-		this.sourceConnectionTestInterval = sourceConnectionTestInterval.longValue();
-	}
-	public int getSourceConnectionTimeout() {
-		return sourceConnectionTimeout;
-	}
-	public void setSourceConnectionTimeout(Integer sourceConnectionTimeout) {
-		this.sourceConnectionTimeout = sourceConnectionTimeout.intValue();
-	}
-	public void setModelAuditFields(Boolean modelAuditFields) {
-		this.auditModelFields = modelAuditFields.booleanValue();
-	}
-	public boolean isModelAuditFields() {
-		return this.auditModelFields;
-	}	
-	
 	@Override
 	public BasicConnectionFactory createConnectionFactory() throws ResourceException {
 		return new BasicConnectionFactory() {
+			private static final long serialVersionUID = 5028356110047329135L;
+
 			@Override
 			public SalesforceConnectionImpl getConnection() throws ResourceException {
-				return new SalesforceConnectionImpl(getUsername(), getPassword(), getURL(), getSourceConnectionTestInterval(), getSourceConnectionTimeout());
+				return new SalesforceConnectionImpl(getUsername(), getPassword(), getURL());
 			}
 		};
 	}

Modified: branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
===================================================================
--- branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java	2010-12-13 15:31:33 UTC (rev 2768)
+++ branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java	2010-12-13 17:55:26 UTC (rev 2769)
@@ -72,8 +72,8 @@
 	
 	PackageVersionHeader pvHeader = partnerFactory.createPackageVersionHeader();
 	
-	public SalesforceConnectionImpl(String username, String password, URL url, long pingInterval, int timeout) throws ResourceException {
-		login(username, password, url, timeout);
+	public SalesforceConnectionImpl(String username, String password, URL url) throws ResourceException {
+		login(username, password, url);
 	}
 	
 	String getUserName() throws ResourceException {
@@ -88,24 +88,22 @@
 		return sfSoap;
 	}
 	
-	private void login(String username, String password, URL url, int timeout) throws ResourceException {
+	private void login(String username, String password, URL url) throws ResourceException {
 		if (!isValid()) {
 			LoginResult loginResult = null;
 			sfSoap = null;
 			sfService = null;
 			co = new CallOptions();
-			co.setClient("RedHat/MetaMatrix/"); //$NON-NLS-1$
+			co.setClient("RedHat/Teiid/"); //$NON-NLS-1$
+			
+			if(url == null) {
+				throw new ResourceException("SalesForce URL is not specified, please provide a valid URL"); //$NON-NLS-1$
+			}
 
 			try {
-				/*
-				if(null != url) {
-					sfService = new SforceService(url);
-					sfSoap = sfService.getSoap();
-				} else {
-					*/
-					sfService = new SforceService();
-					sfSoap = sfService.getSoap();
-				//}
+				sfService = new SforceService();
+				sfSoap = sfService.getSoap();
+				((BindingProvider)sfSoap).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url.toExternalForm());
 				loginResult = sfSoap.login(username, password);
 			} catch (LoginFault e) {
 				throw new ResourceException(e.getCause().getMessage());
@@ -377,4 +375,9 @@
 	public void close() throws ResourceException {
 		
 	}
+	
+	@Override
+	public boolean isAlive() {
+		return isValid();
+	}	
 }

Modified: branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml	2010-12-13 15:31:33 UTC (rev 2768)
+++ branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml	2010-12-13 17:55:26 UTC (rev 2769)
@@ -56,22 +56,9 @@
                <description>{$display:"Salesforce URL",$description:"URL for connecting to Salesforce",$advanced:"true"}</description>
                <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>
-               <description>{$display:"Source Connection Test Interval",$advanced:"true"}</description>
-               <config-property-name>SourceConnectionTestInterval</config-property-name>
-               <config-property-type>java.lang.Long</config-property-type>
-               <config-property-value>5000</config-property-value>
-            </config-property>   
-            
-            <config-property>
-               <description>{$display:"Source Connection Timeout",$advanced:"true"}</description>
-               <config-property-name>SourceConnectionTimeout</config-property-name>
-               <config-property-type>java.lang.Integer</config-property-type>
-               <config-property-value>120000</config-property-value>
-            </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>



More information about the teiid-commits mailing list