[teiid-commits] teiid SVN: r1671 - in branches/JCA: connectors and 14 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Dec 15 18:28:13 EST 2009


Author: rareddy
Date: 2009-12-15 18:28:12 -0500 (Tue, 15 Dec 2009)
New Revision: 1671

Added:
   branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java
   branches/JCA/connectors/connector-salesforce/src/main/rar/
   branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/
   branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
Removed:
   branches/JCA/connectors/connector-salesforce/src/assembly/
   branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java
   branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java
Modified:
   branches/JCA/build/assembly/jboss-container/connectors.xml
   branches/JCA/connectors/connector-ldap/pom.xml
   branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
   branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml
   branches/JCA/connectors/connector-salesforce/pom.xml
   branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
   branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
   branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
   branches/JCA/connectors/connector-text/pom.xml
   branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml
   branches/JCA/connectors/pom.xml
Log:
TEIID-861: Converted Sales Force connector to JCA connector. The credentail map based authentication needs to re-worked based on security profile

Modified: branches/JCA/build/assembly/jboss-container/connectors.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/connectors.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/build/assembly/jboss-container/connectors.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -19,6 +19,7 @@
             <include>org.jboss.teiid.connectors:connector-loopback</include>
             <include>org.jboss.teiid.connectors:connector-text</include>
             <include>org.jboss.teiid.connectors:connector-ldap</include>
+            <include>org.jboss.teiid.connectors:connector-salesforce</include>
         </includes>
 
         <binaries>        

Modified: branches/JCA/connectors/connector-ldap/pom.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/pom.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-ldap/pom.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -9,6 +9,7 @@
   <groupId>org.jboss.teiid.connectors</groupId>
   <name>LDAP Connector</name>
   <description>LDAP Connector</description>
+  <packaging>rar</packaging>
 
     <dependencies>
         <dependency>

Modified: branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -7,7 +7,7 @@
            version="1.5">
 
    <vendor-name>Red Hat Middleware LLC</vendor-name>
-   <eis-type>Teiid JDBC Connector</eis-type>
+   <eis-type>Teiid LDAP Connector</eis-type>
    <resourceadapter-version>1.0</resourceadapter-version>
    <license>
       <description>
@@ -87,7 +87,7 @@
                <config-property-value>10000</config-property-value>
             </config-property>
 
-            <!--  Loopback Specific properties -->
+            <!--  LDAP Specific properties -->
 
             <config-property>
                <description>Default Search Base DN</description>

Modified: branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -7,7 +7,7 @@
            version="1.5">
 
    <vendor-name>Red Hat Middleware LLC</vendor-name>
-   <eis-type>Teiid JDBC Connector</eis-type>
+   <eis-type>Teiid Loopback Connector</eis-type>
    <resourceadapter-version>1.0</resourceadapter-version>
    <license>
       <description>

Modified: branches/JCA/connectors/connector-salesforce/pom.xml
===================================================================
--- branches/JCA/connectors/connector-salesforce/pom.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/pom.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -11,6 +11,7 @@
 	<artifactId>connector-salesforce</artifactId>
 	<groupId>org.jboss.teiid.connectors</groupId>
 	<name>Salesforce Connector</name>
+    <packaging>rar</packaging>
 	<description>Integrates the query engine with Salesforce.com.</description>
 	<dependencies>
         <dependency>
@@ -49,99 +50,27 @@
 			<artifactId>salesforce-api</artifactId>
 			<version>${project.version}</version>
 		</dependency>
-	</dependencies>
-  
-    <!-- This build portion is identical for all the connectors that are deployed; so when making changes make sure
-    it applies to all the connectors. This below block computes the classpath, writes to classpath.properties; it replaces
-    classpath in the xml file, then bundles current project and its dependencies and xml file in a zip for deployment-->
+        <dependency>
+            <groupId>javax.resource</groupId>
+            <artifactId>connector-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
     <build>
         <plugins>
-            <!-- build class path -->
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
+                <artifactId>maven-jar-plugin</artifactId>
                 <executions>
                     <execution>
-                        <id>build-classpath</id>
-                        <phase>generate-sources</phase>
+                        <id>build_jar</id>
+                        <phase>process-classes</phase>
                         <goals>
-                            <goal>build-classpath</goal>
+                            <goal>jar</goal>
                         </goals>
-                        <configuration>
-                            <fileSeparator>:</fileSeparator>
-                            <pathSeparator>;</pathSeparator>
-                            <prefix>extensionjar</prefix>
-                            <excludeTransitive>false</excludeTransitive>
-                            <includeScope>runtime</includeScope>
-                            <excludeTypes>pom</excludeTypes>
-                            <outputFile>target/classpath.properties</outputFile>
-                            <regenerateFile>true</regenerateFile>
-                            <outputFilterFile>true</outputFilterFile>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>
-      
-            <!-- bundles all its dependencies in a single zip file  -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>copy-dependencies</id>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>copy-dependencies</goal>
-                        </goals>
-                        <configuration>
-                            <excludeTransitive>false</excludeTransitive>
-                            <includeScope>runtime</includeScope>
-                            <excludeTypes>pom</excludeTypes>
-                            <outputDirectory>target/dependency</outputDirectory>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>             
-            <plugin>
-                <artifactId>maven-assembly-plugin</artifactId>
-                <version>2.2-beta-2</version>
-                <configuration>
-                    <descriptors>
-                        <descriptor>src/assembly/bundle.xml</descriptor>
-                    </descriptors>
-                    <outputDirectory>target/distribution</outputDirectory>
-                    <workDirectory>target/assembly/work</workDirectory>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>make-assembly</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>single</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
-        <!-- replaces the classpath tokens in the xml file -->
-        <filters>
-            <filter>target/classpath.properties</filter>
-        </filters>
-        <resources>
-            <resource>
-                <directory>src/main/resources</directory>
-                <filtering>true</filtering>
-                <includes>
-                    <include>**/*.xml</include>
-                </includes>
-            </resource>
-            <resource>
-                <directory>src/main/resources</directory>
-                <filtering>false</filtering>
-                <excludes>
-                    <exclude>**/*.xml</exclude>
-                </excludes>
-            </resource>            
-        </resources>
-    </build> 
+    </build>
 </project>
\ No newline at end of file

Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java	2009-12-15 23:28:12 UTC (rev 1671)
@@ -22,139 +22,81 @@
 
 package com.metamatrix.connector.salesforce;
 
-import java.io.Serializable;
-import java.net.MalformedURLException;
-import java.net.URL;
+import javax.security.auth.Subject;
 
 import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.ConnectionContext;
 import org.teiid.connector.api.ConnectorCapabilities;
 import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.CredentialMap;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.ConnectorAnnotations.ConnectionPooling;
 
 import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
 
- at ConnectionPooling
 public class Connector extends org.teiid.connector.basic.BasicConnector {
 
-	private ConnectorLogger logger;
-
-	private ConnectorEnvironment connectorEnv;
+	private SalesForceManagedConnectionFactory connectorEnv;
 	private ConnectorState state;
 	private boolean singleIdentity;
-	private String username;
-	private String password;
-	private URL url;
-	private SalesforceCapabilities salesforceCapabilites;
 
 	// ///////////////////////////////////////////////////////////
 	// Connector implementation
 	// ///////////////////////////////////////////////////////////
-	public Connection getConnection(ExecutionContext secContext)
-			throws ConnectorException {
-		logger.logTrace("Enter SalesforceSourceConnection.getConnection()");
+	@Override
+	public Connection getConnection() throws ConnectorException {
+		getLogger().logTrace("Enter SalesforceSourceConnection.getConnection()");
 		Connection connection = null;
 		if (singleIdentity) {
-			connection = new SalesforceConnection(username, password, url, connectorEnv);
+			connection = new SalesforceConnection(connectorEnv);
 		} else {
-			Serializable trustedPayload = secContext.getTrustedPayload();
-			if(trustedPayload instanceof CredentialMap) {
-		    	CredentialMap map = (CredentialMap) trustedPayload;
-		    	String username = map.getUser(secContext.getConnectorIdentifier());
-		    	String password = map.getPassword(secContext.getConnectorIdentifier());    		
-		    	connection = new SalesforceConnection(username, password, url, connectorEnv);
+			// if the security domain is enabled, then subject is not null.
+			Subject subject = ConnectionContext.getSubject();
+			if(subject != null) {
+		    	connection = new SalesforceConnection(subject, connectorEnv);
 		    } else { 
 		    	throw new ConnectorException("Unknown trusted payload type"); 
 		    }
 		}
-		logger.logTrace("Return SalesforceSourceConnection.getConnection()");
+		getLogger().logTrace("Return SalesforceSourceConnection.getConnection()");
 		return connection;
 	}
 
 	@Override
-	public void start(ConnectorEnvironment env) throws ConnectorException {
-		this.logger = env.getLogger();
-		this.connectorEnv = env;
-		getLogger().logInfo(getLogPreamble().append("Started").toString()); //$NON-NLS-1$
-		this.state = new ConnectorState(env.getProperties(), getLogger());
-		getLogger().logInfo(getLogPreamble().append("Initialized").toString()); //$NON-NLS-1$
-		getLogger().logTrace(getLogPreamble()
-				.append("Initialization Properties: " + env.getProperties()).toString()); //$NON-NLS-1$
-		String urlString =  env.getProperties().getProperty("URL");
-		if(null != urlString && 0 != urlString.length()) {
-			try {
-				url = new URL(urlString);
-			} catch (MalformedURLException e) {
-				throw new ConnectorException(e, e.getMessage());
-			}
-		}
+	public void initialize(ConnectorEnvironment env) throws ConnectorException {
+		super.initialize(env);
 		
-		String username = env.getProperties().getProperty("username");
-		String password =  env.getProperties().getProperty("password");
+		this.connectorEnv = (SalesForceManagedConnectionFactory)env;
 		
+		getLogger().logInfo("Started"); //$NON-NLS-1$
+		this.state = new ConnectorState(this.connectorEnv);
+		
+		getLogger().logInfo("Initialized"); //$NON-NLS-1$
+		getLogger().logTrace("Initialization Properties: " + this.connectorEnv.toString()); //$NON-NLS-1$
+		
 		//validate that both are empty or both have values
-		if(null == username && null == password) {
-			
-		} else if ((null == username || username.equals("")) && (null != password && !password.equals("")) ||
-				((null == password || password.equals("")) && (null != username && !username.equals("")))) {
-					String msg = Messages.getString("SalesforceSourceConnectionFactory.Invalid.username.password.pair");
-					env.getLogger().logError(msg);
-					throw new ConnectorException(msg);
-		} else if(null != username && !username.equals("")) {
+		if(this.connectorEnv.getUsername() != null) {
 			singleIdentity = true;
-			this.password = password;
-			this.username = username;
-		} else {
-			this.setAdminConnectionsAllowed(false);
-			this.setUseCredentialMap(true);
 		}
-		
-		String capabilitiesClass = env.getProperties().getProperty("ConnectorCapabilities", SalesforceCapabilities.class.getName());
-    	try {
-    		Class clazz = Thread.currentThread().getContextClassLoader().loadClass(capabilitiesClass);
-    		salesforceCapabilites = (SalesforceCapabilities) clazz.newInstance();
-		} catch (Exception e) {
-			throw new ConnectorException(e, "Unable to load Capabilities Class");
-		}
-		logger.logTrace("Return SalesforceSourceConnection.initialize()");
-	}
 
-	public void stop() {
-		try {
-			getLogger().logInfo(getLogPreamble().append("Stopped").toString());
-		} catch (ConnectorException e) {
-			// nothing to do here
-		}
+		getLogger().logTrace("Return SalesforceSourceConnection.initialize()");
 	}
 
+
 	/////////////////////////////////////////////////////////////
 	//Utilities
 	/////////////////////////////////////////////////////////////
 
-	public ConnectorLogger getLogger() throws ConnectorException {
-		if(null == logger) {
-			throw new ConnectorException("Error:  Connector initialize not called");
-		}
-		return logger;
+	private ConnectorLogger getLogger(){
+		return this.config.getLogger();
 	}
 
-	public StringBuffer getLogPreamble() {
-		StringBuffer preamble = new StringBuffer();
-		preamble.append("Salesforce Connector id = ");
-		preamble.append(connectorEnv.getConnectorName());
-		preamble.append(":");
-		return preamble;
-	}
 
 	public ConnectorState getState() {
 		return state;
 	}
 	
 	@Override
-	public ConnectorCapabilities getCapabilities() {
-		return salesforceCapabilites;
-	}
+    public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+    	return SalesforceCapabilities.class;
+    }	
 }

Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java	2009-12-15 23:28:12 UTC (rev 1671)
@@ -21,50 +21,26 @@
  */
 package com.metamatrix.connector.salesforce;
 
-import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Properties;
 
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
 
-
 public class ConnectorState {
 	
-	public static final String USERNAME = "username";
-	public static final String PASSWORD = "password";
-	public static final String URL = "URL";
+	private String username;
+	private String password;
+	private URL url;
 	
-	String username;
-	String password;
-	URL url;
-	
-	
-	public ConnectorState(Properties props, ConnectorLogger logger) throws ConnectorException {
-		if (logger == null) {
-            throw new ConnectorException("Internal Exception: logger is null");
-        }
-		
-		String username = props.getProperty(USERNAME);
+	public ConnectorState(SalesForceManagedConnectionFactory config) {
+		String username = config.getUsername();
         if (username != null) {
             setUsername(username);
         }
 		
-		String password = props.getProperty(PASSWORD);
+		String password = config.getPassword();
         if (password != null) {
             setPassword(password);
         }
-        
-        String url = props.getProperty(URL);
-		if(null != url && url.length()!= 0) {
-			URL salesforceURL;
-			try {
-				salesforceURL = new URL(url);
-			} catch (MalformedURLException e) {
-				throw new ConnectorException(e, e.getMessage());
-			}
-			setUrl(salesforceURL);
-		}
+		setUrl(config.getURL());
 	}
 
 	private void setUrl(URL salesforceURL) {

Added: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java	                        (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java	2009-12-15 23:28:12 UTC (rev 1671)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.salesforce;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class SalesForceManagedConnectionFactory extends BasicManagedConnectionFactory {
+	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;
+	
+	public String getUsername() {
+		return username;
+	}
+	public void setUsername(String username) {
+		if (username.trim().length() == 0) {
+			throw new MetaMatrixRuntimeException("Name can not be null");
+		}
+		this.username = username;
+	}
+	public String getConnectorStateClass() {
+		return this.connectorStateClass;
+	}
+	public void setConnectorStateClass(String connectorStateClass) {
+		this.connectorStateClass = connectorStateClass;
+	}
+	public String getPassword() {
+		return this.password;
+	}
+	public void setPassword(String password) {
+		this.password = password;
+	}
+	public URL getURL() {
+		return this.URL;
+	}
+	
+	public void setURL(String uRL) {
+		try {
+			this.URL = new URL(uRL);
+		} catch (MalformedURLException e) {
+			throw new MetaMatrixRuntimeException("URL Supplied is not valid URL"+ e.getMessage());
+		}
+	}
+	
+	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 String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append("username=").append(this.username);
+		sb.append(" ConnectorStateClass=").append(this.connectorStateClass);
+		sb.append(" URL=").append(this.URL);
+		return sb.toString();
+	}	
+}

Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java	2009-12-15 23:28:12 UTC (rev 1671)
@@ -21,11 +21,11 @@
  */
 package com.metamatrix.connector.salesforce.connection;
 
-import java.net.URL;
 import java.util.Calendar;
 import java.util.List;
 
-import org.teiid.connector.api.ConnectorEnvironment;
+import javax.security.auth.Subject;
+
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.connector.api.ProcedureExecution;
@@ -38,6 +38,7 @@
 import org.teiid.connector.metadata.runtime.RuntimeMetadata;
 
 import com.metamatrix.connector.salesforce.Messages;
+import com.metamatrix.connector.salesforce.SalesForceManagedConnectionFactory;
 import com.metamatrix.connector.salesforce.connection.impl.ConnectionImpl;
 import com.metamatrix.connector.salesforce.execution.DataPayload;
 import com.metamatrix.connector.salesforce.execution.DeletedResult;
@@ -45,46 +46,35 @@
 import com.metamatrix.connector.salesforce.execution.QueryExecutionImpl;
 import com.metamatrix.connector.salesforce.execution.UpdateExecutionParent;
 import com.metamatrix.connector.salesforce.execution.UpdatedResult;
+import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.sforce.soap.partner.QueryResult;
 
 public class SalesforceConnection extends BasicConnection {
 
-	private ConnectorEnvironment connectorEnv;
+	private SalesForceManagedConnectionFactory connectorEnv;
 	private ConnectionImpl connection;
 	
-	public SalesforceConnection(String username, String password, URL url, ConnectorEnvironment env) throws ConnectorException {
+	public SalesforceConnection(Subject subject,  SalesForceManagedConnectionFactory env) {
+		throw new MetaMatrixRuntimeException("not supported yet..");
+	}
+	
+	public SalesforceConnection(SalesForceManagedConnectionFactory env) throws ConnectorException {
 		try {
 			connectorEnv = env;
 			
-			long pingInterval = 5000;
-			try {
-				String pingIntervalString = env.getProperties().getProperty("SourceConnectionTestInterval");
-				if(null != pingIntervalString) {
-					pingInterval = Long.decode(pingIntervalString);
-				}
-			}	catch (NumberFormatException e) {
-				throw new ConnectorException(Messages.getString("SalesforceConnection.bad.ping.value"));
-			}
+			long pingInterval = env.getSourceConnectionTestInterval();
+	
 			//600000 - 10 minutes
-			int timeout = 120000; // two minutes
-			try {
-				String timeoutString = env.getProperties().getProperty("SourceConnectionTimeout");
-				if(null != timeoutString) {
-					timeout = Integer.decode(timeoutString).intValue();
-				}
-			}	catch (NumberFormatException e) {
-				throw new ConnectorException(Messages.getString("SalesforceConnection.bad.timeout.value"));
-			}
+			int timeout = env.getSourceConnectionTimeout();
 			
-			connection = new ConnectionImpl(username, password, url, pingInterval, env.getLogger(), timeout);
+			connection = new ConnectionImpl(env.getUsername(), env.getPassword(), env.getURL(), pingInterval, env.getLogger(), timeout);
 		} catch(Throwable t) {
 			env.getLogger().logError("SalesforceConnection() ErrorMessage: " + t.getMessage());
 			if(t instanceof ConnectorException) {
 				// don't wrap it again
 				throw (ConnectorException) t;
-			} else {
-				throw new ConnectorException(t);
-			}
+			} 
+			throw new ConnectorException(t);
 		}
 	}
 	
@@ -132,11 +122,6 @@
 		return connection.isAlive();
 	}
 	
-	@Override
-	public void closeCalled() {
-		
-	}
-
 	public int delete(String[] ids) throws ConnectorException {
 		return connection.delete(ids);
 	}

Added: branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml	                        (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+           http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+           version="1.5">
+
+   <vendor-name>Red Hat Middleware LLC</vendor-name>
+   <eis-type>Teiid Sales Force Connector</eis-type>
+   <resourceadapter-version>1.0</resourceadapter-version>
+   <license>
+      <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+      </description>
+      <license-required>true</license-required>
+   </license>
+   <resourceadapter>
+      <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+      <outbound-resourceadapter>
+         <connection-definition>
+            <managedconnectionfactory-class>com.metamatrix.connector.salesforce.SalesForceManagedConnectionFactory</managedconnectionfactory-class>
+
+            <config-property>
+               <description>Connector Class</description>
+               <config-property-name>ConnectorClass</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+               <config-property-value>com.metamatrix.connector.salesforce.Connector</config-property-value>
+            </config-property>
+
+            <config-property>
+               <description>Connector Capabilities</description>
+               <description>The class to use to provide the Connector Capabilities</description>
+               <config-property-name>CapabilitiesClass</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+               <config-property-value>com.metamatrix.connector.salesforce.SalesforceCapabilities</config-property-value>
+            </config-property>
+            
+            <config-property>
+               <description>Is Immutable</description>
+               <description>Is Immutable, True if the source never changes.</description>
+               <config-property-name>Immutable</config-property-name>
+               <config-property-type>java.lang.Boolean</config-property-type>
+               <config-property-value>false</config-property-value>
+            </config-property>
+            
+            <config-property>
+               <description>Is XA Capable</description>
+               <description>True, if this connector supports XA Transactions</description>
+               <config-property-name>XaCapable</config-property-name>
+               <config-property-type>java.lang.Boolean</config-property-type>
+               <config-property-value>false</config-property-value>
+            </config-property>            
+
+            <config-property>             
+               <description>Exception on Exceeding Max Rows</description>
+               <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+               <config-property-name>ExceptionOnMaxRows</config-property-name>
+               <config-property-type>java.lang.Boolean</config-property-type>
+               <config-property-value>true</config-property-value>
+            </config-property>
+
+            <config-property>
+               <description>Maximum Result Rows</description>
+               <description>Maximum Result Rows allowed</description>
+               <config-property-name>MaxResultRows</config-property-name>
+               <config-property-type>java.lang.Integer</config-property-type>
+               <config-property-value>10000</config-property-value>
+            </config-property>
+
+            <!--  Salesforce Specific properties -->
+
+            <config-property>
+               <description>User Name</description>
+               <description>Name value for Salesforce authentication</description>
+               <config-property-name>username</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+            </config-property>
+         
+             <config-property>
+               <description>Password</description>
+               <description>Password value for Salesforce authentication</description>
+               <config-property-name>password</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+            </config-property>
+            
+            <config-property>
+               <description>Connector State Class</description>
+               <config-property-name>ConnectorStateClass</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+               <config-property-value>com.metamatrix.connector.salesforce.ConnectorState</config-property-value>
+            </config-property>
+            
+            <config-property>
+               <description>Salesforce URL</description>
+               <description>URL for connecting to Salesforce</description>
+               <config-property-name>URL</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+               <config-property-value>com.metamatrix.connector.salesforce.ConnectorState</config-property-value>
+            </config-property>     
+            
+            <config-property>
+               <description>Source Connection Test Interval</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>Source Connection Timeout</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>org.teiid.connector.api.Connector</connectionfactory-interface>
+            <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+            <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+            <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+         </connection-definition>
+         
+         <transaction-support>NoTransaction</transaction-support>
+        
+        <authentication-mechanism>
+            <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+            <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+        </authentication-mechanism>
+        <reauthentication-support>false</reauthentication-support>
+      </outbound-resourceadapter>
+   </resourceadapter>
+</connector>

Deleted: branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java	2009-12-15 23:28:12 UTC (rev 1671)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.salesforce;
-
-import junit.framework.TestCase;
-
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.connector.salesforce.test.util.ObjectFactory;
-
-public class TestConnector extends TestCase {
-
-	Connector connector_not_initialized;
-	Connector connector;
-	Connector noCredConnector;
-    
-    public TestConnector() {
-        super("TestConnector");
-    }
-	
-	protected void setUp() throws Exception {
-		super.setUp();
-		connector_not_initialized = new Connector();
-		
-		ConnectorEnvironment env = ObjectFactory.getDefaultTestConnectorEnvironment();
-		connector = new Connector();
-		connector.start(env);
-		
-		ConnectorEnvironment env2 = ObjectFactory.getNoCredTestConnectorEnvironment();
-		noCredConnector = new Connector();
-		noCredConnector.start(env2);
-	}
-
-	/*
-	public void testGetConnectionTrustedToken() {
-		ExecutionContext secContext = TestObjectFactory.getTokenExecutionContext();
-		try {
-			SalesforceConnection connection = (SalesforceConnection) noCredConnector.getConnection(secContext);
-			assertNotNull("the connection is null", connection);
-		} catch (ConnectorException e) {
-			fail(e.getMessage());
-		}
-	}
-	*/
-	public void testGetConnectionBadUser() {
-		ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentBadUser();
-		ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
-		Connector localConnector = new Connector();
-		try {
-			localConnector.start(env);
-			localConnector.getConnection(secContext);
-			fail("should have produced an exception");
-		} catch (ConnectorException e) {
-			assertFalse("There is no error message", e.getMessage().length() == 0);
-		}
-	}
-	
-	public void testGetConnectionEmptyUser() {
-		ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentEmptyUser();
-		ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
-		Connector localConnector = new Connector();
-		try {
-			localConnector.start(env);
-			localConnector.getConnection(secContext);
-			fail("should have produced an exception");
-		} catch (ConnectorException e) {
-			assertTrue("Wrong error message", e.getMessage().contains("Invalid"));
-		}
-	}
-
-	public void testGetConnectionBadPass() {
-		ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentBadPass();
-		ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
-		Connector localConnector = new Connector();
-		try {
-			localConnector.start(env);
-			localConnector.getConnection(secContext);
-			fail("should have produced an exception");
-		} catch (ConnectorException e) {
-			assertFalse("There is no error message", e.getMessage().length() == 0);
-		}
-	}
-	
-	public void testGetConnectionEmptyPass() {
-		ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentEmptyPass();
-		ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
-		Connector localConnector = new Connector();
-		try {
-			localConnector.start(env);
-			localConnector.getConnection(secContext);
-			fail("should have produced an exception");
-		} catch (ConnectorException e) {
-			assertTrue("Wrong error message", e.getMessage().contains("Invalid credential configuration"));
-		}
-	}
-	
-	public void testInitialize() throws Exception {
-		Connector localConnector = new Connector();
-		localConnector.start(ObjectFactory.getDefaultTestConnectorEnvironment());
-		assertEquals(ObjectFactory.VALID_PASSWORD, connector.getState().getPassword());
-		assertEquals(ObjectFactory.VALID_USERNAME, connector.getState().getUsername());
-	}
-
-
-	public void testGetLogger() throws Exception {
-		assertNotNull(connector.getLogger());
-	}
-
-	public void testGetState() {
-		assertNotNull(connector.getState());
-	}
-
-	public void testStopNoInit() {
-		connector_not_initialized.stop();
-	}
-
-}

Deleted: branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java	2009-12-15 23:28:12 UTC (rev 1671)
@@ -1,120 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.salesforce.test.util;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.CredentialMap;
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.salesforce.ConnectorState;
-
-public class ObjectFactory {
-
-	public static boolean DEBUG = false;
-	
-    public static final String VALID_USERNAME= "jdoyleoss at gmail.com";
-    public static final String VALID_PASSWORD = "l3tm31nNZ4loJCls59GlDr4sZLB8N4TT";
-
-    public static final String BOGUS_USERNAME= "bogus at gmail.com";
-    public static final String BOGUS_PASSWORD = "k33pm30ut";
-
-	public static ConnectorEnvironment getDefaultTestConnectorEnvironment() {
-        Properties props = getDefaultProps(); 
-        ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
-        return env;
-     }
-	
-	public static ConnectorEnvironment getNoCredTestConnectorEnvironment() {
-		Properties props = new Properties();
-		props.put("sandbox", "false"); 
-        ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
-        return env;
-     }
-
-	public static ConnectorEnvironment getConnectorEnvironmentBadUser() {
-        Properties props = getDefaultProps();
-        props.put(ConnectorState.USERNAME, BOGUS_USERNAME);
-        ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
-        return env;
-     }
-	
-	public static ConnectorEnvironment getConnectorEnvironmentBadPass() {
-        Properties props = getDefaultProps();
-        props.put(ConnectorState.PASSWORD, BOGUS_PASSWORD);
-        ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
-        return env;
-     }
-	
-	public static ConnectorEnvironment getConnectorEnvironmentEmptyPass() {
-        Properties props = getDefaultProps();
-        props.put(ConnectorState.PASSWORD, "");
-        ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
-        return env;
-     }
-	
-	public static Properties getDefaultProps() {
-		Properties props = new Properties();
-		
-		props.put(ConnectorState.USERNAME, VALID_USERNAME);
-		props.put(ConnectorState.PASSWORD, VALID_PASSWORD);
-		props.put("sandbox", "false");
-		props.put("ConnectorCapabilities", "com.metamatrix.connector.salesforce.SalesforceCapabilities");
-		props.put("InLimit","-1");
-		return props;
-	}
-	
-	public static Properties getNoCredProps() {
-		Properties props = new Properties();
-		props.put("ConnectorCapabilities", "com.metamatrix.connector.salesforce.SalesforceCapabilities");
-		props.put("sandbox", "false");
-		return props;
-	}
-
-	public static ExecutionContext getDefaultSecurityContext() {
-		return EnvironmentUtility.createSecurityContext("MetaMatrixAdmin");
-	}
-	
-	public static ExecutionContext getTokenSecurityContext() {
-		CredentialMap cMap = getCredentialMap();
-		return EnvironmentUtility.createSecurityContext("Foo","1", "MetaMatrixAdmin", cMap);
-	}
-	
-	public static CredentialMap getCredentialMap() {
-		Map values = new HashMap();
-		values.put(CredentialMap.USER_KEYWORD, VALID_USERNAME);
-		values.put(CredentialMap.PASSWORD_KEYWORD, VALID_PASSWORD);
-		CredentialMap cMap = new CredentialMap();
-		cMap.addSystemCredentials("Connector<CDK>",values);
-		return cMap;
-	}
-	public static ConnectorEnvironment getConnectorEnvironmentEmptyUser() {
-		Properties props = getDefaultProps();
-        props.put(ConnectorState.USERNAME, "");
-        ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
-        return env;
-	}
-}

Modified: branches/JCA/connectors/connector-text/pom.xml
===================================================================
--- branches/JCA/connectors/connector-text/pom.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-text/pom.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -9,7 +9,9 @@
   <artifactId>connector-text</artifactId>
   <groupId>org.jboss.teiid.connectors</groupId>
   <name>Text Connector</name>
+  <packaging>rar</packaging>
   <description>This connector reads data from text files.</description>
+  
     <dependencies>
         <dependency>
           <groupId>org.jboss.teiid</groupId>

Modified: branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -7,7 +7,7 @@
            version="1.5">
 
    <vendor-name>Red Hat Middleware LLC</vendor-name>
-   <eis-type>Teiid JDBC Connector</eis-type>
+   <eis-type>Teiid Text Connector</eis-type>
    <resourceadapter-version>1.0</resourceadapter-version>
    <license>
       <description>

Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml	2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/pom.xml	2009-12-15 23:28:12 UTC (rev 1671)
@@ -85,14 +85,14 @@
     <module>connector-loopback</module>
     <module>connector-text</module>
     <module>connector-ldap</module>
-  
+    <module>connector-salesforce</module>
+    <module>salesforce-api</module>
+    <module>connector-xml-common</module>
+   
     <!--
     <module>connector-xml</module>
     <module>sandbox</module>
-    <module>connector-salesforce</module>
-    <module>salesforce-api</module>
     
-    <module>connector-xml-common</module>
      -->
   </modules>
 </project>
\ No newline at end of file



More information about the teiid-commits mailing list