Author: shawkins
Date: 2010-09-02 12:55:47 -0400 (Thu, 02 Sep 2010)
New Revision: 2520
Added:
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
Modified:
branches/7.1.x/build/assembly/jboss-container/dist.xml
branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
branches/7.1.x/connectors/connector-ws/pom.xml
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
Log:
TEIID-1138 TEIID-1148 initial commit of requiring cxf and adding support for binary
webservice calls
Modified: branches/7.1.x/build/assembly/jboss-container/dist.xml
===================================================================
--- branches/7.1.x/build/assembly/jboss-container/dist.xml 2010-09-02 14:38:11 UTC (rev
2519)
+++ branches/7.1.x/build/assembly/jboss-container/dist.xml 2010-09-02 16:55:47 UTC (rev
2520)
@@ -18,7 +18,8 @@
<includes>
<include>**/*.sh</include>
</includes>
- <fileMode>755</fileMode>
+ <fileMode>755</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
@@ -39,6 +40,7 @@
</includes>
<outputDirectory>lib</outputDirectory>
<fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
@@ -47,7 +49,8 @@
<include>vdb-deployer.xsd</include>
</includes>
<outputDirectory>teiid-docs/schema</outputDirectory>
- <fileMode>0644</fileMode>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<!-- We may want to do this if including multiple doc types or languages
Modified: branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-02 14:38:11
UTC (rev 2519)
+++ branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-02 16:55:47
UTC (rev 2520)
@@ -30,7 +30,8 @@
<LI><B>Improved Plan Caching</B> - plans used by internal
materialization and stored procedure plans will be automatically cached in the prepared
plan cache. Improvements were also made to reduce the memory footprint of the plans.
<LI><B>Refined Load Balancing and Fail Over</B> - clients can use
use the statement "SET NEWINSTANCE TRUE" to allow their connection to select a
new server instance. See the Client Developer's Guide for more information.
<LI><B>Simplified Role Usage</B> - a role can now be assigned to
any authenticated user via the any-authenticated attribute on the data-role element.
- <LI><B>Materialized View Performance</B> - materialized view tables
will now automatically create and use non-unique secondary indexes for unique constraints
and indexes defined on the view.
+ <LI><B>Materialized View Performance</B> - materialized view tables
will now automatically create and use non-unique secondary indexes for unique constraints
and indexes defined on the view.
+ <LI><B>Binary Web Service Calls</B> - the ws translator now
provides an invokeHttp procedure to return the blob contents and string content type of an
http/https call.
</UL>
<h2><a name="Compatibility">Compatibility
Issues</a></h2>
@@ -74,6 +75,8 @@
<h4>from 7.1</h4>
<ul>
+ <li>Apache CXF is now expected to be used as the web services stack provider
through JBossWS-CXF. See the Admin Guide for instructions on
+ installing CXF for use with Teiid's Salesforce and web service connectors.
<li>The default for data role checking is now "true". However only VDBs
with data roles will have roles enforced.
<li>The default prepared plan cache size was increased to 512, since it is
targeted by internal plans as well.
</ul>
@@ -108,26 +111,6 @@
the parseTime function cannot be pushed down. This should be addressed in future
releases.
</ul>
-<h4>Salesforce as Source</h4>
-Before Salesforce is used in your data integration project, the below issues need to be
resolved.
-<ul>
- <li>Manually copy the following libraries from the JBOSS_HOME/client directory to
the JBOSS_HOME/lib/endorsed directory, so that the JAX-WS 2.0 apis supported by JBossWS
are used:
- <ul>
- <li>jbossws-native-saaj.jar</li>
- <li>jbossws-native-jaxrpc.jar</li>
- <li>jbossws-native-jaxws.jar</li>
- <li>jbossws-native-jaxws-ext.jar</li>
- </ul>
- </li>
- <li>There is issue with invoking "https" based URL with out specifying
the either a keystore or truststore properties with JBoss remoting 2.5.1. Generally you do
not need to specify the truststore as a anonymous truststore will be negotiated, however
if you fail to supply the following system properties there will be a error message in the
log (query will execute even with out the properties). Add these to
JBOSS_INSTALL/bin/run.conf file under JAVA_OPTS
- <ul>
- <li>-Djava.net.ssl.keyStore=<path-to-truststore></li>
- <li>-Djava.net.ssl.keyStoreType=<certificate-type></li>
- <li>-Djava.net.ssl.keyStorePassword=<password></li>
- </ul>
- </li>
-</ul>
-
<h2><a name="LibraryUpdates">Thirdparty Library
Updates</a></h2>
The following components have been updated:
Modified:
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
---
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-09-02
16:55:47 UTC (rev 2520)
@@ -40,11 +40,8 @@
import java.util.Map;
import java.util.Set;
-import javax.xml.transform.Source;
-
import org.teiid.core.CorePlugin;
import org.teiid.core.ErrorMessageKeys;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.basic.AnyToObjectTransform;
import org.teiid.core.types.basic.AnyToStringTransform;
import org.teiid.core.types.basic.BooleanToNumberTransform;
@@ -733,21 +730,6 @@
return new XMLType(value);
}
});
- //Note: the default transform from non-InputStreamFactory source is a fully
materialized string
- addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
- @Override
- public XMLType transform(Source value) {
- if (value instanceof InputStreamFactory) {
- return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
- }
- StandardXMLTranslator sxt = new StandardXMLTranslator(value);
- try {
- return new XMLType(new SQLXMLImpl(sxt.getString()));
- } catch (Exception e) {
- throw new TeiidRuntimeException(e);
- }
- }
- });
addSourceTransform(Date.class, new SourceTransform<Date, Timestamp>() {
@Override
public Timestamp transform(Date value) {
Modified: branches/7.1.x/connectors/connector-ws/pom.xml
===================================================================
--- branches/7.1.x/connectors/connector-ws/pom.xml 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/connector-ws/pom.xml 2010-09-02 16:55:47 UTC (rev 2520)
@@ -29,11 +29,29 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-core</artifactId>
- <version>3.1.1.GA</version>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>2.2.2</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-security</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-policy</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified:
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
===================================================================
---
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-02
16:55:47 UTC (rev 2520)
@@ -1,21 +1,41 @@
package org.teiid.resource.adapter.ws;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Future;
+import javax.activation.DataSource;
import javax.resource.ResourceException;
import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
import javax.xml.ws.Dispatch;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Response;
import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.http.HTTPBinding;
-import org.jboss.ws.core.ConfigProvider;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.DispatchImpl;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.core.util.Base64;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.StringUtil;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -28,9 +48,129 @@
* TODO: set a handler chain
*/
public class WSConnectionImpl extends BasicConnection implements WSConnection {
- 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 static final class HttpDataSource implements DataSource {
+ private final URL url;
+ private final HttpURLConnection httpConn;
+
+ private HttpDataSource(URL url, HttpURLConnection httpConn) {
+ this.url = url;
+ this.httpConn = httpConn;
+ }
+
+ @Override
+ public OutputStream getOutputStream() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getName() {
+ return url.getPath();
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return httpConn.getInputStream();
+ }
+
+ @Override
+ public String getContentType() {
+ return httpConn.getContentType();
+ }
+ }
+
+ /**
+ * Workaround dispatch, since neither JBossNative nor CXF 2.2.2 implement
+ * this functionality.
+ */
+ private static final class BinaryDispatch implements Dispatch<DataSource> {
+
+ HashMap<String, Object> requestContext = new HashMap<String, Object>();
+
+ private String endpoint;
+
+ public BinaryDispatch(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ public DataSource invoke(DataSource msg) {
+ try {
+ final URL url = new URL(endpoint);
+ final HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setDoOutput(true);
+ httpConn.setRequestMethod((String)
requestContext.get(MessageContext.HTTP_REQUEST_METHOD));
+ Map<String, List<String>> header = (Map<String,
List<String>>)requestContext.get(MessageContext.HTTP_REQUEST_HEADERS);
+ for (Map.Entry<String, List<String>> entry : header.entrySet()) {
+ String value = StringUtil.join(entry.getValue(), ","); //$NON-NLS-1$
+ httpConn.setRequestProperty(entry.getKey(), value);
+ }
+ String username = (String) requestContext.get(Dispatch.USERNAME_PROPERTY);
+ String password = (String) requestContext.get(Dispatch.PASSWORD_PROPERTY);
+
+ if (username != null) {
+ httpConn.setRequestProperty("Authorization", "Basic " +
Base64.encodeBytes((username + ':' + password).getBytes())); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ if (msg != null) {
+ httpConn.setDoInput(true);
+ OutputStream os = httpConn.getOutputStream();
+ InputStream is = msg.getInputStream();
+ ObjectConverterUtil.write(os, is, -1);
+ }
+
+ return new HttpDataSource(url, httpConn);
+ } catch (IOException e) {
+ throw new WebServiceException(e);
+ }
+ }
+
+ @Override
+ public Response<DataSource> invokeAsync(DataSource msg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Future<?> invokeAsync(DataSource msg, AsyncHandler<DataSource>
handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void invokeOneWay(DataSource msg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Binding getBinding() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public EndpointReference getEndpointReference() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T extends EndpointReference> T getEndpointReference(
+ Class<T> clazz) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Map<String, Object> getRequestContext() {
+ return requestContext;
+ }
+
+ @Override
+ public Map<String, Object> getResponseContext() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ static final String DEFAULT_NAMESPACE_URI = "http://teiid.org"; //$NON-NLS-1$
+ static final String DEFAULT_LOCAL_NAME = "teiid"; //$NON-NLS-1$
+
+ private static QName svcQname = new QName(DEFAULT_NAMESPACE_URI, DEFAULT_LOCAL_NAME);
private WSManagedConnectionFactory mcf;
public WSConnectionImpl(WSManagedConnectionFactory mcf) {
@@ -38,7 +178,7 @@
}
public <T> Dispatch<T> createDispatch(String binding, String endpoint,
Class<T> type, Mode mode) {
- Service svc = Service.create(svcQname);
+ ArgCheck.isNotNull(binding);
if (endpoint != null) {
try {
new URL(endpoint);
@@ -74,15 +214,40 @@
} else {
endpoint = mcf.getEndPoint();
}
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with
endpoint", endpoint); //$NON-NLS-1$
+ Dispatch<T> dispatch = null;
+ if (HTTPBinding.HTTP_BINDING.equals(binding) && type == DataSource.class) {
+ dispatch = (Dispatch<T>) new BinaryDispatch(endpoint);
+ } else {
+ //TODO: cache service/port/dispatch instances?
+ Bus bus = BusFactory.getThreadDefaultBus();
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
+ BusFactory.setThreadDefaultBus(mcf.getBus());
+ }
+ Service svc;
+ try {
+ svc = Service.create(svcQname);
+ } finally {
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
+ BusFactory.setThreadDefaultBus(bus);
+ }
+ }
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with
endpoint", endpoint); //$NON-NLS-1$
+ }
+ svc.addPort(mcf.getPortQName(), binding, endpoint);
+
+ dispatch = svc.createDispatch(mcf.getPortQName(), type, mode);
+
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity
+ && mcf.getOutInterceptors() != null) {
+ Client client = ((DispatchImpl)dispatch).getClient();
+ Endpoint ep = client.getEndpoint();
+ for (Interceptor i : mcf.getOutInterceptors()) {
+ ep.getOutInterceptors().add(i);
+ }
+ }
}
- svc.addPort(portQName, binding, endpoint);
-
- Dispatch<T> dispatch = svc.createDispatch(portQName, type, mode);
-
if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.HTTPBasic){
dispatch.getRequestContext().put(Dispatch.USERNAME_PROPERTY, mcf.getAuthUserName());
dispatch.getRequestContext().put(Dispatch.PASSWORD_PROPERTY, mcf.getAuthPassword());
@@ -96,10 +261,6 @@
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);
- } else if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity)
{
- // JBoss WS-Security
- ((ConfigProvider) dispatch).setSecurityConfig(mcf.getWsSecurityConfigURL());
- ((ConfigProvider) dispatch).setConfigName(mcf.getWsSecurityConfigName());
}
return dispatch;
}
Modified:
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
===================================================================
---
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-02
16:55:47 UTC (rev 2520)
@@ -21,8 +21,16 @@
*/
package org.teiid.resource.adapter.ws;
+import java.util.List;
+
import javax.resource.ResourceException;
+import javax.xml.namespace.QName;
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
import org.teiid.core.BundleUtil;
import org.teiid.resource.spi.BasicConnection;
import org.teiid.resource.spi.BasicConnectionFactory;
@@ -43,8 +51,26 @@
private String authPassword; // httpbasic - password
private String authUserName; // httpbasic - username
+ private Bus bus;
+ private QName portQName;
+ private List<Interceptor> outInterceptors;
+
@Override
public BasicConnectionFactory createConnectionFactory() throws ResourceException {
+ String configName = getWsSecurityConfigName();
+ if (configName == null) {
+ configName = WSConnectionImpl.DEFAULT_LOCAL_NAME;
+ }
+ this.portQName = new QName(WSConnectionImpl.DEFAULT_NAMESPACE_URI, configName);
+ if (wsSecurityConfigURL != null) {
+ bus = new SpringBusFactory().createBus(wsSecurityConfigURL);
+ JaxWsClientFactoryBean instance = new JaxWsClientFactoryBean();
+ Configurer configurer = bus.getExtension(Configurer.class);
+ if (null != configurer) {
+ configurer.configureBean(portQName.toString() +
".jaxws-client.proxyFactory", instance); //$NON-NLS-1$
+ }
+ outInterceptors = instance.getOutInterceptors();
+ }
return new BasicConnectionFactory() {
@Override
public BasicConnection getConnection() throws ResourceException {
@@ -101,4 +127,16 @@
this.wsSecurityConfigName = wsSecurityConfigName;
}
+ public Bus getBus() {
+ return bus;
+ }
+
+ public QName getPortQName() {
+ return portQName;
+ }
+
+ public List<Interceptor> getOutInterceptors() {
+ return outInterceptors;
+ }
+
}
Modified: branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-02
14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-02
16:55:47 UTC (rev 2520)
@@ -66,13 +66,13 @@
</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>
+ <description>{$display:"URL to the WS-Security Configuration
File(typically jbossws-cxf.xml)",$description:"CXF 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>
+ <description>{$display:"WS-Security Configuration
Name",$description:"Local name of the QName of the port configuration to use
with this connection. The port namespace URI should be
http://teiid.org"}</description>
<config-property-name>WsSecurityConfigName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
Added:
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
===================================================================
---
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
(rev 0)
+++
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java 2010-09-02
16:55:47 UTC (rev 2520)
@@ -0,0 +1,128 @@
+/*
+ * 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.translator.ws;
+
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.activation.DataSource;
+import javax.sql.rowset.serial.SerialClob;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.WSConnection;
+
+/**
+ * http handler
+ */
+public class BinaryWSProcedureExecution implements ProcedureExecution {
+
+ RuntimeMetadata metadata;
+ ExecutionContext context;
+ private Call procedure;
+ private DataSource returnValue;
+ private WSConnection conn;
+ WSExecutionFactory executionFactory;
+
+ /**
+ * @param env
+ */
+ public BinaryWSProcedureExecution(Call procedure, RuntimeMetadata metadata,
ExecutionContext context, WSExecutionFactory executionFactory, WSConnection conn) {
+ this.metadata = metadata;
+ this.context = context;
+ this.procedure = procedure;
+ this.conn = conn;
+ this.executionFactory = executionFactory;
+ }
+
+ public void execute() throws TranslatorException {
+ List<Argument> arguments = this.procedure.getArguments();
+
+ String method = (String)arguments.get(0).getArgumentValue().getValue();
+ Object payload = arguments.get(1).getArgumentValue().getValue();
+ String endpoint = (String)arguments.get(2).getArgumentValue().getValue();
+ try {
+ Dispatch<DataSource> dispatch =
conn.createDispatch(HTTPBinding.HTTP_BINDING, endpoint, DataSource.class, Mode.MESSAGE);
+
+ if (method == null) {
+ method = "POST"; //$NON-NLS-1$
+ }
+
+ dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, method);
+ if (payload != null && !"POST".equalsIgnoreCase(method)) {
//$NON-NLS-1$
+ throw new
WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error"));
//$NON-NLS-1$
+ }
+
+ DataSource ds = null;
+ if (payload instanceof String) {
+ ds = new InputStreamFactory.ClobInputStreamFactory(new
SerialClob(((String)payload).toCharArray()));
+ } else if (payload instanceof SQLXML) {
+ ds = new InputStreamFactory.SQLXMLInputStreamFactory((SQLXML)payload);
+ } else if (payload instanceof Clob) {
+ ds = new InputStreamFactory.ClobInputStreamFactory((Clob)payload);
+ } else if (payload instanceof Blob) {
+ ds = new InputStreamFactory.BlobInputStreamFactory((Blob)payload);
+ }
+
+ returnValue = dispatch.invoke(ds);
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ } catch (WebServiceException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ return null;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ //TODO: this blob should bet buffered
+ return Arrays.asList(returnValue, returnValue.getContentType());
+ }
+
+ public void close() {
+
+ }
+
+ public void cancel() throws TranslatorException {
+ // no-op
+ }
+}
Property changes on:
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
===================================================================
---
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-02
16:55:47 UTC (rev 2520)
@@ -52,6 +52,8 @@
@Translator(name="ws", description="A translator for making Web Service
calls")
public class WSExecutionFactory extends ExecutionFactory<ConnectionFactory,
WSConnection> {
+ private static final String INVOKE_HTTP = "invokeHttp"; //$NON-NLS-1$
+
public enum Binding {
HTTP(HTTPBinding.HTTP_BINDING),
SOAP11(SOAPBinding.SOAP11HTTP_BINDING),
@@ -104,6 +106,9 @@
@Override
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext
executionContext, RuntimeMetadata metadata, WSConnection connection)
throws TranslatorException {
+ if (command.getProcedureName().equalsIgnoreCase(INVOKE_HTTP)) {
+ return new BinaryWSProcedureExecution(command, metadata, executionContext, this,
connection);
+ }
return new WSProcedureExecution(command, metadata, executionContext, this,
connection);
}
@@ -140,11 +145,11 @@
param.setNullType(NullType.Nullable);
metadataFactory.addProcedureParameter("result",
TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, p); //$NON-NLS-1$
- /*
+
p = metadataFactory.addProcedure(INVOKE_HTTP);
p.setAnnotation("Invokes a webservice that returns an binary result");
//$NON-NLS-1$
- param = metadataFactory.addProcedureParameter("method",
TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param = metadataFactory.addProcedureParameter("action",
TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
param.setAnnotation("Sets the HTTP Method (GET, POST - default, etc.).");
//$NON-NLS-1$
param.setNullType(NullType.Nullable);
@@ -159,7 +164,6 @@
metadataFactory.addProcedureParameter("result",
TypeFacility.RUNTIME_NAMES.BLOB, Type.ReturnValue, p); //$NON-NLS-1$
metadataFactory.addProcedureParameter("contentType",
TypeFacility.RUNTIME_NAMES.STRING, Type.Out, p); //$NON-NLS-1$
- */
}
}
Modified:
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
===================================================================
---
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-02
16:55:47 UTC (rev 2520)
@@ -83,7 +83,7 @@
String style = (String)arguments.get(0).getArgumentValue().getValue();
String action = (String)arguments.get(1).getArgumentValue().getValue();
XMLType docObject = (XMLType)arguments.get(2).getArgumentValue().getValue();
- Source source = null;
+ StreamSource source = null;
try {
source = convertToSource(docObject);
String endpoint = (String)arguments.get(3).getArgumentValue().getValue();
@@ -99,7 +99,7 @@
}
}
- Dispatch<Source> dispatch = conn.createDispatch(style, endpoint,
Source.class, executionFactory.getDefaultServiceMode());
+ Dispatch<StreamSource> dispatch = conn.createDispatch(style, endpoint,
StreamSource.class, executionFactory.getDefaultServiceMode());
if (Binding.HTTP.getBindingId().equals(style)) {
if (action == null) {
Modified:
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
===================================================================
---
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml 2010-09-02
16:55:47 UTC (rev 2520)
@@ -47,6 +47,35 @@
</orderedlist>
</section>
<section>
+ <title>CXF Installation</title>
+ <para>The usage of CXF is expected for utilizing Salesforce and Web Services
connectivity through Teiid. If you do not plan on integrating either of these features,
then you may leave JBoss AS with the default "native" web services
stack.</para>
+ <orderedlist>
+ <listitem>
+ <para>Download <ulink
url="http://www.jboss.org/jbossws/downloads/">JBossWS-CXF 3.1.2</ulink>
and unzip to a temporary location.</para>
+ </listitem>
+ <listitem>
+ <para>From the jbossws-cxf-bin-dist directory, save the
ant.properties.example file as ant.properties and change the values for jboss510.home,
jbossws.integration.target, jboss.server.instance, jboss.bind.address accordingly:
+ <programlisting>
+...
+jboss510.home=<jboss-install>
+
+# The JBoss server under test. This can be [jboss500|jboss501|jboss510|jboss600]
+jbossws.integration.target=jboss510
+
+# The JBoss settings
+jboss.server.instance=<profile>
+jboss.bind.address=<bind address>
+</programlisting> The jboss-install location should be the root directory of your
AS installation, profile (typically default) should indicate the profile selected for your
Teiid installation, and the bind address should be the bind address used when launching
JBoss AS (use the value localhost if you do not set the bind address when launching JBoss
AS).</para>
+ </listitem>
+ <listitem>
+ <para>From the jbossws-cxf-bin-dist directory, install JBossWS-CXF by
running the ANT build script: <programlisting>$ant
deploy-jboss510</programlisting></para>
+ </listitem>
+ <listitem>
+ <para>Optionally run tests to verify that there are no errors with the
installation: <programlisting>$ant tests</programlisting></para>
+ </listitem>
+ </orderedlist>
+ </section>
+ <section>
<title>Directory Structure Explained</title>
<example>
<title>Directory Structure</title>
Modified:
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
---
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02
16:55:47 UTC (rev 2520)
@@ -53,21 +53,32 @@
<section>
<title>Deploying VDB Dependencies</title>
<para>Apart from deploying the VDB, the user is also responsible for
providing all the necessary
- dependent libraries, configuration for creating the data sources that are needed
by the Schemas (models)
- defined in "META-INF/vdb.xml" file inside your VDB. This section shows
you a sample VDB configuration needed.</para>
+ dependent libraries, configuration for creating the data sources that are needed
by the models (schemas)
+ defined in "META-INF/vdb.xml" file inside your VDB. For example, if
you are trying to integrate Oracle and File sources in your VDB, then you are responsible
for
+ providing the JDBC driver for the Oracle source and any necessary documents and
configuration that are needed by the File Translator.</para>
- <para>For example, if you are trying to integrate Oracle and File sources
in your VDB, then you are responsible for
- providing the JDBC driver for the Oracle source, and any necessary documents and
configuration that are needed by the File Translator.</para>
+ <para>Data source instances may be used by only one VDB, or may be shared
with as many VDBs or other applications as makes since for your deployments.
+ Consider sharing connections to sources that have heavy-weight and resource
constrained connections.</para>
- <para>Once the VDB and its dependencies are deployed, then client
applications can connect using the JDBC API. If there are any errors in the deployment, a
connection attempt will not be successful and a message will be logged. You can use the
- <link linkend="admin-console">admin-console</link> tool or
check the log files for errors and correct them before proceeding.</para>
+ <para>With the exception of JDBC, each of the data sources supported by has
a corresponding .rar (zip format) file in
<jboss-install>/server/<profile>/deploy/teiid/connectors.
+ If not using JOPR or other tooling to create your -ds.xml files, you can consult
the .rar files META-INF/ra.xml for a full description of how the source can be configured.
+ </para>
+ <para>Some -ds.xml files may contain passwords or other sensitive
information.
+ See the WIKI article <ulink
url="http://community.jboss.org/wiki/EncryptingDataSourcePasswords&q...
to not store passwords in plain text.</para>
+
+ <para>Once the VDB and its dependencies are deployed, then client
applications can connect using the JDBC API. If there are any errors in the deployment, a
connection attempt will not be successful and a message will be logged.
+ You can use the <link
linkend="admin-console">admin-console</link> tool or check the log
files for errors and correct them before proceeding.</para>
+
<section>
- <title>Creating An Oracle Data Source</title>
+ <title>JDBC Data Sources</title>
+ <para>The following is an example highlighting configuring an Oracle
data source. The process is nearly identical regardless of the vendor.
+ Typically only the client jar and the setting in the -ds.xml file
change.</para>
+ <para>There are templates for all the data sources in the
"<jboss-install>/docs/examples/jca" directory.</para>
<orderedlist>
<listitem> <para>Copy the Oracle JDBC JAR file into
"<jboss-install>/server/<profile>/lib" directory
</para> </listitem>
<listitem> <para>Create a "data source" to the
Oracle instance in the JBoss container. This typically
- done by creating "xxx-ds.xml" file and copying this file to the
"<jboss-install>/server/%lt;profile>/deploy"
+ done by creating "xxx-ds.xml" file and copying this file to the
"<jboss-install>/server/<profile>/deploy"
directory. The following shows a "-ds.xml" file template for
Oracle. You can also use admin-console to create this data source. </para>
<programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
<datasources>
@@ -99,26 +110,140 @@
</datasources>]]></programlisting>
</listitem>
</orderedlist>
- <para>There are templates for all the data sources in the
"<jboss-install>/docs/examples/jca" directory.</para>
</section>
<section>
- <title>Creating A File Data Source</title>
- <para>File data source uses Teiid specific JCA connector. You need to
create "-ds.xml" file and copy it to the
- "<jboss-install>/server/%lt;profile>/deploy"
directory.</para>
+ <title>File Data Sources</title>
+ <para>File data sources use a Teiid specific JCA connector. You need to
create "-ds.xml" file and copy it to the
+
"<jboss-install>/server/<profile>/deploy"
directory.</para>
<example>
<title>Template for creating a File based data source</title>
<programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
<connection-factories>
<no-tx-connection-factory>
<jndi-name>text-source</jndi-name>
- <rar-name>connector-file-{version}.rar</rar-name>
+ <rar-name>teiid-connector-file.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
- <config-property name="ParentDirectory"
type="java.lang.String">path-to-the-directory-of-data-file</config-property>
- <max-pool-size>1</max-pool-size>
- </no-tx-connection-factory>
+ <config-property
name="ParentDirectory">path-to-the-directory-of-data-file</config-property>
+ </no-tx-connection-factory>
</connection-factories>]]></programlisting></example>
</section>
+
+ <section>
+ <title>Web Service Data Sources</title>
+ <para>Web service data sources use a Teiid specific JCA connector. You
need to create "-ds.xml" file and copy it to the
+
"<jboss-install>/server/<profile>/deploy"
directory.</para>
+ <example>
+ <title>Template for creating a web service based data
source</title>
+ <programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property
name="EndPoint">http://somewhere.com</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ <section>
+ <title>WS-Security</title>
+
+ <para>To enable the use of WS-Security, the
<code>SecurityType</code> should be set to WSSecurity.
+ The <code>WsSecurityConfigURL</code> config property may then be used to
supply the Spring XML configuration
+ file for the CXF Bus and port configuration to be used by these connections. At this
time however, Teiid does not expect or use
+ a WSDL to describe the service being used. Thus the Spring XML configuration file is
not an adjunct
+ to policy information in the WSDL, it must instead contain all of the relevant policy
configuration. It is also expected that only
+ 1 port configuration will be used by this data source. You may explicitly set the
local name of the port QName to use via the
+ <code>WsSecurityConfigName</code>. The namespace URI for the QName
should be
http://teiid.org.</para>
+
+ <example>
+ <title>Example web service based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property
name="EndPoint">http://somewhere.com</config-property>
+ <config-property
name="WsSecurityConfigURL">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
+ <config-property
name="WsSecurityConfigName">port_x</config-property>
+ <config-property
name="SecurityType">WSSecurity</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting>
+<para>Corresponding xxx-jbossws-cxf.xml file that adds a timestamp to the SOAP
header</para>
+<programlisting><![CDATA[<beans
xmlns="http://www.springframework.org/schema/beans"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xmlns:jaxws="http://cxf.apache.org/jaxws"
+
xsi:schemaLocation="http://www.springframework.org/schema/beans
+
http://www.springframework.org/schema/beans/spring-beans.xsd
+
http://cxf.apache.org/jaxws
+
http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <jaxws:client name="{http://teiid.org}port_x"
+ createdFromAPI="true">
+ <jaxws:outInterceptors>
+ <bean
class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="Timestamp_Request"/>
+ </jaxws:outInterceptors>
+ </jaxws:client>
+
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+ id="Timestamp_Request">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp"/>
+ <map>
+ </constructor-arg>
+ </bean>
+
+</beans>]]></programlisting>
+ <para>Note that the client port configuration is matched to the data source
instance by the QName {http://teiid.org}port_x.
+ The configuration may contain other port confiruations with different local
names.</para>
+</example>
+ <para>For more information on configuring CXF interceptors,
+ please consult the <ulink
url="https://cwiki.apache.org/CXF20DOC/ws-security.html">CXF
documentation</ulink> or
+ the <ulink
url="http://community.jboss.org/wiki/JBossWS-StackCXFUserGuide#WSSec...
documentation</ulink>.</para>
+ </section>
+ </section>
+
+ <section>
+ <title>Salesforce Data Sources</title>
+ <para>Salesforce data sources use a Teiid specific JCA connector. You need
to create "-ds.xml" file and copy it to the
+
"<jboss-install>/server/<profile>/deploy"
directory.</para>
+ <example>
+ <title>Template for creating a Salesforce based data
source</title>
+ <programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>sf-source</jndi-name>
+ <rar-name>teiid-connector-salesforce.rar</rar-name>
+
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property
name="URL">https://test.salesforce.com/services/Soap/u/10.0&...
+ <config-property name="username">username</config-property>
+ <config-property name="password">password</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ </section>
+
+ <section>
+ <title>LDAP Data Sources</title>
+ <para>LDAP data sources use a Teiid specific JCA connector. You need to
create "-ds.xml" file and copy it to the
+
"<jboss-install>/server/<profile>/deploy"
directory.</para>
+ <example>
+ <title>Template for creating an LDAP based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>ldap-source</jndi-name>
+ <rar-name>teiid-connector-ldap.rar</rar-name>
+
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property
name="LdapAdminUserDN">cn=x,ou=y,dc=z</config-property>
+ <config-property
name="LdapAdminUserPassword">password</config-property>
+ <config-property
name="LdapUrl">ldap://ldapServer:389</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ </section>
+
</section>
<section id="vdb-versioning">
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-09-02
14:38:11 UTC (rev 2519)
+++
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-09-02
16:55:47 UTC (rev 2520)
@@ -48,8 +48,6 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import javax.xml.transform.Source;
-
import org.teiid.common.buffer.BatchManager;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.FileStore;
@@ -60,20 +58,13 @@
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.BatchManager.ManagedBatch;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.SQLXMLImpl;
-import org.teiid.core.types.SourceTransform;
-import org.teiid.core.types.StandardXMLTranslator;
-import org.teiid.core.types.XMLType;
import org.teiid.core.util.Assertion;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.execution.QueryExecPlugin;
import org.teiid.query.processor.relational.ListNestedSortComparator;
-import org.teiid.query.processor.xml.XMLUtil;
/**
@@ -502,25 +493,7 @@
@Override
public void initialize() throws TeiidComponentException {
- //TODO: remove me - connectors should be able to do this statefully
- DataTypeManager.addSourceTransform(Source.class, new SourceTransform<Source,
XMLType>() {
- @Override
- public XMLType transform(Source value) {
- if (value instanceof InputStreamFactory) {
- return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
- }
- StandardXMLTranslator sxt = new StandardXMLTranslator(value);
- SQLXMLImpl sqlxml;
- try {
- sqlxml = XMLUtil.saveToBufferManager(BufferManagerImpl.this, sxt);
- } catch (TeiidComponentException e) {
- throw new TeiidRuntimeException(e);
- } catch (TeiidProcessingException e) {
- throw new TeiidRuntimeException(e);
- }
- return new XMLType(sqlxml);
- }
- });
+
}
@Override