Author: rareddy
Date: 2009-12-16 12:40:05 -0500 (Wed, 16 Dec 2009)
New Revision: 1673
Added:
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java
branches/JCA/connectors/sandbox/connector-exec/src/main/rar/
branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/
branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java
branches/JCA/connectors/sandbox/connector-object/src/main/rar/
branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/
branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/
branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/
branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml
Removed:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java
Modified:
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
branches/JCA/connectors/pom.xml
branches/JCA/connectors/sandbox/connector-exec/pom.xml
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java
branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
branches/JCA/connectors/sandbox/connector-object/pom.xml
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java
branches/JCA/connectors/sandbox/connector-yahoo/pom.xml
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
Log:
TEIID-861: Adding sandbox connectors as JCA connectors
Modified:
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
===================================================================
---
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -5,8 +5,6 @@
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import com.metamatrix.core.util.ReflectionHelper;
-
public abstract class BasicConnector implements Connector {
protected ConnectorEnvironment config;
@@ -30,19 +28,9 @@
public ConnectorCapabilities getCapabilities() throws ConnectorException {
if (capabilities == null) {
// create Capabilities
- String className = this.config.getCapabilitiesClass();
- try {
- if (className != null && className.length() > 0) {
- capabilities = (ConnectorCapabilities) ReflectionHelper.create(className, null,
Thread.currentThread().getContextClassLoader());
- } else {
- capabilities = getDefaultCapabilities().newInstance();
- }
-
- return capabilities;
- } catch (Exception e) {
- throw new ConnectorException(e);
- }
+ capabilities =
BasicManagedConnectionFactory.getInstance(ConnectorCapabilities.class,
this.config.getCapabilitiesClass(), getDefaultCapabilities());
}
return capabilities;
}
+
}
Modified:
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
===================================================================
---
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -244,4 +244,22 @@
public void setOverrideCapabilitiesFile(String propsFile) {
this.overrideCapabilitiesFile = propsFile;
}
+
+ public static <T> T getInstance(Class<T> clazz, String className, Class
defaultClass) throws ConnectorException {
+ try {
+ if (className == null) {
+ if (defaultClass == null) {
+ throw new ConnectorException("Neither class name or default class specified
to create an instance");
+ }
+ return clazz.cast(defaultClass.newInstance());
+ }
+ return clazz.cast(ReflectionHelper.create(className, null,
Thread.currentThread().getContextClassLoader()));
+ } catch (MetaMatrixCoreException e) {
+ throw new ConnectorException(e);
+ } catch (IllegalAccessException e) {
+ throw new ConnectorException(e);
+ } catch(InstantiationException e) {
+ throw new ConnectorException(e);
+ }
+ }
}
Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/pom.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -88,11 +88,12 @@
<module>connector-salesforce</module>
<module>salesforce-api</module>
<module>connector-xml-common</module>
+ <module>sandbox</module>
<!--
<module>connector-xml</module>
- <module>sandbox</module>
+
-->
</modules>
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/sandbox/connector-exec/pom.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/pom.xml 2009-12-16 00:07:07 UTC (rev
1672)
+++ branches/JCA/connectors/sandbox/connector-exec/pom.xml 2009-12-16 17:40:05 UTC (rev
1673)
@@ -10,6 +10,8 @@
<groupId>org.jboss.teiid.connectors.sandbox</groupId>
<name>Exec Connector</name>
<description>This connector executes Admin API calls and System.exec calls
through the connector using SQL representation</description>
+ <packaging>rar</packaging>
+
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -29,7 +31,30 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-internal</artifactId>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
\ No newline at end of file
Modified:
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -33,8 +33,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location;
@@ -43,9 +41,7 @@
import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
import org.apache.tools.ant.taskdefs.PumpStreamHandler;
import org.apache.tools.ant.types.Commandline.Argument;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicExecution;
@@ -61,18 +57,10 @@
*/
public class ExecAntExecution extends BasicExecution implements ResultSetExecution {
- private static final Random random = new Random(System.currentTimeMillis());
-
private static String INSTALL_DIR = ".";//$NON-NLS-1$
- private static final String WIN_EXEC = "win.executable"; //$NON-NLS-1$
- private static final String UNIX_EXEC = "unix.executable"; //$NON-NLS-1$
-
- private static final String DEFAUTL_WIN_EXEC = "cmd.exe"; //$NON-NLS-1$
- private static final String DEFAUTL_UNIX_EXEC = "/bin/sh"; //$NON-NLS-1$
-
// Connector resources
- private ConnectorEnvironment env;
+ private ExecManagedConnectionFactory config;
private List responses = new ArrayList();
private String execcommand;
private boolean isWin = false;
@@ -86,34 +74,28 @@
private List exclusionList;
private IQuery query;
- public ExecAntExecution(IQuery query, ConnectorEnvironment env, RuntimeMetadata
metadata, ConnectorLogger logger, List exclusionThese) {
- this.env = env;
+ public ExecAntExecution(IQuery query, ExecManagedConnectionFactory env, RuntimeMetadata
metadata, List exclusionThese) {
+ this.config = env;
this.query = query;
if (exclusionThese != null)
exclusionList = exclusionThese;
else
exclusionList = Collections.EMPTY_LIST;
- Properties props = env.getProperties();
if (OSPlatformUtil.isWindows()) {
- execcommand = props.getProperty(WIN_EXEC, DEFAUTL_WIN_EXEC);
- Assertion.isNotNull(execcommand, WIN_EXEC+ " property was not defined for os
type"); //$NON-NLS-1$
+ execcommand = this.config.getWinExec();
+ Assertion.isNotNull(execcommand, "windows Exce property was not defined for os
type"); //$NON-NLS-1$
isWin = true;
} else {
- execcommand = props.getProperty(UNIX_EXEC, DEFAUTL_UNIX_EXEC);
- Assertion.isNotNull(execcommand, UNIX_EXEC + " property was not defined for os
type"); //$NON-NLS-1$
+ execcommand = this.config.getUnixExec();
+ Assertion.isNotNull(execcommand, " Unix exec property was not defined for os
type"); //$NON-NLS-1$
}
}
- /*
- * @see
com.metamatrix.data.SynchQueryExecution#execute(com.metamatrix.data.language.IQuery,
- * int)
- */
- public void execute()
- throws ConnectorException {
+ public void execute() throws ConnectorException {
- env.getLogger().logTrace("Exec executing command: " + query); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Exec executing command: " + query);
//$NON-NLS-1$
org.teiid.connector.language.ICriteria crit = query.getWhere();
if (crit == null)
throw new ConnectorException(ExecPlugin.Util
@@ -135,7 +117,7 @@
try {
execute(command);
} catch (Exception e) {
- env.getLogger().logError("Execution Error", e); //$NON-NLS-1$
+ this.config.getLogger().logError("Execution Error", e); //$NON-NLS-1$
throw new ConnectorException(e);
}
}
@@ -157,8 +139,7 @@
ExecuteMMTask task = createClass();
- env.getLogger().logTrace(
- "Exec: " + execcommand + " command: " + command); //$NON-NLS-1$
//$NON-NLS-2$
+ this.config.getLogger().logTrace("Exec: " + execcommand + " command:
" + command); //$NON-NLS-1$ //$NON-NLS-2$
Project p = new Project();
p.init();
@@ -317,13 +298,13 @@
new InputStreamReader(baise));
while ((oneline = ereader.readLine()) != null) {
if (first) {
- env.getLogger().logError("Error Message:"); //$NON-NLS-1$
+ config.getLogger().logError("Error Message:"); //$NON-NLS-1$
first = false;
}
List row = new ArrayList(1);
row.add(oneline);
responseRows.add(row);
- env.getLogger().logError(oneline);
+ config.getLogger().logError(oneline);
}
ereader.close();
} finally {
Modified:
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -23,9 +23,7 @@
package com.metamatrix.connector.exec;
import java.util.List;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicConnection;
@@ -36,19 +34,15 @@
public class ExecConnection extends BasicConnection {
- ConnectorEnvironment env;
-
- // Connector logger
- ConnectorLogger logger;
+ ExecManagedConnectionFactory config;
private List exclusionList;
/**
* Constructor.
* @param env
*/
- ExecConnection(ConnectorEnvironment env, List exclusionThese) throws
ConnectorException {
- this.env = env;
- this.logger = env.getLogger();
+ public ExecConnection(ExecManagedConnectionFactory env, List exclusionThese) {
+ this.config = env;
this.exclusionList = exclusionThese;
}
@@ -56,12 +50,12 @@
public ResultSetExecution createResultSetExecution(IQueryCommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new ExecAntExecution((IQuery)command, env, metadata, logger,
exclusionList);
+ return new ExecAntExecution((IQuery)command, this.config, metadata,
exclusionList);
}
@Override
public void close() {
- logger.logDetail("Exec Connection is successfully closed.");
//$NON-NLS-1$
+ this.config.getLogger().logDetail("Exec Connection is successfully
closed."); //$NON-NLS-1$
}
}
Modified:
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -32,61 +32,36 @@
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.ExecutionContext;
import org.teiid.connector.basic.BasicConnector;
/**
- * Implementation of text connector.
+ * Implementation of Exec connector.
*/
public class ExecConnector extends BasicConnector {
- private ConnectorLogger logger;
- private ConnectorEnvironment env;
- private boolean start = false;
+ private ExecManagedConnectionFactory config;
private List exclusionList= Collections.EMPTY_LIST;
- private String exclusionFile;
- /**
- * Initialization with environment.
- */
@Override
- public void start( ConnectorEnvironment environment ) throws ConnectorException {
- logger = environment.getLogger();
- this.env = environment;
+ public void initialize(ConnectorEnvironment config ) throws ConnectorException {
+ super.initialize(config);
+ this.config = (ExecManagedConnectionFactory)config;
- exclusionFile =
environment.getProperties().getProperty("exclusionFile"); //$NON-NLS-1$
- if(exclusionFile != null && exclusionFile.trim().length() > 0)
- {
- loadExclusionFile(exclusionFile);
+ if(this.config.getExclusionFile() != null) {
+ loadExclusionFile(this.config.getExclusionFile());
}
-
- // logging
- logger = environment.getLogger();
- start = true;
- logger.logInfo("Exec Connector is started."); //$NON-NLS-1$
}
- public void stop() {
- if(!start){
- return;
- }
-
- start = false;
- logger.logInfo("Exec Connector is stoped."); //$NON-NLS-1$
- }
@Override
- public ConnectorCapabilities getCapabilities() {
- return new ExecCapabilities();
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return ExecCapabilities.class;
+ }
+
+ @Override
+ public Connection getConnection() throws ConnectorException {
+ return new ExecConnection(this.config, exclusionList);
}
-
- /*
- * @see
com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
- public Connection getConnection(ExecutionContext context) throws ConnectorException
{
- return new ExecConnection(this.env, exclusionList);
- }
protected void loadExclusionFile(String file) throws ConnectorException {
try {
@@ -96,7 +71,7 @@
String key;
for (Iterator it = props.keySet().iterator(); it.hasNext();
exclusionList.add(((String) props.get(key)).trim().toLowerCase())) {
key = (String) it.next();
- logger.logInfo("Exec Connector - exclude: " +
props.get(key));//$NON-NLS-1$
+ this.config.getLogger().logInfo("Exec Connector - exclude: " +
props.get(key));//$NON-NLS-1$
}
} catch (IOException err) {
Added:
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java
(rev 0)
+++
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -0,0 +1,57 @@
+/*
+ * 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.exec;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class ExecManagedConnectionFactory extends BasicManagedConnectionFactory {
+ private static final long serialVersionUID = -6043344027191788677L;
+
+ private String exclusionFile;
+ private String winExec;
+ private String unixExec;
+
+ public String getExclusionFile() {
+ return exclusionFile;
+ }
+
+ public void setExclusionFile(String exclusionFile) {
+ this.exclusionFile = exclusionFile;
+ }
+
+ public String getWinExec() {
+ return winExec;
+ }
+
+ public void setWinExec(String winExec) {
+ this.winExec = winExec;
+ }
+
+ public String getUnixExec() {
+ return unixExec;
+ }
+
+ public void setUnixExec(String unixExec) {
+ this.unixExec = unixExec;
+ }
+
+}
Added: branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml
(rev 0)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml 2009-12-16
17:40:05 UTC (rev 1673)
@@ -0,0 +1,128 @@
+<?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 Exec 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.exec.ExecManagedConnectionFactory</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.exec.ExecConnector</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.exec.ExecCapabilities</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>true</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>
+
+ <!-- Exec Specific properties -->
+
+ <config-property>
+ <description>Exclusion File</description>
+ <config-property-name>exclusionFile</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Windows Exec</description>
+ <config-property-name>WinExec</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>cmd.exe</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Unix Exec</description>
+ <config-property-name>UnixExec</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>/bin/sh</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>
Modified:
branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -28,18 +28,17 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.ResultSetExecution;
-import junit.framework.TestCase;
-
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.core.util.UnitTestUtil;
-/**
- */
public class TestsExec extends TestCase {
private List expectedResults;
@@ -56,14 +55,13 @@
public void tearDown(){
if(this.connector != null){
- this.connector.stop();
this.connector = null;
}
expectedResults = null;
}
- private void executeCommand(Properties props) throws ConnectorException{
- ConnectorHost host = new ConnectorHost(new FakeExecConnector(), props, vdbFile,
false);
+ private void executeCommand(ExecManagedConnectionFactory config) throws
ConnectorException{
+ ConnectorHost host = new ConnectorHost(new FakeExecConnector(), config,
vdbFile);
List results = host.executeCommand(command); //$NON-NLS-1$
if (results != null && !results.isEmpty()) {
for (Iterator it=results.iterator(); it.hasNext();) {
@@ -78,17 +76,12 @@
executeCommand(getConnectorProperties());
}
- private Properties getConnectorProperties()
- {
- Properties props = new Properties();
- props.setProperty("win.executable", "cmd.exe");//$NON-NLS-1$
//$NON-NLS-2$
-
- props.setProperty("CapabilitiesClass",
"com.metamatrix.connector.exec.ExecCapabilities"); //$NON-NLS-1$ //$NON-NLS-2$
- props.setProperty("ConnectorClass",
"com.metamatrix.connector.exec.ExecConnnector"); //$NON-NLS-1$ //$NON-NLS-2$
- props.setProperty("ServiceClassName",
"com.metamatrix.server.connector.service.ConnectorService"); //$NON-NLS-1$
//$NON-NLS-2$
-
-
- return props;
+ private ExecManagedConnectionFactory getConnectorProperties(){
+ ExecManagedConnectionFactory config =
Mockito.mock(ExecManagedConnectionFactory.class);
+ Mockito.stub(config.getWinExec()).toReturn("cmd.exe");
+ Mockito.stub(config.getUnixExec()).toReturn("/bin/sh");
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+ return config;
}
//actual tests
@@ -107,13 +100,13 @@
List row1 = new ArrayList();
row1.add("filename"); //$NON-NLS-1$
expectedResults.add(row1);
- Properties prop = getConnectorProperties();
+
String f = UnitTestUtil.getTestDataPath() + File.separator+
"exclusionFile.properties"; //$NON-NLS-1$
- prop.setProperty("exclusionFile", f);//$NON-NLS-1$
- prop.setProperty("ConnectorClass",
"com.metamatrix.connector.exec.TestExecConnnector"); //$NON-NLS-1$
//$NON-NLS-2$
-
+ ExecManagedConnectionFactory config = getConnectorProperties();
+ Mockito.stub(config.getExclusionFile()).toReturn(f);
+
try {
- executeCommand(prop);
+ executeCommand(config);
fail("rm was in the exclusion file, should not have run");
//$NON-NLS-1$
} catch (ConnectorException ce) {
//System.out.print("Passed: " + ce.getMessage()); //$NON-NLS-1$
Modified: branches/JCA/connectors/sandbox/connector-object/pom.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/pom.xml 2009-12-16 00:07:07 UTC (rev
1672)
+++ branches/JCA/connectors/sandbox/connector-object/pom.xml 2009-12-16 17:40:05 UTC (rev
1673)
@@ -10,6 +10,7 @@
<artifactId>connector-object</artifactId>
<groupId>org.jboss.teiid.connectors.sandbox</groupId>
<name>Object Connector</name>
+ <packaging>rar</packaging>
<description>This is generic connector that can be used to wrap
any JAVA API, and turn it into connector</description>
<dependencies>
@@ -24,15 +25,33 @@
<scope>provided</scope>
</dependency>
+
<dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.5</version>
- </dependency>
- <dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-internal</artifactId>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Modified:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -43,48 +43,22 @@
*/
public class ObjectConnection extends BasicConnection {
-// private static final String DEFAULT_TRANSLATOR =
"com.metamatrix.connector.object.extension.source.BasicSourceTranslator";//$NON-NLS-1$
-
private ISourceTranslator translator;
- private IObjectSource api;
+ private IObjectSource objectSource;
+ private ObjectManagedConnectionFactory env;
-
- private ConnectorEnvironment env;
- // Connector logger
- ConnectorLogger logger;
-
- /**
- * Constructor.
- * @param env
- * @throws AdminException
- */
- public ObjectConnection(ConnectorEnvironment environment, IObjectSource objectSource)
throws ConnectorException {
+ public ObjectConnection(ObjectManagedConnectionFactory environment, IObjectSource
objectSource, ISourceTranslator translator) {
if (objectSource == null) {
ArgCheck.isNotNull(objectSource, "ObjectSource is
null");//$NON-NLS-1$
}
- this.api = objectSource;
+ this.objectSource = objectSource;
this.env = environment;
- this.logger = environment.getLogger();
-
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- this.translator = ObjectConnectorUtil.createTranslator(environment, loader);
- } catch (ClassNotFoundException e1) {
- throw new ConnectorException(e1);
- } catch (InstantiationException e2) {
- throw new ConnectorException(e2);
- } catch (IllegalAccessException e3) {
- throw new ConnectorException(e3);
- }
-
-
+ this.translator = translator;
}
@Override
- public ProcedureExecution createProcedureExecution(IProcedure command,
- ExecutionContext executionContext, RuntimeMetadata metadata)
+ public ProcedureExecution createProcedureExecution(IProcedure command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
return new ObjectProcedureExecution(command, getObjectSource(), translator,
metadata, env);
}
@@ -94,7 +68,7 @@
* @since 4.3
*/
public IObjectSource getObjectSource() {
- return api;
+ return objectSource;
}
/**
@@ -103,15 +77,10 @@
*/
public void close() {
try {
- api.closeSource();
+ objectSource.closeSource();
} catch(Exception e) {
}
-
- translator=null;
- logger =null;
- api=null;
- env=null;
}
/**
@@ -119,12 +88,6 @@
* @since 4.3
*/
public boolean isAlive() {
- return api.isAlive();
+ return objectSource.isAlive();
}
-
- @Override
- public void closeCalled() {
-
- }
-
}
Modified:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -26,81 +26,40 @@
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.basic.BasicConnector;
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
-import com.metamatrix.connector.object.util.ObjectConnectorUtil;
+import com.metamatrix.connector.object.extension.IObjectSourceFactory;
+import com.metamatrix.connector.object.extension.ISourceTranslator;
+import com.metamatrix.connector.object.extension.source.BasicSourceTranslator;
/**
- * Implmentation of the connector interface.
+ * Implementation of the connector interface.
*/
public class ObjectConnector extends BasicConnector {
- private ConnectorLogger logger;
- private ConnectorEnvironment env;
- private boolean start = false;
- private SourceConnectionFactory factory;
- private ConnectorCapabilities capabilities;
+ private ObjectManagedConnectionFactory config;
+ IObjectSourceFactory objectSourceFactory;
- /**
- * Initialization with environment.
- */
- public void start( ConnectorEnvironment environment ) throws ConnectorException {
- logger = environment.getLogger();
- this.env = environment;
-
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- this.capabilities = ObjectConnectorUtil.createCapabilities(environment,
loader);
- factory = ObjectConnectorUtil.createFactory(this.env, loader);
- } catch (ClassNotFoundException e1) {
- throw new ConnectorException(e1);
- } catch (InstantiationException e2) {
- throw new ConnectorException(e2);
- } catch (IllegalAccessException e3) {
- throw new ConnectorException(e3);
- }
-
- //test connection
- getConnection(null);
-
- start = true;
-
logger.logInfo(ObjectPlugin.Util.getString("ObjectConnector.Connector_started_4"));//$NON-NLS-1$
+ @Override
+ public void initialize(ConnectorEnvironment environment) throws ConnectorException {
+ this.config = (ObjectManagedConnectionFactory)environment;
+ this.objectSourceFactory =
BasicManagedConnectionFactory.getInstance(IObjectSourceFactory.class,
this.config.getObjectSourceFactoryClass(), null);
}
- public void stop() {
- if(!start){
- return;
- }
-
- env = null;
- start = false;
-
-
logger.logInfo(ObjectPlugin.Util.getString("ObjectConnector.Connector_stopped_3"));//$NON-NLS-1$
-
- logger = null;
- }
-
- /*
- * @see
com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
+
@Override
- public Connection getConnection(final ExecutionContext context) throws
ConnectorException {
- return factory.createConnection(factory.createIdentity(context));
+ public Connection getConnection()throws ConnectorException {
+ ISourceTranslator translator =
BasicManagedConnectionFactory.getInstance(ISourceTranslator.class,
this.config.getExtensionResultsTranslationClass(), BasicSourceTranslator.class);
+ translator.initialize(this.config);
+
+ return new ObjectConnection(config,
objectSourceFactory.getObjectSource(this.config), translator);
}
@Override
- public ConnectorCapabilities getCapabilities() {
- return capabilities;
- }
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return ObjectConnectorCapabilities.class;
+ }
- @Override
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- return factory.createIdentity(context);
- }
-
}
Added:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java
(rev 0)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -0,0 +1,66 @@
+/*
+ * 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.object;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class ObjectManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+ private static final long serialVersionUID = -6901150512654296254L;
+ private String extensionResultsTranslationClass;
+ private String objectSourceFactoryClass;
+
+ public String getObjectSourceFactoryClass() {
+ return objectSourceFactoryClass;
+ }
+
+ public void setObjectSourceFactoryClass(String objectSourceFactoryClass) {
+ this.objectSourceFactoryClass = objectSourceFactoryClass;
+ }
+
+ private String databaseTimeZone;
+ private boolean trimStrings;
+
+ public String getExtensionResultsTranslationClass() {
+ return extensionResultsTranslationClass;
+ }
+
+ public void setExtensionResultsTranslationClass(String extensionResultsTranslationClass)
{
+ this.extensionResultsTranslationClass = extensionResultsTranslationClass;
+ }
+
+ public String getDatabaseTimeZone() {
+ return databaseTimeZone;
+ }
+
+ public void setDatabaseTimeZone(String databaseTimeZone) {
+ this.databaseTimeZone = databaseTimeZone;
+ }
+
+ public boolean isTrimStrings() {
+ return trimStrings;
+ }
+
+ public void setTrimStrings(Boolean trimStrings) {
+ this.trimStrings = trimStrings.booleanValue();
+ }
+}
Modified:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -24,13 +24,11 @@
import java.util.List;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ProcedureExecution;
import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.IParameter;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -64,23 +62,17 @@
public ObjectProcedureExecution(IProcedure procedure, IObjectSource sourceapi,
ISourceTranslator translator,
RuntimeMetadata metadata,
- ConnectorEnvironment environment) {
+ ObjectManagedConnectionFactory environment) {
this.procedure = procedure;
this.metadata = metadata;
this.logger = environment.getLogger();
this.api = sourceapi;
this.translator = translator;
this.metadata = metadata;
-
- String propStr =
environment.getProperties().getProperty(ObjectPropertyNames.TRIM_STRINGS);
- if(propStr != null){
- trimString = Boolean.valueOf(propStr).booleanValue();
- }
-
+ this.trimString = environment.isTrimStrings();
}
-
/**
* @see
org.teiid.connector.api.ProcedureExecution#execute(org.teiid.connector.language.IProcedure,
int)
* @since 4.2
Deleted:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -1,42 +0,0 @@
-package com.metamatrix.connector.object;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.SingleIdentity;
-
-public interface SourceConnectionFactory {
-
- /**
- * Set the environment that this factory is being run in - typically used
- * to obtain properties when creating connections and to log messages as
- * necessary.
- * @param env The environment passed to the connector by the connector manager
- */
- void initialize(ConnectorEnvironment env) throws ConnectorException;
-
- /**
- * Create the source-specific connection based on an identity.
- * @param id The identity object
- * @return The source-specific connection
- * @throws ConnectorException If an error occurs while creating the connection
- */
- Connection createConnection(ConnectorIdentity id) throws ConnectorException;
-
- /**
- * Create an identity object based on a security context. This method determines
- * how different security contexts are treated within the connection pool. For
- * example, using a {@link SingleIdentity} specifies that ALL contexts are treated
- * equally and thus use the same pool. A {@link CredentialMapIdentity} specifies
that contexts
- * are differentiated based on user name, thus creating a per-user pool of
connections.
- * Implementors of this class may use a different implementation of the
- * {@link ConnectorIdentity} interface to similarly affect pooling.
- * @param context The context provided by the Connector Manager
- * @return The associated connector identity
- * @throws ConnectorException If an error occurs while creating the identity
- */
- ConnectorIdentity createIdentity(ExecutionContext context) throws
ConnectorException;
-
-}
Added:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java
(rev 0)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -0,0 +1,30 @@
+/*
+ * 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.object.extension;
+
+import org.teiid.connector.api.ConnectorException;
+
+import com.metamatrix.connector.object.ObjectManagedConnectionFactory;
+
+public interface IObjectSourceFactory {
+ IObjectSource getObjectSource(ObjectManagedConnectionFactory config) throws
ConnectorException ;
+}
Modified:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -26,13 +26,14 @@
import java.util.TimeZone;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.object.ObjectManagedConnectionFactory;
+
/**
* Specify source-specific behavior for translating results.
*/
@@ -44,7 +45,7 @@
* @param env The connector environment
* @throws ConnectorException If an error occurs during initialization
*/
- void initialize(ConnectorEnvironment env) throws ConnectorException;
+ void initialize(ObjectManagedConnectionFactory env) throws ConnectorException;
/**
* Determine the time zone the database is located in. Typically, this time zone is
Deleted:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -1,88 +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.object.extension.source;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.SingleIdentity;
-
-import com.metamatrix.connector.object.ObjectConnection;
-import com.metamatrix.connector.object.SourceConnectionFactory;
-import com.metamatrix.connector.object.extension.IObjectSource;
-
-/**
- * Represents a base factory class for the creation of the source connection.
Subclasses
- * are expected to implement the #getObjectSource method to provide the source specific
- * implmentation to interact with the source.
- */
-public abstract class BaseSourceConnectionFactory implements SourceConnectionFactory {
-
- private ConnectorEnvironment environment;
-
- /**
- *
- */
- public BaseSourceConnectionFactory() {
- super();
- }
-
- public void initialize(ConnectorEnvironment env) throws ConnectorException {
- this.environment = env;
- }
-
- protected ConnectorEnvironment getEnvironment() {
- return environment;
- }
-
-
- /**
- * @see
com.metamatrix.data.pool.SourceConnectionFactory#createConnection(org.teiid.connector.api.ConnectorIdentity)
- * @since 4.3
- */
- public final Connection createConnection(ConnectorIdentity id) throws
ConnectorException {
-
- // must pass the factory to the object source because the factory
- // is used to close the connection
- IObjectSource objectSource = getObjectSource(id);
-
- return new ObjectConnection(getEnvironment(), objectSource);
-
- }
-
- protected abstract IObjectSource getObjectSource(final ConnectorIdentity id) throws
ConnectorException ;
-
-
- /**
- * @see
com.metamatrix.data.pool.SourceConnectionFactory#createIdentity(com.metamatrix.data.api.SecurityContext)
- * @since 4.3
- */
- public ConnectorIdentity createIdentity(ExecutionContext context) throws
ConnectorException {
- return new SingleIdentity();
- }
-
-}
Modified:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -26,14 +26,13 @@
import java.util.TimeZone;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.object.ObjectPropertyNames;
+import com.metamatrix.connector.object.ObjectManagedConnectionFactory;
import com.metamatrix.connector.object.extension.IObjectCommand;
import com.metamatrix.connector.object.extension.ISourceTranslator;
import com.metamatrix.connector.object.extension.IValueRetriever;
@@ -53,12 +52,11 @@
/**
* @see
com.metamatrix.connector.jdbc.extension.ResultsTranslator#initialize(com.metamatrix.data.ConnectorEnvironment)
*/
- public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ public void initialize(ObjectManagedConnectionFactory env) throws ConnectorException
{
this.typeFacility = env.getTypeFacility();
-
- String timeZone =
env.getProperties().getProperty(ObjectPropertyNames.DATABASE_TIME_ZONE);
+ String timeZone = env.getDatabaseTimeZone();
if(timeZone != null && timeZone.trim().length() > 0) {
this.dbmsTimeZone = TimeZone.getTimeZone(timeZone);
Modified:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -22,10 +22,6 @@
package com.metamatrix.connector.object.util;
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IMetadataReference;
@@ -33,9 +29,6 @@
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.object.ObjectPlugin;
-import com.metamatrix.connector.object.ObjectPropertyNames;
-import com.metamatrix.connector.object.SourceConnectionFactory;
-import com.metamatrix.connector.object.extension.ISourceTranslator;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -43,11 +36,8 @@
* @since 4.3
*/
public class ObjectConnectorUtil {
- private static final String DEFAULT_TRANSLATOR =
"com.metamatrix.connector.object.extension.source.BasicSourceTranslator";//$NON-NLS-1$
- private static final String DEFAULT_CAPABILITIES =
"com.metamatrix.connector.object.ObjectConnectorCapabilities";//$NON-NLS-1$
-
- public static final String getMetadataObjectNameInSource(final RuntimeMetadata
metadata, final ICommand command, IMetadataReference reference) throws ConnectorException
{
+ public static final String getMetadataObjectNameInSource(final RuntimeMetadata metadata,
final ICommand command, IMetadataReference reference) throws ConnectorException {
if(reference == null) {
return null;
}
@@ -58,64 +48,6 @@
}
return null;
}
- throw new MetaMatrixRuntimeException(
-
ObjectPlugin.Util.getString("ObjectConnector.Could_not_resolve_name_for_query___1",
//$NON-NLS-1$
- new Object[] {command.toString()}));
-
+ throw new
MetaMatrixRuntimeException(ObjectPlugin.Util.getString("ObjectConnector.Could_not_resolve_name_for_query___1",new
Object[] { command.toString() }));
}
-
- public static final SourceConnectionFactory createFactory(final ConnectorEnvironment
environment, ClassLoader loader)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException,
ConnectorException {
- if (environment == null || loader == null || environment.getProperties() == null)
{
- return null;
- }
-
- Properties props = environment.getProperties();
- String scfClassName =
props.getProperty(ObjectPropertyNames.EXT_CONNECTION_FACTORY_CLASS);
-
- //create source connection factory
- Class scfClass = loader.loadClass(scfClassName);
- SourceConnectionFactory adminFactory = (SourceConnectionFactory)
scfClass.newInstance();
- adminFactory.initialize(environment);
-
- return adminFactory;
-
- }
-
- public static final ISourceTranslator createTranslator(final ConnectorEnvironment
environment, ClassLoader loader)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException,
ConnectorException {
-
- //create ResultsTranslator
- ISourceTranslator translator = null;
- String className =
environment.getProperties().getProperty(ObjectPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS);
- if (className == null) {
- environment.getLogger().logInfo(
ObjectPlugin.Util.getString("ObjectConnector.Property_{0}_is_not_defined_use_default",
new Object[] {ObjectPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS, DEFAULT_TRANSLATOR} ));
//$NON-NLS-1$
- className = DEFAULT_TRANSLATOR;
- }
-
- Class sourceTransClass = loader.loadClass(className);
- translator = (ISourceTranslator) sourceTransClass.newInstance();
- translator.initialize(environment);
-
- return translator;
-
- }
-
-
- public static final ConnectorCapabilities createCapabilities(final
ConnectorEnvironment environment, ClassLoader loader)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException,
ConnectorException {
-
- //create Capabilities
- ConnectorCapabilities capabilities;
- String className =
environment.getProperties().getProperty(ObjectPropertyNames.EXT_CAPABILITY_CLASS);
- if(className == null){
- environment.getLogger().logInfo(
ObjectPlugin.Util.getString("ObjectConnector.Property_{0}_is_not_defined_use_default",
new Object[] {ObjectPropertyNames.EXT_CAPABILITY_CLASS, DEFAULT_CAPABILITIES} ));
//$NON-NLS-1$
- className = DEFAULT_CAPABILITIES;
- }
- Class capabilitiesClass = loader.loadClass(className);
- capabilities = (ConnectorCapabilities) capabilitiesClass.newInstance();
-
- return capabilities;
- }
-
}
Added: branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml
(rev 0)
+++
branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml 2009-12-16
17:40:05 UTC (rev 1673)
@@ -0,0 +1,135 @@
+<?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 Object 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.object.ObjectManagedConnectionFactory</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.object.ObjectConnector</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.object.ObjectConnectorCapabilities</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>
+
+ <!-- Object Specific properties -->
+
+ <config-property>
+ <description>Object Source Factory Class</description>
+
<config-property-name>ObjectSourceFactoryClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Results Translation Class</description>
+
<config-property-name>ExtensionResultsTranslationClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>com.metamatrix.connector.object.extension.source.BasicSourceTranslator</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Database Timezone</description>
+ <config-property-name>DatabaseTimeZone</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Trim Result Strings</description>
+ <config-property-name>TrimStrings</config-property-name>
+
<config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</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>
Modified: branches/JCA/connectors/sandbox/connector-yahoo/pom.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/pom.xml 2009-12-16 00:07:07 UTC (rev
1672)
+++ branches/JCA/connectors/sandbox/connector-yahoo/pom.xml 2009-12-16 17:40:05 UTC (rev
1673)
@@ -10,7 +10,7 @@
<groupId>org.jboss.teiid.connectors.sandbox</groupId>
<name>Yahoo Connector</name>
<description>Test connector used to query ticker symbols from Yahoo
website</description>
-
+ <packaging>rar</packaging>
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -22,5 +22,27 @@
<artifactId>teiid-common-core</artifactId>
<scope>provided</scope>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Modified:
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.yahoo;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
@@ -37,26 +36,18 @@
*/
public class YahooConnection extends BasicConnection {
- private ConnectorEnvironment env;
+ private YahooManagedConnectionFactory config;
- /**
- *
- */
- public YahooConnection(ConnectorEnvironment env) {
- this.env = env;
+ public YahooConnection(YahooManagedConnectionFactory env) {
+ this.config = env;
}
@Override
- public ResultSetExecution createResultSetExecution(IQueryCommand command,
- ExecutionContext executionContext, RuntimeMetadata metadata)
+ public ResultSetExecution createResultSetExecution(IQueryCommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new YahooExecution((IQuery)command, env, metadata);
+ return new YahooExecution((IQuery)command, config, metadata);
}
-
- /*
- * @see com.metamatrix.data.Connection#close()
- */
public void close() {
// nothing to do
}
Modified:
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -22,48 +22,28 @@
package com.metamatrix.connector.yahoo;
-import org.teiid.connector.api.*;
+import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.basic.BasicConnector;
public class YahooConnector extends BasicConnector {
- private ConnectorEnvironment env;
+ private YahooManagedConnectionFactory config;
- static final ConnectorCapabilities CAPABILITIES = new YahooCapabilities();
-
- /**
- *
- */
- public YahooConnector() {
- super();
- }
-
- /*
- * @see
com.metamatrix.data.Connector#initialize(com.metamatrix.data.ConnectorEnvironment)
- */
@Override
- public void start(ConnectorEnvironment environment) throws ConnectorException {
- this.env = environment;
+ public void initialize(ConnectorEnvironment environment) throws ConnectorException {
+ this.config = (YahooManagedConnectionFactory)environment;
}
- /*
- * @see com.metamatrix.data.Connector#stop()
- */
@Override
- public void stop() {
- // nothing to do
+ public Connection getConnection() throws ConnectorException {
+ return new YahooConnection(this.config);
}
-
- /*
- * @see
com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
+
@Override
- public Connection getConnection(ExecutionContext context) throws ConnectorException
{
- return new YahooConnection(env);
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return YahooCapabilities.class;
}
-
- @Override
- public ConnectorCapabilities getCapabilities() {
- return CAPABILITIES;
- }
}
Modified:
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2009-12-16
00:07:07 UTC (rev 1672)
+++
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -35,11 +35,9 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
@@ -59,8 +57,6 @@
* Represents the execution of a command.
*/
public class YahooExecution extends BasicExecution implements ResultSetExecution {
- public static final String HTTP_PROXY_HOST = "HttpProxyHost";
//$NON-NLS-1$
- public static final String HTTP_PROXY_PORT = "HttpProxyPort";
//$NON-NLS-1$
public static final String JAVA_PROP_HTTP_PROXY_HOST = "http.proxyHost";
//$NON-NLS-1$
public static final String JAVA_PROP_HTTP_PROXY_PORT = "http.proxyPort";
//$NON-NLS-1$
@@ -69,7 +65,7 @@
private static SimpleDateFormat TIME_FORMAT = new
SimpleDateFormat("HH:mma"); //$NON-NLS-1$
// Connector resources
- private ConnectorEnvironment env;
+ private YahooManagedConnectionFactory config;
private RuntimeMetadata metadata;
private IQuery command;
@@ -85,8 +81,8 @@
/**
*
*/
- public YahooExecution(IQuery query, ConnectorEnvironment env, RuntimeMetadata
metadata) {
- this.env = env;
+ public YahooExecution(IQuery query, YahooManagedConnectionFactory env,
RuntimeMetadata metadata) {
+ this.config = env;
this.metadata = metadata;
this.query = query;
}
@@ -97,13 +93,13 @@
@Override
public void execute() throws ConnectorException {
// Log our command
- env.getLogger().logTrace("Yahoo executing command: " + command);
//$NON-NLS-1$
+ this.config.getLogger().logTrace("Yahoo executing command: " +
command); //$NON-NLS-1$
// Build url
String yahooUrl = translateIntoUrl(query);
// Execute url to get results
- this.results = executeUrl(yahooUrl, this.env.getLogger());
+ this.results = executeUrl(yahooUrl, this.config.getLogger());
// Determine needed columns in results
this.neededColumns = getNeededColumns(query.getSelect(), this.metadata);
@@ -307,16 +303,16 @@
}
private void setProxy() {
- Properties props = env.getProperties();
- String proxyHost = props.getProperty(HTTP_PROXY_HOST);
- String proxyPort = props.getProperty(HTTP_PROXY_PORT);
+ String proxyHost = this.config.getHttpProxyHost();
+ String proxyPort = this.config.getHttpProxyPort();
+
previousHttpProxyHost = System.getProperty(JAVA_PROP_HTTP_PROXY_HOST);
previousHttpProxyPort = System.getProperty(JAVA_PROP_HTTP_PROXY_PORT);
if(proxyHost != null) {
System.setProperty(JAVA_PROP_HTTP_PROXY_HOST, proxyHost);
if(proxyPort == null) {
-
env.getLogger().logWarning(YahooPlugin.Util.getString("YahooConnector.proxyPortNotSet"));//$NON-NLS-1$
+
this.config.getLogger().logWarning(YahooPlugin.Util.getString("YahooConnector.proxyPortNotSet"));//$NON-NLS-1$
}else {
System.setProperty(JAVA_PROP_HTTP_PROXY_PORT, proxyPort);
}
Added:
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java
===================================================================
---
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java
(rev 0)
+++
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java 2009-12-16
17:40:05 UTC (rev 1673)
@@ -0,0 +1,50 @@
+/*
+ * 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.yahoo;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class YahooManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+ private static final long serialVersionUID = -8938107803750844843L;
+
+ private String httpProxyHost;
+ private String httpProxyPort;
+
+ public String getHttpProxyHost() {
+ return httpProxyHost;
+ }
+
+ public void setHttpProxyHost(String httpProxyHost) {
+ this.httpProxyHost = httpProxyHost;
+ }
+
+ public String getHttpProxyPort() {
+ return httpProxyPort;
+ }
+
+ public void setHttpProxyPort(String httpProxyPort) {
+ this.httpProxyPort = httpProxyPort;
+ }
+
+
+}
Added: branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml
(rev 0)
+++
branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml 2009-12-16
17:40:05 UTC (rev 1673)
@@ -0,0 +1,120 @@
+<?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 Yahoo 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.yahoo.YahooManagedConnectionFactory</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.yahoo.YahooConnector</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.yahoo.YahooCapabilities</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>true</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>
+
+ <!-- Yahoo Specific properties -->
+
+ <config-property>
+ <description>HttpProxyHost</description>
+ <config-property-name>HttpProxyHost</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>HttpProxyPort</description>
+ <config-property-name>HttpProxyPort</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </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>