Author: rareddy
Date: 2010-05-18 08:01:08 -0400 (Tue, 18 May 2010)
New Revision: 2134
Added:
trunk/connectors/connector-ws/
trunk/connectors/connector-ws/pom.xml
trunk/connectors/connector-ws/src/
trunk/connectors/connector-ws/src/main/
trunk/connectors/connector-ws/src/main/java/
trunk/connectors/connector-ws/src/main/java/org/
trunk/connectors/connector-ws/src/main/java/org/teiid/
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
trunk/connectors/connector-ws/src/main/rar/
trunk/connectors/connector-ws/src/main/rar/META-INF/
trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml
trunk/connectors/connector-ws/src/main/resources/
Removed:
trunk/connectors/connector-xml/
Log:
TEIID-1077: adding the connector-ws module
Added: trunk/connectors/connector-ws/pom.xml
===================================================================
--- trunk/connectors/connector-ws/pom.xml (rev 0)
+++ trunk/connectors/connector-ws/pom.xml 2010-05-18 12:01:08 UTC (rev 2134)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <artifactId>connectors</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>connector-ws</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <name>Web Service Connector</name>
+ <packaging>rar</packaging>
+ <description>This connector reads data from Web Services</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ws.native</groupId>
+ <artifactId>jbossws-native-core</artifactId>
+ <version>3.1.1.GA</version>
+ <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>
+ <execution>
+ <id>deploy_jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <classifier>lib</classifier>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java
===================================================================
---
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java
(rev 0)
+++
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java 2010-05-18
12:01:08 UTC (rev 2134)
@@ -0,0 +1,188 @@
+package org.teiid.resource.adapter.ws;
+
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import javax.resource.ResourceException;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Response;
+import javax.xml.ws.Service;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.jboss.ws.core.ConfigProvider;
+import org.teiid.resource.adapter.ws.WSManagedConnectionFactory.ParameterType;
+import org.teiid.resource.spi.BasicConnection;
+
+public class WSConnection extends BasicConnection implements Dispatch<Source>{
+ private static QName svcQname = new QName("http://teiid.org",
"teiid"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static QName portQName = new QName("http://teiid.org",
"teiid");//$NON-NLS-1$ //$NON-NLS-2$
+
+ private Dispatch delegate;
+ private WSManagedConnectionFactory mcf;
+
+ public WSConnection(WSManagedConnectionFactory mcf) {
+ if (mcf.getInvocationType() == WSManagedConnectionFactory.InvocationType.SOAP) {
+ this.delegate = createSOAPDispatch(mcf);
+ }
+ else if (mcf.getInvocationType() == WSManagedConnectionFactory.InvocationType.HTTP_GET)
{
+ this.delegate = createHTTPDispatch(mcf, "GET"); //$NON-NLS-1$
+ }
+ else if (mcf.getInvocationType() ==
WSManagedConnectionFactory.InvocationType.HTTP_POST) {
+ this.delegate = createHTTPDispatch(mcf, "POST"); //$NON-NLS-1$
+ }
+ this.mcf = mcf;
+ }
+
+
+ private Dispatch createHTTPDispatch(WSManagedConnectionFactory mcf, String
requestMethod){
+ Service svc = Service.create(svcQname);
+ svc.addPort(portQName, HTTPBinding.HTTP_BINDING, mcf.getEndPoint());
+
+ Dispatch<Source> dispatch = svc.createDispatch(portQName, Source.class,
Service.Mode.PAYLOAD);
+ dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, requestMethod);
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.HTTPBasic){
+ dispatch.getRequestContext().put(Dispatch.USERNAME_PROPERTY, mcf.getAuthUserName());
+ dispatch.getRequestContext().put(Dispatch.PASSWORD_PROPERTY, mcf.getAuthPassword());
+ }
+
+ Map<String, List<String>> httpHeaders = (Map<String,
List<String>>)dispatch.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
+ if(httpHeaders == null) {
+ httpHeaders = new HashMap<String, List<String>>();
+ }
+ httpHeaders.put("Content-Type",
Collections.singletonList("text/xml; charset=utf-8"));//$NON-NLS-1$
//$NON-NLS-2$
+ httpHeaders.put("User-Agent", Collections.singletonList("Teiid
Server"));//$NON-NLS-1$ //$NON-NLS-2$
+ dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
httpHeaders);
+
+ return dispatch;
+ }
+
+ private Dispatch createSOAPDispatch(WSManagedConnectionFactory mcf) {
+ Service svc = Service.create(svcQname);
+
+ svc.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, mcf.getEndPoint());
+
+ Dispatch dispatch = svc.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
+ // JBoss WS-Security
+ ((ConfigProvider) this.delegate).setSecurityConfig(mcf.getWsSecurityConfigURL());
+ ((ConfigProvider) delegate).setConfigName(mcf.getWsSecurityConfigName());
+ }
+ return dispatch;
+ }
+
+ public Binding getBinding() {
+ return delegate.getBinding();
+ }
+
+ public EndpointReference getEndpointReference() {
+ return delegate.getEndpointReference();
+ }
+
+ public <T extends EndpointReference> T getEndpointReference(Class<T> clazz)
{
+ return delegate.getEndpointReference(clazz);
+ }
+
+ public Map<String, Object> getRequestContext() {
+ return delegate.getRequestContext();
+ }
+
+ public Map<String, Object> getResponseContext() {
+ return delegate.getResponseContext();
+ }
+
+
+ /**
+ * NOTE: the source msg from the teiid translator going to be SOAP. If execution is
different from
+ * soap then fix it now.
+ */
+ @Override
+ public Source invoke(Source msg) {
+
+ String xmlPayload = null;
+ Map<String, Object> map =
(Map)getRequestContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
+ if (map != null) {
+ xmlPayload = (String)map.remove("xml"); //$NON-NLS-1$
+ }
+
+ if (this.mcf.getInvocationType() == WSManagedConnectionFactory.InvocationType.HTTP_GET)
{
+ if (isXMLInput() && xmlPayload != null) {
+ getRequestContext().put(MessageContext.QUERY_STRING,
this.mcf.getXMLParamName()+"="+xmlPayload); //$NON-NLS-1$
+ }
+ else {
+ if (getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null) {
+
+ String path = (String)getRequestContext().get(MessageContext.PATH_INFO);
+ String queryString = (String)getRequestContext().get(MessageContext.QUERY_STRING);
+ String url = this.mcf.getEndPoint();
+ if (path != null) {
+ url = url + "/" + path; //$NON-NLS-1$
+ }
+ if (queryString != null) {
+ url = url + "?" + queryString; //$NON-NLS-1$
+ }
+ getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
+ }
+ }
+ msg = null;
+ }
+ else if (this.mcf.getInvocationType() ==
WSManagedConnectionFactory.InvocationType.HTTP_POST) {
+ getRequestContext().put(MessageContext.QUERY_STRING, ""); //$NON-NLS-1$
+ if (isXMLInput() && xmlPayload != null) {
+ msg = new StreamSource(new StringReader(xmlPayload));
+ }
+ else {
+ msg = null;
+ }
+ }
+ else if (this.mcf.getInvocationType() ==
WSManagedConnectionFactory.InvocationType.SOAP) {
+ // JBossWS native adds the null based address property somewhere and results in error
if this
+ // is corrected
+ if (getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null) {
+ getRequestContext().remove(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+ }
+ }
+
+ if (msg == null) {
+ // JBoss Native DispatchImpl throws exception when the source is null
+ msg = new StreamSource(new StringReader("<none/>"));
+ }
+ return (Source)delegate.invoke(msg);
+ }
+
+ private boolean isXMLInput() {
+ return (this.mcf.getParameterMethod() == ParameterType.XMLInQueryString ||
this.mcf.getParameterMethod() == ParameterType.XMLRequest);
+ }
+
+ @Override
+ public Future invokeAsync(Source msg, AsyncHandler handler) {
+ return delegate.invokeAsync(msg, handler);
+ }
+
+ @Override
+ public Response invokeAsync(Source msg) {
+ return delegate.invokeAsync(msg);
+ }
+
+ @Override
+ public void invokeOneWay(Source msg) {
+ delegate.invokeOneWay(msg);
+ }
+
+ @Override
+ public void close() throws ResourceException {
+ this.delegate = null;
+ }
+}
Added:
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
===================================================================
---
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
(rev 0)
+++
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-05-18
12:01:08 UTC (rev 2134)
@@ -0,0 +1,134 @@
+/*
+ * 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 org.teiid.resource.adapter.ws;
+
+import javax.resource.ResourceException;
+import javax.resource.cci.ConnectionSpec;
+
+import org.teiid.resource.spi.BasicConnection;
+import org.teiid.resource.spi.BasicConnectionFactory;
+import org.teiid.resource.spi.BasicManagedConnectionFactory;
+
+public class WSManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+ private static final long serialVersionUID = -2998163922934555003L;
+
+ enum InvocationType {HTTP_GET, HTTP_POST, SOAP};
+ enum SecurityType {None,HTTPBasic,WSSecurity}
+ enum ParameterType{None,Name_Value,XMLRequest,XMLInQueryString};
+
+ private String invocationType;
+ private String endPoint;
+
+ private String securityType; // None, HTTPBasic, WS-Security
+ private String wsSecurityConfigURL; // path to the "jboss-wsse-client.xml"
file
+ private String wsSecurityConfigName; // ws-security config name in the above file
+ private String authPassword; // httpbasic - password
+ private String authUserName; // httpbasic - username
+ private String parameterMethod;
+ private String xMLParamName;
+
+
+ @Override
+ public Object createConnectionFactory() throws ResourceException {
+ return new BasicConnectionFactory() {
+ @Override
+ public BasicConnection getConnection() throws ResourceException {
+ return new WSConnection(WSManagedConnectionFactory.this);
+ }
+ };
+ }
+
+
+ public InvocationType getInvocationType() {
+ return InvocationType.valueOf(invocationType);
+ }
+
+
+ public void setInvocationType(String invocationType) {
+ this.invocationType = invocationType;
+ }
+
+ public String getAuthPassword() {
+ return this.authPassword;
+ }
+
+ public void setAuthPassword(String authPassword) {
+ this.authPassword = authPassword;
+ }
+
+ public String getAuthUserName() {
+ return this.authUserName;
+ }
+
+ public void setAuthUserName(String authUserName) {
+ this.authUserName = authUserName;
+ }
+
+ public String getEndPoint() {
+ return this.endPoint;
+ }
+
+ public void setEndPoint(String endPoint) {
+ this.endPoint = endPoint;
+ }
+
+ public SecurityType getSecurityType() {
+ return SecurityType.valueOf(this.securityType);
+ }
+
+ public void setSecurityType(String securityType) {
+ this.securityType = securityType;
+ }
+
+ public String getWsSecurityConfigURL() {
+ return wsSecurityConfigURL;
+ }
+
+ public void setWsSecurityConfigURL(String wsSecurityConfigURL) {
+ this.wsSecurityConfigURL = wsSecurityConfigURL;
+ }
+
+ public String getWsSecurityConfigName() {
+ return wsSecurityConfigName;
+ }
+
+ public void setWsSecurityConfigName(String wsSecurityConfigName) {
+ this.wsSecurityConfigName = wsSecurityConfigName;
+ }
+
+ public ParameterType getParameterMethod() {
+ return ParameterType.valueOf(parameterMethod);
+ }
+
+ public void setParameterMethod(String parameterMethod) {
+ this.parameterMethod = parameterMethod;
+ }
+
+ public String getXMLParamName() {
+ return xMLParamName;
+ }
+
+ public void setXMLParamName(String xMLParamName) {
+ this.xMLParamName = xMLParamName;
+ }
+}
Added: trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml
(rev 0)
+++ trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-05-18 12:01:08 UTC
(rev 2134)
@@ -0,0 +1,116 @@
+<?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 XML SOAP 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.resource.spi.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+
<managedconnectionfactory-class>org.teiid.resource.adapter.ws.WSManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>{$display:"Invocation
Type",$description:"Service Invocation type (HTTP or SOAP)",
$allowed="HTTP_GET, HTTP_POST,SOAP", $required="true",
$defaultValue="SOAP"}</description>
+ <config-property-name>InvocationType</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ <config-property-value>SOAP</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"URL, End
Point",$description:"URL for HTTP, Service Endpoint for
SOAP",$required="true"}</description>
+ <config-property-name>EndPoint</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"WebService Security Used(None,
HTTPBasic, WS-Security)",$allowed="None,HTTPBasic,WSSecurity",
$description:"Type of Authentication to used with the web service; If WS-Secuirty is
being used, then WS-Secuirty type must be defined", $required:"true",
$defaultValue="None"}</description>
+ <config-property-name>SecurityType</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ <config-property-value>None</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"Authentication User
Name",$description:"Name value for
authentication",$advanced:"true"}</description>
+ <config-property-name>AuthUserName</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"Authentication User
Password",$description:"Password value for
authentication",$advanced:"true",$masked:"true"}</description>
+ <config-property-name>AuthPassword</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"URL to the WS-Security Configuration
File(jboss-wsse-client.xml)",$description:"JBoss WS-Security client
configuration File"}</description>
+
<config-property-name>WsSecurityConfigURL</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"WS-Security Configuration Name in
jboss-wsse-client.xml",$description:"JBoss WS-Security client configuration name
to use"}</description>
+
<config-property-name>WsSecurityConfigName</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"XML Parameter Name",
$description="only required for the HTTP with XML based
request"}</description>
+ <config-property-name>XMLParamName</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"Parameter Method (None, Name_Value,
XMLRequest,
XMLInQueryString)",$description:"",$allowed:["None","Name_Value","XMLRequest","XMLInQueryString"],
$editable:"false", defaultValue="Name_Value"}</description>
+ <config-property-name>ParameterMethod</config-property-name>
+
<config-property-type>java.lang.String</config-property-type>
+ <config-property-value>Name_Value</config-property-value>
+ </config-property>
+
+
<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
+
<connectionfactory-impl-class>org.teiid.resource.spi.WrappedConnectionFactory</connectionfactory-impl-class>
+
<connection-interface>javax.resource.cci.Connection</connection-interface>
+
<connection-impl-class>org.teiid.resource.spi.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>