AXIS2-5434: Removed modules that have been integrated into Axis2 core.
diff --git a/modules/base/pom.xml b/modules/base/pom.xml
deleted file mode 100644
index 31a11f0..0000000
--- a/modules/base/pom.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transports</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
- <name>Apache Axis2 - Transport - Base</name>
- <description>Apache Axis2 - Base Transport</description>
- <packaging>bundle</packaging>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/base</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/base</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/base</url>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
- <Bundle-Description>${project.description}</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.apache.axis2.transport.base.*;-split-package:=merge-last,
- org.apache.axis2.format.*;-split-package:=merge-last,
- </Export-Package>
- <Import-Package>
- !javax.xml.namespace,
- javax.xml.namespace; version=0.0.0,
- *;resolution:=optional,
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
- <!-- Axis2 -->
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-kernel</artifactId>
- <version>${axis2.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.0</version>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <version>1.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/modules/base/src/main/java/org/apache/axis2/format/BinaryBuilder.java b/modules/base/src/main/java/org/apache/axis2/format/BinaryBuilder.java
deleted file mode 100644
index cd5c3e5..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/BinaryBuilder.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.Parameter;
-import org.apache.commons.io.IOUtils;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.BaseUtils;
-
-/**
- * Message builder for binary payloads.
- * <p>
- * This builder processes the input message as binary and wraps
- * the data in a wrapper element. The name of the wrapper element can
- * be configured as a service parameter (see {@link BaseConstants#WRAPPER_PARAM}).
- * It defaults to {@link BaseConstants#DEFAULT_BINARY_WRAPPER}.
- */
-public class BinaryBuilder implements DataSourceMessageBuilder {
- public OMElement processDocument(DataSource dataSource,
- String contentType,
- MessageContext msgContext) throws AxisFault {
- QName wrapperQName = BaseConstants.DEFAULT_BINARY_WRAPPER;
- if (msgContext.getAxisService() != null) {
- Parameter wrapperParam = msgContext.getAxisService().getParameter(BaseConstants.WRAPPER_PARAM);
- if (wrapperParam != null) {
- wrapperQName = BaseUtils.getQNameFromString(wrapperParam.getValue());
- }
- }
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMElement wrapper = factory.createOMElement(wrapperQName, null);
- DataHandler dataHandler = new DataHandler(dataSource);
- wrapper.addChild(factory.createOMText(dataHandler, true));
- msgContext.setDoingMTOM(true);
- return wrapper;
- }
-
- public OMElement processDocument(InputStream inputStream,
- String contentType,
- MessageContext msgContext) throws AxisFault {
- // TODO: this could be further optimized by deferring the read operation
- byte[] msgBytes;
- try {
- msgBytes = IOUtils.toByteArray(inputStream);
- } catch (IOException ex) {
- throw new AxisFault("Unable to read message payload", ex);
- }
- return processDocument(new ByteArrayDataSource(msgBytes), contentType, msgContext);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java b/modules/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java
deleted file mode 100644
index 7e40dc5..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URL;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.OMText;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.http.util.URLTemplatingUtil;
-import org.apache.axis2.transport.base.BaseConstants;
-
-public class BinaryFormatter implements MessageFormatterEx {
- public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- writeTo(messageContext, format, baos, true);
- return baos.toByteArray();
- }
-
- private DataHandler getDataHandler(MessageContext messageContext) {
- OMElement firstChild = messageContext.getEnvelope().getBody().getFirstElement();
- if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) {
- OMNode omNode = firstChild.getFirstOMChild();
- if (omNode != null && omNode instanceof OMText) {
- Object dh = ((OMText)omNode).getDataHandler();
- if (dh != null && dh instanceof DataHandler) {
- return (DataHandler)dh;
- }
- }
- }
- return null;
- }
-
- public void writeTo(MessageContext messageContext, OMOutputFormat format,
- OutputStream outputStream, boolean preserve) throws AxisFault {
- DataHandler dh = getDataHandler(messageContext);
- if (dh != null) {
- try {
- dh.writeTo(outputStream);
- } catch (IOException e) {
- throw new AxisFault("Error serializing binary content of element : " +
- BaseConstants.DEFAULT_BINARY_WRAPPER, e);
- }
- }
- }
-
- public String getContentType(MessageContext messageContext,
- OMOutputFormat format, String soapAction) {
- DataHandler dh = getDataHandler(messageContext);
- if (dh != null) {
- return dh.getContentType();
- } else {
- return null;
- }
- }
-
- public URL getTargetAddress(MessageContext messageContext,
- OMOutputFormat format, URL targetURL) throws AxisFault {
- return URLTemplatingUtil.getTemplatedURL(targetURL, messageContext, false);
- }
-
- public String formatSOAPAction(MessageContext messageContext,
- OMOutputFormat format, String soapAction) {
- return null;
- }
-
- public DataSource getDataSource(MessageContext messageContext,
- OMOutputFormat format, String soapAction) throws AxisFault {
- return getDataHandler(messageContext).getDataSource();
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java b/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java
deleted file mode 100644
index ddbf69e..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import javax.activation.DataSource;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.builder.Builder;
-import org.apache.axis2.context.MessageContext;
-
-/**
- * Message builder able to build messages from {@link DataSource} objects.
- * This interface can be optionally implemented by {@link Builder}
- * implementations that support building messages from {@link DataSource} objects.
- * Since by definition the data from a {@link DataSource} can be read multiple
- * times, this interface can be used by message builders to avoid storing the
- * message content in memory.
- * <p>
- * If a message builder implements this interface and the transport is able to
- * provide the message payload as a data source, then the method defined by this
- * interface should be preferred over the method defined by {@link Builder}.
- * <p>
- * Implementing this interface helps optimizing message processing with transports
- * that use messaging providers that store messages in memory or on the file system.
- * Examples are JMS and VFS.
- * <p>
- * The builder will typically expose the data source directly or indirectly through
- * the returned {@link OMElement}, e.g. by adding to the tree an {@link org.apache.axiom.om.OMText}
- * or {@link org.apache.axiom.om.OMDataSource} node referencing the data source.
- * This means that the builder will not be able to guarantee that all streams requested
- * from the data source are properly closed. Note that code accessing the returned
- * {@link OMElement} can't be expected to take care of this since in many cases the fact
- * that a data source is being used is completely transparent to that code.
- * It is therefore the responsibility of the transport to make sure that all resources linked to
- * the data source itself as well as any open stream requested from that data source are properly
- * released after the message has been processed. Depending on the type of transport, there are
- * three possible cases:
- * <ol>
- * <li>All resources allocated to the data source or streams requested from it are
- * memory based. In that case the garbage collector will take care of freeing
- * these resources and the transport should simply pass the data source object
- * to the builder.</li>
- * <li>There are operation system resources linked to the data source and open
- * streams will become invalid when these resources are freed, i.e.
- * it is not required that all streams be closed explicitly.
- * In this case the transport only needs to take care to properly dispose of
- * the data source after the message has been processed by the Axis2 engine.</li>
- * <li>Requesting a stream from the data source allocates operation system resources
- * (e.g. a network connection) that remain linked to the stream, i.e. all streams requested
- * from the data source must be closed properly. In that case the transport should use
- * {@link ManagedDataSourceFactory#create(DataSource)} to wrap the original data source
- * before passing it to the builder. After the message has been processed it should
- * then call {@link ManagedDataSource#destroy()} on the wrapper to close all remaining
- * open streams.</li>
- * </ol>
- */
-public interface DataSourceMessageBuilder extends Builder {
- public OMElement processDocument(DataSource dataSource, String contentType,
- MessageContext messageContext) throws AxisFault;
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java b/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java
deleted file mode 100644
index f72d7e9..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import javax.activation.DataSource;
-
-/**
- * Managed data source.
- * This type of data source keeps track of the streams that have been
- * requested using {@link DataSource#getInputStream()} and allows to
- * forcibly close these streams. Any existing data source can be converted
- * to a managed data source using {@link ManagedDataSourceFactory#create(DataSource)}.
- */
-public interface ManagedDataSource extends DataSource {
- /**
- * Close all streams that have been requested from this data source
- * and that are not yet closed.
- */
- void destroy();
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java b/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java
deleted file mode 100644
index d27024c..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.activation.DataSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Utility class to create {@link ManagedDataSource} objects.
- */
-public class ManagedDataSourceFactory {
- private static class ManagedInputStream extends FilterInputStream {
- private DataSourceManager manager;
-
- public ManagedInputStream(DataSourceManager manager, InputStream parent) {
- super(parent);
- this.manager = manager;
- }
-
- @Override
- public void close() throws IOException {
- if (manager != null) {
- manager.notifyStreamClosed(this);
- manager = null;
- }
- super.close();
- }
- }
-
- private static class DataSourceManager implements InvocationHandler {
- private static final Log log = LogFactory.getLog(DataSourceManager.class);
-
- private static final Method getInputStreamMethod;
- private static final Method destroyMethod;
-
- static {
- try {
- getInputStreamMethod = DataSource.class.getMethod("getInputStream");
- destroyMethod = ManagedDataSource.class.getMethod("destroy");
- } catch (NoSuchMethodException ex) {
- throw new NoSuchMethodError(ex.getMessage());
- }
- }
-
- private final DataSource dataSource;
- private final List<ManagedInputStream> openStreams = Collections.synchronizedList(
- new LinkedList<ManagedInputStream>());
-
- public DataSourceManager(DataSource dataSource) {
- this.dataSource = dataSource;
- }
-
- public void notifyStreamClosed(ManagedInputStream managedInputStream) {
- if (!openStreams.remove(managedInputStream)) {
- throw new IllegalStateException();
- }
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- try {
- if (method.equals(getInputStreamMethod)) {
- InputStream in = (InputStream)method.invoke(dataSource, args);
- ManagedInputStream in2 = new ManagedInputStream(this, in);
- openStreams.add(in2);
- return in2;
- } else if (method.equals(destroyMethod)) {
- while (!openStreams.isEmpty()) {
- try {
- openStreams.get(0).close();
- } catch (IOException ex) {
- log.warn("Exception when closing open stream from managed data source", ex);
- }
- }
- return null;
- } else {
- return method.invoke(dataSource, args);
- }
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- }
- }
-
- }
-
- /**
- * Create a {@link ManagedDataSource} proxy for an existing data source.
- * This will create a dynamic proxy implementing the same interfaces as
- * the original data source.
- *
- * @param ds the original data source
- * @return a data source proxy implementing {@link ManagedDataSource}
- */
- public static ManagedDataSource create(DataSource ds) {
- Class<?>[] orgIfaces = ds.getClass().getInterfaces();
- Class<?>[] ifaces = new Class[orgIfaces.length+1];
- ifaces[0] = ManagedDataSource.class;
- System.arraycopy(orgIfaces, 0, ifaces, 1, orgIfaces.length);
- return (ManagedDataSource)Proxy.newProxyInstance(
- ManagedDataSourceFactory.class.getClassLoader(), ifaces,
- new DataSourceManager(ds));
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/MessageFormatterEx.java b/modules/base/src/main/java/org/apache/axis2/format/MessageFormatterEx.java
deleted file mode 100644
index aee5acb..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/MessageFormatterEx.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import javax.activation.DataSource;
-
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.MessageFormatter;
-
-/**
- * Message formatter with extended capabilities.
- * This interface adds new methods to the {@link MessageFormatter}
- * interface, allowing transport to optimize data transfers.
- */
-public interface MessageFormatterEx extends MessageFormatter {
- /**
- * Get the formatted message as a {@link DataSource} object.
- *
- * @param messageContext
- * @param format
- * @param soapAction
- * @return
- * @throws AxisFault
- */
- DataSource getDataSource(MessageContext messageContext, OMOutputFormat format, String soapAction) throws AxisFault;
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/MessageFormatterExAdapter.java b/modules/base/src/main/java/org/apache/axis2/format/MessageFormatterExAdapter.java
deleted file mode 100644
index a802e2f..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/MessageFormatterExAdapter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.OutputStream;
-import java.net.URL;
-
-import javax.activation.DataSource;
-
-import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.MessageFormatter;
-
-/**
- * Adapter to add the {@link MessageFormatterEx} interface to an
- * existing {@link MessageFormatter}.
- * It implements the {@link MessageFormatterEx#getDataSource(MessageContext, OMOutputFormat, String)} method
- * using {@link MessageFormatter#getBytes(MessageContext, OMOutputFormat)} and
- * {@link MessageFormatter#getContentType(MessageContext, OMOutputFormat, String)}.
- */
-public class MessageFormatterExAdapter implements MessageFormatterEx {
- private final MessageFormatter messageFormatter;
-
- public MessageFormatterExAdapter(MessageFormatter messageFormatter) {
- this.messageFormatter = messageFormatter;
- }
-
- public DataSource getDataSource(MessageContext messageContext,
- OMOutputFormat format,
- String soapAction) throws AxisFault {
- return new ByteArrayDataSource(
- getBytes(messageContext, format),
- getContentType(messageContext, format, soapAction));
- }
-
- public String formatSOAPAction(MessageContext messageContext,
- OMOutputFormat format,
- String soapAction) {
- return messageFormatter.formatSOAPAction(messageContext, format, soapAction);
- }
-
- public byte[] getBytes(MessageContext messageContext,
- OMOutputFormat format) throws AxisFault {
- return messageFormatter.getBytes(messageContext, format);
- }
-
- public String getContentType(MessageContext messageContext,
- OMOutputFormat format,
- String soapAction) {
- return messageFormatter.getContentType(messageContext, format, soapAction);
- }
-
- public URL getTargetAddress(MessageContext messageContext,
- OMOutputFormat format,
- URL targetURL) throws AxisFault {
- return messageFormatter.getTargetAddress(messageContext, format, targetURL);
- }
-
- public void writeTo(MessageContext messageContext,
- OMOutputFormat format,
- OutputStream outputStream,
- boolean preserve) throws AxisFault {
- messageFormatter.writeTo(messageContext, format, outputStream, preserve);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java b/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java
deleted file mode 100644
index 38a532f..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-
-import javax.activation.DataSource;
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromDataSource;
-import org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.builder.BuilderUtil;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.BaseUtils;
-
-/**
- * Message builder for plain text payloads.
- * <p>
- * This builder processes the input message as plain text and wraps
- * the text in a wrapper element. The name of the wrapper element can
- * be configured as a service parameter (see {@link BaseConstants#WRAPPER_PARAM}).
- * It defaults to {@link BaseConstants#DEFAULT_TEXT_WRAPPER}.
- * If the content is provided as an {@link InputStream} and the content type specifies a
- * <tt>charset</tt> parameter (e.g. <tt>text/plain; charset=ISO-8859-15</tt>),
- * this information is used to decode the text.
- * If the content is provided as an {@link InputStream} but no <tt>charset</tt> parameter
- * is specified on the content type, the default charset encoding specified by
- * {@link MessageContext#DEFAULT_CHAR_SET_ENCODING} is used.
- */
-public class PlainTextBuilder implements TextMessageBuilder, DataSourceMessageBuilder {
- private static QName getWrapperQName(MessageContext msgContext) {
- QName wrapperQName = BaseConstants.DEFAULT_TEXT_WRAPPER;
- if (msgContext.getAxisService() != null) {
- Parameter wrapperParam
- = msgContext.getAxisService().getParameter(BaseConstants.WRAPPER_PARAM);
- if (wrapperParam != null) {
- wrapperQName = BaseUtils.getQNameFromString(wrapperParam.getValue());
- }
- }
- return wrapperQName;
- }
-
- public OMElement processDocument(InputStream inputStream,
- String contentType,
- MessageContext msgContext) throws AxisFault {
-
- OMFactory factory = OMAbstractFactory.getOMFactory();
- String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
- QName wrapperQName = getWrapperQName(msgContext);
- Reader reader;
- try {
- reader = new InputStreamReader(inputStream, charSetEnc);
- } catch (UnsupportedEncodingException ex) {
- throw new AxisFault("Unsupported encoding: " + charSetEnc, ex);
- }
- return factory.createOMElement(new WrappedTextNodeOMDataSourceFromReader(wrapperQName,
- reader), wrapperQName);
- }
-
- public OMElement processDocument(Reader reader,
- String contentType,
- MessageContext msgContext) throws AxisFault {
-
- OMFactory factory = OMAbstractFactory.getOMFactory();
- QName wrapperQName = getWrapperQName(msgContext);
- return factory.createOMElement(new WrappedTextNodeOMDataSourceFromReader(wrapperQName,
- reader), wrapperQName);
- }
-
- public OMElement processDocument(String content,
- String contentType,
- MessageContext msgContext) throws AxisFault {
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMElement wrapper = factory.createOMElement(getWrapperQName(msgContext), null);
- factory.createOMText(wrapper, content);
- return wrapper;
- }
-
- public OMElement processDocument(DataSource dataSource,
- String contentType,
- MessageContext msgContext) throws AxisFault {
-
- OMFactory factory = OMAbstractFactory.getOMFactory();
- Charset cs = Charset.forName(BuilderUtil.getCharSetEncoding(contentType));
- QName wrapperQName = getWrapperQName(msgContext);
- return factory.createOMElement(new WrappedTextNodeOMDataSourceFromDataSource(wrapperQName,
- dataSource, cs), wrapperQName);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/PlainTextFormatter.java b/modules/base/src/main/java/org/apache/axis2/format/PlainTextFormatter.java
deleted file mode 100644
index 51a9726..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/PlainTextFormatter.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.format;
-
-import org.apache.axis2.transport.http.util.URLTemplatingUtil;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.AxisFault;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.ElementHelper;
-import org.apache.axis2.transport.base.BaseConstants;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.net.URL;
-
-import javax.activation.DataSource;
-import javax.xml.stream.XMLStreamException;
-
-public class PlainTextFormatter implements MessageFormatterEx {
-
- public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- writeTo(messageContext, format, baos, true);
- return baos.toByteArray();
- }
-
- public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault {
- OMElement textElt = messageContext.getEnvelope().getBody().getFirstElement();
- if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(textElt.getQName())) {
- try {
- Writer out = new OutputStreamWriter(outputStream, format.getCharSetEncoding());
- ElementHelper.writeTextTo(textElt, out, preserve);
- out.flush();
- } catch (IOException e) {
- throw new AxisFault("Error writing text message to stream", e);
- } catch (XMLStreamException e) {
- throw new AxisFault("Error extracting the text payload from the message", e);
- }
- }
- }
-
- public String getContentType(MessageContext messageContext, OMOutputFormat format, String soapAction) {
- String encoding = format.getCharSetEncoding();
- String contentType = "text/plain";
-
- if (encoding != null) {
- contentType += "; charset=" + encoding;
- }
-
- // if soap action is there (can be there is soap response MEP is used) add it.
- if ((soapAction != null)
- && !"".equals(soapAction.trim())
- && !"\"\"".equals(soapAction.trim())) {
- contentType = contentType + ";action=\"" + soapAction + "\";";
- }
-
- return contentType;
- }
-
- public URL getTargetAddress(MessageContext msgCtxt, OMOutputFormat format, URL targetURL) throws AxisFault {
- // Check whether there is a template in the URL, if so we have to replace then with data
- // values and create a new target URL.
- targetURL = URLTemplatingUtil.getTemplatedURL(targetURL, msgCtxt, false);
- return targetURL;
- }
-
- public String formatSOAPAction(MessageContext messageContext, OMOutputFormat format, String soapAction) {
- return null;
- }
-
- public DataSource getDataSource(MessageContext messageContext,
- OMOutputFormat format, String soapAction) throws AxisFault {
- return new TextFromElementDataSource(
- messageContext.getEnvelope().getBody().getFirstElement(),
- format.getCharSetEncoding(),
- getContentType(messageContext, format, soapAction));
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/TextFromElementDataSource.java b/modules/base/src/main/java/org/apache/axis2/format/TextFromElementDataSource.java
deleted file mode 100644
index 357bad2..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/TextFromElementDataSource.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.activation.DataSource;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.ElementHelper;
-import org.apache.commons.io.input.ReaderInputStream;
-
-/**
- * Data source that represents the text of a given {@link OMElement}.
- * <p>
- * The expression
- * <pre>new TextFromElementDataSource(element, charset, contentType)</pre>
- * produces a DataSource implementation that is equivalent to
- * <pre>new ByteArrayDataSource(element.getText().getBytes(charset), contentType)</pre>
- * but that is more efficient.
- */
-public class TextFromElementDataSource implements DataSource {
- private final OMElement element;
- private final String charset;
- private final String contentType;
-
- public TextFromElementDataSource(OMElement element, String charset, String contentType) {
- this.element = element;
- this.charset = charset;
- this.contentType = contentType;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public String getName() {
- return null;
- }
-
- public InputStream getInputStream() throws IOException {
- return new ReaderInputStream(ElementHelper.getTextAsStream(element, true), charset);
- }
-
- public OutputStream getOutputStream() throws IOException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/TextMessageBuilder.java b/modules/base/src/main/java/org/apache/axis2/format/TextMessageBuilder.java
deleted file mode 100644
index b2b0328..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/TextMessageBuilder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.format;
-
-import java.io.Reader;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.builder.Builder;
-import org.apache.axis2.context.MessageContext;
-
-/**
- * Message builder able to build messages from a character stream.
- * This interface can be optionally implemented by {@link Builder}
- * implementations that support building a message from a character
- * stream.
- * <p>
- * The character stream can either be provided as a string or a
- * {@link Reader} object. The caller should use a {@link Reader} object
- * except if the content of the message is available as a string anyway.
- * <p>
- * This interface is currently used by the JMS transport to process
- * {@link javax.jms.TextMessage} instances.
- */
-public interface TextMessageBuilder extends Builder {
- public OMElement processDocument(Reader reader, String contentType,
- MessageContext messageContext) throws AxisFault;
-
- public OMElement processDocument(String content, String contentType,
- MessageContext messageContext) throws AxisFault;
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/format/TextMessageBuilderAdapter.java b/modules/base/src/main/java/org/apache/axis2/format/TextMessageBuilderAdapter.java
deleted file mode 100644
index e6937af..0000000
--- a/modules/base/src/main/java/org/apache/axis2/format/TextMessageBuilderAdapter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.format;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-
-import javax.mail.internet.ContentType;
-import javax.mail.internet.ParseException;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.builder.Builder;
-import org.apache.axis2.context.MessageContext;
-import org.apache.commons.io.input.ReaderInputStream;
-
-/**
- * Adapter to add the {@link TextMessageBuilder} interface to an
- * existing {@link Builder}.
- * It implements the {@link TextMessageBuilder#processDocument(Reader, String, MessageContext)}
- * and {@link TextMessageBuilder#processDocument(String, String, MessageContext)} by converting
- * the character stream to a byte stream using {@link ReaderInputStream}.
- *
- * TODO: specifying encoding
- */
-public class TextMessageBuilderAdapter implements TextMessageBuilder {
- private final Builder builder;
-
- public TextMessageBuilderAdapter(Builder builder) {
- this.builder = builder;
- }
-
- public OMElement processDocument(InputStream inputStream, String contentType,
- MessageContext messageContext) throws AxisFault {
- return builder.processDocument(inputStream, contentType, messageContext);
- }
-
- public OMElement processDocument(Reader reader, String contentType,
- MessageContext messageContext) throws AxisFault {
- String charset;
- try {
- ContentType ct = new ContentType(contentType);
- charset = ct.getParameter("charset");
- } catch (ParseException ex) {
- charset = null;
- }
- if (charset == null) {
- charset = MessageContext.DEFAULT_CHAR_SET_ENCODING;
- }
- messageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charset);
- return processDocument(new ReaderInputStream(reader, charset), contentType,
- messageContext);
- }
-
- public OMElement processDocument(String content, String contentType,
- MessageContext messageContext) throws AxisFault {
- return processDocument(new StringReader(content), contentType, messageContext);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java b/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java
deleted file mode 100644
index 53c9a8b..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-import java.util.TimerTask;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class AbstractPollTableEntry extends ProtocolEndpoint {
- private static final Log log = LogFactory.getLog(AbstractPollTableEntry.class);
-
- // status of last scan
- public static final int SUCCSESSFUL = 0;
- public static final int WITH_ERRORS = 1;
- public static final int FAILED = 2;
- public static final int NONE = 3;
-
- /** next poll time */
- private long nextPollTime;
- /** last poll performed at */
- private long lastPollTime;
- /** duration in ms between successive polls */
- private long pollInterval;
- /** state of the last poll */
- private int lastPollState;
- /** can polling occur in parallel? */
- private boolean concurrentPollingAllowed = false;
- /** The timer task that will trigger the next poll */
- TimerTask timerTask;
- /** Flag indicating whether polling has been canceled. */
- boolean canceled;
-
- public long getNextPollTime() {
- return nextPollTime;
- }
-
- public void setNextPollTime(long nextPollTime) {
- this.nextPollTime = nextPollTime;
- }
-
- public long getLastPollTime() {
- return lastPollTime;
- }
-
- public void setLastPollTime(long lastPollTime) {
- this.lastPollTime = lastPollTime;
- }
-
- public long getPollInterval() {
- return pollInterval;
- }
-
- public void setPollInterval(long pollInterval) {
- this.pollInterval = pollInterval;
- }
-
- public int getLastPollState() {
- return lastPollState;
- }
-
- public void setLastPollState(int lastPollState) {
- this.lastPollState = lastPollState;
- }
-
- public boolean isConcurrentPollingAllowed() {
- return concurrentPollingAllowed;
- }
-
- public void setConcurrentPollingAllowed(boolean concurrentPollingAllowed) {
- this.concurrentPollingAllowed = concurrentPollingAllowed;
- }
-
- @Override
- public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
- Parameter param = params.getParameter(BaseConstants.TRANSPORT_POLL_INTERVAL);
- pollInterval = BaseConstants.DEFAULT_POLL_INTERVAL;
- if (param != null && param.getValue() instanceof String) {
- String s = (String)param.getValue();
- int multiplier;
- if (s.endsWith("ms")) {
- s = s.substring(0, s.length()-2);
- multiplier = 1;
- } else {
- multiplier = 1000;
- }
- try {
- pollInterval = Integer.parseInt(s) * multiplier;
- } catch (NumberFormatException e) {
- log.error("Invalid poll interval : " + param.getValue() + ", default to : "
- + (BaseConstants.DEFAULT_POLL_INTERVAL / 1000) + "sec", e);
- }
- }
- return true;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java b/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java
deleted file mode 100644
index af113d7..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.AxisFault;
-
-import java.util.TimerTask;
-import java.util.Timer;
-
-public abstract class AbstractPollingTransportListener<T extends AbstractPollTableEntry>
- extends AbstractTransportListenerEx<T> {
-
- /** The main timer. */
- private Timer timer;
-
- @Override
- protected void doInit() throws AxisFault {
- timer = new Timer("PollTimer");
- }
-
- @Override
- public void destroy() {
- super.destroy();
- timer.cancel();
- timer = null;
- }
-
- /**
- * Schedule a repeated poll at the specified interval for a given service.
- * The method will schedule a single-shot timer task with executes a work
- * task on the worker pool. At the end of this work task, a new timer task
- * is scheduled for the next poll (except if the polling for the service
- * has been canceled). This effectively schedules the poll repeatedly
- * with fixed delay.
- * @param entry the poll table entry with the configuration for the service
- * @param pollInterval the interval between successive polls in milliseconds
- */
- void schedulePoll(final T entry) {
- final long pollInterval = entry.getPollInterval();
- TimerTask timerTask = new TimerTask() {
- @Override
- public void run() {
- workerPool.execute(new Runnable() {
- public void run() {
- if (state == BaseConstants.PAUSED) {
- if (log.isDebugEnabled()) {
- log.debug("Transport " + getTransportName() +
- " poll trigger : Transport is currently paused..");
- }
- } else {
- poll(entry);
- }
- }
- });
- }
- };
- entry.timerTask = timerTask;
- if (entry.isConcurrentPollingAllowed()) {
- timer.scheduleAtFixedRate(timerTask, pollInterval, pollInterval);
- } else {
- timer.schedule(timerTask, pollInterval);
- }
- }
-
- @Override
- protected void startEndpoint(T endpoint) throws AxisFault {
- schedulePoll(endpoint);
- }
-
- @Override
- protected void stopEndpoint(T endpoint) {
- synchronized (endpoint) {
- endpoint.timerTask.cancel();
- endpoint.canceled = true;
- }
- }
-
- protected abstract void poll(T entry);
-
- protected void onPollCompletion(T entry) {
- if (!entry.isConcurrentPollingAllowed()) {
- synchronized (entry) {
- if (!entry.canceled) {
- schedulePoll(entry);
- }
- }
- }
- }
-
- /**
- * method to log a failure to the log file and to update the last poll status and time
- * @param msg text for the log message
- * @param e optional exception encountered or null
- * @param entry the PollTableEntry
- */
- protected void processFailure(String msg, Exception e, T entry) {
- if (e == null) {
- log.error(msg);
- } else {
- log.error(msg, e);
- }
- long now = System.currentTimeMillis();
- entry.setLastPollState(AbstractPollTableEntry.FAILED);
- entry.setLastPollTime(now);
- entry.setNextPollTime(now + entry.getPollInterval());
- onPollCompletion(entry);
- }
-
- // -- jmx/management methods--
- /**
- * Pause the listener - Stop accepting/processing new messages, but continues processing existing
- * messages until they complete. This helps bring an instance into a maintenence mode
- * @throws org.apache.axis2.AxisFault on error
- */
- public void pause() throws AxisFault {
- if (state != BaseConstants.STARTED) return;
- state = BaseConstants.PAUSED;
- log.info("Listener paused");
- }
-
- /**
- * Resume the lister - Brings the lister into active mode back from a paused state
- * @throws AxisFault on error
- */
- public void resume() throws AxisFault {
- if (state != BaseConstants.PAUSED) return;
- state = BaseConstants.STARTED;
- log.info("Listener resumed");
- }
-
- /**
- * Stop processing new messages, and wait the specified maximum time for in-flight
- * requests to complete before a controlled shutdown for maintenence
- *
- * @param millis a number of milliseconds to wait until pending requests are allowed to complete
- * @throws AxisFault on error
- */
- public void maintenenceShutdown(long millis) throws AxisFault {
- if (state != BaseConstants.STARTED) return;
- stop();
- state = BaseConstants.STOPPED;
- log.info("Listener shutdown");
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java b/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java
deleted file mode 100644
index 3e75fb6..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.SessionContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.*;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.util.MessageContextBuilder;
-import org.apache.axis2.transport.base.threads.WorkerPool;
-import org.apache.axis2.transport.base.threads.WorkerPoolFactory;
-import org.apache.axis2.transport.base.tracker.AxisServiceFilter;
-import org.apache.axis2.transport.base.tracker.AxisServiceTracker;
-import org.apache.axis2.transport.base.tracker.AxisServiceTrackerListener;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.util.UIDGenerator;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.util.*;
-import java.lang.management.ManagementFactory;
-
-public abstract class AbstractTransportListener implements TransportListener {
-
- /** the reference to the actual commons logger to be used for log messages */
- protected Log log = null;
-
- /** the axis2 configuration context */
- protected ConfigurationContext cfgCtx = null;
-
- /** transport in description */
- private TransportInDescription transportIn = null;
- /** transport out description */
- private TransportOutDescription transportOut = null;
- /** state of the listener */
- protected int state = BaseConstants.STOPPED;
- /** is this transport non-blocking? */
- protected boolean isNonBlocking = false;
- /**
- * Service tracker used to invoke {@link #internalStartListeningForService(AxisService)}
- * and {@link #internalStopListeningForService(AxisService)}. */
- private AxisServiceTracker serviceTracker;
-
- /** the thread pool to execute actual poll invocations */
- protected WorkerPool workerPool = null;
- /** use the thread pool available in the axis2 configuration context */
- protected boolean useAxis2ThreadPool = false;
- /** JMX support */
- private TransportMBeanSupport mbeanSupport;
- /** Metrics collector for this transport */
- protected MetricsCollector metrics = new MetricsCollector();
- /** Transport Configuration for the respective transports */
- protected TransportConfiguration config;
-
- /**
- * A constructor that makes subclasses pick up the correct logger
- */
- protected AbstractTransportListener() {
- log = LogFactory.getLog(this.getClass());
- }
-
- /**
- * Initialize the generic transport. Sets up the transport and the thread pool to be used
- * for message processing. Also creates an AxisObserver that gets notified of service
- * life cycle events for the transport to act on
- * @param cfgCtx the axis configuration context
- * @param transportIn the transport-in description
- * @throws AxisFault on error
- */
- public void init(ConfigurationContext cfgCtx, TransportInDescription transportIn)
- throws AxisFault {
-
- this.cfgCtx = cfgCtx;
- this.transportIn = transportIn;
- this.transportOut = cfgCtx.getAxisConfiguration().getTransportOut(getTransportName());
- this.config = TransportConfiguration.getConfiguration(getTransportName());
-
- if (useAxis2ThreadPool) {
- //this.workerPool = cfgCtx.getThreadPool(); not yet implemented
- throw new AxisFault("Unsupported thread pool for task execution - Axis2 thread pool");
- } else {
- if (this.workerPool == null) { // FIXME <-- workaround for AXIS2-4552
- this.workerPool = WorkerPoolFactory.getWorkerPool(
- config.getServerCoreThreads(),
- config.getServerMaxThreads(),
- config.getServerKeepalive(),
- config.getServerQueueLen(),
- getTransportName() + "Server Worker thread group",
- getTransportName() + "-Worker");
- }
-
- }
-
- // register to receive updates on services for lifetime management
- serviceTracker = new AxisServiceTracker(
- cfgCtx.getAxisConfiguration(),
- new AxisServiceFilter() {
- public boolean matches(AxisService service) {
- return !service.getName().startsWith("__") // these are "private" services
- && BaseUtils.isUsingTransport(service, getTransportName());
- }
- },
- new AxisServiceTrackerListener() {
- public void serviceAdded(AxisService service) {
- internalStartListeningForService(service);
- }
-
- public void serviceRemoved(AxisService service) {
- internalStopListeningForService(service);
- }
- });
-
- // register with JMX
- if (mbeanSupport == null) { // FIXME <-- workaround for AXIS2-4552
- mbeanSupport = new TransportMBeanSupport(this, getTransportName());
- mbeanSupport.register();
- }
-
- }
-
- public void destroy() {
- try {
- if (state == BaseConstants.STARTED) {
- try {
- stop();
- } catch (AxisFault ignore) {
- log.warn("Error stopping the transport : " + getTransportName());
- }
- }
- } finally {
- state = BaseConstants.STOPPED;
- mbeanSupport.unregister();
- }
- try {
- workerPool.shutdown(10000);
- } catch (InterruptedException ex) {
- log.warn("Thread interrupted while waiting for worker pool to shut down");
- }
- }
-
- public void stop() throws AxisFault {
- if (state == BaseConstants.STARTED) {
- state = BaseConstants.STOPPED;
- // cancel receipt of service lifecycle events
- log.info(getTransportName().toUpperCase() + " Listener Shutdown");
- serviceTracker.stop();
- }
- }
-
- public void start() throws AxisFault {
- if (state != BaseConstants.STARTED) {
- state = BaseConstants.STARTED;
- // register to receive updates on services for lifetime management
- // cfgCtx.getAxisConfiguration().addObservers(axisObserver);
- log.info(getTransportName().toUpperCase() + " listener started");
- // iterate through deployed services and start
- serviceTracker.start();
- }
- }
-
- public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault {
- return getEPRsForService(serviceName);
- }
-
- protected EndpointReference[] getEPRsForService(String serviceName) {
- return null;
- }
-
- public void disableTransportForService(AxisService service) {
-
- log.warn("Disabling the " + getTransportName() + " transport for the service "
- + service.getName() + ", because it is not configured properly for the service");
-
- if (service.isEnableAllTransports()) {
- ArrayList<String> exposedTransports = new ArrayList<String>();
- for(Object obj: cfgCtx.getAxisConfiguration().getTransportsIn().values()) {
- String transportName = ((TransportInDescription) obj).getName();
- if (!transportName.equals(getTransportName())) {
- exposedTransports.add(transportName);
- }
- }
- service.setEnableAllTransports(false);
- service.setExposedTransports(exposedTransports);
- } else {
- service.removeExposedTransport(getTransportName());
- }
- }
-
- void internalStartListeningForService(AxisService service) {
- String serviceName = service.getName();
- try {
- startListeningForService(service);
- } catch (AxisFault ex) {
- String transportName = getTransportName().toUpperCase();
- String msg = "Unable to configure the service " + serviceName + " for the " +
- transportName + " transport: " + ex.getMessage() + ". " +
- "This service is being marked as faulty and will not be available over the " +
- transportName + " transport.";
- // Only log the message at level WARN and log the full stack trace at level DEBUG.
- // TODO: We should have a way to distinguish a missing configuration
- // from an error. This may be addressed when implementing the enhancement
- // described in point 3 of http://markmail.org/message/umhenrurlrekk5jh
- log.warn(msg);
- log.debug("Disabling service " + serviceName + " for the " + transportName +
- "transport", ex);
- BaseUtils.markServiceAsFaulty(serviceName, msg, service.getAxisConfiguration());
- disableTransportForService(service);
- return;
- } catch (Throwable ex) {
- String msg = "Unexpected error when configuring service " + serviceName +
- " for the " + getTransportName().toUpperCase() + " transport. It will be" +
- " disabled for this transport and marked as faulty.";
- log.error(msg, ex);
- BaseUtils.markServiceAsFaulty(serviceName, msg, service.getAxisConfiguration());
- disableTransportForService(service);
- return;
- }
- registerMBean(new TransportListenerEndpointView(this, serviceName),
- getEndpointMBeanName(serviceName));
- }
-
- void internalStopListeningForService(AxisService service) {
- unregisterMBean(getEndpointMBeanName(service.getName()));
- stopListeningForService(service);
- }
-
- protected abstract void startListeningForService(AxisService service) throws AxisFault;
-
- protected abstract void stopListeningForService(AxisService service);
-
- /**
- * This is a deprecated method in Axis2 and this default implementation returns the first
- * result from the getEPRsForService() method
- */
- public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault {
- return getEPRsForService(serviceName, ip)[0];
- }
-
- public SessionContext getSessionContext(MessageContext messageContext) {
- return null;
- }
-
- /**
- * Create a new axis MessageContext for an incoming message through this transport
- * @return the newly created message context
- */
- public MessageContext createMessageContext() {
- MessageContext msgCtx = new MessageContext();
- msgCtx.setConfigurationContext(cfgCtx);
-
- msgCtx.setIncomingTransportName(getTransportName());
- msgCtx.setTransportOut(transportOut);
- msgCtx.setTransportIn(transportIn);
- msgCtx.setServerSide(true);
- msgCtx.setMessageID(UIDGenerator.generateURNString());
-
- // There is a discrepency in what I thought, Axis2 spawns a nes threads to
- // send a message is this is TRUE - and I want it to be the other way
- msgCtx.setProperty(MessageContext.CLIENT_API_NON_BLOCKING, Boolean.valueOf(!isNonBlocking));
-
- // are these relevant?
- //msgCtx.setServiceGroupContextId(UUIDGenerator.getUUID());
- // this is required to support Sandesha 2
- //msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
- // new HttpCoreRequestResponseTransport(msgContext));
-
- return msgCtx;
- }
-
- /**
- * Process a new incoming message through the axis engine
- * @param msgCtx the axis MessageContext
- * @param trpHeaders the map containing transport level message headers
- * @param soapAction the optional soap action or null
- * @param contentType the optional content-type for the message
- */
- public void handleIncomingMessage(
- MessageContext msgCtx, Map trpHeaders,
- String soapAction, String contentType) throws AxisFault {
-
- // set the soapaction if one is available via a transport header
- if (soapAction != null) {
- msgCtx.setSoapAction(soapAction);
- }
-
- // set the transport headers to the message context
- msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, trpHeaders);
-
- // send the message context through the axis engine
- try {
- // check if an Axis2 callback has been registered for this message
- Map callBackMap = (Map) msgCtx.getConfigurationContext().
- getProperty(BaseConstants.CALLBACK_TABLE);
- // FIXME: transport headers are protocol specific; the correlation ID should be
- // passed as argument to this method
- Object replyToMessageID = trpHeaders.get(BaseConstants.HEADER_IN_REPLY_TO);
- // if there is a callback registerd with this replyto ID then this has to
- // be handled as a synchronous incoming message, via the
- if (replyToMessageID != null && callBackMap != null &&
- callBackMap.get(replyToMessageID) != null) {
-
- SynchronousCallback synchronousCallback =
- (SynchronousCallback) callBackMap.get(replyToMessageID);
- synchronousCallback.setInMessageContext(msgCtx);
- callBackMap.remove(replyToMessageID);
- } else {
- AxisEngine.receive(msgCtx);
- }
-
- } catch (AxisFault e) {
- if (log.isDebugEnabled()) {
- log.debug("Error receiving message", e);
- }
- if (msgCtx.isServerSide()) {
- AxisEngine.sendFault(MessageContextBuilder.createFaultMessageContext(msgCtx, e));
- }
- }
- }
-
- protected void handleException(String msg, Exception e) throws AxisFault {
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
-
- protected void logException(String msg, Exception e) {
- log.error(msg, e);
- }
-
- public TransportInDescription getTransportInDescription() {
- return transportIn;
- }
-
- public String getTransportName() {
- return transportIn.getName();
- }
-
- public ConfigurationContext getConfigurationContext() {
- return cfgCtx;
- }
-
- public MetricsCollector getMetricsCollector() {
- return metrics;
- }
-
- // -- jmx/management methods--
- /**
- * Pause the listener - Stop accepting/processing new messages, but continues processing existing
- * messages until they complete. This helps bring an instance into a maintenence mode
- * @throws AxisFault on error
- */
- public void pause() throws AxisFault {}
- /**
- * Resume the lister - Brings the lister into active mode back from a paused state
- * @throws AxisFault on error
- */
- public void resume() throws AxisFault {}
-
- /**
- * Stop processing new messages, and wait the specified maximum time for in-flight
- * requests to complete before a controlled shutdown for maintenence
- *
- * @param millis a number of milliseconds to wait until pending requests are allowed to complete
- * @throws AxisFault on error
- */
- public void maintenenceShutdown(long millis) throws AxisFault {}
-
- /**
- * Returns the number of active threads processing messages
- * @return number of active threads processing messages
- */
- public int getActiveThreadCount() {
- return workerPool.getActiveCount();
- }
-
- /**
- * Return the number of requests queued in the thread pool
- * @return queue size
- */
- public int getQueueSize() {
- return workerPool.getQueueSize();
- }
-
- public long getMessagesReceived() {
- if (metrics != null) {
- return metrics.getMessagesReceived();
- }
- return -1;
- }
-
- public long getFaultsReceiving() {
- if (metrics != null) {
- return metrics.getFaultsReceiving();
- }
- return -1;
- }
-
- public long getBytesReceived() {
- if (metrics != null) {
- return metrics.getBytesReceived();
- }
- return -1;
- }
-
- public long getMessagesSent() {
- if (metrics != null) {
- return metrics.getMessagesSent();
- }
- return -1;
- }
-
- public long getFaultsSending() {
- if (metrics != null) {
- return metrics.getFaultsSending();
- }
- return -1;
- }
-
- public long getBytesSent() {
- if (metrics != null) {
- return metrics.getBytesSent();
- }
- return -1;
- }
-
- public long getTimeoutsReceiving() {
- if (metrics != null) {
- return metrics.getTimeoutsReceiving();
- }
- return -1;
- }
-
- public long getTimeoutsSending() {
- if (metrics != null) {
- return metrics.getTimeoutsSending();
- }
- return -1;
- }
-
- public long getMinSizeReceived() {
- if (metrics != null) {
- return metrics.getMinSizeReceived();
- }
- return -1;
- }
-
- public long getMaxSizeReceived() {
- if (metrics != null) {
- return metrics.getMaxSizeReceived();
- }
- return -1;
- }
-
- public double getAvgSizeReceived() {
- if (metrics != null) {
- return metrics.getAvgSizeReceived();
- }
- return -1;
- }
-
- public long getMinSizeSent() {
- if (metrics != null) {
- return metrics.getMinSizeSent();
- }
- return -1;
- }
-
- public long getMaxSizeSent() {
- if (metrics != null) {
- return metrics.getMaxSizeSent();
- }
- return -1;
- }
-
- public double getAvgSizeSent() {
- if (metrics != null) {
- return metrics.getAvgSizeSent();
- }
- return -1;
- }
-
- public Map getResponseCodeTable() {
- if (metrics != null) {
- return metrics.getResponseCodeTable();
- }
- return null;
- }
-
- public void resetStatistics() {
- if (metrics != null) {
- metrics.reset();
- }
- }
-
- public long getLastResetTime() {
- if (metrics != null) {
- return metrics.getLastResetTime();
- }
- return -1;
- }
-
- public long getMetricsWindow() {
- if (metrics != null) {
- return System.currentTimeMillis() - metrics.getLastResetTime();
- }
- return -1;
- }
-
- private String getEndpointMBeanName(String serviceName) {
- return mbeanSupport.getMBeanName() + ",Group=Services,Service=" + serviceName;
- }
-
- /**
- * Utility method to allow transports to register MBeans
- * @param mbeanInstance bean instance
- * @param objectName name
- */
- private void registerMBean(Object mbeanInstance, String objectName) {
- try {
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- ObjectName name = new ObjectName(objectName);
- Set set = mbs.queryNames(name, null);
- if (set != null && set.isEmpty()) {
- mbs.registerMBean(mbeanInstance, name);
- } else {
- mbs.unregisterMBean(name);
- mbs.registerMBean(mbeanInstance, name);
- }
- } catch (Exception e) {
- log.warn("Error registering a MBean with objectname ' " + objectName +
- " ' for JMX management", e);
- }
- }
-
- private void unregisterMBean(String objectName) {
- try {
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- ObjectName objName = new ObjectName(objectName);
- if (mbs.isRegistered(objName)) {
- mbs.unregisterMBean(objName);
- }
- } catch (Exception e) {
- log.warn("Error un-registering a MBean with objectname ' " + objectName +
- " ' for JMX management", e);
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java b/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java
deleted file mode 100644
index eaa4723..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.axis2.transport.base;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.TransportInDescription;
-
-/**
- * Partial implementation of {@link AbstractTransportListener} with a higher level
- * of abstraction. It maintains the mapping between services and protocol specific
- * endpoints.
- * <p>
- * Note: the intention is to eventually merge the code in this class into
- * {@link AbstractTransportListener}
- *
- * @param <E> the type of protocol endpoint for this transport
- */
-public abstract class AbstractTransportListenerEx<E extends ProtocolEndpoint>
- extends AbstractTransportListener {
-
- /**
- * The collection of protocol specific endpoints configured at the service level.
- */
- private List<E> serviceEndpoints = new ArrayList<E>();
-
- /**
- * The endpoint configured at the transport level. <code>null</code> if no
- * such endpoint is configured.
- */
- private E globalEndpoint;
-
- @Override
- public final void init(ConfigurationContext cfgCtx,
- TransportInDescription transportIn) throws AxisFault {
-
- super.init(cfgCtx, transportIn);
-
- doInit();
-
- // Create endpoint configured at transport level (if available)
- E endpoint = createEndpoint();
- endpoint.init(this, null);
- if (endpoint.loadConfiguration(transportIn)) {
- globalEndpoint = endpoint;
- }
- }
-
- /**
- * Initialize the transport. This method will be called after the initialization work in
- * {@link AbstractTransportListener} and before the first endpoint is created, i.e. before the
- * first call to {@link #createEndpoint()}.
- *
- * @throws AxisFault
- */
- protected abstract void doInit() throws AxisFault;
-
- @Override
- public void start() throws AxisFault {
- super.start();
- // Explicitly start the endpoint configured at the transport level. All other endpoints will
- // be started by startListeningForService.
- if (globalEndpoint != null) {
- startEndpoint(globalEndpoint);
- }
- }
-
- @Override
- public void stop() throws AxisFault {
- super.stop();
- // Explicitly stop the endpoint configured at the transport level. All other endpoints will
- // be stopped by stopListeningForService.
- if (globalEndpoint != null) {
- stopEndpoint(globalEndpoint);
- }
- }
-
- @Override
- public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault {
- // strip out the endpoint name if present
- if (serviceName.indexOf('.') != -1) {
- serviceName = serviceName.substring(0, serviceName.indexOf('.'));
- }
- for (E endpoint : serviceEndpoints) {
- AxisService service = endpoint.getService();
- if (service.getName().equals(serviceName)) {
- return endpoint.getEndpointReferences(service, ip);
- }
- }
- // If we get here, this means that the service is not explicitly configured
- // with a specific protocol endpoint. However, it is still exposed over the
- // transport. In this case, we build the EPR using the endpoint configured
- // at the transport level, if there is one.
- if (globalEndpoint != null) {
- AxisService service = cfgCtx.getAxisConfiguration().getService(serviceName);
- if (service == null) {
- // Oops, something strange is happening here
- return null;
- } else {
- return globalEndpoint.getEndpointReferences(service, ip);
- }
- } else {
- return null;
- }
- }
-
- /**
- * Get the collection of all protocol endpoints managed by this transport, including the
- * endpoint configured at the transport level.
- *
- * @return the collection of all protocol endpoints
- */
- public final Collection<E> getEndpoints() {
- if (globalEndpoint == null) {
- return Collections.unmodifiableCollection(serviceEndpoints);
- } else {
- List<E> endpoints = new ArrayList<E>(serviceEndpoints.size() + 1);
- endpoints.add(globalEndpoint);
- endpoints.addAll(serviceEndpoints);
- return endpoints;
- }
- }
-
- protected abstract E createEndpoint();
-
- @Override
- protected final void startListeningForService(AxisService service) throws AxisFault {
- E endpoint = createEndpoint();
- endpoint.init(this, service);
- if (endpoint.loadConfiguration(service)) {
- startEndpoint(endpoint);
- serviceEndpoints.add(endpoint);
- } else if (globalEndpoint != null) {
- return;
- } else {
- throw new AxisFault("Service doesn't have configuration information for transport " +
- getTransportName());
- }
- }
-
- protected abstract void startEndpoint(E endpoint) throws AxisFault;
-
- @Override
- protected final void stopListeningForService(AxisService service) {
- for (E endpoint : serviceEndpoints) {
- if (service == endpoint.getService()) {
- stopEndpoint(endpoint);
- serviceEndpoints.remove(endpoint);
- return;
- }
- }
- if (globalEndpoint == null) {
- log.error("Unable to stop service : " + service.getName() +
- " - unable to find the corresponding protocol endpoint");
- }
- }
-
- protected abstract void stopEndpoint(E endpoint);
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportSender.java b/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportSender.java
deleted file mode 100644
index 5e8963f..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportSender.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.axis2.util.MessageContextBuilder;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.transport.TransportSender;
-import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.WSDL2Constants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.util.UIDGenerator;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.util.Map;
-import java.util.Set;
-
-public abstract class AbstractTransportSender extends AbstractHandler implements TransportSender {
-
- /** the reference to the actual commons logger to be used for log messages */
- protected Log log = null;
-
- /** the axis2 configuration context */
- protected ConfigurationContext cfgCtx = null;
- /** transport in description */
- private TransportInDescription transportIn = null;
- /** transport out description */
- private TransportOutDescription transportOut = null;
- /** JMX support */
- private TransportMBeanSupport mbeanSupport;
- /** Metrics collector for the sender */
- protected MetricsCollector metrics = new MetricsCollector();
- /** state of the listener */
- private int state = BaseConstants.STOPPED;
-
- /**
- * A constructor that makes subclasses pick up the correct logger
- */
- protected AbstractTransportSender() {
- log = LogFactory.getLog(this.getClass());
- }
-
- /**
- * Initialize the generic transport sender.
- *
- * @param cfgCtx the axis configuration context
- * @param transportOut the transport-out description
- * @throws AxisFault on error
- */
- public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut)
- throws AxisFault {
- this.cfgCtx = cfgCtx;
- this.transportOut = transportOut;
- this.transportIn = cfgCtx.getAxisConfiguration().getTransportIn(getTransportName());
- this.state = BaseConstants.STARTED;
-
- // register with JMX
- mbeanSupport = new TransportMBeanSupport(this, getTransportName());
- mbeanSupport.register();
- log.info(getTransportName().toUpperCase() + " Sender started");
- }
-
- public void stop() {
- if (state != BaseConstants.STARTED) return;
- state = BaseConstants.STOPPED;
- mbeanSupport.unregister();
- log.info(getTransportName().toUpperCase() + " Sender Shutdown");
- }
-
- public void cleanup(MessageContext msgContext) throws AxisFault {}
-
- public abstract void sendMessage(MessageContext msgCtx, String targetEPR,
- OutTransportInfo outTransportInfo) throws AxisFault;
-
- public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
-
- // is there a transport url which may be different to the WS-A To but has higher precedence
- String targetAddress = (String) msgContext.getProperty(
- Constants.Configuration.TRANSPORT_URL);
-
- if (targetAddress != null) {
- sendMessage(msgContext, targetAddress, null);
- } else if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
- targetAddress = msgContext.getTo().getAddress();
-
- if (!msgContext.getTo().hasNoneAddress()) {
- sendMessage(msgContext, targetAddress, null);
- } else {
- //Don't send the message.
- return InvocationResponse.CONTINUE;
- }
- } else if (msgContext.isServerSide()) {
- // get the out transport info for server side when target EPR is unknown
- sendMessage(msgContext, null,
- (OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO));
- }
-
- return InvocationResponse.CONTINUE;
- }
-
- /**
- * Process a new incoming message (Response) through the axis engine
- * @param msgCtx the axis MessageContext
- * @param trpHeaders the map containing transport level message headers
- * @param soapAction the optional soap action or null
- * @param contentType the optional content-type for the message
- */
- public void handleIncomingMessage(
- MessageContext msgCtx, Map trpHeaders,
- String soapAction, String contentType) {
-
- // set the soapaction if one is available via a transport header
- if (soapAction != null) {
- msgCtx.setSoapAction(soapAction);
- }
-
- // set the transport headers to the message context
- msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, trpHeaders);
-
- // send the message context through the axis engine
- try {
- try {
- AxisEngine.receive(msgCtx);
- } catch (AxisFault e) {
- if (log.isDebugEnabled()) {
- log.debug("Error receiving message", e);
- }
- if (msgCtx.isServerSide()) {
- AxisEngine.sendFault(MessageContextBuilder.createFaultMessageContext(msgCtx, e));
- }
- }
- } catch (AxisFault axisFault) {
- logException("Error processing response message", axisFault);
- }
- }
-
- /**
- * Create a new axis MessageContext for an incoming response message
- * through this transport, for the given outgoing message
- *
- * @param outMsgCtx the outgoing message
- * @return the newly created message context
- */
- public MessageContext createResponseMessageContext(MessageContext outMsgCtx) {
-
- MessageContext responseMsgCtx = null;
- try {
- responseMsgCtx = outMsgCtx.getOperationContext().
- getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
- } catch (AxisFault af) {
- log.error("Error getting IN message context from the operation context", af);
- }
-
- if (responseMsgCtx == null) {
- responseMsgCtx = new MessageContext();
- responseMsgCtx.setOperationContext(outMsgCtx.getOperationContext());
- }
-
- responseMsgCtx.setIncomingTransportName(getTransportName());
- responseMsgCtx.setTransportOut(transportOut);
- responseMsgCtx.setTransportIn(transportIn);
-
- responseMsgCtx.setMessageID(UIDGenerator.generateURNString());
-
- responseMsgCtx.setDoingREST(outMsgCtx.isDoingREST());
- responseMsgCtx.setProperty(
- MessageContext.TRANSPORT_IN, outMsgCtx.getProperty(MessageContext.TRANSPORT_IN));
- responseMsgCtx.setAxisMessage(outMsgCtx.getOperationContext().getAxisOperation().
- getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
- responseMsgCtx.setTo(null);
- //msgCtx.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, isNonBlocking);
-
-
- // are these relevant?
- //msgCtx.setServiceGroupContextId(UUIDGenerator.getUUID());
- // this is required to support Sandesha 2
- //msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
- // new HttpCoreRequestResponseTransport(msgContext));
-
- return responseMsgCtx;
- }
-
- /**
- * Should the transport sender wait for a synchronous response to be received?
- * @param msgCtx the outgoing message context
- * @return true if a sync response is expected
- */
- protected boolean waitForSynchronousResponse(MessageContext msgCtx) {
- return
- msgCtx.getOperationContext() != null &&
- WSDL2Constants.MEP_URI_OUT_IN.equals(
- msgCtx.getOperationContext().getAxisOperation().getMessageExchangePattern());
- }
-
- public String getTransportName() {
- return transportOut.getName();
- }
-
- protected void handleException(String msg, Exception e) throws AxisFault {
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
-
- protected void handleException(String msg) throws AxisFault {
- log.error(msg);
- throw new AxisFault(msg);
- }
-
- protected void logException(String msg, Exception e) {
- log.error(msg, e);
- }
-
- //--- jmx/management methods ---
- public void pause() throws AxisFault {
- if (state != BaseConstants.STARTED) return;
- state = BaseConstants.PAUSED;
- log.info("Sender paused");
- }
-
- public void resume() throws AxisFault {
- if (state != BaseConstants.PAUSED) return;
- state = BaseConstants.STARTED;
- log.info("Sender resumed");
- }
-
- public void maintenenceShutdown(long millis) throws AxisFault {
- if (state != BaseConstants.STARTED) return;
- long start = System.currentTimeMillis();
- stop();
- state = BaseConstants.STOPPED;
- log.info("Sender shutdown in : " + (System.currentTimeMillis() - start) / 1000 + "s");
- }
-
- /**
- * Returns the number of active threads processing messages
- * @return number of active threads processing messages
- */
- public int getActiveThreadCount() {
- return 0;
- }
-
- /**
- * Return the number of requests queued in the thread pool
- * @return queue size
- */
- public int getQueueSize() {
- return 0;
- }
-
- // -- jmx/management methods--
- public long getMessagesReceived() {
- if (metrics != null) {
- return metrics.getMessagesReceived();
- }
- return -1;
- }
-
- public long getFaultsReceiving() {
- if (metrics != null) {
- return metrics.getFaultsReceiving();
- }
- return -1;
- }
-
- public long getBytesReceived() {
- if (metrics != null) {
- return metrics.getBytesReceived();
- }
- return -1;
- }
-
- public long getMessagesSent() {
- if (metrics != null) {
- return metrics.getMessagesSent();
- }
- return -1;
- }
-
- public long getFaultsSending() {
- if (metrics != null) {
- return metrics.getFaultsSending();
- }
- return -1;
- }
-
- public long getBytesSent() {
- if (metrics != null) {
- return metrics.getBytesSent();
- }
- return -1;
- }
-
- public long getTimeoutsReceiving() {
- if (metrics != null) {
- return metrics.getTimeoutsReceiving();
- }
- return -1;
- }
-
- public long getTimeoutsSending() {
- if (metrics != null) {
- return metrics.getTimeoutsSending();
- }
- return -1;
- }
-
- public long getMinSizeReceived() {
- if (metrics != null) {
- return metrics.getMinSizeReceived();
- }
- return -1;
- }
-
- public long getMaxSizeReceived() {
- if (metrics != null) {
- return metrics.getMaxSizeReceived();
- }
- return -1;
- }
-
- public double getAvgSizeReceived() {
- if (metrics != null) {
- return metrics.getAvgSizeReceived();
- }
- return -1;
- }
-
- public long getMinSizeSent() {
- if (metrics != null) {
- return metrics.getMinSizeSent();
- }
- return -1;
- }
-
- public long getMaxSizeSent() {
- if (metrics != null) {
- return metrics.getMaxSizeSent();
- }
- return -1;
- }
-
- public double getAvgSizeSent() {
- if (metrics != null) {
- return metrics.getAvgSizeSent();
- }
- return -1;
- }
-
- public Map getResponseCodeTable() {
- if (metrics != null) {
- return metrics.getResponseCodeTable();
- }
- return null;
- }
-
- public void resetStatistics() {
- if (metrics != null) {
- metrics.reset();
- }
- }
-
- public long getLastResetTime() {
- if (metrics != null) {
- return metrics.getLastResetTime();
- }
- return -1;
- }
-
- public long getMetricsWindow() {
- if (metrics != null) {
- return System.currentTimeMillis() - metrics.getLastResetTime();
- }
- return -1;
- }
-
- private void registerMBean(MBeanServer mbs, Object mbeanInstance, String objectName) {
- try {
- ObjectName name = new ObjectName(objectName);
- Set set = mbs.queryNames(name, null);
- if (set != null && set.isEmpty()) {
- mbs.registerMBean(mbeanInstance, name);
- } else {
- mbs.unregisterMBean(name);
- mbs.registerMBean(mbeanInstance, name);
- }
- } catch (Exception e) {
- log.warn("Error registering a MBean with objectname ' " + objectName +
- " ' for JMX management", e);
- }
- }
-
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/BaseConstants.java b/modules/base/src/main/java/org/apache/axis2/transport/base/BaseConstants.java
deleted file mode 100644
index fb7a825..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/BaseConstants.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-
-import javax.xml.namespace.QName;
-
-public class BaseConstants {
- // -- status of a transport --
- public final static int STOPPED = 0;
- public final static int STARTED = 1;
- public final static int PAUSED = 2;
-
- /**
- * A message property specifying the SOAP Action
- */
- public static final String SOAPACTION = "SOAPAction";
- /**
- * A message property specifying the content type
- */
- public static final String CONTENT_TYPE = "Content-Type";
- /**
- * A message context property indicating "TRUE", if a transport or the message builder
- * has information that the current message is a fault (e.g. SOAP faults, non-HTTP 2xx, etc)
- */
- public static final String FAULT_MESSAGE = "FAULT_MESSAGE";
- /**
- * content type identifier for multipart / MTOM messages
- */
- public static final String MULTIPART_RELATED = "multipart/related";
- /**
- * character set marker to identify charset from a Content-Type string
- */
- public static final String CHARSET_PARAM = "; charset=";
- /**
- * The property specifying an optional message level metrics collector
- */
- public static final String METRICS_COLLECTOR = "METRICS_COLLECTOR";
-
- //------------------------------------ defaults ------------------------------------
- /**
- * The default operation name to be used for non SOAP/XML messages
- * if the operation cannot be determined
- */
- public static final QName DEFAULT_OPERATION = new QName("urn:mediate");
- /**
- * The name of the element which wraps binary content into a SOAP envelope
- */
-
- // This has to match org.apache.synapse.util.PayloadHelper
- // at some future point this can be merged into Axiom as a common base
- public final static String AXIOMPAYLOADNS = "http://ws.apache.org/commons/ns/payload";
-
-
- public static final QName DEFAULT_BINARY_WRAPPER =
- new QName(AXIOMPAYLOADNS, "binary");
- /**
- * The name of the element which wraps plain text content into a SOAP envelope
- */
- public static final QName DEFAULT_TEXT_WRAPPER =
- new QName(AXIOMPAYLOADNS, "text");
-
- //-------------------------- services.xml parameters --------------------------------
- /**
- * The Parameter name indicating the operation to dispatch non SOAP/XML messages
- */
- public static final String OPERATION_PARAM = "Operation";
- /**
- * The Parameter name indicating the wrapper element for non SOAP/XML messages
- */
- public static final String WRAPPER_PARAM = "Wrapper";
- /**
- * the parameter in the services.xml that specifies the poll interval for a service
- */
- public static final String TRANSPORT_POLL_INTERVAL = "transport.PollInterval";
- /**
- * Could polling take place in parallel, i.e. starting at fixed intervals?
- */
- public static final String TRANSPORT_POLL_IN_PARALLEL = "transport.ConcurrentPollingAllowed";
- /**
- * The default poll interval in milliseconds.
- */
- public static final int DEFAULT_POLL_INTERVAL = 5 * 60 * 1000; // 5 mins by default
-
- public static final String CALLBACK_TABLE = "callbackTable";
- public static final String HEADER_IN_REPLY_TO = "In-Reply-To";
-
- // this is an property required by axis2
- // FIXME: where is this required in Axis2?
- public final static String MAIL_CONTENT_TYPE = "mail.contenttype";
-
- /** Service transaction level - non-transactional */
- public static final int TRANSACTION_NONE = 0;
- /** Service transaction level - use non-JTA (i.e. local) transactions */
- public static final int TRANSACTION_LOCAL = 1;
- /** Service transaction level - use JTA transactions */
- public static final int TRANSACTION_JTA = 2;
- /** Service transaction level - non-transactional */
- public static final String STR_TRANSACTION_NONE = "none";
- /** Service transaction level - use non-JTA (i.e. local) transactions */
- public static final String STR_TRANSACTION_LOCAL = "local";
- /** Service transaction level - use JTA transactions */
- public static final String STR_TRANSACTION_JTA = "jta";
-
- /** The Parameter name indicating the transactionality of a service */
- public static final String PARAM_TRANSACTIONALITY = "transport.Transactionality";
- /** Parameter name indicating the JNDI name to get a UserTransaction from JNDI */
- public static final String PARAM_USER_TXN_JNDI_NAME = "transport.UserTxnJNDIName";
- /** Parameter that indicates if a UserTransaction reference could be cached - default yes */
- public static final String PARAM_CACHE_USER_TXN = "transport.CacheUserTxn";
-
- /** The UserTransaction associated with this message */
- public static final String USER_TRANSACTION = "UserTransaction";
- /** A message level property indicating a request to rollback the transaction associated with the message */
- public static final String SET_ROLLBACK_ONLY = "SET_ROLLBACK_ONLY";
- /** A message level property indicating a commit is required after the next immidiate send over a transport */
- public static final String JTA_COMMIT_AFTER_SEND = "JTA_COMMIT_AFTER_SEND";
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/BaseTransportException.java b/modules/base/src/main/java/org/apache/axis2/transport/base/BaseTransportException.java
deleted file mode 100644
index b69dc9e..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/BaseTransportException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-public class BaseTransportException extends RuntimeException {
-
- BaseTransportException() {
- super();
- }
-
- public BaseTransportException(String msg) {
- super(msg);
- }
-
- public BaseTransportException(String msg, Exception e) {
- super(msg, e);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/BaseUtils.java b/modules/base/src/main/java/org/apache/axis2/transport/base/BaseUtils.java
deleted file mode 100644
index cdcaab0..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/BaseUtils.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.impl.builder.StAXBuilder;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.format.BinaryFormatter;
-import org.apache.axis2.format.PlainTextFormatter;
-import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.util.MessageProcessorSelector;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-public class BaseUtils {
-
- private static final Log log = LogFactory.getLog(BaseUtils.class);
-
- /**
- * Return a QName from the String passed in of the form {ns}element
- * @param obj a QName or a String containing a QName in {ns}element form
- * @return a corresponding QName object
- */
- public static QName getQNameFromString(Object obj) {
- String value;
- if (obj instanceof QName) {
- return (QName) obj;
- } else {
- value = obj.toString();
- }
- int open = value.indexOf('{');
- int close = value.indexOf('}');
- if (close > open && open > -1 && value.length() > close) {
- return new QName(value.substring(open+1, close-open), value.substring(close+1));
- } else {
- return new QName(value);
- }
- }
-
- /**
- * Marks the given service as faulty with the given comment
- *
- * @param serviceName service name
- * @param msg comment for being faulty
- * @param axisCfg configuration context
- */
- public static void markServiceAsFaulty(String serviceName, String msg,
- AxisConfiguration axisCfg) {
- if (serviceName != null) {
- try {
- AxisService service = axisCfg.getService(serviceName);
- if (service != null) {
- axisCfg.getFaultyServices().put(service.getName(), msg);
- }
- } catch (AxisFault axisFault) {
- log.warn("Error marking service : " + serviceName + " as faulty", axisFault);
- }
- }
- }
-
- /**
- * Create a SOAP envelope using SOAP 1.1 or 1.2 depending on the namespace
- * @param in InputStream for the payload
- * @param namespace the SOAP namespace
- * @return the SOAP envelope for the correct version
- * @throws javax.xml.stream.XMLStreamException on error
- */
- public static SOAPEnvelope getEnvelope(InputStream in, String namespace) throws XMLStreamException {
-
- try {
- in.reset();
- } catch (IOException ignore) {}
- XMLStreamReader xmlreader =
- StAXUtils.createXMLStreamReader(in, MessageContext.DEFAULT_CHAR_SET_ENCODING);
- StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, namespace);
- return (SOAPEnvelope) builder.getDocumentElement();
- }
-
- /**
- * Get the OMOutput format for the given message
- * @param msgContext the axis message context
- * @return the OMOutput format to be used
- */
- public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) {
-
- OMOutputFormat format = new OMOutputFormat();
- msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext));
- msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext));
- msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext));
- format.setSOAP11(msgContext.isSOAP11());
- format.setDoOptimize(msgContext.isDoingMTOM());
- format.setDoingSWA(msgContext.isDoingSwA());
-
- format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext));
- Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY);
- if (mimeBoundaryProperty != null) {
- format.setMimeBoundary((String) mimeBoundaryProperty);
- }
- return format;
- }
-
- /**
- * Get the MessageFormatter for the given message.
- * @param msgContext the axis message context
- * @return the MessageFormatter to be used
- */
- public static MessageFormatter getMessageFormatter(MessageContext msgContext) {
- // check the first element of the SOAP body, do we have content wrapped using the
- // default wrapper elements for binary (BaseConstants.DEFAULT_BINARY_WRAPPER) or
- // text (BaseConstants.DEFAULT_TEXT_WRAPPER) ? If so, select the appropriate
- // message formatter directly ...
- OMElement firstChild = msgContext.getEnvelope().getBody().getFirstElement();
- if (firstChild != null) {
- if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) {
- return new BinaryFormatter();
- } else if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(firstChild.getQName())) {
- return new PlainTextFormatter();
- }
- }
-
- // ... otherwise, let Axis choose the right message formatter:
- try {
- return MessageProcessorSelector.getMessageFormatter(msgContext);
- } catch (AxisFault axisFault) {
- throw new BaseTransportException("Unable to get the message formatter to use");
- }
- }
-
- protected static void handleException(String s) {
- log.error(s);
- throw new BaseTransportException(s);
- }
-
- protected static void handleException(String s, Exception e) {
- log.error(s, e);
- throw new BaseTransportException(s, e);
- }
-
- /**
- * Utility method to check if a string is null or empty
- * @param str the string to check
- * @return true if the string is null or empty
- */
- public static boolean isBlank(String str) {
- if (str == null || str.length() == 0) {
- return true;
- }
- for (int i = 0; i < str.length(); i++) {
- if (!Character.isWhitespace(str.charAt(i))) {
- return false;
- }
- }
- return true;
- }
-
- public static boolean isUsingTransport(AxisService service, String transportName) {
- boolean process = service.isEnableAllTransports();
- if (process) {
- return true;
-
- } else {
- List transports = service.getExposedTransports();
- for (Object transport : transports) {
- if (transportName.equals(transport)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Extract the properties from an endpoint reference.
- *
- * @param url an endpoint reference
- * @return the extracted properties
- */
- public static Hashtable<String,String> getEPRProperties(String url) {
- Hashtable<String,String> h = new Hashtable<String,String>();
- int propPos = url.indexOf("?");
- if (propPos != -1) {
- StringTokenizer st = new StringTokenizer(url.substring(propPos + 1), "&");
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
- int sep = token.indexOf("=");
- if (sep != -1) {
- h.put(token.substring(0, sep), token.substring(sep + 1));
- } else {
- // ignore, what else can we do?
- }
- }
- }
- return h;
- }
-
- /**
- * Loads the properties from a given property file path
- *
- * @param filePath Path of the property file
- * @return Properties loaded from given file
- */
- public static Properties loadProperties(String filePath) {
-
- Properties properties = new Properties();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
-
- if (log.isDebugEnabled()) {
- log.debug("Loading a file '" + filePath + "' from classpath");
- }
-
- InputStream in = cl.getResourceAsStream(filePath);
- if (in == null) {
- if (log.isDebugEnabled()) {
- log.debug("Unable to load file '" + filePath + "'");
- }
-
- filePath = "conf" +
- File.separatorChar + filePath;
- if (log.isDebugEnabled()) {
- log.debug("Loading a file '" + filePath + "' from classpath");
- }
-
- in = cl.getResourceAsStream(filePath);
- if (in == null) {
- if (log.isDebugEnabled()) {
- log.debug("Unable to load file ' " + filePath + " '");
- }
- }
- }
- if (in != null) {
- try {
- properties.load(in);
- } catch (IOException e) {
- String msg = "Error loading properties from a file at :" + filePath;
- log.error(msg, e);
- throw new BaseTransportException(msg, e);
- }
- }
- return properties;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/ManagementSupport.java b/modules/base/src/main/java/org/apache/axis2/transport/base/ManagementSupport.java
deleted file mode 100644
index 4b28ca5..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/ManagementSupport.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.AxisFault;
-import java.util.Map;
-
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-public interface ManagementSupport {
- public void pause() throws AxisFault;
- public void resume() throws AxisFault;
- void maintenenceShutdown(long millis) throws AxisFault;
- public int getActiveThreadCount();
- public int getQueueSize();
-
- public long getMessagesReceived();
- public long getFaultsReceiving();
- public long getTimeoutsReceiving();
- public long getMessagesSent();
- public long getFaultsSending();
- public long getTimeoutsSending();
- public long getBytesReceived();
- public long getBytesSent();
- public long getMinSizeReceived();
- public long getMaxSizeReceived();
- public double getAvgSizeReceived();
- public long getMinSizeSent();
- public long getMaxSizeSent();
- public double getAvgSizeSent();
- public Map getResponseCodeTable();
-
- public void resetStatistics();
- public long getLastResetTime();
- public long getMetricsWindow();
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/MessageLevelMetricsCollector.java b/modules/base/src/main/java/org/apache/axis2/transport/base/MessageLevelMetricsCollector.java
deleted file mode 100644
index 9d2f94c..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/MessageLevelMetricsCollector.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-public interface MessageLevelMetricsCollector {
-
- public void incrementMessagesReceived();
-
- public void incrementFaultsReceiving(int errorCode);
-
- public void incrementTimeoutsReceiving();
-
- public void incrementBytesReceived(long size);
-
- public void incrementMessagesSent();
-
- public void incrementFaultsSending(int errorCode);
-
- public void incrementTimeoutsSending();
-
- public void incrementBytesSent(long size);
-
- public void notifyReceivedMessageSize(long size);
-
- public void notifySentMessageSize(long size);
-
- public void reportReceivingFault(int errorCode);
-
- public void reportSendingFault(int errorCode);
-
- public void reportResponseCode(int respCode);
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/MetricsCollector.java b/modules/base/src/main/java/org/apache/axis2/transport/base/MetricsCollector.java
deleted file mode 100644
index 92aaeac..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/MetricsCollector.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-import org.apache.axis2.context.MessageContext;
-
-import java.util.Map;
-import java.util.Collections;
-import java.util.HashMap;
-
-/**
- * Collects metrics related to a transport that has metrics support enabled
- */
-public class MetricsCollector {
-
- public static final int LEVEL_NONE = 0;
- public static final int LEVEL_TRANSPORT = 1;
- public static final int LEVEL_FULL = 2;
- private static final Long ONE = (long) 1;
-
- /** By default, full metrics collection is enabled */
- private int level = LEVEL_FULL;
-
- private long messagesReceived;
- private long faultsReceiving;
- private long timeoutsReceiving;
- private long bytesReceived;
- private long minSizeReceived;
- private long maxSizeReceived;
- private double avgSizeReceived;
-
- private long messagesSent;
- private long faultsSending;
- private long timeoutsSending;
- private long bytesSent;
- private long minSizeSent;
- private long maxSizeSent;
- private double avgSizeSent;
-
- private final Map<Integer, Long> responseCodeTable =
- Collections.synchronizedMap(new HashMap<Integer, Long>());
-
- private long lastResetTime = System.currentTimeMillis();
-
- public void reset() {
- messagesReceived = 0;
- faultsReceiving = 0;
- timeoutsReceiving = 0;
- bytesReceived = 0;
- minSizeReceived = 0;
- maxSizeReceived = 0;
- avgSizeReceived = 0;
-
- messagesSent = 0;
- faultsSending = 0;
- timeoutsSending = 0;
- bytesSent = 0;
- minSizeSent = 0;
- maxSizeSent = 0;
- avgSizeSent = 0;
-
- responseCodeTable.clear();
- lastResetTime = System.currentTimeMillis();
- }
-
- public int getLevel() {
- return level;
- }
-
- public void setLevel(int level) {
- this.level = level;
- }
-
- public long getLastResetTime() {
- return lastResetTime;
- }
-
- public long getMessagesReceived() {
- return messagesReceived;
- }
-
- public long getFaultsReceiving() {
- return faultsReceiving;
- }
-
- public long getTimeoutsReceiving() {
- return timeoutsReceiving;
- }
-
- public long getBytesReceived() {
- return bytesReceived;
- }
-
- /**
- * Get the number of messages sent. This metrics is incremented after a
- * message has been completely and successfully put on the wire.
- *
- * @return the number of messages sent
- */
- public long getMessagesSent() {
- return messagesSent;
- }
-
- public long getFaultsSending() {
- return faultsSending;
- }
-
- public long getTimeoutsSending() {
- return timeoutsSending;
- }
-
- public long getBytesSent() {
- return bytesSent;
- }
-
- public long getMinSizeReceived() {
- return minSizeReceived;
- }
-
- public long getMaxSizeReceived() {
- return maxSizeReceived;
- }
-
- public long getMinSizeSent() {
- return minSizeSent;
- }
-
- public long getMaxSizeSent() {
- return maxSizeSent;
- }
-
- public double getAvgSizeReceived() {
- return avgSizeReceived;
- }
-
- public double getAvgSizeSent() {
- return avgSizeSent;
- }
-
- public Map<Integer, Long> getResponseCodeTable() {
- return responseCodeTable;
- }
-
- public synchronized void incrementMessagesReceived() {
- messagesReceived++;
- }
-
- public synchronized void incrementFaultsReceiving() {
- faultsReceiving++;
- }
-
- public synchronized void incrementTimeoutsReceiving() {
- timeoutsReceiving++;
- }
-
- public synchronized void incrementBytesReceived(long size) {
- bytesReceived += size;
- }
-
- public synchronized void incrementMessagesSent() {
- messagesSent++;
- }
-
- public synchronized void incrementFaultsSending() {
- faultsSending++;
- }
-
- public synchronized void incrementTimeoutsSending() {
- timeoutsSending++;
- }
-
- public synchronized void incrementBytesSent(long size) {
- bytesSent += size;
- }
-
- public synchronized void notifyReceivedMessageSize(long size) {
- if (minSizeReceived == 0 || size < minSizeReceived) {
- minSizeReceived = size;
- }
- if (size > maxSizeReceived) {
- maxSizeReceived = size;
- }
- avgSizeReceived = (avgSizeReceived == 0 ? size : (avgSizeReceived + size) / 2);
- }
-
- public synchronized void notifySentMessageSize(long size) {
- if (minSizeSent == 0 || size < minSizeSent) {
- minSizeSent = size;
- }
- if (size > maxSizeSent) {
- maxSizeSent = size;
- }
- avgSizeSent = (avgSizeSent == 0 ? size : (avgSizeSent + size) / 2);
- }
-
- public void reportResponseCode(int respCode) {
- synchronized(responseCodeTable) {
- Object o = responseCodeTable.get(respCode);
- if (o == null) {
- responseCodeTable.put(respCode, ONE);
- } else {
- responseCodeTable.put(respCode, (Long) o + 1);
- }
- }
- }
-
- // --- enhanced methods ---
- private MessageLevelMetricsCollector getMsgLevelMetrics(MessageContext mc) {
- if (mc != null && level == LEVEL_FULL) {
- return (MessageLevelMetricsCollector) mc.getProperty(BaseConstants.METRICS_COLLECTOR);
- }
- return null;
- }
-
- public void incrementMessagesReceived(MessageContext mc) {
- incrementMessagesReceived();
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementMessagesReceived();
- }
- }
-
- public void incrementFaultsReceiving(int errorCode, MessageContext mc) {
- incrementFaultsReceiving();
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementFaultsReceiving(errorCode);
- }
- }
-
- public void incrementTimeoutsReceiving(MessageContext mc) {
- incrementTimeoutsReceiving();
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementTimeoutsReceiving();
- }
- }
-
- public void incrementBytesReceived(MessageContext mc, long size) {
- incrementBytesReceived(size);
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementBytesReceived(size);
- }
- }
-
- public void incrementMessagesSent(MessageContext mc) {
- incrementMessagesSent();
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementMessagesSent();
- }
- }
-
- public void incrementFaultsSending(int errorCode, MessageContext mc) {
- incrementFaultsSending();
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementFaultsSending(errorCode);
- }
- }
-
- public void incrementTimeoutsSending(MessageContext mc) {
- incrementTimeoutsSending();
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementTimeoutsSending();
- }
- }
-
- public void incrementBytesSent(MessageContext mc, long size) {
- incrementBytesSent(size);
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.incrementBytesSent(size);
- }
- }
-
- public void notifyReceivedMessageSize(MessageContext mc, long size) {
- notifyReceivedMessageSize(size);
-
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.notifyReceivedMessageSize(size);
- }
- }
-
- public void notifySentMessageSize(MessageContext mc, long size) {
- notifySentMessageSize(size);
-
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.notifySentMessageSize(size);
- }
- }
-
- public void reportResponseCode(MessageContext mc, int respCode) {
- reportResponseCode(respCode);
-
- MessageLevelMetricsCollector m = getMsgLevelMetrics(mc);
- if (m != null) {
- m.reportResponseCode(respCode);
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java b/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java
deleted file mode 100644
index 77e6815..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.util.JavaUtils;
-
-/**
- * Utility class with methods to manipulate service or transport parameters.
- */
-public class ParamUtils {
- private ParamUtils() {}
-
- public static String getRequiredParam(ParameterInclude paramInclude, String paramName) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- if (param != null && param.getValue() != null && param.getValue() instanceof String) {
- return (String) param.getValue();
- } else {
- throw new AxisFault("Cannot find parameter '" + paramName + "' for "
- + getDescriptionFor(paramInclude));
- }
- }
-
- public static String getOptionalParam(ParameterInclude paramInclude, String paramName) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- if (param != null && param.getValue() != null && param.getValue() instanceof String) {
- return (String) param.getValue();
- } else {
- return null;
- }
- }
-
- public static Integer getOptionalParamInt(ParameterInclude paramInclude, String paramName) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- if (param == null || param.getValue() == null) {
- return null;
- } else {
- Object paramValue = param.getValue();
- if (paramValue instanceof Integer) {
- return (Integer)paramValue;
- } else if (paramValue instanceof String) {
- try {
- return Integer.valueOf((String)paramValue);
- } catch (NumberFormatException ex) {
- throw new AxisFault("Invalid value '" + paramValue + "' for parameter '" + paramName +
- "' for " + getDescriptionFor(paramInclude));
- }
- } else {
- throw new AxisFault("Invalid type for parameter '" + paramName + "' for " +
- getDescriptionFor(paramInclude));
- }
- }
- }
-
- public static int getOptionalParamInt(ParameterInclude paramInclude, String paramName, int defaultValue) throws AxisFault {
- Integer value = getOptionalParamInt(paramInclude, paramName);
- return value == null ? defaultValue : value.intValue();
- }
-
- public static boolean getOptionalParamBoolean(ParameterInclude paramInclude, String paramName, boolean defaultValue) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- return param == null ? defaultValue : JavaUtils.isTrueExplicitly(param.getValue(), defaultValue);
- }
-
- public static int getRequiredParamInt(ParameterInclude paramInclude, String paramName) throws AxisFault {
- Integer value = getOptionalParamInt(paramInclude, paramName);
- if (value == null) {
- throw new AxisFault("Cannot find parameter '" + paramName +
- "' for " + getDescriptionFor(paramInclude));
- } else {
- return value.intValue();
- }
- }
-
- private static String getDescriptionFor(ParameterInclude paramInclude) {
- if (paramInclude instanceof AxisService) {
- return "service '" + ((AxisService)paramInclude).getName() + "'";
- } else if (paramInclude instanceof TransportInDescription) {
- return "transport receiver '" + ((TransportInDescription)paramInclude).getName() + "'";
- } else if (paramInclude instanceof TransportOutDescription) {
- return "transport sender '" + ((TransportOutDescription)paramInclude).getName() + "'";
- } else {
- return paramInclude.getClass().getName();
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java b/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java
deleted file mode 100644
index cb8dfee..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.axis2.transport.base;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.WSDL2Constants;
-
-/**
- * Describes a protocol specific endpoint. This might be a TCP/UDP port, a mail account,
- * a JMS destination, etc. Typically, a protocol specific endpoint is mapped to a
- * service.
- */
-public abstract class ProtocolEndpoint {
- private AbstractTransportListenerEx<?> listener;
- /** Axis2 service */
- private AxisService service;
-
- // This is called only by AbstractTransportListenerEx and must have package access
- void init(AbstractTransportListenerEx<?> listener, AxisService service) {
- this.listener = listener;
- this.service = service;
- }
-
- public final AbstractTransportListenerEx<?> getListener() {
- return listener;
- }
-
- public final AxisService getService() {
- return service;
- }
-
- /**
- * Get the name of the service to which messages received by this endpoint are pre-dispatched.
- *
- * @return the name of the service, or <code>null</code> if message are not pre-dispatched
- */
- public final String getServiceName() {
- return service == null ? null : service.getName();
- }
-
- /**
- * Get the Axis2 configuration context. This is a convenience method that can be used by
- * subclasses to get the {@link ConfigurationContext} object from the listener.
- *
- * @return the configuration context
- */
- protected final ConfigurationContext getConfigurationContext() {
- return listener.getConfigurationContext();
- }
-
- /**
- * Configure the endpoint based on the provided parameters.
- * If no relevant parameters are found, the implementation should
- * return <code>false</code>. An exception should only be thrown if there is an
- * error or inconsistency in the parameters.
- *
- * @param params The source of the parameters to configure the
- * endpoint. If the parameters are defined on
- * a service, this will be an {@link AxisService}
- * instance.
- * @return <code>true</code> if the parameters contained the required configuration
- * information and the endpoint has been configured, <code>false</code> if
- * the no configuration for the endpoint is present in the parameters
- * @throws AxisFault if configuration information is present, but there is an
- * error or inconsistency in the parameters
- */
- public abstract boolean loadConfiguration(ParameterInclude params) throws AxisFault;
-
- /**
- * Get the endpoint references for this protocol endpoint.
- *
- * @param service The service to build the EPR for. If {@link #getService()} returns
- * a non null value, then it has the same value as this parameter, which
- * is never null.
- * @param ip The host name or IP address of the local host. The implementation should use
- * this information instead of {@link java.net.InetAddress#getLocalHost()}.
- * The value of this parameter may be <code>null</code>, in which case the
- * implementation should use {@link org.apache.axis2.util.Utils#getIpAddress(
- * org.apache.axis2.engine.AxisConfiguration)}.
- * @return an array of endpoint references
- * @throws AxisFault
- *
- * @see org.apache.axis2.transport.TransportListener#getEPRsForService(String, String)
- */
- public abstract EndpointReference[] getEndpointReferences(AxisService service, String ip) throws AxisFault;
-
- /**
- * Get a short description of this endpoint suitable for inclusion in log messages.
- *
- * @return a short description of the endpoint
- */
- // TODO: we should implement this method in all derived transports and make it abstract here
- public String getDescription() {
- return toString();
- }
-
- public MessageContext createMessageContext() throws AxisFault {
- MessageContext msgContext = listener.createMessageContext();
-
- if (service != null) {
- msgContext.setAxisService(service);
-
- // find the operation for the message, or default to one
- Parameter operationParam = service.getParameter(BaseConstants.OPERATION_PARAM);
- QName operationQName = (
- operationParam != null ?
- BaseUtils.getQNameFromString(operationParam.getValue()) :
- BaseConstants.DEFAULT_OPERATION);
-
- AxisOperation operation = service.getOperation(operationQName);
- if (operation != null) {
- msgContext.setAxisOperation(operation);
- msgContext.setAxisMessage(
- operation.getMessage(WSDL2Constants.MESSAGE_LABEL_IN));
- msgContext.setSoapAction("urn:" + operation.getName().getLocalPart());
- }
- }
- return msgContext;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/SynchronousCallback.java b/modules/base/src/main/java/org/apache/axis2/transport/base/SynchronousCallback.java
deleted file mode 100644
index fd00cee..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/SynchronousCallback.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisMessage;
-import org.apache.axis2.wsdl.WSDLConstants;
-
-
-public class SynchronousCallback {
-
- private MessageContext outMessageContext;
- private MessageContext inMessageContext;
-
- private boolean isComplete;
-
- public SynchronousCallback(MessageContext outMessageContext) {
- this.outMessageContext = outMessageContext;
- this.isComplete = false;
- }
-
- public synchronized void setInMessageContext(MessageContext inMessageContext) throws AxisFault {
-
- // if some other thread has access and complete then return without doing any thing.
- // thread should have activate by the first message.
- if (!isComplete) {
- // this code is invoked only if the code use with axis2 at the client side
- // when axis2 client receive messages it waits in the sending thread until the response comes.
- // so this thread only notify the waiting thread and hence we need to build the message here.
- inMessageContext.getEnvelope().build();
- OperationContext operationContext = outMessageContext.getOperationContext();
- MessageContext msgCtx =
- operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-
- if (msgCtx == null) {
- // try to see whether there is a piggy back message context
- if (outMessageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) != null) {
-
- msgCtx = (MessageContext) outMessageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE);
- msgCtx.setTransportIn(inMessageContext.getTransportIn());
- msgCtx.setTransportOut(inMessageContext.getTransportOut());
- msgCtx.setServerSide(false);
- msgCtx.setProperty(BaseConstants.MAIL_CONTENT_TYPE,
- inMessageContext.getProperty(BaseConstants.MAIL_CONTENT_TYPE));
- // FIXME: this class must not be transport dependent since it is used by AbstractTransportListener
- msgCtx.setIncomingTransportName(org.apache.axis2.Constants.TRANSPORT_MAIL);
- msgCtx.setEnvelope(inMessageContext.getEnvelope());
-
- } else {
- inMessageContext.setOperationContext(operationContext);
- inMessageContext.setServiceContext(outMessageContext.getServiceContext());
- if (!operationContext.isComplete()) {
- operationContext.addMessageContext(inMessageContext);
- }
- AxisOperation axisOp = operationContext.getAxisOperation();
- AxisMessage inMessage = axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- inMessageContext.setAxisMessage(inMessage);
- inMessageContext.setServerSide(false);
- }
-
- } else {
- msgCtx.setOperationContext(operationContext);
- msgCtx.setServiceContext(outMessageContext.getServiceContext());
- AxisOperation axisOp = operationContext.getAxisOperation();
- AxisMessage inMessage = axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- msgCtx.setAxisMessage(inMessage);
- msgCtx.setTransportIn(inMessageContext.getTransportIn());
- msgCtx.setTransportOut(inMessageContext.getTransportOut());
- msgCtx.setServerSide(false);
- msgCtx.setProperty(BaseConstants.MAIL_CONTENT_TYPE,
- inMessageContext.getProperty(BaseConstants.MAIL_CONTENT_TYPE));
- // FIXME: this class must not be transport dependent since it is used by AbstractTransportListener
- msgCtx.setIncomingTransportName(org.apache.axis2.Constants.TRANSPORT_MAIL);
- msgCtx.setEnvelope(inMessageContext.getEnvelope());
-
- }
- this.inMessageContext = inMessageContext;
- isComplete = true;
- this.notifyAll();
- }
-
- }
-
-
- public boolean isComplete() {
- return isComplete;
- }
-
- public void setComplete(boolean complete) {
- isComplete = complete;
- }
-
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportConfiguration.java b/modules/base/src/main/java/org/apache/axis2/transport/base/TransportConfiguration.java
deleted file mode 100644
index a9c3c44..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportConfiguration.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Properties;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- *
- */
-public class TransportConfiguration {
-
- // defaults
- private static final int WORKERS_CORE_THREADS = 20;
- private static final int WORKERS_MAX_THREADS = 100;
- private static final int WORKER_KEEP_ALIVE = 5;
- private static final int BLOCKING_QUEUE_LENGTH = -1;
-
- // server listener
- private static final String S_T_CORE = "snd_t_core";
- private static final String S_T_MAX = "snd_t_max";
- private static final String S_T_ALIVE = "snd_alive_sec";
- private static final String S_T_QLEN = "snd_qlen";
-
- // client sender
- private static final String C_T_CORE = "lst_t_core";
- private static final String C_T_MAX = "lst_t_max";
- private static final String C_T_ALIVE = "lst_alive_sec";
- private static final String C_T_QLEN = "lst_qlen";
-
- private static final Log log = LogFactory.getLog(TransportConfiguration.class);
- private static Map<String, TransportConfiguration> _configurations
- = new HashMap<String, TransportConfiguration>();
- private Properties props;
-
- private TransportConfiguration(String transportName) {
- try {
- props = BaseUtils.loadProperties(transportName + ".properties");
- } catch (Exception ignore) {}
- }
-
- public static TransportConfiguration getConfiguration(String transportName) {
- if (_configurations.containsKey(transportName)) {
- return _configurations.get(transportName);
- } else {
- TransportConfiguration config = new TransportConfiguration(transportName);
- _configurations.put(transportName, config);
- return config;
- }
- }
-
- public int getServerCoreThreads() {
- return getProperty(S_T_CORE, WORKERS_CORE_THREADS);
- }
-
- public int getServerMaxThreads() {
- return getProperty(S_T_MAX, WORKERS_MAX_THREADS);
- }
-
- public int getServerKeepalive() {
- return getProperty(S_T_ALIVE, WORKER_KEEP_ALIVE);
- }
-
- public int getServerQueueLen() {
- return getProperty(S_T_QLEN, BLOCKING_QUEUE_LENGTH);
- }
-
- public int getClientCoreThreads() {
- return getProperty(C_T_CORE, WORKERS_CORE_THREADS);
- }
-
- public int getClientMaxThreads() {
- return getProperty(C_T_MAX, WORKERS_MAX_THREADS);
- }
-
- public int getClientKeepalive() {
- return getProperty(C_T_ALIVE, WORKER_KEEP_ALIVE);
- }
-
- public int getClientQueueLen() {
- return getProperty(C_T_QLEN, BLOCKING_QUEUE_LENGTH);
- }
-
- /**
- * Get properties that tune nhttp transport. Preference to system properties
- * @param name name of the system/config property
- * @param def default value to return if the property is not set
- * @return the value of the property to be used
- */
- public int getProperty(String name, int def) {
- String val = System.getProperty(name);
- if (val == null) {
- val = props.getProperty(name);
- }
-
- if (val != null && Integer.valueOf(val) > 0) {
- if (log.isDebugEnabled()) {
- log.debug("Using transport tuning parameter : " + name + " = " + val);
- }
- return Integer.valueOf(val);
- }
- return def;
- }
-
- /**
- * Get properties that tune nhttp transport. Preference to system properties
- * @param name name of the system/config property
- * @param def default value to return if the property is not set
- * @return the value of the property to be used
- */
- public boolean getBooleanValue(String name, boolean def) {
- String val = System.getProperty(name);
- if (val == null) {
- val = props.getProperty(name);
- }
-
- if (val != null && Boolean.parseBoolean(val)) {
- if (log.isDebugEnabled()) {
- log.debug("Using transport tuning parameter : " + name);
- }
- return true;
- }
- return def;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointView.java b/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointView.java
deleted file mode 100644
index 2649291..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointView.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.axis2.transport.base;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-
-public class TransportListenerEndpointView implements TransportListenerEndpointViewMBean {
- private final AbstractTransportListener listener;
- private final String serviceName;
-
- public TransportListenerEndpointView(AbstractTransportListener listener, String serviceName) {
- this.listener = listener;
- this.serviceName = serviceName;
- }
-
- public String[] getAddresses() {
- String hostname;
- try {
- hostname = InetAddress.getLocalHost().getHostName();
- }
- catch (UnknownHostException ex) {
- hostname = "localhost";
- }
- EndpointReference[] epr;
- try {
- epr = listener.getEPRsForService(serviceName, hostname);
- }
- catch (AxisFault ex) {
- return null;
- }
- if (epr == null) {
- return null;
- } else {
- String[] result = new String[epr.length];
- for (int i=0; i<epr.length; i++) {
- result[i] = epr[i].getAddress();
- }
- return result;
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointViewMBean.java b/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointViewMBean.java
deleted file mode 100644
index 64d97c8..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointViewMBean.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.axis2.transport.base;
-
-public interface TransportListenerEndpointViewMBean {
- String[] getAddresses();
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportMBeanSupport.java b/modules/base/src/main/java/org/apache/axis2/transport/base/TransportMBeanSupport.java
deleted file mode 100644
index 703afc9..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportMBeanSupport.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-import java.lang.management.ManagementFactory;
-
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.TransportSender;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Support class to register MBeans for transport listeners and senders.
- * This class can be used by {@link TransportListener} and {@link TransportSender} classes
- * to register the {@link TransportView} management bean. It takes care of registering
- * the bean under a consistent name and makes sure that a JMX related error doesn't stop
- * the transport from working: a failure to register the MBean will cause JMX support
- * to be disabled.
- */
-public class TransportMBeanSupport {
- private static final Log log = LogFactory.getLog(TransportMBeanSupport.class);
-
- private boolean enabled = true;
- private boolean registered;
- private MBeanServer mbs;
- private ObjectName mbeanName;
- private TransportView mbeanInstance;
-
- private TransportMBeanSupport(String connectorName, TransportView mbeanInstance) {
- try {
- mbs = ManagementFactory.getPlatformMBeanServer();
- } catch (SecurityException ex) {
- log.warn("Unable to get the platform MBean server; JMX support disabled", ex);
- enabled = false;
- return;
- }
- String jmxAgentName = System.getProperty("jmx.agent.name");
- if (jmxAgentName == null || "".equals(jmxAgentName)) {
- jmxAgentName = "org.apache.axis2";
- }
- String mbeanNameString = jmxAgentName + ":Type=Transport,ConnectorName=" + connectorName;
- try {
- mbeanName = ObjectName.getInstance(mbeanNameString);
- } catch (MalformedObjectNameException ex) {
- log.warn("Unable to create object name '" + mbeanNameString
- + "'; JMX support disabled", ex);
- enabled = false;
- }
- this.mbeanInstance = mbeanInstance;
- }
-
- public TransportMBeanSupport(TransportListener listener, String name) {
- this(name + "-listener-" + listener.hashCode(), new TransportView(listener, null));
- }
-
- public TransportMBeanSupport(TransportSender sender, String name) {
- this(name + "-sender-" + sender.hashCode(), new TransportView(null, sender));
- }
-
- public ObjectName getMBeanName() {
- return mbeanName;
- }
-
- /**
- * Register the {@link TransportView} MBean.
- */
- public void register() {
- if (enabled && !registered) {
- try {
- mbs.registerMBean(mbeanInstance, mbeanName);
- registered = true;
- } catch (Exception e) {
- log.warn("Error registering a MBean with objectname ' " + mbeanName +
- " ' for JMX management", e);
- enabled = false;
- }
- }
- }
-
- /**
- * Unregister the {@link TransportView} MBean.
- */
- public void unregister() {
- if (enabled && registered) {
- try {
- mbs.unregisterMBean(mbeanName);
- registered = false;
- } catch (Exception e) {
- log.warn("Error un-registering a MBean with objectname ' " + mbeanName +
- " ' for JMX management", e);
- }
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportView.java b/modules/base/src/main/java/org/apache/axis2/transport/base/TransportView.java
deleted file mode 100644
index 3eae31a..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportView.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.TransportSender;
-
-import java.util.Map;
-
-public class TransportView implements TransportViewMBean {
-
- private ManagementSupport managementSupport = null;
-
- private TransportListener listener = null;
-
- private TransportSender sender = null;
-
- public TransportView(TransportListener listener, TransportSender sender) {
- if (listener != null) {
- this.listener = listener;
- if (listener instanceof ManagementSupport) {
- managementSupport = (ManagementSupport) listener;
- }
- }
- if (sender != null) {
- this.sender = sender;
- if (sender instanceof ManagementSupport) {
- managementSupport = (ManagementSupport) sender;
- }
- }
- }
-
- // JMX Attributes
- public long getMessagesReceived() {
- if (managementSupport != null) {
- return managementSupport.getMessagesReceived();
- }
- return -1;
- }
-
- public long getFaultsReceiving() {
- if (managementSupport != null) {
- return managementSupport.getFaultsReceiving();
- }
- return -1;
- }
-
- public long getTimeoutsReceiving() {
- if (managementSupport != null) {
- return managementSupport.getTimeoutsReceiving();
- }
- return -1;
- }
-
- public long getTimeoutsSending() {
- if (managementSupport != null) {
- managementSupport.getTimeoutsSending();
- }
- return -1;
- }
-
- public long getBytesReceived() {
- if (managementSupport != null) {
- return managementSupport.getBytesReceived();
- }
- return -1;
- }
-
- public long getMessagesSent() {
- if (managementSupport != null) {
- return managementSupport.getMessagesSent();
- }
- return -1;
- }
-
- public long getFaultsSending() {
- if (managementSupport != null) {
- return managementSupport.getFaultsSending();
- }
- return -1;
- }
-
- public long getBytesSent() {
- if (managementSupport != null) {
- return managementSupport.getBytesSent();
- }
- return -1;
- }
-
- public long getMinSizeReceived() {
- if (managementSupport != null) {
- return managementSupport.getMinSizeReceived();
- }
- return -1;
- }
-
- public long getMaxSizeReceived() {
- if (managementSupport != null) {
- return managementSupport.getMaxSizeReceived();
- }
- return -1;
- }
-
- public double getAvgSizeReceived() {
- if (managementSupport != null) {
- return managementSupport.getAvgSizeReceived();
- }
- return -1;
- }
-
- public long getMinSizeSent() {
- if (managementSupport != null) {
- return managementSupport.getMinSizeSent();
- }
- return -1;
- }
-
- public long getMaxSizeSent() {
- if (managementSupport != null) {
- return managementSupport.getMaxSizeSent();
- }
- return -1;
- }
-
- public double getAvgSizeSent() {
- if (managementSupport != null) {
- return managementSupport.getAvgSizeSent();
- }
- return -1;
- }
-
- public Map getResponseCodeTable() {
- if (managementSupport != null ) {
- return managementSupport.getResponseCodeTable();
- }
- return null;
- }
-
- public int getActiveThreadCount() {
- if (managementSupport != null) {
- return managementSupport.getActiveThreadCount();
- }
- return -1;
- }
-
- public int getQueueSize() {
- if (managementSupport != null) {
- return managementSupport.getQueueSize();
- }
- return -1;
- }
-
- // JMX Operations
- public void start() throws Exception{
- if (listener != null) {
- listener.start();
- }
- }
-
- public void stop() throws Exception {
- if (listener != null) {
- listener.stop();
- } else if (sender != null) {
- sender.stop();
- }
- }
-
- public void pause() throws Exception {
- if (managementSupport != null) {
- managementSupport.pause();
- }
- }
-
- public void resume() throws Exception {
- if (managementSupport != null) {
- managementSupport.resume();
- }
- }
-
- public void maintenenceShutdown(long seconds) throws Exception {
- if (managementSupport != null) {
- managementSupport.maintenenceShutdown(seconds * 1000);
- }
- }
-
- public void resetStatistics() {
- if (managementSupport != null) {
- managementSupport.resetStatistics();
- }
- }
-
- public long getLastResetTime() {
- if (managementSupport != null) {
- return managementSupport.getLastResetTime();
- }
- return -1;
- }
-
- public long getMetricsWindow() {
- if (managementSupport != null) {
- return System.currentTimeMillis() - managementSupport.getLastResetTime();
- }
- return -1;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportViewMBean.java b/modules/base/src/main/java/org/apache/axis2/transport/base/TransportViewMBean.java
deleted file mode 100644
index 71219eb..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/TransportViewMBean.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base;
-import java.util.Map;
-
-public interface TransportViewMBean {
-
- // JMX Attributes
- public long getMessagesReceived();
- public long getFaultsReceiving();
- public long getTimeoutsReceiving();
- public long getMessagesSent();
- public long getFaultsSending();
- public long getTimeoutsSending();
- public long getBytesReceived();
- public long getBytesSent();
- public long getMinSizeReceived();
- public long getMaxSizeReceived();
- public double getAvgSizeReceived();
- public long getMinSizeSent();
- public long getMaxSizeSent();
- public double getAvgSizeSent();
- public int getActiveThreadCount();
- public int getQueueSize();
- public Map getResponseCodeTable();
-
- // JMX Operations
- public void start() throws Exception;
- public void stop() throws Exception;
- public void pause() throws Exception;
- public void resume() throws Exception;
- public void maintenenceShutdown(long seconds) throws Exception;
-
- public void resetStatistics();
- public long getLastResetTime();
- public long getMetricsWindow();
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java
deleted file mode 100644
index f94d452..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base.datagram;
-
-import java.io.IOException;
-import java.net.SocketException;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.transport.base.AbstractTransportListenerEx;
-
-public abstract class AbstractDatagramTransportListener<E extends DatagramEndpoint>
- extends AbstractTransportListenerEx<E> {
-
- private DatagramDispatcher<E> dispatcher;
- private String defaultIp;
-
- @Override
- protected void doInit() throws AxisFault {
- DatagramDispatcherCallback callback = new DatagramDispatcherCallback() {
-
- public void receive(DatagramEndpoint endpoint,
- byte[] data,
- int length,
- DatagramOutTransportInfo outInfo) {
- workerPool.execute(new ProcessPacketTask(endpoint, data, length, outInfo));
- }
- };
-
- try {
- dispatcher = createDispatcher(callback);
- } catch (IOException ex) {
- throw new AxisFault("Unable to create selector", ex);
- }
-
- try {
- defaultIp = org.apache.axis2.util.Utils.getIpAddress(cfgCtx.getAxisConfiguration());
- } catch (SocketException ex) {
- throw new AxisFault("Unable to determine the host's IP address", ex);
- }
- }
-
- @Override
- protected final E createEndpoint() {
- E endpoint = doCreateEndpoint();
- endpoint.setMetrics(metrics);
- return endpoint;
- }
-
- protected abstract E doCreateEndpoint();
-
- @Override
- protected void startEndpoint(E endpoint) throws AxisFault {
- try {
- dispatcher.addEndpoint(endpoint);
- } catch (IOException ex) {
- // TODO: passing endpoint.getService() is not correct because it may be null
- throw new AxisFault("Unable to listen on endpoint " + endpoint.getDescription(), ex);
- }
- if (log.isDebugEnabled()) {
- log.debug("Started listening on endpoint " + endpoint.getDescription() +
- " [contentType=" + endpoint.getContentType() +
- "; service=" + endpoint.getServiceName() + "]");
- }
- }
-
- @Override
- protected void stopEndpoint(E endpoint) {
- try {
- dispatcher.removeEndpoint(endpoint);
- } catch (IOException ex) {
- log.error("I/O exception while stopping listener for service " +
- endpoint.getServiceName(), ex);
- }
- }
-
- @Override
- public void destroy() {
- super.destroy();
- try {
- dispatcher.stop();
- } catch (IOException ex) {
- log.error("Failed to stop dispatcher", ex);
- }
- }
-
- protected abstract DatagramDispatcher<E> createDispatcher(DatagramDispatcherCallback callback)
- throws IOException;
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcher.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcher.java
deleted file mode 100644
index dac82c0..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcher.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base.datagram;
-
-import java.io.IOException;
-
-public interface DatagramDispatcher<E> {
- void addEndpoint(E endpoint) throws IOException;
- void removeEndpoint(E endpoint) throws IOException;
- void stop() throws IOException;
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcherCallback.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcherCallback.java
deleted file mode 100644
index f494f6b..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcherCallback.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base.datagram;
-
-public interface DatagramDispatcherCallback {
- /**
- * Receive a message and inject it into the Axis2 engine.
- *
- * @param endpoint
- * the endpoint that received the message
- * @param data
- * the data of the message
- * @param length
- * the length of the message
- * @param outInfo
- * The out transport information that should be used to send back a response. This
- * should only be set by transports that support an explicit back channel.
- */
- void receive(DatagramEndpoint endpoint,
- byte[] data,
- int length,
- DatagramOutTransportInfo outInfo);
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java
deleted file mode 100644
index b2cf6f4..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base.datagram;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.transport.base.MetricsCollector;
-import org.apache.axis2.transport.base.ParamUtils;
-import org.apache.axis2.transport.base.ProtocolEndpoint;
-
-/**
- * Endpoint description.
- * This class is used by the transport to store information
- * about an endpoint, e.g. the Axis service it is bound to.
- * Transports extend this abstract class to store additional
- * transport specific information, such as the port number
- * the transport listens on.
- */
-public abstract class DatagramEndpoint extends ProtocolEndpoint {
- private String contentType;
- private MetricsCollector metrics;
-
- public String getContentType() {
- return contentType;
- }
-
- public MetricsCollector getMetrics() {
- return metrics;
- }
-
- public void setMetrics(MetricsCollector metrics) {
- this.metrics = metrics;
- }
-
- @Override
- public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
- contentType = ParamUtils.getRequiredParam(
- params, "transport." + getListener().getTransportName() + ".contentType");
- return true;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramOutTransportInfo.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramOutTransportInfo.java
deleted file mode 100644
index dbac4e4..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramOutTransportInfo.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.transport.base.datagram;
-
-import org.apache.axis2.transport.OutTransportInfo;
-
-public class DatagramOutTransportInfo implements OutTransportInfo {
- private String contentType;
-
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/ProcessPacketTask.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/ProcessPacketTask.java
deleted file mode 100644
index a969222..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/ProcessPacketTask.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base.datagram;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axis2.transport.base.MetricsCollector;
-import org.apache.axis2.Constants;
-
-/**
- * Task encapsulating the processing of a datagram.
- * Instances of this class will be dispatched to worker threads for
- * execution.
- */
-public class ProcessPacketTask implements Runnable {
- private static final Log log = LogFactory.getLog(ProcessPacketTask.class);
-
- private final DatagramEndpoint endpoint;
- private final byte[] data;
- private final int length;
-
- //back channel data
- private DatagramOutTransportInfo outInfo;
-
- public ProcessPacketTask(DatagramEndpoint endpoint,
- byte[] data,
- int length,
- DatagramOutTransportInfo outInfo) {
- this.endpoint = endpoint;
- this.data = data;
- this.length = length;
- this.outInfo = outInfo;
- }
-
- public void run() {
- MetricsCollector metrics = endpoint.getMetrics();
- try {
- InputStream inputStream = new ByteArrayInputStream(data, 0, length);
- MessageContext msgContext = endpoint.createMessageContext();
- SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, inputStream, endpoint.getContentType());
- msgContext.setEnvelope(envelope);
-
- if (outInfo != null) {
- if (outInfo.getContentType() == null) {
- outInfo.setContentType(endpoint.getContentType());
- }
- msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outInfo);
- }
-
- AxisEngine.receive(msgContext);
- metrics.incrementMessagesReceived();
- metrics.incrementBytesReceived(length);
- } catch (Exception ex) {
- metrics.incrementFaultsReceiving();
- StringBuilder buffer = new StringBuilder("Error during processing of datagram:\n");
- Utils.hexDump(buffer, data, length);
- log.error(buffer.toString(), ex);
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/Utils.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/Utils.java
deleted file mode 100644
index 3954bb3..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/Utils.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base.datagram;
-
-/**
- * Utility class with methods used by datagram transports.
- */
-public class Utils {
- private Utils() {}
-
- public static void hexDump(StringBuilder buffer, byte[] data, int length) {
- for (int start = 0; start < length; start += 16) {
- for (int i=0; i<16; i++) {
- int index = start+i;
- if (index < length) {
- String hex = Integer.toHexString(data[start+i] & 0xFF);
- if (hex.length() < 2) {
- buffer.append('0');
- }
- buffer.append(hex);
- } else {
- buffer.append(" ");
- }
- buffer.append(' ');
- if (i == 7) {
- buffer.append(' ');
- }
- }
- buffer.append(" |");
- for (int i=0; i<16; i++) {
- int index = start+i;
- if (index < length) {
- int b = data[index] & 0xFF;
- if (32 <= b && b < 128) {
- buffer.append((char)b);
- } else {
- buffer.append('.');
- }
- } else {
- buffer.append(' ');
- }
- }
- buffer.append('|');
- buffer.append('\n');
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/package-info.java b/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/package-info.java
deleted file mode 100644
index 0a79235..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Base classes for datagram transports.
- * <p>
- * A datagram type transport is a transport that entirely reads a message
- * into memory before starting to process it: in contrast to transports like HTTP,
- * it doesn't support streaming. This approach can be chosen either because
- * of the characteristics of the underlying protocol (such as in the case of UDP)
- * or because streaming a message would unnecessarily delay the processing of the
- * next available message (as in the case of a UNIX pipe).
- */
-package org.apache.axis2.transport.base.datagram;
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/URLEndpoint.java b/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/URLEndpoint.java
deleted file mode 100644
index 89bdbf7..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/URLEndpoint.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.endpoint;
-
-import org.apache.axis2.builder.Builder;
-import org.apache.axis2.builder.SOAPBuilder;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.Parameter;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class URLEndpoint {
- private Pattern urlPattern;
-
- private Map<String, Builder> messageBuilders = new HashMap<String, Builder>();
-
- private List<Parameter> parameters = new ArrayList<Parameter>();
-
- private Builder defaultBuilder = new SOAPBuilder();
-
- public URLEndpoint(Pattern urlPattern) {
- this.urlPattern = urlPattern;
- }
-
- public boolean isMatching(String url) {
- Matcher matcher = urlPattern.matcher(url);
- return matcher.matches();
- }
-
- public void addBuilder(String name, Builder builder) {
- messageBuilders.put(name, builder);
- }
-
- public void addParameter(Parameter parameter) {
- parameters.add(parameter);
- }
-
- public Parameter getParameter(String name) {
- for (Parameter p : parameters) {
- if (p.getName().equals(name)) {
- return p;
- }
- }
- return null;
- }
-
- public List<Parameter> getParameters() {
- return parameters;
- }
-
- public void setDefaultBuilder(Builder defaultBuilder) {
- this.defaultBuilder = defaultBuilder;
- }
-
- public Builder getBuilder(String contentType) {
- Builder builder = messageBuilders.get(contentType);
- if (builder == null) {
- return defaultBuilder;
- }
-
- return builder;
- }
-
- public void setParameters(MessageContext msgCtx) {
- for (Parameter p : parameters) {
- msgCtx.setProperty(p.getName(), p.getValue());
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/URLEndpointsConfiguration.java b/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/URLEndpointsConfiguration.java
deleted file mode 100644
index e3a41d9..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/URLEndpointsConfiguration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base.endpoint;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class URLEndpointsConfiguration {
- public static final String URL_PATTERN = "urlPattern";
- public static final String MESSAGE_BUILDERS = "messageBuilders";
- public static final String MESSAGE_BUILDER = "messageBuilder";
- public static final String CONTENT_TYPE = "contentType";
- public static final String CLASS = "class";
- public static final String PARAMETER = "parameter";
- public static final String NAME = "name";
- public static final String ENDPOINT = "endpoint";
- private List<URLEndpoint> endpoints = new ArrayList<URLEndpoint>();
-
- /**
- * Return the endpoint matching the given URL.
- * @param url url of the request
- * @return the endpoint matching the given url
- */
- public URLEndpoint getEndpoint(String url) {
- for (URLEndpoint epr : endpoints) {
- if (epr.isMatching(url)) {
- return epr;
- }
- }
-
- return null;
- }
-
- public List<URLEndpoint> getEndpoints() {
- return endpoints;
- }
-
- public void addEndpoint(URLEndpoint endpoint) {
- endpoints.add(endpoint);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/config/URLEndpointFactory.java b/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/config/URLEndpointFactory.java
deleted file mode 100644
index 116cca5..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/config/URLEndpointFactory.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.endpoint.config;
-
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.builder.Builder;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.transport.base.endpoint.URLEndpoint;
-import org.apache.axis2.transport.base.endpoint.URLEndpointsConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.regex.Pattern;
-
-public class URLEndpointFactory {
- private static final Log log = LogFactory.getLog(URLEndpointFactory.class);
-
- public URLEndpoint create(OMElement xml) throws AxisFault {
- OMAttribute urlPatternAttr = xml.getAttribute(new QName(URLEndpointsConfiguration.URL_PATTERN));
- if (urlPatternAttr == null) {
- handleException(URLEndpointsConfiguration.URL_PATTERN +
- " attribute is mandory for an URLEndpoint configuration");
- return null;
- }
-
- String pattern = urlPatternAttr.getAttributeValue();
- URLEndpoint endpoint = new URLEndpoint(Pattern.compile(pattern));
-
- OMElement messageBuilders = xml.getFirstChildWithName(
- new QName(URLEndpointsConfiguration.MESSAGE_BUILDERS));
-
- if (messageBuilders != null) {
- OMAttribute defaultBuilderAttr = messageBuilders.getAttribute(
- new QName("defaultBuilder"));
- if (defaultBuilderAttr != null) {
- Builder builder = loadBuilder(defaultBuilderAttr.getAttributeValue());
- if (builder != null) {
- endpoint.setDefaultBuilder(builder);
- }
- }
-
- Iterator it = messageBuilders.getChildrenWithName(
- new QName(URLEndpointsConfiguration.MESSAGE_BUILDER));
- while(it.hasNext()) {
- OMElement builderElement = (OMElement) it.next();
-
- OMAttribute contentTypeAttr = builderElement.getAttribute(
- new QName(URLEndpointsConfiguration.CONTENT_TYPE));
- if (contentTypeAttr == null) {
- handleException(URLEndpointsConfiguration.CONTENT_TYPE +
- " attribute cannot be null for URLEndpoint " +
- "with the " + URLEndpointsConfiguration.URL_PATTERN + " : " + pattern);
- }
-
- OMAttribute classAttr = builderElement.getAttribute(
- new QName(URLEndpointsConfiguration.CLASS));
- if (classAttr == null) {
- handleException(URLEndpointsConfiguration.CLASS +
- " attribute cannot be null for URLEndpoint " +
- "with the " + URLEndpointsConfiguration.URL_PATTERN + " : " + pattern);
- }
-
- if (classAttr != null && contentTypeAttr != null) {
- Builder builder = loadBuilder(classAttr.getAttributeValue());
- if (builder != null) {
- endpoint.addBuilder(contentTypeAttr.getAttributeValue(), builder);
- }
- }
- }
- }
-
- Iterator paramItr = xml.getChildrenWithName(
- new QName(URLEndpointsConfiguration.PARAMETER));
- while (paramItr.hasNext()) {
- OMElement p = (OMElement) paramItr.next();
- OMAttribute paramNameAttr = p.getAttribute(new QName(URLEndpointsConfiguration.NAME));
- if (paramNameAttr == null) {
- handleException("Parameter " + URLEndpointsConfiguration.NAME + " cannot be null");
- } else {
- endpoint.addParameter(new Parameter(paramNameAttr.getAttributeValue(), p.getText()));
- }
- }
-
- return endpoint;
- }
-
- private Builder loadBuilder(String name) throws AxisFault {
- try {
- if (name != null) {
- Class c = Class.forName(name);
- Object o = c.newInstance();
- if (o instanceof Builder) {
- return (Builder) o;
- } else {
- handleException("Class : " + name +
- " should be a Builder");
- }
- }
- } catch (ClassNotFoundException e) {
- handleException("Error creating builder: " + name, e);
- } catch (InstantiationException e) {
- handleException("Error initializing builder: " + name, e);
- } catch (IllegalAccessException e) {
- handleException("Error initializing builder: " + name, e);
- }
-
- return null;
- }
-
- private void handleException(String msg) throws AxisFault {
- log.error(msg);
- throw new AxisFault(msg);
- }
-
- private void handleException(String msg, Exception e) throws AxisFault {
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/config/URLEndpointsConfigurationFactory.java b/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/config/URLEndpointsConfigurationFactory.java
deleted file mode 100644
index 8537451..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/endpoint/config/URLEndpointsConfigurationFactory.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.endpoint.config;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.transport.base.endpoint.URLEndpoint;
-import org.apache.axis2.transport.base.endpoint.URLEndpointsConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.Iterator;
-
-public class URLEndpointsConfigurationFactory {
- private static final Log log = LogFactory.getLog(URLEndpointsConfigurationFactory.class);
-
- public URLEndpointsConfiguration create(OMElement element) throws AxisFault {
- Iterator iterator = element.getChildrenWithName(new QName(URLEndpointsConfiguration.ENDPOINT));
- URLEndpointsConfiguration configuration = new URLEndpointsConfiguration();
- URLEndpointFactory fac = new URLEndpointFactory();
- while (iterator.hasNext()) {
- OMElement endpoint = (OMElement) iterator.next();
-
- URLEndpoint epr = fac.create(endpoint);
- configuration.addEndpoint(epr);
- }
-
- return configuration;
- }
-
- public URLEndpointsConfiguration create(String fileName) throws AxisFault {
- File synapseConfigLocation = new File(fileName);
-
- FileInputStream is = null;
- try {
- is = new FileInputStream(synapseConfigLocation);
- } catch (FileNotFoundException e) {
- handleException("Error reading file: " + fileName + "for creating the " +
- URLEndpointsConfiguration.ENDPOINT + " configurations");
- }
- OMElement element = OMXMLBuilderFactory.createOMBuilder(is).getDocumentElement();
- element.build();
-
- Iterator iterator = element.getChildrenWithName(new QName(URLEndpointsConfiguration.ENDPOINT));
- URLEndpointsConfiguration configuration = new URLEndpointsConfiguration();
- URLEndpointFactory fac = new URLEndpointFactory();
- while (iterator.hasNext()) {
- OMElement endpoint = (OMElement) iterator.next();
-
- URLEndpoint epr = fac.create(endpoint);
- configuration.addEndpoint(epr);
- }
-
- return configuration;
- }
-
- private void handleException(String msg) throws AxisFault {
- log.error(msg);
- throw new AxisFault(msg);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java b/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java
deleted file mode 100644
index 6808859..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.event;
-
-import org.apache.axis2.description.AxisService;
-
-public class TransportError {
- private final Object source;
- private final AxisService service;
- private final Throwable exception;
-
- public TransportError(Object source, AxisService service, Throwable exception) {
- this.source = source;
- this.service = service;
- this.exception = exception;
- }
-
- public Object getSource() {
- return source;
- }
-
- public AxisService getService() {
- return service;
- }
-
- public Throwable getException() {
- return exception;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java b/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java
deleted file mode 100644
index 2bb7c3b..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.event;
-
-public interface TransportErrorListener {
- void error(TransportError error);
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java b/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java
deleted file mode 100644
index d87e559..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.event;
-
-public interface TransportErrorSource {
- void addErrorListener(TransportErrorListener listener);
- void removeErrorListener(TransportErrorListener listener);
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java b/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java
deleted file mode 100644
index f4c7b69..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.event;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.axis2.description.AxisService;
-
-public class TransportErrorSourceSupport implements TransportErrorSource {
- private final Object source;
- private final List<TransportErrorListener> listeners = new LinkedList<TransportErrorListener>();
-
- public TransportErrorSourceSupport(Object source) {
- this.source = source;
- }
-
- public synchronized void addErrorListener(TransportErrorListener listener) {
- listeners.add(listener);
- }
-
- public synchronized void removeErrorListener(TransportErrorListener listener) {
- listeners.remove(listener);
- }
-
- public synchronized void error(AxisService service, Throwable ex) {
- if (!listeners.isEmpty()) {
- TransportError error = new TransportError(source, service, ex);
- for (TransportErrorListener listener : listeners) {
- listener.error(error);
- }
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeThreadFactory.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeThreadFactory.java
deleted file mode 100644
index fe771ed..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeThreadFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * This is a simple ThreadFactory implementation using java.util.concurrent
- * Creates threads with the given name prefix
- */
-public class NativeThreadFactory implements
- ThreadFactory {
-
- final ThreadGroup group;
- final AtomicInteger count;
- final String namePrefix;
-
- public NativeThreadFactory(final ThreadGroup group, final String namePrefix) {
- super();
- this.count = new AtomicInteger(1);
- this.group = group;
- this.namePrefix = namePrefix;
- }
-
- public Thread newThread(final Runnable runnable) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(this.namePrefix);
- buffer.append('-');
- buffer.append(this.count.getAndIncrement());
- Thread t = new Thread(group, runnable, buffer.toString(), 0);
- t.setDaemon(false);
- t.setPriority(Thread.NORM_PRIORITY);
- return t;
- }
-}
\ No newline at end of file
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeWorkerPool.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeWorkerPool.java
deleted file mode 100644
index aa322ba..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeWorkerPool.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads;
-
-import org.apache.axis2.transport.base.threads.watermark.DefaultWaterMarkQueue;
-import org.apache.axis2.transport.base.threads.watermark.WaterMarkExecutor;
-import org.apache.axis2.transport.base.threads.watermark.WaterMarkQueue;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.concurrent.*;
-
-/**
- * Worker pool implementation based on java.util.concurrent in JDK 1.5 or later.
- */
-public class NativeWorkerPool implements WorkerPool {
-
- static final Log log = LogFactory.getLog(NativeWorkerPool.class);
-
- private final ThreadPoolExecutor executor;
- private final BlockingQueue<Runnable> blockingQueue;
-
- public NativeWorkerPool(int core, int max, int keepAlive,
- int queueLength, String threadGroupName, String threadGroupId) {
-
- if (log.isDebugEnabled()) {
- log.debug("Using native util.concurrent package..");
- }
- blockingQueue =
- (queueLength == -1 ? new LinkedBlockingQueue<Runnable>()
- : new LinkedBlockingQueue<Runnable>(queueLength));
- executor = new ThreadPoolExecutor(
- core, max, keepAlive,
- TimeUnit.SECONDS,
- blockingQueue,
- new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
- }
-
- public NativeWorkerPool(int core, int max, int keepAlive,
- int queueLength, String threadGroupName,
- String threadGroupId, BlockingQueue<Runnable> queue) {
-
- if (log.isDebugEnabled()) {
- log.debug("Using native util.concurrent package..");
- }
-
- if (queue == null) {
- blockingQueue =
- (queueLength == -1 ? new LinkedBlockingQueue<Runnable>()
- : new LinkedBlockingQueue<Runnable>(queueLength));
- } else {
- blockingQueue = queue;
- }
-
- executor = new ThreadPoolExecutor(
- core, max, keepAlive,
- TimeUnit.SECONDS,
- blockingQueue,
- new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
- }
-
- public NativeWorkerPool(int core, int max, int keepAlive,
- int queueLength, String threadGroupName,
- String threadGroupId, BlockingQueue<Runnable> queue,
- RejectedExecutionHandler rejectedExecutionHandler) {
-
- if (log.isDebugEnabled()) {
- log.debug("Using native util.concurrent package..");
- }
-
- if (queue == null) {
- blockingQueue =
- (queueLength == -1 ? new LinkedBlockingQueue<Runnable>()
- : new LinkedBlockingQueue<Runnable>(queueLength));
- } else {
- blockingQueue = queue;
- }
-
- executor = new ThreadPoolExecutor(
- core, max, keepAlive,
- TimeUnit.SECONDS,
- blockingQueue,
- new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId),
- rejectedExecutionHandler);
- }
-
- public NativeWorkerPool(int core, int max, int keepAlive,
- int queueLength, int waterMark, String threadGroupName,
- String threadGroupId) {
-
- if (log.isDebugEnabled()) {
- log.debug("Using native util.concurrent package..");
- }
-
-
- blockingQueue =
- (queueLength == -1 ? new DefaultWaterMarkQueue<Runnable>(waterMark)
- : new DefaultWaterMarkQueue<Runnable>(waterMark, queueLength));
-
- executor = new WaterMarkExecutor(
- core, max, keepAlive,
- TimeUnit.SECONDS,
- (WaterMarkQueue<Runnable>) blockingQueue,
- new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
- }
-
- public NativeWorkerPool(int core, int max, int keepAlive,
- int queueLength, int waterMark, String threadGroupName,
- String threadGroupId, WaterMarkQueue<Runnable> queue) {
-
- if (log.isDebugEnabled()) {
- log.debug("Using native util.concurrent package..");
- }
-
- if (queue == null) {
- blockingQueue =
- (queueLength == -1 ? new DefaultWaterMarkQueue<Runnable>(waterMark)
- : new DefaultWaterMarkQueue<Runnable>(waterMark, queueLength));
- } else {
- blockingQueue = queue;
- }
-
- executor = new WaterMarkExecutor(
- core, max, keepAlive,
- TimeUnit.SECONDS,
- (WaterMarkQueue<Runnable>) blockingQueue,
- new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
- }
-
- public NativeWorkerPool(int core, int max, int keepAlive,
- int queueLength, int waterMark, String threadGroupName,
- String threadGroupId,
- RejectedExecutionHandler rejectedExecutionHandler) {
-
- if (log.isDebugEnabled()) {
- log.debug("Using native util.concurrent package..");
- }
-
-
- blockingQueue =
- (queueLength == -1 ? new DefaultWaterMarkQueue<Runnable>(waterMark)
- : new DefaultWaterMarkQueue<Runnable>(waterMark, queueLength));
-
- executor = new WaterMarkExecutor(
- core, max, keepAlive,
- TimeUnit.SECONDS,
- (WaterMarkQueue<Runnable>) blockingQueue,
- new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId),
- rejectedExecutionHandler);
- }
-
- public void execute(final Runnable task) {
- executor.execute(new Runnable() {
- public void run() {
- try {
- task.run();
- } catch (Throwable t) {
- log.error("Uncaught exception", t);
- }
- }
- });
- }
-
- public int getActiveCount() {
- return executor.getActiveCount();
- }
-
- public int getQueueSize() {
- return blockingQueue.size();
- }
-
- public void shutdown(int timeout) throws InterruptedException {
- executor.shutdown();
- executor.awaitTermination(timeout, TimeUnit.MILLISECONDS);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPool.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPool.java
deleted file mode 100644
index a05bf95..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPool.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads;
-
-public interface WorkerPool {
- /**
- * Asynchronously execute the given task using one of the threads of the worker pool.
- * The task is expected to terminate gracefully, i.e. {@link Runnable#run()} should not
- * throw an exception. Any uncaught exceptions should be logged by the worker pool
- * implementation.
- *
- * @param task the task to execute
- */
- public void execute(Runnable task);
-
- public int getActiveCount();
- public int getQueueSize();
-
- /**
- * Destroy the worker pool. The pool will immediately stop
- * accepting new tasks. All previously submitted tasks will
- * be executed. The method blocks until all tasks have
- * completed execution, or the timeout occurs, or the current
- * thread is interrupted, whichever happens first.
- *
- * @param timeout the timeout value in milliseconds
- * @throws InterruptedException if the current thread was
- * interrupted while waiting for pending tasks to
- * finish execution
- */
- public void shutdown(int timeout) throws InterruptedException;
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPoolFactory.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPoolFactory.java
deleted file mode 100644
index ae3506c..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPoolFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads;
-
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Worker pool factory.
- * For the moment this always creates {@link NativeWorkerPool} instances since
- * we assume that we are running on Java 1.5 or above.
- */
-public class WorkerPoolFactory {
-
- public static WorkerPool getWorkerPool(int core, int max, int keepAlive,
- int queueLength, String threadGroupName,
- String threadGroupId) {
- return new NativeWorkerPool(
- core, max, keepAlive, queueLength, threadGroupName, threadGroupId);
- }
-
- public static WorkerPool getWorkerPool(int core, int max, int keepAlive,
- int queueLength, int waterMark, String threadGroupName,
- String threadGroupId) {
- return new NativeWorkerPool(core, max, keepAlive,
- queueLength, waterMark, threadGroupName,
- threadGroupId);
- }
-
- public static WorkerPool getWorkerPool(int core, int max, int keepAlive,
- int queueLength, String threadGroupName,
- String threadGroupId, BlockingQueue<Runnable> queue) {
- return new NativeWorkerPool(core, max, keepAlive,
- queueLength, threadGroupName,
- threadGroupId, queue);
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/DefaultWaterMarkQueue.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/DefaultWaterMarkQueue.java
deleted file mode 100644
index c31e2bf..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/DefaultWaterMarkQueue.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads.watermark;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Queue;
-import java.util.concurrent.*;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * A Default implementation for WaterMarkQueue interface. The implementation uses an
- * {@link ArrayBlockingQueue} up to water mark. Then it uses a {@link LinkedBlockingQueue} or
- * ArrayBlocking queue from the water mark point. The LinkedBlockingQueue is used if a queue
- * size is specified other than the waterMark.
- *
- * @param <T>
- */
-public class DefaultWaterMarkQueue<T> implements WaterMarkQueue<T> {
-
- private volatile ArrayBlockingQueue<T> waterMarkQueue;
-
- private volatile Queue<T> afterWaterMarkQueue;
-
- private Lock lock = new ReentrantLock();
-
- /**
- * Create a {@link WaterMarkQueue} with a waterMark. The queue will first fill up
- * to waterMark. These items will be inserted in to an {@link ArrayBlockingQueue}.
- * After this an {@link LinkedBlockingQueue} will be used without a bound.
- *
- * @param waterMark the waterMark of the queue
- */
- public DefaultWaterMarkQueue(int waterMark) {
- afterWaterMarkQueue = new LinkedBlockingQueue<T>();
-
- waterMarkQueue = new ArrayBlockingQueue<T>(waterMark);
- }
-
- /**
- * Create a {@link WaterMarkQueue} with a waterMark. The queue will first fill up
- * to waterMark. These items will be inserted in to an {@link ArrayBlockingQueue}.
- * After this an {@link LinkedBlockingQueue} will be used with capacity
- * <code>size - waterMark.</code>
- *
- * @param waterMark the waterMark of the queue
- * @param size the size of the queue
- */
- public DefaultWaterMarkQueue(int waterMark, int size) {
- if (waterMark <= size) {
- afterWaterMarkQueue = new ArrayBlockingQueue<T>(size - waterMark);
- } else {
- throw new IllegalArgumentException("Size should be equal or greater than water mark");
- }
-
- waterMarkQueue = new ArrayBlockingQueue<T>(waterMark);
- }
-
- public boolean add(T t) {
- return waterMarkQueue.add(t);
-
- }
-
- public boolean offer(T t) {
- return waterMarkQueue.offer(t);
- }
-
- public T remove() {
- T t = waterMarkQueue.remove();
- tryMoveTasks();
- return t;
- }
-
- public T poll() {
- T t = waterMarkQueue.poll();
- tryMoveTasks();
- return t;
- }
-
- public T element() {
- return waterMarkQueue.element();
- }
-
- public T peek() {
- return waterMarkQueue.peek();
- }
-
- public void put(T t) throws InterruptedException {
- waterMarkQueue.put(t);
- }
-
- public boolean offer(T t, long l, TimeUnit timeUnit) throws InterruptedException {
- return waterMarkQueue.offer(t, l, timeUnit);
- }
-
- public T take() throws InterruptedException {
- T t = waterMarkQueue.take();
- tryMoveTasks();
- return t;
- }
-
- public T poll(long l, TimeUnit timeUnit) throws InterruptedException {
- T t = waterMarkQueue.poll(l, timeUnit);
- tryMoveTasks();
- return t;
- }
-
- public int remainingCapacity() {
- return waterMarkQueue.remainingCapacity();
- }
-
- public boolean remove(Object o) {
- boolean b = waterMarkQueue.remove(o);
- tryMoveTasks();
- return b;
- }
-
- public boolean containsAll(Collection<?> objects) {
- return waterMarkQueue.containsAll(objects);
- }
-
- public boolean addAll(Collection<? extends T> ts) {
- return waterMarkQueue.addAll(ts);
- }
-
- public boolean removeAll(Collection<?> objects) {
- boolean b = waterMarkQueue.removeAll(objects);
- tryMoveTasks();
-
- return b;
- }
-
- public boolean retainAll(Collection<?> objects) {
- return waterMarkQueue.retainAll(objects);
- }
-
- public void clear() {
- waterMarkQueue.clear();
- afterWaterMarkQueue.clear();
- }
-
- public int size() {
- return waterMarkQueue.size() + afterWaterMarkQueue.size();
- }
-
- public boolean isEmpty() {
- tryMoveTasks();
- return waterMarkQueue.isEmpty();
- }
-
- private void tryMoveTasks() {
- if (afterWaterMarkQueue.size() > 0) {
- lock.lock();
- try {
- while (afterWaterMarkQueue.size() > 0) {
- T w = afterWaterMarkQueue.poll();
- boolean offer = waterMarkQueue.offer(w);
- if (!offer) {
- afterWaterMarkQueue.offer(w);
- break;
- }
- }
- } finally {
- lock.unlock();
- }
- }
- }
-
- public boolean contains(Object o) {
- return waterMarkQueue.contains(o) || afterWaterMarkQueue.contains(o);
- }
-
- public Iterator<T> iterator() {
- return new IteratorImpl();
- }
-
- public Object[] toArray() {
- return waterMarkQueue.toArray();
- }
-
- public <T> T[] toArray(T[] ts) {
- T[] waterMarkArray = waterMarkQueue.toArray(ts);
- T[] afterWaterMarkArray = afterWaterMarkQueue.toArray(ts);
-
- final int alen = waterMarkArray.length;
- final int blen = afterWaterMarkArray.length;
- if (alen == 0) {
- return afterWaterMarkArray;
- }
-
- if (blen == 0) {
- return waterMarkArray;
- }
-
- final T[] result = (T[]) java.lang.reflect.Array.
- newInstance(waterMarkArray.getClass().getComponentType(), alen + blen);
- System.arraycopy(waterMarkArray, 0, result, 0, alen);
- System.arraycopy(afterWaterMarkArray, 0, result, alen, blen);
- return result;
- }
-
- public int drainTo(Collection<? super T> objects) {
- int n = waterMarkQueue.drainTo(objects);
- tryMoveTasks();
-
- return n;
- }
-
- public int drainTo(Collection<? super T> objects, int i) {
- int n = waterMarkQueue.drainTo(objects, i);
- tryMoveTasks();
- return n;
- }
-
- public boolean offerAfter(T t) {
- lock.lock();
- try {
- return afterWaterMarkQueue.offer(t);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Iterator for DefaultWaterMarkQueue
- */
- private class IteratorImpl implements Iterator<T> {
- Iterator<T> waterMarkIterator = null;
-
- Iterator<T> afterWaterMarkIterator = null;
-
- boolean waterMarkQueueDone = false;
-
- private IteratorImpl() {
- waterMarkIterator = waterMarkQueue.iterator();
- afterWaterMarkIterator = afterWaterMarkQueue.iterator();
-
- waterMarkQueueDone = false;
- }
-
- public boolean hasNext() {
- return waterMarkIterator.hasNext() || afterWaterMarkIterator.hasNext();
- }
-
- public T next() {
- lock.lock();
- try {
- if (waterMarkIterator.hasNext()) {
- return waterMarkIterator.next();
- } else {
- waterMarkQueueDone = true;
- return afterWaterMarkIterator.next();
- }
- } finally {
- lock.unlock();
- }
- }
-
- public void remove() {
- if (!waterMarkQueueDone) {
- waterMarkIterator.remove();
- } else {
- afterWaterMarkIterator.remove();
- }
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkExecutor.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkExecutor.java
deleted file mode 100644
index c33e111..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkExecutor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads.watermark;
-
-import java.util.concurrent.*;
-
-/**
- * An {@link ExecutorService} that executes each submitted task using
- * one of possibly several pooled threads, but the execution happens differently
- * from the {@link ThreadPoolExecutor}. In this executor after all the core pool threads
- * are used queuing happens until the water mark. If the more tasks are submitted after
- * the queue is filled up to the water mark the number of threads increases to max.
- * If the number of tasks continue to increase the Queue begins to fill up. If the queue
- * is a bounded queue and the queue is completely filled a {@link RejectedExecutionHandler}
- * is executed if one specified. Otherwise the task is rejected.
- */
-public class WaterMarkExecutor extends ThreadPoolExecutor {
- public WaterMarkExecutor(int core, int max, long keepAlive,
- TimeUnit timeUnit, WaterMarkQueue<Runnable> queue) {
- super(core, max, keepAlive, timeUnit, queue, new WaterMarkRejectionHandler(null));
- }
-
- public WaterMarkExecutor(int core, int max, long keepAlive,
- TimeUnit timeUnit, WaterMarkQueue<Runnable> queue,
- ThreadFactory threadFactory) {
- super(core, max, keepAlive,
- timeUnit, queue, threadFactory, new WaterMarkRejectionHandler(null));
- }
-
- public WaterMarkExecutor(int core, int max,
- long keepAlive, TimeUnit timeUnit,
- WaterMarkQueue<Runnable> queue,
- RejectedExecutionHandler rejectedExecutionHandler) {
-
- super(core, max, keepAlive, timeUnit,
- queue, new WaterMarkRejectionHandler(rejectedExecutionHandler));
- }
-
- public WaterMarkExecutor(int core, int max, long keepAlive,
- TimeUnit timeUnit, WaterMarkQueue<Runnable> queue,
- ThreadFactory threadFactory,
- RejectedExecutionHandler rejectedExecutionHandler) {
- super(core, max, keepAlive, timeUnit,
- queue, threadFactory, new WaterMarkRejectionHandler(rejectedExecutionHandler));
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkQueue.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkQueue.java
deleted file mode 100644
index 2bdefd9..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkQueue.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads.watermark;
-
-import java.util.concurrent.BlockingQueue;
-
-/**
- * This queue acts as a queue with a mark. The methods exposed by the <code>BlockingQueue</code>
- * interface will add elements up to the mark. We call this mark the waterMark. After the
- * water mark the all the insertion operations will fails as if the queue is bounded by
- * this waterMark. After this to add values to the queue the offerAfter method should be called.
- *
- * @param <T> The object
- */
-public interface WaterMarkQueue<T> extends BlockingQueue<T> {
- /**
- * Offer the element after the water mark.
- *
- * @param object object to be inserted
- * @return true if the insert is successful
- */
- public boolean offerAfter(T object);
-}
-
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkRejectionHandler.java b/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkRejectionHandler.java
deleted file mode 100644
index 4f38c73..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkRejectionHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads.watermark;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * This class implements the {@link RejectedExecutionHandler} and provide a mechanism for
- * having the water mark in the {@link WaterMarkExecutor}. This is an internal class used by
- * the {@link WaterMarkExecutor}.
- */
-class WaterMarkRejectionHandler implements RejectedExecutionHandler {
- RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.AbortPolicy();
-
- public WaterMarkRejectionHandler(RejectedExecutionHandler rejectedExecutionHandler) {
- if (rejectedExecutionHandler != null) {
- this.rejectedExecutionHandler = rejectedExecutionHandler;
- }
- }
-
- public void rejectedExecution(Runnable runnable, ThreadPoolExecutor threadPoolExecutor) {
- BlockingQueue q = threadPoolExecutor.getQueue();
- if (q instanceof WaterMarkQueue) {
- WaterMarkQueue wq = (WaterMarkQueue) q;
-
- if (!wq.offerAfter(runnable)) {
- if (rejectedExecutionHandler != null) {
- rejectedExecutionHandler.rejectedExecution(runnable, threadPoolExecutor);
- }
- }
- }
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceFilter.java b/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceFilter.java
deleted file mode 100644
index 35c9e0a..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceFilter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.tracker;
-
-import org.apache.axis2.description.AxisService;
-
-/**
- * Filter for {@link AxisService} instances. This interface is used by
- * {@link AxisServiceTracker}.
- */
-public interface AxisServiceFilter {
- /**
- * Examine whether a given service matches the filter criteria.
- *
- * @param service the service to examine
- * @return <code>true</code> if the service matches the filter criteria
- */
- boolean matches(AxisService service);
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceTracker.java b/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceTracker.java
deleted file mode 100644
index 19b5258..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceTracker.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.tracker;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.Set;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.AxisEvent;
-import org.apache.axis2.engine.AxisObserver;
-
-/**
- * <p>Tracks services deployed in a given {@link AxisConfiguration}.
- * The tracker is configured with references to three objects:</p>
- * <ol>
- * <li>An {@link AxisConfiguration} to watch.</li>
- * <li>An {@link AxisServiceFilter} restricting the services to track.</li>
- * <li>An {@link AxisServiceTrackerListener} receiving tracking events.</li>
- * </ol>
- * <p>An instance of this class maintains an up-to-date list of services
- * satisfying all of the following criteria:</p>
- * <ol>
- * <li>The service is deployed in the given {@link AxisConfiguration}.</li>
- * <li>The service is started, i.e. {@link AxisService#isActive()} returns true.</li>
- * <li>The service matches the criteria specified by the given
- * {@link AxisServiceFilter} instance.</li>
- * </ol>
- * <p>Whenever a service appears on the list, the tracker will call
- * {@link AxisServiceTrackerListener#serviceAdded(AxisService)}. When a service disappears, it
- * will call {@link AxisServiceTrackerListener#serviceRemoved(AxisService)}.</p>
- * <p>When the tracker is created, it is initially in the stopped state. In this state no
- * events will be sent to the listener. It can be started using {@link #start()} and stopped again
- * using {@link #stop()}. The tracker list is defined to be empty when the tracker is in the
- * stopped state. This implies that a call to {@link #start()} will generate
- * {@link AxisServiceTrackerListener#serviceAdded(AxisService)} events for all services that meet
- * the above criteria at that point in time. In the same way, {@link #stop()} will generate
- * {@link AxisServiceTrackerListener#serviceRemoved(AxisService)} events for the current entries
- * in the list.</p>
- * <p>As a corollary the tracker guarantees that during a complete lifecycle (start-stop),
- * there will be exactly one {@link AxisServiceTrackerListener#serviceRemoved(AxisService)} event
- * for every {@link AxisServiceTrackerListener#serviceAdded(AxisService)} event and vice-versa.
- * This property is important when the tracker is used to allocate resources for a dynamic set
- * of services.</p>
- *
- * <h2>Limitations</h2>
- *
- * <p>The tracker is not able to detect property changes on services. E.g. if a service initially
- * matches the filter criteria, but later changes so that it doesn't match the criteria any more,
- * the tracker will not be able to detect this and the service will not be removed from the tracker
- * list.</p>
- */
-public class AxisServiceTracker {
- private final AxisObserver observer = new AxisObserver() {
- public void init(AxisConfiguration axisConfig) {}
-
- public void serviceUpdate(AxisEvent event, final AxisService service) {
- switch (event.getEventType()) {
- case AxisEvent.SERVICE_DEPLOY:
- case AxisEvent.SERVICE_START:
- if (filter.matches(service)) {
- boolean pending;
- synchronized (lock) {
- if (pending = (pendingActions != null)) {
- pendingActions.add(new Runnable() {
- public void run() {
- serviceAdded(service);
- }
- });
- }
- }
- if (!pending) {
- serviceAdded(service);
- }
- }
- break;
- case AxisEvent.SERVICE_REMOVE:
- case AxisEvent.SERVICE_STOP:
- // Don't check filter here because the properties of the service may have
- // changed in the meantime.
- boolean pending;
- synchronized (lock) {
- if (pending = (pendingActions != null)) {
- pendingActions.add(new Runnable() {
- public void run() {
- serviceRemoved(service);
- }
- });
- }
- }
- if (!pending) {
- serviceRemoved(service);
- }
- }
- }
-
- public void moduleUpdate(AxisEvent event, AxisModule module) {}
- public void addParameter(Parameter param) throws AxisFault {}
- public void removeParameter(Parameter param) throws AxisFault {}
- public void deserializeParameters(OMElement parameterElement) throws AxisFault {}
- public Parameter getParameter(String name) { return null; }
- public ArrayList<Parameter> getParameters() { return null; }
- public boolean isParameterLocked(String parameterName) { return false; }
- public void serviceGroupUpdate(AxisEvent event, AxisServiceGroup serviceGroup) {}
- };
-
- private final AxisConfiguration config;
- final AxisServiceFilter filter;
- private final AxisServiceTrackerListener listener;
-
- /**
- * Object used to synchronize access to {@link #pendingActions} and {@link #services}.
- */
- final Object lock = new Object();
-
- /**
- * Queue for notifications received by the {@link AxisObserver} during startup of the tracker.
- * We need this because the events may already be reflected in the list of services returned
- * by {@link AxisConfiguration#getServices()} (getting the list of currently deployed services
- * and adding the observer can't be done atomically). It also allows us to make sure that
- * events are sent to the listener in the right order, e.g. when a service is being removed
- * during startup of the tracker.
- */
- Queue<Runnable> pendingActions;
-
- /**
- * The current list of services. <code>null</code> if the tracker is stopped.
- */
- private Set<AxisService> services;
-
- public AxisServiceTracker(AxisConfiguration config, AxisServiceFilter filter,
- AxisServiceTrackerListener listener) {
- this.config = config;
- this.filter = filter;
- this.listener = listener;
- }
-
- /**
- * Check whether the tracker is started.
- *
- * @return <code>true</code> if the tracker is started
- */
- public boolean isStarted() {
- return services != null;
- }
-
- /**
- * Start the tracker.
- *
- * @throws IllegalStateException if the tracker has already been started
- */
- public void start() {
- if (services != null) {
- throw new IllegalStateException();
- }
- synchronized (lock) {
- pendingActions = new LinkedList<Runnable>();
- config.addObservers(observer);
- services = new HashSet<AxisService>();
- }
- for (AxisService service : config.getServices().values()) {
- if (service.isActive() && filter.matches(service)) {
- serviceAdded(service);
- }
- }
- while (true) {
- Runnable action;
- synchronized (lock) {
- action = pendingActions.poll();
- if (action == null) {
- pendingActions = null;
- break;
- }
- }
- action.run();
- }
- }
-
- void serviceAdded(AxisService service) {
- // callListener may be false because the observer got an event for a service that
- // was already in the initial list of services retrieved by AxisConfiguration#getServices.
- boolean callListener;
- synchronized (lock) {
- callListener = services.add(service);
- }
- if (callListener) {
- listener.serviceAdded(service);
- }
- }
-
- void serviceRemoved(AxisService service) {
- // callListener may be false because the observer invokes this method without applying the
- // filter.
- boolean callListener;
- synchronized (lock) {
- callListener = services.remove(service);
- }
- if (callListener) {
- listener.serviceRemoved(service);
- }
- }
-
- /**
- * Stop the tracker.
- *
- * @throws IllegalStateException if the tracker is not started
- */
- public void stop() {
- if (services == null) {
- throw new IllegalStateException();
- }
- config.removeObserver(observer);
- for (AxisService service : services) {
- listener.serviceRemoved(service);
- }
- services = null;
- }
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceTrackerListener.java b/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceTrackerListener.java
deleted file mode 100644
index 285d91d..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/AxisServiceTrackerListener.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.tracker;
-
-import org.apache.axis2.description.AxisService;
-
-/**
- * Listener for events generated by an {@link AxisServiceTracker}.
- */
-public interface AxisServiceTrackerListener {
- /**
- * Inform the listener that a service has been added to tracker list.
- *
- * @param service the service that has been added to the tracker list
- */
- void serviceAdded(AxisService service);
-
- /**
- * Inform the listener that a service has been removed from the tracker list.
- *
- * @param service the service that has been removed from the tracker list
- */
- void serviceRemoved(AxisService service);
-}
diff --git a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/package-info.java b/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/package-info.java
deleted file mode 100644
index 30dc21e..0000000
--- a/modules/base/src/main/java/org/apache/axis2/transport/base/tracker/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Contains utility classes to track a dynamic set of services deployed in an
- * Axis configuration.
- *
- * @see org.apache.axis2.transport.base.tracker.AxisServiceTracker
- */
-package org.apache.axis2.transport.base.tracker;
\ No newline at end of file
diff --git a/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java b/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java
deleted file mode 100644
index fea1733..0000000
--- a/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.activation.DataSource;
-
-import junit.framework.TestCase;
-
-public class ManagedDataSourceFactoryTest extends TestCase {
- /**
- * Test that exceptions thrown by {@link DataSource#getInputStream()} are
- * correctly propagated. Since {@link ManagedDataSourceFactory} uses dynamic
- * proxies this aspect needs particular attention.
- */
- public void testExceptionPropagation() {
- ManagedDataSource ds = ManagedDataSourceFactory.create(new DataSource() {
- public String getContentType() {
- return null;
- }
-
- public InputStream getInputStream() throws IOException {
- throw new IOException("TEST");
- }
-
- public OutputStream getOutputStream() throws IOException {
- return null;
- }
-
- public String getName() {
- return null;
- }
- });
- try {
- ds.getInputStream();
- } catch (IOException ex) {
- assertEquals("TEST", ex.getMessage());
- }
- }
-}
diff --git a/modules/base/src/test/java/org/apache/axis2/format/PlainTextFormatterTest.java b/modules/base/src/test/java/org/apache/axis2/format/PlainTextFormatterTest.java
deleted file mode 100644
index 683f910..0000000
--- a/modules/base/src/test/java/org/apache/axis2/format/PlainTextFormatterTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.format;
-
-import java.io.ByteArrayOutputStream;
-
-import junit.framework.TestCase;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.format.PlainTextFormatter;
-import org.apache.axis2.transport.base.BaseConstants;
-
-public class PlainTextFormatterTest extends TestCase {
- private static final String testString = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre";
-
- private MessageContext createMessageContext(String textPayload) throws AxisFault {
- MessageContext messageContext = new MessageContext();
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- OMElement textWrapper = factory.createOMElement(BaseConstants.DEFAULT_TEXT_WRAPPER);
- textWrapper.setText(textPayload);
- envelope.getBody().addChild(textWrapper);
- messageContext.setEnvelope(envelope);
- return messageContext;
- }
-
- private void testGetBytes(String encoding) throws Exception {
- MessageContext messageContext = createMessageContext(testString);
- OMOutputFormat format = new OMOutputFormat();
- format.setCharSetEncoding(encoding);
- byte[] bytes = new PlainTextFormatter().getBytes(messageContext, format);
- assertEquals(testString, new String(bytes, encoding));
- }
-
- public void testGetBytesUTF8() throws Exception {
- testGetBytes("UTF-8");
- }
-
- public void testGetBytesLatin1() throws Exception {
- testGetBytes("ISO-8859-1");
- }
-
- private void testWriteTo(String encoding) throws Exception {
- MessageContext messageContext = createMessageContext(testString);
- OMOutputFormat format = new OMOutputFormat();
- format.setCharSetEncoding(encoding);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- new PlainTextFormatter().writeTo(messageContext, format, baos, false);
- assertEquals(testString, new String(baos.toByteArray(), encoding));
- }
-
- public void testWriteToUTF8() throws Exception {
- testWriteTo("UTF-8");
- }
-
- public void testWriteToLatin1() throws Exception {
- testWriteTo("ISO-8859-1");
- }
-}
diff --git a/modules/base/src/test/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkExecutorTest.java b/modules/base/src/test/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkExecutorTest.java
deleted file mode 100644
index be83b00..0000000
--- a/modules/base/src/test/java/org/apache/axis2/transport/base/threads/watermark/WaterMarkExecutorTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.base.threads.watermark;
-
-import junit.framework.TestCase;
-
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class WaterMarkExecutorTest extends TestCase {
-
- private WaterMarkExecutor executor = null;
-
- private WaterMarkExecutor executor2 = null;
-
- private final int TASKS = 1000;
-
- private volatile int runTasks = 0;
-
- private volatile int[] tasksSubmitted = new int[TASKS];
-
- private Lock lock = new ReentrantLock();
-
- @Override
- protected void setUp() throws Exception {
- executor = new WaterMarkExecutor(10, 100, 10,
- TimeUnit.SECONDS, new DefaultWaterMarkQueue<Runnable>(100, 500),
- new ThreadPoolExecutor.CallerRunsPolicy());
-
- executor2 = new WaterMarkExecutor(10, 100, 10,
- TimeUnit.SECONDS, new DefaultWaterMarkQueue<Runnable>(100),
- new ThreadPoolExecutor.CallerRunsPolicy());
- }
-
- public void testExecutor() {
- for (int i = 0; i < TASKS; i++) {
- tasksSubmitted[i] = i + 1;
- }
-
- for (int i = 0; i < TASKS; i++) {
- executor.execute(new Test(i + 1, lock));
- }
-
- // this is an best effort number so we wait another 1 second for
- // the executor to finish the tasks
- while (executor.getActiveCount() > 0) {}
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
-
- }
-
- int tasks = 0;
- for (int aTasksSubmitted : tasksSubmitted) {
- if (aTasksSubmitted != 0) {
- tasks++;
- }
- }
-
- assertEquals(TASKS, runTasks);
- assertEquals(tasks, 0);
-
- executor.shutdown();
-
- }
-
- public void testExecutor2() {
- for (int i = 0; i < TASKS; i++) {
- tasksSubmitted[i] = i + 1;
- }
-
- for (int i = 0; i < TASKS; i++) {
- executor2.execute(new Test(i + 1, lock));
- }
-
- // this is an best effort number so we wait another 1 second for
- // the executor to finish the tasks
- while (executor2.getActiveCount() > 0) {}
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
-
- }
-
- int tasks = 0;
- for (int aTasksSubmitted : tasksSubmitted) {
- if (aTasksSubmitted != 0) {
- tasks++;
- }
- }
-
- assertEquals(TASKS, runTasks);
- assertEquals(tasks, 0);
-
- executor2.shutdown();
-
- }
-
- private class Test implements Runnable {
- long taskId;
- Lock tLock;
-
- private Test(long taskId, Lock lock) {
- this.taskId = taskId;
- tLock = lock;
- }
-
- public void run() {
- tLock.lock();
- try {
- runTasks++;
- for (int i = 0; i < TASKS; i++) {
- if (taskId == tasksSubmitted[i]) {
- tasksSubmitted[i] = 0;
- }
- }
- } finally {
- tLock.unlock();
- }
-
- }
- }
-}
diff --git a/modules/jms/pom.xml b/modules/jms/pom.xml
deleted file mode 100644
index a9001e6..0000000
--- a/modules/jms/pom.xml
+++ /dev/null
@@ -1,176 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transports</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-jms</artifactId>
- <name>Apache Axis2 - Transport - JMS</name>
- <description>Apache Axis2 - JMS Transport</description>
- <packaging>bundle</packaging>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/jms</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/jms</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/jms</url>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.0</version>
- <executions>
- <execution>
- <id>copy</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <stripVersion>true</stripVersion>
- <artifactItems>
- <artifactItem>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjweaver</artifactId>
- <outputDirectory>target/lib</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>log4j.configuration</name>
- <value>file:../../log4j.properties</value>
- </property>
- </systemProperties>
- <argLine>-javaagent:target/lib/aspectjweaver.jar -Xms64m -Xmx128m</argLine>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
- <Bundle-Description>${project.description}</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.apache.axis2.transport.jms.*;-split-package:=merge-last,
- </Export-Package>
- <Import-Package>
- !javax.xml.namespace,
- javax.xml.namespace; version=0.0.0,
- *; resolution:=optional
- </Import-Package>
- <DynamicImport-Package>*</DynamicImport-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-testkit</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockejb</groupId>
- <artifactId>mockejb</artifactId>
- <version>0.6-beta2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>qpid-broker</artifactId>
- <version>0.18</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>qpid-client</artifactId>
- <version>0.18</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-core</artifactId>
- <version>5.1.0</version>
- <scope>test</scope>
- <exclusions>
- <!-- We want to choose the JAF implementation ourselves -->
- <exclusion>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_1.1_spec</artifactId>
- <version>${jms-1.1-spec.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
- <version>${jta-spec.version}</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <properties>
- <jms-1.1-spec.version>1.1</jms-1.1-spec.version>
- <jta-spec.version>1.0</jta-spec.version>
- </properties>
-
-</project>
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/AxisJMSException.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/AxisJMSException.java
deleted file mode 100644
index 0a98b14..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/AxisJMSException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-public class AxisJMSException extends RuntimeException {
- private static final long serialVersionUID = 630157137524249401L;
-
- AxisJMSException() {
- super();
- }
-
- AxisJMSException(String msg) {
- super(msg);
- }
-
- AxisJMSException(String msg, Exception e) {
- super(msg, e);
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
deleted file mode 100644
index 5f6405c..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterIncludeImpl;
-import org.apache.axis2.AxisFault;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Hashtable;
-
-/**
- * Encapsulate a JMS Connection factory definition within an Axis2.xml
- *
- * JMS Connection Factory definitions, allows JNDI properties as well as other service
- * level parameters to be defined, and re-used by each service that binds to it
- *
- * When used for sending messages out, the JMSConnectionFactory'ies are able to cache
- * a Connection, Session or Producer
- */
-public class JMSConnectionFactory {
-
- private static final Log log = LogFactory.getLog(JMSConnectionFactory.class);
-
- /** The name used for the connection factory definition within Axis2 */
- private String name = null;
- /** The list of parameters from the axis2.xml definition */
- private Hashtable<String, String> parameters = new Hashtable<String, String>();
-
- /** The cached InitialContext reference */
- private Context context = null;
- /** The JMS ConnectionFactory this definition refers to */
- private ConnectionFactory conFactory = null;
- /** The shared JMS Connection for this JMS connection factory */
- private Connection sharedConnection = null;
- /** The shared JMS Session for this JMS connection factory */
- private Session sharedSession = null;
- /** The shared JMS MessageProducer for this JMS connection factory */
- private MessageProducer sharedProducer = null;
- /** The Shared Destination */
- private Destination sharedDestination = null;
- /** The shared JMS connection for this JMS connection factory */
- private int cacheLevel = JMSConstants.CACHE_CONNECTION;
-
- /**
- * Digest a JMS CF definition from an axis2.xml 'Parameter' and construct
- * @param parameter the axis2.xml 'Parameter' that defined the JMS CF
- */
- public JMSConnectionFactory(Parameter parameter) {
-
- this.name = parameter.getName();
- ParameterIncludeImpl pi = new ParameterIncludeImpl();
-
- try {
- pi.deserializeParameters(parameter.getParameterElement());
- } catch (AxisFault axisFault) {
- handleException("Error reading parameters for JMS connection factory" + name, axisFault);
- }
-
- for (Object o : pi.getParameters()) {
- Parameter p = (Parameter) o;
- parameters.put(p.getName(), (String) p.getValue());
- }
-
- digestCacheLevel();
- try {
- context = new InitialContext(parameters);
- conFactory = JMSUtils.lookup(context, ConnectionFactory.class,
- parameters.get(JMSConstants.PARAM_CONFAC_JNDI_NAME));
- if (parameters.get(JMSConstants.PARAM_DESTINATION) != null) {
- sharedDestination = JMSUtils.lookup(context, Destination.class,
- parameters.get(JMSConstants.PARAM_DESTINATION));
- }
- log.info("JMS ConnectionFactory : " + name + " initialized");
-
- } catch (NamingException e) {
- throw new AxisJMSException("Cannot acquire JNDI context, JMS Connection factory : " +
- parameters.get(JMSConstants.PARAM_CONFAC_JNDI_NAME) + " or default destination : " +
- parameters.get(JMSConstants.PARAM_DESTINATION) +
- " for JMS CF : " + name + " using : " + parameters, e);
- }
- }
-
- /**
- * Digest the cache value if specified
- */
- private void digestCacheLevel() {
-
- String key = JMSConstants.PARAM_CACHE_LEVEL;
- String val = parameters.get(key);
-
- if ("none".equalsIgnoreCase(val)) {
- this.cacheLevel = JMSConstants.CACHE_NONE;
- } else if ("connection".equalsIgnoreCase(val)) {
- this.cacheLevel = JMSConstants.CACHE_CONNECTION;
- } else if ("session".equals(val)){
- this.cacheLevel = JMSConstants.CACHE_SESSION;
- } else if ("consumer".equals(val)) {
- this.cacheLevel = JMSConstants.CACHE_CONSUMER;
- } else if ("producer".equals(val)) {
- this.cacheLevel = JMSConstants.CACHE_PRODUCER;
- } else if ("consumer".equals(val)) {
- this.cacheLevel = JMSConstants.CACHE_CONSUMER;
- } else if (val != null) {
- throw new AxisJMSException("Invalid cache level : " + val + " for JMS CF : " + name);
- }
- }
-
- /**
- * Close all connections, sessions etc.. and stop this connection factory
- */
- public synchronized void stop() {
- if (sharedConnection != null) {
- try {
- sharedConnection.close();
- } catch (JMSException e) {
- log.warn("Error shutting down connection factory : " + name, e);
- }
- }
- }
-
- /**
- * Return the name assigned to this JMS CF definition
- * @return name of the JMS CF
- */
- public String getName() {
- return name;
- }
-
- /**
- * The list of properties (including JNDI and non-JNDI)
- * @return properties defined on the JMS CF
- */
- public Hashtable<String, String> getParameters() {
- return parameters;
- }
-
- /**
- * Get cached InitialContext
- * @return cache InitialContext
- */
- public Context getContext() {
- return context;
- }
-
- /**
- * Cache level applicable for this JMS CF
- * @return applicable cache level
- */
- public int getCacheLevel() {
- return cacheLevel;
- }
-
- /**
- * Get the shared Destination - if defined
- * @return
- */
- public Destination getSharedDestination() {
- return sharedDestination;
- }
-
- /**
- * Lookup a Destination using this JMS CF definitions and JNDI name
- * @param destinationName JNDI name of the Destionation
- * @param destinationType looking up destination type
- * @return JMS Destination for the given JNDI name or null
- */
- public Destination getDestination(String destinationName, String destinationType) {
- try {
- return JMSUtils.lookupDestination(context, destinationName, destinationType);
- } catch (NamingException e) {
- handleException("Error looking up the JMS destination with name " + destinationName
- + " of type " + destinationType, e);
- }
-
- // never executes but keeps the compiler happy
- return null;
- }
-
- /**
- * Get the reply Destination from the PARAM_REPLY_DESTINATION parameter
- * @return reply destination defined in the JMS CF
- */
- public String getReplyToDestination() {
- return parameters.get(JMSConstants.PARAM_REPLY_DESTINATION);
- }
-
- /**
- * Get the reply destination type from the PARAM_REPLY_DEST_TYPE parameter
- * @return reply destination defined in the JMS CF
- */
- public String getReplyDestinationType() {
- return parameters.get(JMSConstants.PARAM_REPLY_DEST_TYPE) != null ?
- parameters.get(JMSConstants.PARAM_REPLY_DEST_TYPE) :
- JMSConstants.DESTINATION_TYPE_GENERIC;
- }
-
- private void handleException(String msg, Exception e) {
- log.error(msg, e);
- throw new AxisJMSException(msg, e);
- }
-
- /**
- * Should the JMS 1.1 API be used? - defaults to yes
- * @return true, if JMS 1.1 api should be used
- */
- public boolean isJmsSpec11() {
- return parameters.get(JMSConstants.PARAM_JMS_SPEC_VER) == null ||
- "1.1".equals(parameters.get(JMSConstants.PARAM_JMS_SPEC_VER));
- }
-
- /**
- * Return the type of the JMS CF Destination
- * @return TRUE if a Queue, FALSE for a Topic and NULL for a JMS 1.1 Generic Destination
- */
- public Boolean isQueue() {
- if (parameters.get(JMSConstants.PARAM_CONFAC_TYPE) == null &&
- parameters.get(JMSConstants.PARAM_DEST_TYPE) == null) {
- return null;
- }
-
- if (parameters.get(JMSConstants.PARAM_CONFAC_TYPE) != null) {
- if ("queue".equalsIgnoreCase(parameters.get(JMSConstants.PARAM_CONFAC_TYPE))) {
- return true;
- } else if ("topic".equalsIgnoreCase(parameters.get(JMSConstants.PARAM_CONFAC_TYPE))) {
- return false;
- } else {
- throw new AxisJMSException("Invalid " + JMSConstants.PARAM_CONFAC_TYPE + " : " +
- parameters.get(JMSConstants.PARAM_CONFAC_TYPE) + " for JMS CF : " + name);
- }
- } else {
- if ("queue".equalsIgnoreCase(parameters.get(JMSConstants.PARAM_DEST_TYPE))) {
- return true;
- } else if ("topic".equalsIgnoreCase(parameters.get(JMSConstants.PARAM_DEST_TYPE))) {
- return false;
- } else {
- throw new AxisJMSException("Invalid " + JMSConstants.PARAM_DEST_TYPE + " : " +
- parameters.get(JMSConstants.PARAM_DEST_TYPE) + " for JMS CF : " + name);
- }
- }
- }
-
- /**
- * Is a session transaction requested from users of this JMS CF?
- * @return session transaction required by the clients of this?
- */
- private boolean isSessionTransacted() {
- return parameters.get(JMSConstants.PARAM_SESSION_TRANSACTED) != null &&
- Boolean.valueOf(parameters.get(JMSConstants.PARAM_SESSION_TRANSACTED));
- }
-
- /**
- * Create a new Connection
- * @return a new Connection
- */
- private Connection createConnection() {
-
- Connection connection = null;
- try {
- connection = JMSUtils.createConnection(
- conFactory,
- parameters.get(JMSConstants.PARAM_JMS_USERNAME),
- parameters.get(JMSConstants.PARAM_JMS_PASSWORD),
- isJmsSpec11(), isQueue());
-
- if (log.isDebugEnabled()) {
- log.debug("New JMS Connection from JMS CF : " + name + " created");
- }
-
- } catch (JMSException e) {
- handleException("Error acquiring a Connection from the JMS CF : " + name +
- " using properties : " + parameters, e);
- }
- return connection;
- }
-
- /**
- * Create a new Session
- * @param connection Connection to use
- * @return A new Session
- */
- private Session createSession(Connection connection) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Creating a new JMS Session from JMS CF : " + name);
- }
- return JMSUtils.createSession(
- connection, isSessionTransacted(), Session.AUTO_ACKNOWLEDGE, isJmsSpec11(), isQueue());
-
- } catch (JMSException e) {
- handleException("Error creating JMS session from JMS CF : " + name, e);
- }
- return null;
- }
-
- /**
- * Create a new MessageProducer
- * @param session Session to be used
- * @param destination Destination to be used
- * @return a new MessageProducer
- */
- private MessageProducer createProducer(Session session, Destination destination) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Creating a new JMS MessageProducer from JMS CF : " + name);
- }
-
- return JMSUtils.createProducer(
- session, destination, isQueue(), isJmsSpec11());
-
- } catch (JMSException e) {
- handleException("Error creating JMS producer from JMS CF : " + name,e);
- }
- return null;
- }
-
- /**
- * Get a new Connection or shared Connection from this JMS CF
- * @return new or shared Connection from this JMS CF
- */
- public Connection getConnection() {
- if (cacheLevel > JMSConstants.CACHE_NONE) {
- return getSharedConnection();
- } else {
- return createConnection();
- }
- }
-
- /**
- * Get a new Session or shared Session from this JMS CF
- * @param connection the Connection to be used
- * @return new or shared Session from this JMS CF
- */
- public Session getSession(Connection connection) {
- if (cacheLevel > JMSConstants.CACHE_CONNECTION) {
- return getSharedSession();
- } else {
- return createSession((connection == null ? getConnection() : connection));
- }
- }
-
- /**
- * Get a new MessageProducer or shared MessageProducer from this JMS CF
- * @param connection the Connection to be used
- * @param session the Session to be used
- * @param destination the Destination to bind MessageProducer to
- * @return new or shared MessageProducer from this JMS CF
- */
- public MessageProducer getMessageProducer(
- Connection connection, Session session, Destination destination) {
- if (cacheLevel > JMSConstants.CACHE_SESSION) {
- return getSharedProducer();
- } else {
- return createProducer((session == null ? getSession(connection) : session), destination);
- }
- }
-
- /**
- * Get a new Connection or shared Connection from this JMS CF
- * @return new or shared Connection from this JMS CF
- */
- private synchronized Connection getSharedConnection() {
- if (sharedConnection == null) {
- sharedConnection = createConnection();
- if (log.isDebugEnabled()) {
- log.debug("Created shared JMS Connection for JMS CF : " + name);
- }
- }
- return sharedConnection;
- }
-
- /**
- * Get a shared Session from this JMS CF
- * @return shared Session from this JMS CF
- */
- private synchronized Session getSharedSession() {
- if (sharedSession == null) {
- sharedSession = createSession(getSharedConnection());
- if (log.isDebugEnabled()) {
- log.debug("Created shared JMS Session for JMS CF : " + name);
- }
- }
- return sharedSession;
- }
-
- /**
- * Get a shared MessageProducer from this JMS CF
- * @return shared MessageProducer from this JMS CF
- */
- private synchronized MessageProducer getSharedProducer() {
- if (sharedProducer == null) {
- sharedProducer = createProducer(getSharedSession(), sharedDestination);
- if (log.isDebugEnabled()) {
- log.debug("Created shared JMS MessageConsumer for JMS CF : " + name);
- }
- }
- return sharedProducer;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactoryManager.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactoryManager.java
deleted file mode 100644
index 02df7e2..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactoryManager.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.Context;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Class managing a set of {@link JMSConnectionFactory} objects.
- */
-public class JMSConnectionFactoryManager {
-
- private static final Log log = LogFactory.getLog(JMSConnectionFactoryManager.class);
-
- /** A Map containing the JMS connection factories managed by this, keyed by name */
- private final Map<String,JMSConnectionFactory> connectionFactories =
- new HashMap<String,JMSConnectionFactory>();
-
- /**
- * Construct a Connection factory manager for the JMS transport sender or receiver
- * @param trpInDesc
- */
- public JMSConnectionFactoryManager(ParameterInclude trpInDesc) {
- loadConnectionFactoryDefinitions(trpInDesc);
- }
-
- /**
- * Create JMSConnectionFactory instances for the definitions in the transport configuration,
- * and add these into our collection of connectionFactories map keyed by name
- *
- * @param trpDesc the transport description for JMS
- */
- private void loadConnectionFactoryDefinitions(ParameterInclude trpDesc) {
-
- for (Parameter p : trpDesc.getParameters()) {
- try {
- JMSConnectionFactory jmsConFactory = new JMSConnectionFactory(p);
- connectionFactories.put(jmsConFactory.getName(), jmsConFactory);
- } catch (AxisJMSException e) {
- log.error("Error setting up connection factory : " + p.getName(), e);
- }
- }
- }
-
- /**
- * Get the JMS connection factory with the given name.
- *
- * @param name the name of the JMS connection factory
- * @return the JMS connection factory or null if no connection factory with
- * the given name exists
- */
- public JMSConnectionFactory getJMSConnectionFactory(String name) {
- return connectionFactories.get(name);
- }
-
- /**
- * Get the JMS connection factory that matches the given properties, i.e. referring to
- * the same underlying connection factory. Used by the JMSSender to determine if already
- * available resources should be used for outgoing messages
- *
- * @param props a Map of connection factory JNDI properties and name
- * @return the JMS connection factory or null if no connection factory compatible
- * with the given properties exists
- */
- public JMSConnectionFactory getJMSConnectionFactory(Map<String,String> props) {
- for (JMSConnectionFactory cf : connectionFactories.values()) {
- Map<String,String> cfProperties = cf.getParameters();
-
- if (equals(props.get(JMSConstants.PARAM_CONFAC_JNDI_NAME),
- cfProperties.get(JMSConstants.PARAM_CONFAC_JNDI_NAME))
- &&
- equals(props.get(Context.INITIAL_CONTEXT_FACTORY),
- cfProperties.get(Context.INITIAL_CONTEXT_FACTORY))
- &&
- equals(props.get(Context.PROVIDER_URL),
- cfProperties.get(Context.PROVIDER_URL))
- &&
- equals(props.get(Context.SECURITY_PRINCIPAL),
- cfProperties.get(Context.SECURITY_PRINCIPAL))
- &&
- equals(props.get(Context.SECURITY_CREDENTIALS),
- cfProperties.get(Context.SECURITY_CREDENTIALS))) {
- return cf;
- }
- }
- return null;
- }
-
- /**
- * Compare two values preventing NPEs
- */
- private static boolean equals(Object s1, Object s2) {
- return s1 == s2 || s1 != null && s1.equals(s2);
- }
-
- /**
- * Stop all connection factories.
- */
- public void stop() {
- for (JMSConnectionFactory conFac : connectionFactories.values()) {
- conFac.stop();
- }
- }
-
- protected void handleException(String msg, Exception e) throws AxisFault {
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConstants.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConstants.java
deleted file mode 100644
index a6c74cf..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConstants.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.client.Options;
-
-public class JMSConstants {
-
- /**
- * The prefix indicating an Axis JMS URL
- */
- public static final String JMS_PREFIX = "jms:/";
-
- //------------------------------------ defaults / constants ------------------------------------
- /**
- * The local (Axis2) JMS connection factory name of the default connection
- * factory to be used, if a service does not explicitly state the connection
- * factory it should be using by a Parameter named JMSConstants.CONFAC_PARAM
- */
- public static final String DEFAULT_CONFAC_NAME = "default";
- /**
- * The default JMS time out waiting for a reply - also see {@link JMS_WAIT_REPLY}
- */
- public static final long DEFAULT_JMS_TIMEOUT = Options.DEFAULT_TIMEOUT_MILLISECONDS;
- /**
- * Value indicating a Queue used for {@link DEST_PARAM_TYPE}, {@link REPLY_PARAM_TYPE}
- */
- public static final String DESTINATION_TYPE_QUEUE = "queue";
- /**
- * Value indicating a Topic used for {@link DEST_PARAM_TYPE}, {@link REPLY_PARAM_TYPE}
- */
- public static final String DESTINATION_TYPE_TOPIC = "topic";
- /**
- * Value indicating a JMS 1.1 Generic Destination used by {@link DEST_PARAM_TYPE}, {@link REPLY_PARAM_TYPE}
- */
- public static final String DESTINATION_TYPE_GENERIC = "generic";
-
- /** Do not cache any JMS resources between tasks (when sending) or JMS CF's (when sending) */
- public static final int CACHE_NONE = 0;
- /** Cache only the JMS connection between tasks (when receiving), or JMS CF's (when sending)*/
- public static final int CACHE_CONNECTION = 1;
- /** Cache only the JMS connection and Session between tasks (receiving), or JMS CF's (sending) */
- public static final int CACHE_SESSION = 2;
- /** Cache the JMS connection, Session and Consumer between tasks when receiving*/
- public static final int CACHE_CONSUMER = 3;
- /** Cache the JMS connection, Session and Producer within a JMSConnectionFactory when sending */
- public static final int CACHE_PRODUCER = 4;
- /** automatic choice of an appropriate caching level (depending on the transaction strategy) */
- public static final int CACHE_AUTO = 5;
-
- /** A JMS 1.1 Generic Destination type or ConnectionFactory */
- public static final int GENERIC = 0;
- /** A Queue Destination type or ConnectionFactory */
- public static final int QUEUE = 1;
- /** A Topic Destination type or ConnectionFactory */
- public static final int TOPIC = 2;
-
- /**
- * The EPR parameter name indicating the name of the message level property that indicated the content type.
- */
- public static final String CONTENT_TYPE_PROPERTY_PARAM = "transport.jms.ContentTypeProperty";
-
- //---------------------------------- services.xml parameters -----------------------------------
- /**
- * The Service level Parameter name indicating the JMS destination for requests of a service
- */
- public static final String PARAM_DESTINATION = "transport.jms.Destination";
- /**
- * The Service level Parameter name indicating the destination type for requests.
- * also see {@link DESTINATION_TYPE_QUEUE}, {@link DESTINATION_TYPE_TOPIC}
- */
- public static final String PARAM_DEST_TYPE = "transport.jms.DestinationType";
- /**
- * The Service level Parameter name indicating the [default] response destination of a service
- */
- public static final String PARAM_REPLY_DESTINATION = "transport.jms.ReplyDestination";
- /**
- * The Service level Parameter name indicating the response destination type
- * also see {@link DESTINATION_TYPE_QUEUE}, {@link DESTINATION_TYPE_TOPIC}
- */
- public static final String PARAM_REPLY_DEST_TYPE = "transport.jms.ReplyDestinationType";
- /**
- * The Parameter name of an Axis2 service, indicating the JMS connection
- * factory which should be used to listen for messages for it. This is
- * the local (Axis2) name of the connection factory and not the JNDI name
- */
- public static final String PARAM_JMS_CONFAC = "transport.jms.ConnectionFactory";
- /**
- * Connection factory type if using JMS 1.0, either DESTINATION_TYPE_QUEUE or DESTINATION_TYPE_TOPIC
- */
- public static final String PARAM_CONFAC_TYPE = "transport.jms.ConnectionFactoryType";
- /**
- * The Parameter name indicating the JMS connection factory JNDI name
- */
- public static final String PARAM_CONFAC_JNDI_NAME = "transport.jms.ConnectionFactoryJNDIName";
- /**
- * The Parameter indicating the expected content type for messages received by the service.
- */
- public static final String CONTENT_TYPE_PARAM = "transport.jms.ContentType";
- /**
- * The Parameter indicating a final EPR as a String, to be published on the WSDL of a service
- * Could occur more than once, and could provide additional connection properties or a subset
- * of the properties auto computed. Also could replace IP addresses with hostnames, and expose
- * public credentials clients. If a user specified this parameter, the auto generated EPR will
- * not be exposed - unless an instance of this parameter is added with the string "legacy"
- * This parameter could be used to expose EPR's conforming to the proposed SOAP/JMS spec
- * until such time full support is implemented for it.
- */
- public static final String PARAM_PUBLISH_EPR = "transport.jms.PublishEPR";
- /** The parameter indicating the JMS API specification to be used - if this is "1.1" the JMS
- * 1.1 API would be used, else the JMS 1.0.2B
- */
- public static final String PARAM_JMS_SPEC_VER = "transport.jms.JMSSpecVersion";
-
- /**
- * The Parameter indicating whether the JMS Session should be transacted for the service
- * Specified as a "true" or "false"
- */
- public static final String PARAM_SESSION_TRANSACTED = "transport.jms.SessionTransacted";
- /**
- * The Parameter indicating the Session acknowledgement for the service. Must be one of the
- * following Strings, or the appropriate Integer used by the JMS API
- * "AUTO_ACKNOWLEDGE", "CLIENT_ACKNOWLEDGE", "DUPS_OK_ACKNOWLEDGE" or "SESSION_TRANSACTED"
- */
- public static final String PARAM_SESSION_ACK = "transport.jms.SessionAcknowledgement";
- /** A message selector to be used when messages are sought for this service */
- public static final String PARAM_MSG_SELECTOR = "transport.jms.MessageSelector";
- /** Is the Subscription durable ? - "true" or "false" See {@link PARAM_DURABLE_SUB_NAME} */
- public static final String PARAM_SUB_DURABLE = "transport.jms.SubscriptionDurable";
- /** The name for the durable subscription See {@link PARAM_SUB_DURABLE}*/
- public static final String PARAM_DURABLE_SUB_NAME = "transport.jms.DurableSubscriberName";
- /**
- * JMS Resource cachable level to be used for the service One of the following:
- * {@link CACHE_NONE}, {@link CACHE_CONNECTION}, {@link CACHE_SESSION}, {@link CACHE_PRODUCER},
- * {@link CACHE_CONSUMER}, or {@link CACHE_AUTO} - to let the transport decide
- */
- public static final String PARAM_CACHE_LEVEL = "transport.jms.CacheLevel";
- /** Should a pub-sub connection receive messages published by itself? */
- public static final String PARAM_PUBSUB_NO_LOCAL = "transport.jms.PubSubNoLocal";
- /**
- * The number of milliseconds to wait for a message on a consumer.receive() call
- * negative number - wait forever
- * 0 - do not wait at all
- * positive number - indicates the number of milliseconds to wait
- */
- public static final String PARAM_RCV_TIMEOUT = "transport.jms.ReceiveTimeout";
- /**
- *The number of concurrent consumers to be created to poll for messages for this service
- * For Topics, this should be ONE, to prevent receipt of multiple copies of the same message
- */
- public static final String PARAM_CONCURRENT_CONSUMERS = "transport.jms.ConcurrentConsumers";
- /**
- * The maximum number of concurrent consumers for the service - See {@link PARAM_CONCURRENT_CONSUMERS}
- */
- public static final String PARAM_MAX_CONSUMERS = "transport.jms.MaxConcurrentConsumers";
- /**
- * The number of idle (i.e. message-less) polling attempts before a worker task commits suicide,
- * to scale down resources, as load decreases
- */
- public static final String PARAM_IDLE_TASK_LIMIT = "transport.jms.IdleTaskLimit";
- /**
- * The maximum number of messages a polling worker task should process, before suicide - to
- * prevent many longer running threads - default is unlimited (i.e. a worker task will live forever)
- */
- public static final String PARAM_MAX_MSGS_PER_TASK = "transport.jms.MaxMessagesPerTask";
- /**
- * Number of milliseconds before the first reconnection attempt is tried, on detection of an
- * error. Subsequent retries follow a geometric series, where the
- * duration = previous duration * factor
- * This is further limited by the {@link PARAM_RECON_MAX_DURATION} to be meaningful
- */
- public static final String PARAM_RECON_INIT_DURATION = "transport.jms.InitialReconnectDuration";
- /** @see PARAM_RECON_INIT_DURATION */
- public static final String PARAM_RECON_FACTOR = "transport.jms.ReconnectProgressFactor";
- /** @see PARAM_RECON_INIT_DURATION */
- public static final String PARAM_RECON_MAX_DURATION = "transport.jms.MaxReconnectDuration";
-
- /** The username to use when obtaining a JMS Connection */
- public static final String PARAM_JMS_USERNAME = "transport.jms.UserName";
- /** The password to use when obtaining a JMS Connection */
- public static final String PARAM_JMS_PASSWORD = "transport.jms.Password";
-
- //-------------- message context / transport header properties and client options --------------
- /**
- * A MessageContext property or client Option indicating the JMS message type
- */
- public static final String JMS_MESSAGE_TYPE = "JMS_MESSAGE_TYPE";
- /**
- * The message type indicating a BytesMessage. See {@link JMS_MESSAGE_TYPE}
- */
- public static final String JMS_BYTE_MESSAGE = "JMS_BYTE_MESSAGE";
- /**
- * The message type indicating a TextMessage. See {@link JMS_MESSAGE_TYPE}
- */
- public static final String JMS_TEXT_MESSAGE = "JMS_TEXT_MESSAGE";
- /**
- * A MessageContext property or client Option indicating the time to wait for a response JMS message
- */
- public static final String JMS_WAIT_REPLY = "JMS_WAIT_REPLY";
- /**
- * A MessageContext property or client Option indicating the JMS correlation id
- */
- public static final String JMS_COORELATION_ID = "JMS_COORELATION_ID";
- /**
- * A MessageContext property or client Option indicating the JMS message id
- */
- public static final String JMS_MESSAGE_ID = "JMS_MESSAGE_ID";
- /**
- * A MessageContext property or client Option indicating the JMS delivery mode as an Integer or String
- * Value 1 - javax.jms.DeliveryMode.NON_PERSISTENT
- * Value 2 - javax.jms.DeliveryMode.PERSISTENT
- */
- public static final String JMS_DELIVERY_MODE = "JMS_DELIVERY_MODE";
- /**
- * A MessageContext property or client Option indicating the JMS destination to use on a Send
- */
- public static final String JMS_DESTINATION = "JMS_DESTINATION";
- /**
- * A MessageContext property or client Option indicating the JMS message expiration - a Long value
- * specified as a String
- */
- public static final String JMS_EXPIRATION = "JMS_EXPIRATION";
- /**
- * A MessageContext property indicating if the message is a redelivery (Boolean as a String)
- */
- public static final String JMS_REDELIVERED = "JMS_REDELIVERED";
- /**
- * A MessageContext property or client Option indicating the JMS replyTo Destination
- */
- public static final String JMS_REPLY_TO = "JMS_REPLY_TO";
- /**
- * A MessageContext property or client Option indicating the JMS replyTo Destination type
- * See {@link DESTINATION_TYPE_QUEUE} and {@link DESTINATION_TYPE_TOPIC}
- */
- public static final String JMS_REPLY_TO_TYPE = "JMS_REPLY_TO_TYPE";
- /**
- * A MessageContext property or client Option indicating the JMS timestamp (Long specified as String)
- */
- public static final String JMS_TIMESTAMP = "JMS_TIMESTAMP";
- /**
- * A MessageContext property indicating the JMS type String returned by {@link javax.jms.Message.getJMSType()}
- */
- public static final String JMS_TYPE = "JMS_TYPE";
- /**
- * A MessageContext property or client Option indicating the JMS priority
- */
- public static final String JMS_PRIORITY = "JMS_PRIORITY";
- /**
- * A MessageContext property or client Option indicating the JMS time to live for message sent
- */
- public static final String JMS_TIME_TO_LIVE = "JMS_TIME_TO_LIVE";
-
- /** The prefix that denotes JMSX properties */
- public static final String JMSX_PREFIX = "JMSX";
- /** The JMSXGroupID property */
- public static final String JMSX_GROUP_ID = "JMSXGroupID";
- /** The JMSXGroupSeq property */
- public static final String JMSX_GROUP_SEQ = "JMSXGroupSeq";
-
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
deleted file mode 100644
index 3f5f00b..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.ParamUtils;
-import org.apache.axis2.transport.base.ProtocolEndpoint;
-import org.apache.axis2.transport.base.threads.WorkerPool;
-import org.apache.axis2.transport.jms.ctype.ContentTypeRuleFactory;
-import org.apache.axis2.transport.jms.ctype.ContentTypeRuleSet;
-import org.apache.axis2.transport.jms.ctype.MessageTypeRule;
-import org.apache.axis2.transport.jms.ctype.PropertyRule;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashSet;
-
-import javax.jms.BytesMessage;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-
-/**
- * Class that links an Axis2 service to a JMS destination. Additionally, it contains
- * all the required information to process incoming JMS messages and to inject them
- * into Axis2.
- */
-public class JMSEndpoint extends ProtocolEndpoint {
- private static final Log log = LogFactory.getLog(JMSEndpoint.class);
-
- private final JMSListener listener;
- private final WorkerPool workerPool;
-
- private JMSConnectionFactory cf;
- private String jndiDestinationName;
- private int destinationType = JMSConstants.GENERIC;
- private String jndiReplyDestinationName;
- private String replyDestinationType = JMSConstants.DESTINATION_TYPE_GENERIC;
- private Set<EndpointReference> endpointReferences = new HashSet<EndpointReference>();
- private ContentTypeRuleSet contentTypeRuleSet;
- private ServiceTaskManager serviceTaskManager;
-
- public JMSEndpoint(JMSListener listener, WorkerPool workerPool) {
- this.listener = listener;
- this.workerPool = workerPool;
- }
-
- public String getJndiDestinationName() {
- return jndiDestinationName;
- }
-
- private void setDestinationType(String destinationType) {
- if (JMSConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(destinationType)) {
- this.destinationType = JMSConstants.TOPIC;
- } else if (JMSConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(destinationType)) {
- this.destinationType = JMSConstants.QUEUE;
- } else {
- this.destinationType = JMSConstants.GENERIC;
- }
- }
-
- private void setReplyDestinationType(String destinationType) {
- if (JMSConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(destinationType)) {
- this.replyDestinationType = JMSConstants.DESTINATION_TYPE_TOPIC;
- } else if (JMSConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(destinationType)) {
- this.replyDestinationType = JMSConstants.DESTINATION_TYPE_QUEUE;
- } else {
- this.replyDestinationType = JMSConstants.DESTINATION_TYPE_GENERIC;
- }
- }
-
- public String getJndiReplyDestinationName() {
- return jndiReplyDestinationName;
- }
-
- public String getReplyDestinationType() {
- return replyDestinationType;
- }
-
- @Override
- public EndpointReference[] getEndpointReferences(AxisService service, String ip) {
- return endpointReferences.toArray(new EndpointReference[endpointReferences.size()]);
- }
-
- private void computeEPRs() {
- List<EndpointReference> eprs = new ArrayList<EndpointReference>();
- for (Object o : getService().getParameters()) {
- Parameter p = (Parameter) o;
- if (JMSConstants.PARAM_PUBLISH_EPR.equals(p.getName()) && p.getValue() instanceof String) {
- if ("legacy".equalsIgnoreCase((String) p.getValue())) {
- // if "legacy" specified, compute and replace it
- endpointReferences.add(
- new EndpointReference(getEPR()));
- } else {
- endpointReferences.add(new EndpointReference((String) p.getValue()));
- }
- }
- }
-
- if (eprs.isEmpty()) {
- // if nothing specified, compute and return legacy EPR
- endpointReferences.add(new EndpointReference(getEPR()));
- }
- }
-
- /**
- * Get the EPR for the given JMS connection factory and destination
- * the form of the URL is
- * jms:/<destination>?[<key>=<value>&]*
- * Credentials Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS
- * JMSConstants.PARAM_JMS_USERNAME and JMSConstants.PARAM_JMS_USERNAME are filtered
- *
- * @return the EPR as a String
- */
- private String getEPR() {
- StringBuffer sb = new StringBuffer();
-
- sb.append(
- JMSConstants.JMS_PREFIX).append(jndiDestinationName);
- sb.append("?").
- append(JMSConstants.PARAM_DEST_TYPE).append("=").append(
- destinationType == JMSConstants.TOPIC ?
- JMSConstants.DESTINATION_TYPE_TOPIC : JMSConstants.DESTINATION_TYPE_QUEUE);
-
- if (contentTypeRuleSet != null) {
- String contentTypeProperty = contentTypeRuleSet.getDefaultContentTypeProperty();
- if (contentTypeProperty != null) {
- sb.append("&");
- sb.append(JMSConstants.CONTENT_TYPE_PROPERTY_PARAM);
- sb.append("=");
- sb.append(contentTypeProperty);
- }
- }
-
- for (Map.Entry<String,String> entry : cf.getParameters().entrySet()) {
- if (!Context.SECURITY_PRINCIPAL.equalsIgnoreCase(entry.getKey()) &&
- !Context.SECURITY_CREDENTIALS.equalsIgnoreCase(entry.getKey()) &&
- !JMSConstants.PARAM_JMS_USERNAME.equalsIgnoreCase(entry.getKey()) &&
- !JMSConstants.PARAM_JMS_PASSWORD.equalsIgnoreCase(entry.getKey())) {
- sb.append("&").append(
- entry.getKey()).append("=").append(entry.getValue());
- }
- }
- return sb.toString();
- }
-
- public ContentTypeRuleSet getContentTypeRuleSet() {
- return contentTypeRuleSet;
- }
-
- public JMSConnectionFactory getCf() {
- return cf;
- }
-
- public ServiceTaskManager getServiceTaskManager() {
- return serviceTaskManager;
- }
-
- public void setServiceTaskManager(ServiceTaskManager serviceTaskManager) {
- this.serviceTaskManager = serviceTaskManager;
- }
-
- @Override
- public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
- // We only support endpoints configured at service level
- if (!(params instanceof AxisService)) {
- return false;
- }
-
- AxisService service = (AxisService)params;
-
- cf = listener.getConnectionFactory(service);
- if (cf == null) {
- return false;
- }
-
- Parameter destParam = service.getParameter(JMSConstants.PARAM_DESTINATION);
- if (destParam != null) {
- jndiDestinationName = (String)destParam.getValue();
- } else {
- // Assume that the JNDI destination name is the same as the service name
- jndiDestinationName = service.getName();
- }
-
- Parameter destTypeParam = service.getParameter(JMSConstants.PARAM_DEST_TYPE);
- if (destTypeParam != null) {
- String paramValue = (String) destTypeParam.getValue();
- if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(paramValue) ||
- JMSConstants.DESTINATION_TYPE_TOPIC.equals(paramValue) ) {
- setDestinationType(paramValue);
- } else {
- throw new AxisFault("Invalid destinaton type value " + paramValue);
- }
- } else {
- log.debug("JMS destination type not given. default queue");
- destinationType = JMSConstants.QUEUE;
- }
-
- Parameter replyDestTypeParam = service.getParameter(JMSConstants.PARAM_REPLY_DEST_TYPE);
- if (replyDestTypeParam != null) {
- String paramValue = (String) replyDestTypeParam.getValue();
- if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(paramValue) ||
- JMSConstants.DESTINATION_TYPE_TOPIC.equals(paramValue) ) {
- setReplyDestinationType(paramValue);
- } else {
- throw new AxisFault("Invalid destinaton type value " + paramValue);
- }
- } else {
- log.debug("JMS reply destination type not given. default queue");
- replyDestinationType = JMSConstants.DESTINATION_TYPE_QUEUE;
- }
-
- jndiReplyDestinationName = ParamUtils.getOptionalParam(service,
- JMSConstants.PARAM_REPLY_DESTINATION);
-
- Parameter contentTypeParam = service.getParameter(JMSConstants.CONTENT_TYPE_PARAM);
- if (contentTypeParam == null) {
- contentTypeRuleSet = new ContentTypeRuleSet();
- contentTypeRuleSet.addRule(new PropertyRule(BaseConstants.CONTENT_TYPE));
- contentTypeRuleSet.addRule(new MessageTypeRule(BytesMessage.class, "application/octet-stream"));
- contentTypeRuleSet.addRule(new MessageTypeRule(TextMessage.class, "text/plain"));
- } else {
- contentTypeRuleSet = ContentTypeRuleFactory.parse(contentTypeParam);
- }
-
- computeEPRs(); // compute service EPR and keep for later use
-
- serviceTaskManager = ServiceTaskManagerFactory.createTaskManagerForService(cf, service, workerPool);
- serviceTaskManager.setJmsMessageReceiver(new JMSMessageReceiver(listener, cf, this));
-
- return true;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java
deleted file mode 100644
index 66a642c..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.transport.base.AbstractTransportListenerEx;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.ManagementSupport;
-import org.apache.axis2.transport.base.event.TransportErrorListener;
-import org.apache.axis2.transport.base.event.TransportErrorSource;
-import org.apache.axis2.transport.base.event.TransportErrorSourceSupport;
-
-/**
- * The revamped JMS Transport listener implementation. Creates {@link ServiceTaskManager} instances
- * for each service requesting exposure over JMS, and stops these if they are undeployed / stopped.
- * <p>
- * A service indicates a JMS Connection factory definition by name, which would be defined in the
- * JMSListner on the axis2.xml, and this provides a way to reuse common configuration between
- * services, as well as to optimize resources utilized
- * <p>
- * If the connection factory name was not specified, it will default to the one named "default"
- * {@see JMSConstants.DEFAULT_CONFAC_NAME}
- * <p>
- * If a destination JNDI name is not specified, a service will expect to use a Queue with the same
- * JNDI name as of the service. Additional Parameters allows one to bind to a Topic or specify
- * many more detailed control options. See package documentation for more details
- * <p>
- * All Destinations / JMS Administered objects used MUST be pre-created or already available
- */
-public class JMSListener extends AbstractTransportListenerEx<JMSEndpoint> implements ManagementSupport,
- TransportErrorSource {
-
- public static final String TRANSPORT_NAME = Constants.TRANSPORT_JMS;
-
- /** The JMSConnectionFactoryManager which centralizes the management of defined factories */
- private JMSConnectionFactoryManager connFacManager;
-
- private final TransportErrorSourceSupport tess = new TransportErrorSourceSupport(this);
-
- @Override
- protected void doInit() throws AxisFault {
- connFacManager = new JMSConnectionFactoryManager(getTransportInDescription());
- log.info("JMS Transport Receiver/Listener initialized...");
- }
-
- @Override
- protected JMSEndpoint createEndpoint() {
- return new JMSEndpoint(this, workerPool);
- }
-
- /**
- * Listen for JMS messages on behalf of the given service
- *
- * @param service the Axis service for which to listen for messages
- */
- @Override
- protected void startEndpoint(JMSEndpoint endpoint) throws AxisFault {
- ServiceTaskManager stm = endpoint.getServiceTaskManager();
-
- stm.start();
-
- for (int i=0; i<3; i++) {
- // Check the consumer count rather than the active task count. Reason: if the
- // destination is of type topic, then the transport is only ready to receive
- // messages if at least one consumer exists. This is of not much importance,
- // except for automated tests.
- if (stm.getConsumerCount() > 0) {
- log.info("Started to listen on destination : " + stm.getDestinationJNDIName() +
- " of type " + JMSUtils.getDestinationTypeAsString(stm.getDestinationType()) +
- " for service " + stm.getServiceName());
- return;
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {}
- }
-
- log.warn("Polling tasks on destination : " + stm.getDestinationJNDIName() +
- " of type " + JMSUtils.getDestinationTypeAsString(stm.getDestinationType()) +
- " for service " + stm.getServiceName() + " have not yet started after 3 seconds ..");
- }
-
- /**
- * Stops listening for messages for the service thats undeployed or stopped
- *
- * @param service the service that was undeployed or stopped
- */
- @Override
- protected void stopEndpoint(JMSEndpoint endpoint) {
- ServiceTaskManager stm = endpoint.getServiceTaskManager();
- if (log.isDebugEnabled()) {
- log.debug("Stopping listening on destination : " + stm.getDestinationJNDIName() +
- " for service : " + stm.getServiceName());
- }
-
- stm.stop();
-
- log.info("Stopped listening for JMS messages to service : " + endpoint.getServiceName());
- }
-
- /**
- * Return the connection factory name for this service. If this service
- * refers to an invalid factory or defaults to a non-existent default
- * factory, this returns null
- *
- * @param service the AxisService
- * @return the JMSConnectionFactory to be used, or null if reference is invalid
- */
- public JMSConnectionFactory getConnectionFactory(AxisService service) {
-
- Parameter conFacParam = service.getParameter(JMSConstants.PARAM_JMS_CONFAC);
- // validate connection factory name (specified or default)
- if (conFacParam != null) {
- return connFacManager.getJMSConnectionFactory((String) conFacParam.getValue());
- } else {
- return connFacManager.getJMSConnectionFactory(JMSConstants.DEFAULT_CONFAC_NAME);
- }
- }
-
- // -- jmx/management methods--
- /**
- * Pause the listener - Stop accepting/processing new messages, but continues processing existing
- * messages until they complete. This helps bring an instance into a maintenence mode
- * @throws AxisFault on error
- */
- @Override
- public void pause() throws AxisFault {
- if (state != BaseConstants.STARTED) return;
- try {
- for (JMSEndpoint endpoint : getEndpoints()) {
- endpoint.getServiceTaskManager().pause();
- }
- state = BaseConstants.PAUSED;
- log.info("Listener paused");
- } catch (AxisJMSException e) {
- log.error("At least one service could not be paused", e);
- }
- }
-
- /**
- * Resume the lister - Brings the lister into active mode back from a paused state
- * @throws AxisFault on error
- */
- @Override
- public void resume() throws AxisFault {
- if (state != BaseConstants.PAUSED) return;
- try {
- for (JMSEndpoint endpoint : getEndpoints()) {
- endpoint.getServiceTaskManager().resume();
- }
- state = BaseConstants.STARTED;
- log.info("Listener resumed");
- } catch (AxisJMSException e) {
- log.error("At least one service could not be resumed", e);
- }
- }
-
- /**
- * Stop processing new messages, and wait the specified maximum time for in-flight
- * requests to complete before a controlled shutdown for maintenence
- *
- * @param millis a number of milliseconds to wait until pending requests are allowed to complete
- * @throws AxisFault on error
- */
- @Override
- public void maintenenceShutdown(long millis) throws AxisFault {
- if (state != BaseConstants.STARTED) return;
- try {
- long start = System.currentTimeMillis();
- stop();
- state = BaseConstants.STOPPED;
- log.info("Listener shutdown in : " + (System.currentTimeMillis() - start) / 1000 + "s");
- } catch (Exception e) {
- handleException("Error shutting down the listener for maintenence", e);
- }
- }
-
- public void addErrorListener(TransportErrorListener listener) {
- tess.addErrorListener(listener);
- }
-
- public void removeErrorListener(TransportErrorListener listener) {
- tess.removeErrorListener(listener);
- }
-
- void error(AxisService service, Throwable ex) {
- tess.error(service, ex);
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
deleted file mode 100644
index 61f5df5..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.MetricsCollector;
-import org.apache.axis2.transport.jms.ctype.ContentTypeInfo;
-import org.apache.axis2.context.MessageContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.*;
-import javax.transaction.UserTransaction;
-
-/**
- * This is the JMS message receiver which is invoked when a message is received. This processes
- * the message through the engine
- */
-public class JMSMessageReceiver {
-
- private static final Log log = LogFactory.getLog(JMSMessageReceiver.class);
-
- /** The JMSListener */
- private JMSListener jmsListener = null;
- /** A reference to the JMS Connection Factory */
- private JMSConnectionFactory jmsConnectionFactory = null;
- /** The JMS metrics collector */
- private MetricsCollector metrics = null;
- /** The endpoint this message receiver is bound to */
- final JMSEndpoint endpoint;
-
- /**
- * Create a new JMSMessage receiver
- *
- * @param jmsListener the JMS transport Listener
- * @param jmsConFac the JMS connection factory we are associated with
- * @param workerPool the worker thread pool to be used
- * @param cfgCtx the axis ConfigurationContext
- * @param serviceName the name of the Axis service
- * @param endpoint the JMSEndpoint definition to be used
- */
- JMSMessageReceiver(JMSListener jmsListener, JMSConnectionFactory jmsConFac, JMSEndpoint endpoint) {
- this.jmsListener = jmsListener;
- this.jmsConnectionFactory = jmsConFac;
- this.endpoint = endpoint;
- this.metrics = jmsListener.getMetricsCollector();
- }
-
- /**
- * Process a new message received
- *
- * @param message the JMS message received
- * @param ut UserTransaction which was used to receive the message
- * @return true if caller should commit
- */
- public boolean onMessage(Message message, UserTransaction ut) {
-
- try {
- if (log.isDebugEnabled()) {
- StringBuffer sb = new StringBuffer();
- sb.append("Received new JMS message for service :").append(endpoint.getServiceName());
- sb.append("\nDestination : ").append(message.getJMSDestination());
- sb.append("\nMessage ID : ").append(message.getJMSMessageID());
- sb.append("\nCorrelation ID : ").append(message.getJMSCorrelationID());
- sb.append("\nReplyTo : ").append(message.getJMSReplyTo());
- sb.append("\nRedelivery ? : ").append(message.getJMSRedelivered());
- sb.append("\nPriority : ").append(message.getJMSPriority());
- sb.append("\nExpiration : ").append(message.getJMSExpiration());
- sb.append("\nTimestamp : ").append(message.getJMSTimestamp());
- sb.append("\nMessage Type : ").append(message.getJMSType());
- sb.append("\nPersistent ? : ").append(
- DeliveryMode.PERSISTENT == message.getJMSDeliveryMode());
-
- log.debug(sb.toString());
- if (log.isTraceEnabled() && message instanceof TextMessage) {
- log.trace("\nMessage : " + ((TextMessage) message).getText());
- }
- }
- } catch (JMSException e) {
- if (log.isDebugEnabled()) {
- log.debug("Error reading JMS message headers for debug logging", e);
- }
- }
-
- // update transport level metrics
- try {
- metrics.incrementBytesReceived(JMSUtils.getMessageSize(message));
- } catch (JMSException e) {
- log.warn("Error reading JMS message size to update transport metrics", e);
- }
-
- // has this message already expired? expiration time == 0 means never expires
- // TODO: explain why this is necessary; normally it is the responsibility of the provider to handle message expiration
- try {
- long expiryTime = message.getJMSExpiration();
- if (expiryTime > 0 && System.currentTimeMillis() > expiryTime) {
- if (log.isDebugEnabled()) {
- log.debug("Discard expired message with ID : " + message.getJMSMessageID());
- }
- return true;
- }
- } catch (JMSException ignore) {}
-
-
- boolean successful = false;
- try {
- successful = processThoughEngine(message, ut);
-
- } catch (JMSException e) {
- log.error("JMS Exception encountered while processing", e);
- } catch (AxisFault e) {
- log.error("Axis fault processing message", e);
- } catch (Exception e) {
- log.error("Unknown error processing message", e);
-
- } finally {
- if (successful) {
- metrics.incrementMessagesReceived();
- } else {
- metrics.incrementFaultsReceiving();
- }
- }
-
- return successful;
- }
-
- /**
- * Process the new message through Axis2
- *
- * @param message the JMS message
- * @param ut the UserTransaction used for receipt
- * @return true if the caller should commit
- * @throws JMSException, on JMS exceptions
- * @throws AxisFault on Axis2 errors
- */
- private boolean processThoughEngine(Message message, UserTransaction ut)
- throws JMSException, AxisFault {
-
- MessageContext msgContext = endpoint.createMessageContext();
-
- // set the JMS Message ID as the Message ID of the MessageContext
- try {
- msgContext.setMessageID(message.getJMSMessageID());
- String jmsCorrelationID = message.getJMSCorrelationID();
- if (jmsCorrelationID != null && jmsCorrelationID.length() > 0) {
- msgContext.setProperty(JMSConstants.JMS_COORELATION_ID, jmsCorrelationID);
- } else {
- msgContext.setProperty(JMSConstants.JMS_COORELATION_ID, message.getJMSMessageID());
- }
- } catch (JMSException ignore) {}
-
- String soapAction = JMSUtils.getProperty(message, BaseConstants.SOAPACTION);
-
- ContentTypeInfo contentTypeInfo =
- endpoint.getContentTypeRuleSet().getContentTypeInfo(message);
- if (contentTypeInfo == null) {
- throw new AxisFault("Unable to determine content type for message " +
- msgContext.getMessageID());
- }
-
- // set the message property OUT_TRANSPORT_INFO
- // the reply is assumed to be over the JMSReplyTo destination, using
- // the same incoming connection factory, if a JMSReplyTo is available
- Destination replyTo = message.getJMSReplyTo();
- if (replyTo == null) {
- // does the service specify a default reply destination ?
- String jndiReplyDestinationName = endpoint.getJndiReplyDestinationName();
- if (jndiReplyDestinationName != null) {
- replyTo = jmsConnectionFactory.getDestination(jndiReplyDestinationName,
- endpoint.getReplyDestinationType());
- }
-
- }
- if (replyTo != null) {
- msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
- new JMSOutTransportInfo(jmsConnectionFactory, replyTo,
- contentTypeInfo.getPropertyName()));
- }
-
- JMSUtils.setSOAPEnvelope(message, msgContext, contentTypeInfo.getContentType());
- if (ut != null) {
- msgContext.setProperty(BaseConstants.USER_TRANSACTION, ut);
- }
-
- jmsListener.handleIncomingMessage(
- msgContext,
- JMSUtils.getTransportHeaders(message),
- soapAction,
- contentTypeInfo.getContentType());
-
- Object o = msgContext.getProperty(BaseConstants.SET_ROLLBACK_ONLY);
- if (o != null) {
- if ((o instanceof Boolean && ((Boolean) o)) ||
- (o instanceof String && Boolean.valueOf((String) o))) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
deleted file mode 100644
index a93df63..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.base.BaseConstants;
-
-import javax.jms.*;
-import javax.transaction.*;
-
-/**
- * Performs the actual sending of a JMS message, and the subsequent committing of a JTA transaction
- * (if requested) or the local session transaction, if used. An instance of this class is unique
- * to a single message send out operation and will not be shared.
- */
-public class JMSMessageSender {
-
- private static final Log log = LogFactory.getLog(JMSMessageSender.class);
-
- /** The Connection to be used to send out */
- private Connection connection = null;
- /** The Session to be used to send out */
- private Session session = null;
- /** The MessageProducer used */
- private MessageProducer producer = null;
- /** Target Destination */
- private Destination destination = null;
- /** The level of cachability for resources */
- private int cacheLevel = JMSConstants.CACHE_CONNECTION;
- /** Should this sender use JMS 1.1 ? (if false, defaults to 1.0.2b) */
- private boolean jmsSpec11 = true;
- /** Are we sending to a Queue ? */
- private Boolean isQueue = null;
-
- /**
- * This is a low-end method to support the one-time sends using JMS 1.0.2b
- * @param connection the JMS Connection
- * @param session JMS Session
- * @param producer the MessageProducer
- * @param destination the JMS Destination
- * @param cacheLevel cacheLevel - None | Connection | Session | Producer
- * @param jmsSpec11 true if the JMS 1.1 API should be used
- * @param isQueue posting to a Queue?
- */
- public JMSMessageSender(Connection connection, Session session, MessageProducer producer,
- Destination destination, int cacheLevel, boolean jmsSpec11, Boolean isQueue) {
-
- this.connection = connection;
- this.session = session;
- this.producer = producer;
- this.destination = destination;
- this.cacheLevel = cacheLevel;
- this.jmsSpec11 = jmsSpec11;
- this.isQueue = isQueue;
- }
-
- /**
- * Create a JMSSender using a JMSConnectionFactory and target EPR
- *
- * @param jmsConnectionFactory the JMSConnectionFactory
- * @param targetAddress target EPR
- */
- public JMSMessageSender(JMSConnectionFactory jmsConnectionFactory, String targetAddress) {
-
- this.cacheLevel = jmsConnectionFactory.getCacheLevel();
- this.jmsSpec11 = jmsConnectionFactory.isJmsSpec11();
- this.connection = jmsConnectionFactory.getConnection();
- this.session = jmsConnectionFactory.getSession(connection);
- this.destination =
- jmsConnectionFactory.getSharedDestination() == null ?
- jmsConnectionFactory.getDestination(JMSUtils.getDestination(targetAddress),
- JMSConstants.DESTINATION_TYPE_GENERIC) :
- jmsConnectionFactory.getSharedDestination();
- this.producer = jmsConnectionFactory.getMessageProducer(connection, session, destination);
- }
-
- /**
- * Perform actual send of JMS message to the Destination selected
- *
- * @param message the JMS message
- * @param msgCtx the Axis2 MessageContext
- */
- public void send(Message message, MessageContext msgCtx) {
-
- Boolean jtaCommit = getBooleanProperty(msgCtx, BaseConstants.JTA_COMMIT_AFTER_SEND);
- Boolean rollbackOnly = getBooleanProperty(msgCtx, BaseConstants.SET_ROLLBACK_ONLY);
- Boolean persistent = getBooleanProperty(msgCtx, JMSConstants.JMS_DELIVERY_MODE);
- Integer priority = getIntegerProperty(msgCtx, JMSConstants.JMS_PRIORITY);
- Integer timeToLive = getIntegerProperty(msgCtx, JMSConstants.JMS_TIME_TO_LIVE);
-
- // Do not commit, if message is marked for rollback
- if (rollbackOnly != null && rollbackOnly) {
- jtaCommit = Boolean.FALSE;
- }
-
- if (persistent != null) {
- try {
- producer.setDeliveryMode(DeliveryMode.PERSISTENT);
- } catch (JMSException e) {
- handleException("Error setting JMS Producer for PERSISTENT delivery", e);
- }
- }
- if (priority != null) {
- try {
- producer.setPriority(priority);
- } catch (JMSException e) {
- handleException("Error setting JMS Producer priority to : " + priority, e);
- }
- }
- if (timeToLive != null) {
- try {
- producer.setTimeToLive(timeToLive);
- } catch (JMSException e) {
- handleException("Error setting JMS Producer TTL to : " + timeToLive, e);
- }
- }
-
- boolean sendingSuccessful = false;
- // perform actual message sending
- try {
- if (jmsSpec11 || isQueue == null) {
- producer.send(message);
-
- } else {
- if (isQueue) {
- ((QueueSender) producer).send(message);
-
- } else {
- ((TopicPublisher) producer).publish(message);
- }
- }
-
- // set the actual MessageID to the message context for use by any others down the line
- String msgId = null;
- try {
- msgId = message.getJMSMessageID();
- if (msgId != null) {
- msgCtx.setProperty(JMSConstants.JMS_MESSAGE_ID, msgId);
- }
- } catch (JMSException ignore) {}
-
- sendingSuccessful = true;
-
- if (log.isDebugEnabled()) {
- log.debug("Sent Message Context ID : " + msgCtx.getMessageID() +
- " with JMS Message ID : " + msgId +
- " to destination : " + producer.getDestination());
- }
-
- } catch (JMSException e) {
- log.error("Error sending message with MessageContext ID : " +
- msgCtx.getMessageID() + " to destination : " + destination, e);
-
- } finally {
-
- if (jtaCommit != null) {
-
- UserTransaction ut = (UserTransaction) msgCtx.getProperty(BaseConstants.USER_TRANSACTION);
- if (ut != null) {
-
- try {
- if (sendingSuccessful && jtaCommit) {
- ut.commit();
- } else {
- ut.rollback();
- }
- msgCtx.removeProperty(BaseConstants.USER_TRANSACTION);
-
- if (log.isDebugEnabled()) {
- log.debug((sendingSuccessful ? "Committed" : "Rolled back") +
- " JTA Transaction");
- }
-
- } catch (Exception e) {
- handleException("Error committing/rolling back JTA transaction after " +
- "sending of message with MessageContext ID : " + msgCtx.getMessageID() +
- " to destination : " + destination, e);
- }
- }
-
- } else {
- try {
- if (session.getTransacted()) {
- if (sendingSuccessful && (rollbackOnly == null || !rollbackOnly)) {
- session.commit();
- } else {
- session.rollback();
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug((sendingSuccessful ? "Committed" : "Rolled back") +
- " local (JMS Session) Transaction");
- }
-
- } catch (JMSException e) {
- handleException("Error committing/rolling back local (i.e. session) " +
- "transaction after sending of message with MessageContext ID : " +
- msgCtx.getMessageID() + " to destination : " + destination, e);
- }
- }
- }
- }
-
- /**
- * Close non-shared producer, session and connection if any
- */
- public void close() {
- if (producer != null && cacheLevel < JMSConstants.CACHE_PRODUCER) {
- try {
- producer.close();
- } catch (JMSException e) {
- log.error("Error closing JMS MessageProducer after send", e);
- } finally {
- producer = null;
- }
- }
-
- if (session != null && cacheLevel < JMSConstants.CACHE_SESSION) {
- try {
- session.close();
- } catch (JMSException e) {
- log.error("Error closing JMS Session after send", e);
- } finally {
- session = null;
- }
- }
-
- if (connection != null && cacheLevel < JMSConstants.CACHE_CONNECTION) {
- try {
- connection.close();
- } catch (JMSException e) {
- log.error("Error closing JMS Connection after send", e);
- } finally {
- connection = null;
- }
- }
- }
-
- private void handleException(String message, Exception e) {
- log.error(message, e);
- throw new AxisJMSException(message, e);
- }
-
- private Boolean getBooleanProperty(MessageContext msgCtx, String name) {
- Object o = msgCtx.getProperty(name);
- if (o != null) {
- if (o instanceof Boolean) {
- return (Boolean) o;
- } else if (o instanceof String) {
- return Boolean.valueOf((String) o);
- }
- }
- return null;
- }
-
- private Integer getIntegerProperty(MessageContext msgCtx, String name) {
- Object o = msgCtx.getProperty(name);
- if (o != null) {
- if (o instanceof Integer) {
- return (Integer) o;
- } else if (o instanceof String) {
- return Integer.parseInt((String) o);
- }
- }
- return null;
- }
-
- public void setConnection(Connection connection) {
- this.connection = connection;
- }
-
- public void setSession(Session session) {
- this.session = session;
- }
-
- public void setProducer(MessageProducer producer) {
- this.producer = producer;
- }
-
- public void setCacheLevel(int cacheLevel) {
- this.cacheLevel = cacheLevel;
- }
-
- public int getCacheLevel() {
- return cacheLevel;
- }
-
- public Connection getConnection() {
- return connection;
- }
-
- public MessageProducer getProducer() {
- return producer;
- }
-
- public Session getSession() {
- return session;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSOutTransportInfo.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSOutTransportInfo.java
deleted file mode 100644
index 864c057..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSOutTransportInfo.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.transport.base.BaseUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.*;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Hashtable;
-
-/**
- * The JMS OutTransportInfo is a holder of information to send an outgoing message
- * (e.g. a Response) to a JMS destination. Thus at a minimum a reference to a
- * ConnectionFactory and a Destination are held
- */
-public class JMSOutTransportInfo implements OutTransportInfo {
-
- private static final Log log = LogFactory.getLog(JMSOutTransportInfo.class);
-
- /** The naming context */
- private Context context;
- /**
- * this is a reference to the underlying JMS ConnectionFactory when sending messages
- * through connection factories not defined at the TransportSender level
- */
- private ConnectionFactory connectionFactory = null;
- /**
- * this is a reference to a JMS Connection Factory instance, which has a reference
- * to the underlying actual connection factory, an open connection to the JMS provider
- * and optionally a session already available for use
- */
- private JMSConnectionFactory jmsConnectionFactory = null;
- /** the Destination queue or topic for the outgoing message */
- private Destination destination = null;
- /** the Destination queue or topic for the outgoing message
- * i.e. JMSConstants.DESTINATION_TYPE_QUEUE, DESTINATION_TYPE_TOPIC or DESTINATION_TYPE_GENERIC
- */
- private String destinationType = JMSConstants.DESTINATION_TYPE_GENERIC;
- /** the Reply Destination queue or topic for the outgoing message */
- private Destination replyDestination = null;
- /** the Reply Destination name */
- private String replyDestinationName = null;
- /** the Reply Destination queue or topic for the outgoing message
- * i.e. JMSConstants.DESTINATION_TYPE_QUEUE, DESTINATION_TYPE_TOPIC or DESTINATION_TYPE_GENERIC
- */
- private String replyDestinationType = JMSConstants.DESTINATION_TYPE_GENERIC;
- /** the EPR properties when the out-transport info is generated from a target EPR */
- private Hashtable<String,String> properties = null;
- /** the target EPR string where applicable */
- private String targetEPR = null;
- /** the message property name that stores the content type of the outgoing message */
- private String contentTypeProperty;
-
- /**
- * Creates an instance using the given JMS connection factory and destination
- *
- * @param jmsConnectionFactory the JMS connection factory
- * @param dest the destination
- * @param contentTypeProperty the content type
- */
- JMSOutTransportInfo(JMSConnectionFactory jmsConnectionFactory, Destination dest,
- String contentTypeProperty) {
- this.jmsConnectionFactory = jmsConnectionFactory;
- this.destination = dest;
- destinationType = dest instanceof Topic ? JMSConstants.DESTINATION_TYPE_TOPIC
- : JMSConstants.DESTINATION_TYPE_QUEUE;
- this.contentTypeProperty = contentTypeProperty;
- }
-
- /**
- * Creates and instance using the given URL
- *
- * @param targetEPR the target EPR
- */
- JMSOutTransportInfo(String targetEPR) {
-
- this.targetEPR = targetEPR;
- if (!targetEPR.startsWith(JMSConstants.JMS_PREFIX)) {
- handleException("Invalid prefix for a JMS EPR : " + targetEPR);
-
- } else {
- properties = BaseUtils.getEPRProperties(targetEPR);
- String destinationType = properties.get(JMSConstants.PARAM_DEST_TYPE);
- if (destinationType != null) {
- setDestinationType(destinationType);
- }
-
- String replyDestinationType = properties.get(JMSConstants.PARAM_REPLY_DEST_TYPE);
- if (replyDestinationType != null) {
- setReplyDestinationType(replyDestinationType);
- }
-
- replyDestinationName = properties.get(JMSConstants.PARAM_REPLY_DESTINATION);
- contentTypeProperty = properties.get(JMSConstants.CONTENT_TYPE_PROPERTY_PARAM);
- try {
- context = new InitialContext(properties);
- } catch (NamingException e) {
- handleException("Could not get an initial context using " + properties, e);
- }
-
- destination = getDestination(context, targetEPR);
- replyDestination = getReplyDestination(context, targetEPR);
- }
- }
-
- /**
- * Provides a lazy load when created with a target EPR. This method performs actual
- * lookup for the connection factory and destination
- */
- public void loadConnectionFactoryFromProperies() {
- if (properties != null) {
- connectionFactory = getConnectionFactory(context, properties);
- }
- }
-
- /**
- * Get the referenced ConnectionFactory using the properties from the context
- *
- * @param context the context to use for lookup
- * @param props the properties which contains the JNDI name of the factory
- * @return the connection factory
- */
- private ConnectionFactory getConnectionFactory(Context context, Hashtable<String,String> props) {
- try {
-
- String conFacJndiName = props.get(JMSConstants.PARAM_CONFAC_JNDI_NAME);
- if (conFacJndiName != null) {
- return JMSUtils.lookup(context, ConnectionFactory.class, conFacJndiName);
- } else {
- handleException("Connection Factory JNDI name cannot be determined");
- }
- } catch (NamingException e) {
- handleException("Failed to look up connection factory from JNDI", e);
- }
- return null;
- }
-
- /**
- * Get the JMS destination specified by the given URL from the context
- *
- * @param context the Context to lookup
- * @param url URL
- * @return the JMS destination, or null if it does not exist
- */
- private Destination getDestination(Context context, String url) {
- String destinationName = JMSUtils.getDestination(url);
- if (log.isDebugEnabled()) {
- log.debug("Lookup the JMS destination " + destinationName + " of type "
- + destinationType + " extracted from the URL " + url);
- }
-
- try {
- return JMSUtils.lookupDestination(context, destinationName, destinationType);
- } catch (NamingException e) {
- handleException("Couldn't locate the JMS destination " + destinationName
- + " of type " + destinationType + " extracted from the URL " + url, e);
- }
-
- // never executes but keeps the compiler happy
- return null;
- }
-
- /**
- * Get the JMS reply destination specified by the given URL from the context
- *
- * @param context the Context to lookup
- * @param url URL
- * @return the JMS destination, or null if it does not exist
- */
- private Destination getReplyDestination(Context context, String url) {
- String replyDestinationName = properties.get(JMSConstants.PARAM_REPLY_DESTINATION);
- if (log.isDebugEnabled()) {
- log.debug("Lookup the JMS destination " + replyDestinationName + " of type "
- + replyDestinationType + " extracted from the URL " + url);
- }
-
- try {
- return JMSUtils.lookupDestination(context, replyDestinationName, replyDestinationType);
- } catch (NamingException e) {
- handleException("Couldn't locate the JMS destination " + replyDestinationName
- + " of type " + replyDestinationType + " extracted from the URL " + url, e);
- }
-
- // never executes but keeps the compiler happy
- return null;
- }
-
- /**
- * Look up for the given destination
- * @param replyDest the JNDI name to lookup Destination required
- * @return Destination for the JNDI name passed
- */
- public Destination getReplyDestination(String replyDest) {
- if (log.isDebugEnabled()) {
- log.debug("Lookup the JMS destination " + replyDest + " of type "
- + replyDestinationType);
- }
-
- try {
- return JMSUtils.lookupDestination(
- jmsConnectionFactory.getContext(), replyDest, replyDestinationType);
- } catch (NamingException e) {
- handleException("Couldn't locate the JMS destination " + replyDest
- + " of type " + replyDestinationType, e);
- }
-
- // never executes but keeps the compiler happy
- return null;
- }
-
-
- private void handleException(String s) {
- log.error(s);
- throw new AxisJMSException(s);
- }
-
- private void handleException(String s, Exception e) {
- log.error(s, e);
- throw new AxisJMSException(s, e);
- }
-
- public Destination getDestination() {
- return destination;
- }
-
- public ConnectionFactory getConnectionFactory() {
- return connectionFactory;
- }
-
- public JMSConnectionFactory getJmsConnectionFactory() {
- return jmsConnectionFactory;
- }
-
- public void setContentType(String contentType) {
- // this is a useless Axis2 method imposed by the OutTransportInfo interface :(
- }
-
- public Hashtable<String,String> getProperties() {
- return properties;
- }
-
- public String getTargetEPR() {
- return targetEPR;
- }
-
- public String getDestinationType() {
- return destinationType;
- }
-
- public void setDestinationType(String destinationType) {
- if (destinationType != null) {
- this.destinationType = destinationType;
- }
- }
-
- public Destination getReplyDestination() {
- return replyDestination;
- }
-
- public void setReplyDestination(Destination replyDestination) {
- this.replyDestination = replyDestination;
- }
-
- public String getReplyDestinationType() {
- return replyDestinationType;
- }
-
- public void setReplyDestinationType(String replyDestinationType) {
- this.replyDestinationType = replyDestinationType;
- }
-
- public String getReplyDestinationName() {
- return replyDestinationName;
- }
-
- public void setReplyDestinationName(String replyDestinationName) {
- this.replyDestinationName = replyDestinationName;
- }
-
- public String getContentTypeProperty() {
- return contentTypeProperty;
- }
-
- public void setContentTypeProperty(String contentTypeProperty) {
- this.contentTypeProperty = contentTypeProperty;
- }
-
- /**
- * Create a one time MessageProducer for this JMS OutTransport information.
- * For simplicity and best compatibility, this method uses only JMS 1.0.2b API.
- * Please be cautious when making any changes
- *
- * @return a JMSSender based on one-time use resources
- * @throws JMSException on errors, to be handled and logged by the caller
- */
- public JMSMessageSender createJMSSender() throws JMSException {
-
- // digest the targetAddress and locate CF from the EPR
- loadConnectionFactoryFromProperies();
-
- // create a one time connection and session to be used
- String user = properties != null ? properties.get(JMSConstants.PARAM_JMS_USERNAME) : null;
- String pass = properties != null ? properties.get(JMSConstants.PARAM_JMS_PASSWORD) : null;
-
- QueueConnectionFactory qConFac = null;
- TopicConnectionFactory tConFac = null;
-
- int destType = -1;
- // TODO: there is something missing here for destination type generic
- if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(destinationType)) {
- destType = JMSConstants.QUEUE;
- qConFac = (QueueConnectionFactory) connectionFactory;
-
- } else if (JMSConstants.DESTINATION_TYPE_TOPIC.equals(destinationType)) {
- destType = JMSConstants.TOPIC;
- tConFac = (TopicConnectionFactory) connectionFactory;
- } else{
- //treat jmsdestination type=queue(default is queue)
- destType = JMSConstants.QUEUE;
- qConFac = (QueueConnectionFactory) connectionFactory;
- }
-
- Connection connection = null;
- if (user != null && pass != null) {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection(user, pass);
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection(user, pass);
- }
- } else {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection();
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection();
- }
- }
-
- if (connection == null) {
- connection = jmsConnectionFactory != null ? jmsConnectionFactory.getConnection() : null;
- }
-
- Session session = null;
- MessageProducer producer = null;
-
- if (connection != null) {
- if (destType == JMSConstants.QUEUE) {
- session = ((QueueConnection) connection).
- createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- producer = ((QueueSession) session).createSender((Queue) destination);
- } else {
- session = ((TopicConnection) connection).
- createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- producer = ((TopicSession) session).createPublisher((Topic) destination);
- }
- }
-
- return new JMSMessageSender(
- connection,
- session,
- producer,
- destination,
- jmsConnectionFactory == null ?
- JMSConstants.CACHE_NONE : jmsConnectionFactory.getCacheLevel(),
- false,
- destType == -1 ?
- null : destType == JMSConstants.QUEUE ? Boolean.TRUE : Boolean.FALSE
- );
-
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
deleted file mode 100644
index 8b69e65..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.OMNode;
-import org.apache.axis2.util.MessageProcessorSelector;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.transport.base.*;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.transport.jms.iowrappers.BytesMessageOutputStream;
-import org.apache.commons.io.output.WriterOutputStream;
-
-import javax.jms.*;
-import javax.activation.DataHandler;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.nio.charset.UnsupportedCharsetException;
-import java.util.*;
-
-/**
- * The TransportSender for JMS
- */
-public class JMSSender extends AbstractTransportSender implements ManagementSupport {
-
- public static final String TRANSPORT_NAME = Constants.TRANSPORT_JMS;
-
- /** The JMS connection factory manager to be used when sending messages out */
- private JMSConnectionFactoryManager connFacManager;
-
- /**
- * Initialize the transport sender by reading pre-defined connection factories for
- * outgoing messages.
- *
- * @param cfgCtx the configuration context
- * @param transportOut the transport sender definition from axis2.xml
- * @throws AxisFault on error
- */
- @Override
- public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
- super.init(cfgCtx, transportOut);
- connFacManager = new JMSConnectionFactoryManager(transportOut);
- log.info("JMS Transport Sender initialized...");
- }
-
- @Override
- public void stop() {
-
- // clean up any shared JMS resources in this sender's connection factories
- connFacManager.stop();
-
- super.stop();
- }
-
- /**
- * Get corresponding JMS connection factory defined within the transport sender for the
- * transport-out information - usually constructed from a targetEPR
- *
- * @param trpInfo the transport-out information
- * @return the corresponding JMS connection factory, if any
- */
- private JMSConnectionFactory getJMSConnectionFactory(JMSOutTransportInfo trpInfo) {
- Map<String,String> props = trpInfo.getProperties();
- if (trpInfo.getProperties() != null) {
- String jmsConnectionFactoryName = props.get(JMSConstants.PARAM_JMS_CONFAC);
- if (jmsConnectionFactoryName != null) {
- return connFacManager.getJMSConnectionFactory(jmsConnectionFactoryName);
- } else {
- JMSConnectionFactory fac = connFacManager.getJMSConnectionFactory(props);
- if (fac == null) {
- fac = connFacManager.getJMSConnectionFactory(JMSConstants.DEFAULT_CONFAC_NAME);
- }
- return fac;
- }
- } else {
- return null;
- }
- }
-
- /**
- * Performs the actual sending of the JMS message
- */
- @Override
- public void sendMessage(MessageContext msgCtx, String targetAddress,
- OutTransportInfo outTransportInfo) throws AxisFault {
-
- JMSConnectionFactory jmsConnectionFactory = null;
- JMSOutTransportInfo jmsOut = null;
- JMSMessageSender messageSender = null;
-
- if (targetAddress != null) {
-
- jmsOut = new JMSOutTransportInfo(targetAddress);
- // do we have a definition for a connection factory to use for this address?
- jmsConnectionFactory = getJMSConnectionFactory(jmsOut);
-
- if (jmsConnectionFactory != null) {
- messageSender = new JMSMessageSender(jmsConnectionFactory, targetAddress);
-
- } else {
- try {
- messageSender = jmsOut.createJMSSender();
- } catch (JMSException e) {
- handleException("Unable to create a JMSMessageSender for : " + outTransportInfo, e);
- }
- }
-
- } else if (outTransportInfo != null && outTransportInfo instanceof JMSOutTransportInfo) {
-
- jmsOut = (JMSOutTransportInfo) outTransportInfo;
- try {
- messageSender = jmsOut.createJMSSender();
- } catch (JMSException e) {
- handleException("Unable to create a JMSMessageSender for : " + outTransportInfo, e);
- }
- }
-
- // The message property to be used to send the content type is determined by
- // the out transport info, i.e. either from the EPR if we are sending a request,
- // or, if we are sending a response, from the configuration of the service that
- // received the request). The property name can be overridden by a message
- // context property.
- String contentTypeProperty =
- (String) msgCtx.getProperty(JMSConstants.CONTENT_TYPE_PROPERTY_PARAM);
- if (contentTypeProperty == null) {
- contentTypeProperty = jmsOut.getContentTypeProperty();
- }
-
- // need to synchronize as Sessions are not thread safe
- synchronized (messageSender.getSession()) {
- try {
- sendOverJMS(msgCtx, messageSender, contentTypeProperty, jmsConnectionFactory, jmsOut);
- } finally {
- messageSender.close();
- }
- }
- }
-
- /**
- * Perform actual sending of the JMS message
- */
- private void sendOverJMS(MessageContext msgCtx, JMSMessageSender messageSender,
- String contentTypeProperty, JMSConnectionFactory jmsConnectionFactory,
- JMSOutTransportInfo jmsOut) throws AxisFault {
-
- // convert the axis message context into a JMS Message that we can send over JMS
- Message message = null;
- String correlationId = null;
- try {
- message = createJMSMessage(msgCtx, messageSender.getSession(), contentTypeProperty);
- } catch (JMSException e) {
- handleException("Error creating a JMS message from the message context", e);
- }
-
- // should we wait for a synchronous response on this same thread?
- boolean waitForResponse = waitForSynchronousResponse(msgCtx);
- Destination replyDestination = jmsOut.getReplyDestination();
-
- // if this is a synchronous out-in, prepare to listen on the response destination
- if (waitForResponse) {
-
- String replyDestName = (String) msgCtx.getProperty(JMSConstants.JMS_REPLY_TO);
- if (replyDestName == null && jmsConnectionFactory != null) {
- replyDestName = jmsConnectionFactory.getReplyToDestination();
- }
-
- String replyDestType = (String) msgCtx.getProperty(JMSConstants.JMS_REPLY_TO_TYPE);
- if (replyDestType == null && jmsConnectionFactory != null) {
- replyDestType = jmsConnectionFactory.getReplyDestinationType();
- }
-
- if (replyDestName != null) {
- if (jmsConnectionFactory != null) {
- replyDestination = jmsConnectionFactory.getDestination(
- replyDestName, replyDestType);
- } else {
- replyDestination = jmsOut.getReplyDestination(replyDestName);
- }
- }
- replyDestination = JMSUtils.setReplyDestination(
- replyDestination, messageSender.getSession(), message);
- }
-
- try {
- messageSender.send(message, msgCtx);
- metrics.incrementMessagesSent(msgCtx);
-
- } catch (AxisJMSException e) {
- metrics.incrementFaultsSending();
- handleException("Error sending JMS message", e);
- }
-
- try {
- metrics.incrementBytesSent(msgCtx, JMSUtils.getMessageSize(message));
- } catch (JMSException e) {
- log.warn("Error reading JMS message size to update transport metrics", e);
- }
-
- // if we are expecting a synchronous response back for the message sent out
- if (waitForResponse) {
- // TODO ********************************************************************************
- // TODO **** replace with asynchronous polling via a poller task to process this *******
- // information would be given. Then it should poll (until timeout) the
- // requested destination for the response message and inject it from a
- // asynchronous worker thread
- try {
- messageSender.getConnection().start(); // multiple calls are safely ignored
- } catch (JMSException ignore) {}
-
- try {
- String jmsCorrelationID = message.getJMSCorrelationID();
- if (jmsCorrelationID != null && jmsCorrelationID.length() > 0) {
- correlationId = jmsCorrelationID;
- } else {
- correlationId = message.getJMSMessageID();
- }
- } catch(JMSException ignore) {}
-
- // We assume here that the response uses the same message property to
- // specify the content type of the message.
- waitForResponseAndProcess(messageSender.getSession(), replyDestination,
- msgCtx, correlationId, contentTypeProperty);
- // TODO ********************************************************************************
- }
- }
-
- /**
- * Create a Consumer for the reply destination and wait for the response JMS message
- * synchronously. If a message arrives within the specified time interval, process it
- * through Axis2
- * @param session the session to use to listen for the response
- * @param replyDestination the JMS reply Destination
- * @param msgCtx the outgoing message for which we are expecting the response
- * @param contentTypeProperty the message property used to determine the content type
- * of the response message
- * @throws AxisFault on error
- */
- private void waitForResponseAndProcess(Session session, Destination replyDestination,
- MessageContext msgCtx, String correlationId,
- String contentTypeProperty) throws AxisFault {
-
- try {
- MessageConsumer consumer;
- consumer = JMSUtils.createConsumer(session, replyDestination,
- "JMSCorrelationID = '" + correlationId + "'");
-
- // how long are we willing to wait for the sync response
- long timeout = JMSConstants.DEFAULT_JMS_TIMEOUT;
- String waitReply = (String) msgCtx.getProperty(JMSConstants.JMS_WAIT_REPLY);
- if (waitReply != null) {
- timeout = Long.valueOf(waitReply).longValue();
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Waiting for a maximum of " + timeout +
- "ms for a response message to destination : " + replyDestination +
- " with JMS correlation ID : " + correlationId);
- }
-
- Message reply = consumer.receive(timeout);
-
- if (reply != null) {
-
- // update transport level metrics
- metrics.incrementMessagesReceived();
- try {
- metrics.incrementBytesReceived(JMSUtils.getMessageSize(reply));
- } catch (JMSException e) {
- log.warn("Error reading JMS message size to update transport metrics", e);
- }
-
- try {
- processSyncResponse(msgCtx, reply, contentTypeProperty);
- metrics.incrementMessagesReceived();
- } catch (AxisFault e) {
- metrics.incrementFaultsReceiving();
- throw e;
- }
-
- } else {
- log.warn("Did not receive a JMS response within " +
- timeout + " ms to destination : " + replyDestination +
- " with JMS correlation ID : " + correlationId);
- metrics.incrementTimeoutsReceiving();
- }
-
- } catch (JMSException e) {
- metrics.incrementFaultsReceiving();
- handleException("Error creating a consumer, or receiving a synchronous reply " +
- "for outgoing MessageContext ID : " + msgCtx.getMessageID() +
- " and reply Destination : " + replyDestination, e);
- }
- }
-
- /**
- * Create a JMS Message from the given MessageContext and using the given
- * session
- *
- * @param msgContext the MessageContext
- * @param session the JMS session
- * @param contentTypeProperty the message property to be used to store the
- * content type
- * @return a JMS message from the context and session
- * @throws JMSException on exception
- * @throws AxisFault on exception
- */
- private Message createJMSMessage(MessageContext msgContext, Session session,
- String contentTypeProperty) throws JMSException, AxisFault {
-
- Message message = null;
- String msgType = getProperty(msgContext, JMSConstants.JMS_MESSAGE_TYPE);
-
- // check the first element of the SOAP body, do we have content wrapped using the
- // default wrapper elements for binary (BaseConstants.DEFAULT_BINARY_WRAPPER) or
- // text (BaseConstants.DEFAULT_TEXT_WRAPPER) ? If so, do not create SOAP messages
- // for JMS but just get the payload in its native format
- String jmsPayloadType = guessMessageType(msgContext);
-
- if (jmsPayloadType == null) {
-
- OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
- MessageFormatter messageFormatter = null;
- try {
- messageFormatter = MessageProcessorSelector.getMessageFormatter(msgContext);
- } catch (AxisFault axisFault) {
- throw new JMSException("Unable to get the message formatter to use");
- }
-
- String contentType = messageFormatter.getContentType(
- msgContext, format, msgContext.getSoapAction());
-
- boolean useBytesMessage =
- msgType != null && JMSConstants.JMS_BYTE_MESSAGE.equals(msgType) ||
- contentType.indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1;
-
- OutputStream out;
- StringWriter sw;
- if (useBytesMessage) {
- BytesMessage bytesMsg = session.createBytesMessage();
- sw = null;
- out = new BytesMessageOutputStream(bytesMsg);
- message = bytesMsg;
- } else {
- sw = new StringWriter();
- try {
- out = new WriterOutputStream(sw, format.getCharSetEncoding());
- } catch (UnsupportedCharsetException ex) {
- handleException("Unsupported encoding " + format.getCharSetEncoding(), ex);
- return null;
- }
- }
-
- try {
- messageFormatter.writeTo(msgContext, format, out, true);
- out.close();
- } catch (IOException e) {
- handleException("IO Error while creating BytesMessage", e);
- }
-
- if (!useBytesMessage) {
- TextMessage txtMsg = session.createTextMessage();
- txtMsg.setText(sw.toString());
- message = txtMsg;
- }
-
- if (contentTypeProperty != null) {
- message.setStringProperty(contentTypeProperty, contentType);
- }
-
- } else if (JMSConstants.JMS_BYTE_MESSAGE.equals(jmsPayloadType)) {
- message = session.createBytesMessage();
- BytesMessage bytesMsg = (BytesMessage) message;
- OMElement wrapper = msgContext.getEnvelope().getBody().
- getFirstChildWithName(BaseConstants.DEFAULT_BINARY_WRAPPER);
- OMNode omNode = wrapper.getFirstOMChild();
- if (omNode != null && omNode instanceof OMText) {
- Object dh = ((OMText) omNode).getDataHandler();
- if (dh != null && dh instanceof DataHandler) {
- try {
- ((DataHandler) dh).writeTo(new BytesMessageOutputStream(bytesMsg));
- } catch (IOException e) {
- handleException("Error serializing binary content of element : " +
- BaseConstants.DEFAULT_BINARY_WRAPPER, e);
- }
- }
- }
-
- } else if (JMSConstants.JMS_TEXT_MESSAGE.equals(jmsPayloadType)) {
- message = session.createTextMessage();
- TextMessage txtMsg = (TextMessage) message;
- txtMsg.setText(msgContext.getEnvelope().getBody().
- getFirstChildWithName(BaseConstants.DEFAULT_TEXT_WRAPPER).getText());
- }
-
- // set the JMS correlation ID if specified
- String correlationId = getProperty(msgContext, JMSConstants.JMS_COORELATION_ID);
- if (correlationId == null && msgContext.getRelatesTo() != null) {
- correlationId = msgContext.getRelatesTo().getValue();
- }
-
- if (correlationId != null) {
- message.setJMSCorrelationID(correlationId);
- }
-
- if (msgContext.isServerSide()) {
- // set SOAP Action as a property on the JMS message
- setProperty(message, msgContext, BaseConstants.SOAPACTION);
- } else {
- String action = msgContext.getOptions().getAction();
- if (action != null) {
- message.setStringProperty(BaseConstants.SOAPACTION, action);
- }
- }
-
- JMSUtils.setTransportHeaders(msgContext, message);
- return message;
- }
-
- /**
- * Guess the message type to use for JMS looking at the message contexts' envelope
- * @param msgContext the message context
- * @return JMSConstants.JMS_BYTE_MESSAGE or JMSConstants.JMS_TEXT_MESSAGE or null
- */
- private String guessMessageType(MessageContext msgContext) {
- OMElement firstChild = msgContext.getEnvelope().getBody().getFirstElement();
- if (firstChild != null) {
- if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) {
- return JMSConstants.JMS_BYTE_MESSAGE;
- } else if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(firstChild.getQName())) {
- return JMSConstants.JMS_TEXT_MESSAGE;
- }
- }
- return null;
- }
-
- /**
- * Creates an Axis MessageContext for the received JMS message and
- * sets up the transports and various properties
- *
- * @param outMsgCtx the outgoing message for which we are expecting the response
- * @param message the JMS response message received
- * @param contentTypeProperty the message property used to determine the content type
- * of the response message
- * @throws AxisFault on error
- */
- private void processSyncResponse(MessageContext outMsgCtx, Message message,
- String contentTypeProperty) throws AxisFault {
-
- MessageContext responseMsgCtx = createResponseMessageContext(outMsgCtx);
-
- // load any transport headers from received message
- JMSUtils.loadTransportHeaders(message, responseMsgCtx);
-
- String contentType = contentTypeProperty == null ? null
- : JMSUtils.getProperty(message, contentTypeProperty);
-
- try {
- JMSUtils.setSOAPEnvelope(message, responseMsgCtx, contentType);
- } catch (JMSException ex) {
- throw AxisFault.makeFault(ex);
- }
-
- handleIncomingMessage(
- responseMsgCtx,
- JMSUtils.getTransportHeaders(message),
- JMSUtils.getProperty(message, BaseConstants.SOAPACTION),
- contentType
- );
- }
-
- private void setProperty(Message message, MessageContext msgCtx, String key) {
-
- String value = getProperty(msgCtx, key);
- if (value != null) {
- try {
- message.setStringProperty(key, value);
- } catch (JMSException e) {
- log.warn("Couldn't set message property : " + key + " = " + value, e);
- }
- }
- }
-
- private String getProperty(MessageContext mc, String key) {
- return (String) mc.getProperty(key);
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java
deleted file mode 100644
index b3ee738..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java
+++ /dev/null
@@ -1,724 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.builder.Builder;
-import org.apache.axis2.builder.BuilderUtil;
-import org.apache.axis2.builder.SOAPBuilder;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.util.MessageProcessorSelector;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.format.DataSourceMessageBuilder;
-import org.apache.axis2.format.TextMessageBuilder;
-import org.apache.axis2.format.TextMessageBuilderAdapter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.transport.base.BaseUtils;
-import org.apache.axis2.transport.jms.iowrappers.BytesMessageDataSource;
-import org.apache.axis2.transport.jms.iowrappers.BytesMessageInputStream;
-
-import javax.jms.*;
-import javax.jms.Queue;
-import javax.mail.internet.ContentType;
-import javax.mail.internet.ParseException;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.NameNotFoundException;
-
-import java.lang.reflect.Method;
-import java.util.*;
-
-/**
- * Miscallaneous methods used for the JMS transport
- */
-public class JMSUtils extends BaseUtils {
-
- private static final Log log = LogFactory.getLog(JMSUtils.class);
- private static final Class<?>[] NOARGS = new Class<?>[] {};
- private static final Object[] NOPARMS = new Object[] {};
-
- /**
- * Should this service be enabled over the JMS transport?
- *
- * @param service the Axis service
- * @return true if JMS should be enabled
- */
- public static boolean isJMSService(AxisService service) {
- if (service.isEnableAllTransports()) {
- return true;
-
- } else {
- for (String transport : service.getExposedTransports()) {
- if (JMSListener.TRANSPORT_NAME.equals(transport)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Get a String property from the JMS message
- *
- * @param message JMS message
- * @param property property name
- * @return property value
- */
- public static String getProperty(Message message, String property) {
- try {
- return message.getStringProperty(property);
- } catch (JMSException e) {
- return null;
- }
- }
-
- /**
- * Return the destination name from the given URL
- *
- * @param url the URL
- * @return the destination name
- */
- public static String getDestination(String url) {
- String tempUrl = url.substring(JMSConstants.JMS_PREFIX.length());
- int propPos = tempUrl.indexOf("?");
-
- if (propPos == -1) {
- return tempUrl;
- } else {
- return tempUrl.substring(0, propPos);
- }
- }
-
- /**
- * Set the SOAPEnvelope to the Axis2 MessageContext, from the JMS Message passed in
- * @param message the JMS message read
- * @param msgContext the Axis2 MessageContext to be populated
- * @param contentType content type for the message
- * @throws AxisFault
- * @throws JMSException
- */
- public static void setSOAPEnvelope(Message message, MessageContext msgContext, String contentType)
- throws AxisFault, JMSException {
-
- if (contentType == null) {
- if (message instanceof TextMessage) {
- contentType = "text/plain";
- } else {
- contentType = "application/octet-stream";
- }
- if (log.isDebugEnabled()) {
- log.debug("No content type specified; assuming " + contentType);
- }
- }
-
- int index = contentType.indexOf(';');
- String type = index > 0 ? contentType.substring(0, index) : contentType;
- Builder builder = MessageProcessorSelector.getMessageBuilder(type, msgContext);
- if (builder == null) {
- if (log.isDebugEnabled()) {
- log.debug("No message builder found for type '" + type + "'. Falling back to SOAP.");
- }
- builder = new SOAPBuilder();
- }
-
- OMElement documentElement;
- if (message instanceof BytesMessage) {
- // Extract the charset encoding from the content type and
- // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
- String charSetEnc = null;
- try {
- if (contentType != null) {
- charSetEnc = new ContentType(contentType).getParameter("charset");
- }
- } catch (ParseException ex) {
- // ignore
- }
- msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
-
- if (builder instanceof DataSourceMessageBuilder) {
- documentElement = ((DataSourceMessageBuilder)builder).processDocument(
- new BytesMessageDataSource((BytesMessage)message), contentType,
- msgContext);
- } else {
- documentElement = builder.processDocument(
- new BytesMessageInputStream((BytesMessage)message), contentType,
- msgContext);
- }
- } else if (message instanceof TextMessage) {
- TextMessageBuilder textMessageBuilder;
- if (builder instanceof TextMessageBuilder) {
- textMessageBuilder = (TextMessageBuilder)builder;
- } else {
- textMessageBuilder = new TextMessageBuilderAdapter(builder);
- }
- String content = ((TextMessage)message).getText();
- documentElement = textMessageBuilder.processDocument(content, contentType, msgContext);
- } else {
- handleException("Unsupported JMS message type " + message.getClass().getName());
- return; // Make compiler happy
- }
- msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
- }
-
- /**
- * Set the JMS ReplyTo for the message
- *
- * @param replyDestination the JMS Destination where the reply is expected
- * @param session the session to use to create a temp Queue if a response is expected
- * but a Destination has not been specified
- * @param message the JMS message where the final Destinatio would be set as the JMS ReplyTo
- * @return the JMS ReplyTo Destination for the message
- */
- public static Destination setReplyDestination(Destination replyDestination, Session session,
- Message message) {
-
- if (replyDestination == null) {
- try {
- // create temporary queue to receive the reply
- replyDestination = createTemporaryDestination(session);
- } catch (JMSException e) {
- handleException("Error creating temporary queue for response", e);
- }
- }
-
- try {
- message.setJMSReplyTo(replyDestination);
- } catch (JMSException e) {
- log.warn("Error setting JMS ReplyTo destination to : " + replyDestination, e);
- }
-
- if (log.isDebugEnabled()) {
- try {
- assert replyDestination != null;
- log.debug("Expecting a response to JMS Destination : " +
- (replyDestination instanceof Queue ?
- ((Queue) replyDestination).getQueueName() :
- ((Topic) replyDestination).getTopicName()));
- } catch (JMSException ignore) {}
- }
- return replyDestination;
- }
-
- /**
- * Set transport headers from the axis message context, into the JMS message
- *
- * @param msgContext the axis message context
- * @param message the JMS Message
- * @throws JMSException on exception
- */
- public static void setTransportHeaders(MessageContext msgContext, Message message)
- throws JMSException {
-
- Map<?,?> headerMap = (Map<?,?>) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
-
- if (headerMap == null) {
- return;
- }
-
- for (Object headerName : headerMap.keySet()) {
-
- String name = (String) headerName;
-
- if (name.startsWith(JMSConstants.JMSX_PREFIX) &&
- !(name.equals(JMSConstants.JMSX_GROUP_ID) || name.equals(JMSConstants.JMSX_GROUP_SEQ))) {
- continue;
- }
-
- if (JMSConstants.JMS_COORELATION_ID.equals(name)) {
- message.setJMSCorrelationID(
- (String) headerMap.get(JMSConstants.JMS_COORELATION_ID));
- } else if (JMSConstants.JMS_DELIVERY_MODE.equals(name)) {
- Object o = headerMap.get(JMSConstants.JMS_DELIVERY_MODE);
- if (o instanceof Integer) {
- message.setJMSDeliveryMode((Integer) o);
- } else if (o instanceof String) {
- try {
- message.setJMSDeliveryMode(Integer.parseInt((String) o));
- } catch (NumberFormatException nfe) {
- log.warn("Invalid delivery mode ignored : " + o, nfe);
- }
- } else {
- log.warn("Invalid delivery mode ignored : " + o);
- }
-
- } else if (JMSConstants.JMS_EXPIRATION.equals(name)) {
- message.setJMSExpiration(
- Long.parseLong((String) headerMap.get(JMSConstants.JMS_EXPIRATION)));
- } else if (JMSConstants.JMS_MESSAGE_ID.equals(name)) {
- message.setJMSMessageID((String) headerMap.get(JMSConstants.JMS_MESSAGE_ID));
- } else if (JMSConstants.JMS_PRIORITY.equals(name)) {
- message.setJMSPriority(
- Integer.parseInt((String) headerMap.get(JMSConstants.JMS_PRIORITY)));
- } else if (JMSConstants.JMS_TIMESTAMP.equals(name)) {
- message.setJMSTimestamp(
- Long.parseLong((String) headerMap.get(JMSConstants.JMS_TIMESTAMP)));
- } else if (JMSConstants.JMS_MESSAGE_TYPE.equals(name)) {
- message.setJMSType((String) headerMap.get(JMSConstants.JMS_MESSAGE_TYPE));
-
- } else {
- Object value = headerMap.get(name);
- if (value instanceof String) {
- message.setStringProperty(name, (String) value);
- } else if (value instanceof Boolean) {
- message.setBooleanProperty(name, (Boolean) value);
- } else if (value instanceof Integer) {
- message.setIntProperty(name, (Integer) value);
- } else if (value instanceof Long) {
- message.setLongProperty(name, (Long) value);
- } else if (value instanceof Double) {
- message.setDoubleProperty(name, (Double) value);
- } else if (value instanceof Float) {
- message.setFloatProperty(name, (Float) value);
- }
- }
- }
- }
-
- /**
- * Read the transport headers from the JMS Message and set them to the axis2 message context
- *
- * @param message the JMS Message received
- * @param responseMsgCtx the axis message context
- * @throws AxisFault on error
- */
- public static void loadTransportHeaders(Message message, MessageContext responseMsgCtx)
- throws AxisFault {
- responseMsgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, getTransportHeaders(message));
- }
-
- /**
- * Extract transport level headers for JMS from the given message into a Map
- *
- * @param message the JMS message
- * @return a Map of the transport headers
- */
- public static Map<String, Object> getTransportHeaders(Message message) {
- // create a Map to hold transport headers
- Map<String, Object> map = new HashMap<String, Object>();
-
- // correlation ID
- try {
- if (message.getJMSCorrelationID() != null) {
- map.put(JMSConstants.JMS_COORELATION_ID, message.getJMSCorrelationID());
- }
- } catch (JMSException ignore) {}
-
- // set the delivery mode as persistent or not
- try {
- map.put(JMSConstants.JMS_DELIVERY_MODE, Integer.toString(message.getJMSDeliveryMode()));
- } catch (JMSException ignore) {}
-
- // destination name
- try {
- if (message.getJMSDestination() != null) {
- Destination dest = message.getJMSDestination();
- map.put(JMSConstants.JMS_DESTINATION,
- dest instanceof Queue ?
- ((Queue) dest).getQueueName() : ((Topic) dest).getTopicName());
- }
- } catch (JMSException ignore) {}
-
- // expiration
- try {
- map.put(JMSConstants.JMS_EXPIRATION, Long.toString(message.getJMSExpiration()));
- } catch (JMSException ignore) {}
-
- // if a JMS message ID is found
- try {
- if (message.getJMSMessageID() != null) {
- map.put(JMSConstants.JMS_MESSAGE_ID, message.getJMSMessageID());
- }
- } catch (JMSException ignore) {}
-
- // priority
- try {
- map.put(JMSConstants.JMS_PRIORITY, Long.toString(message.getJMSPriority()));
- } catch (JMSException ignore) {}
-
- // redelivered
- try {
- map.put(JMSConstants.JMS_REDELIVERED, Boolean.toString(message.getJMSRedelivered()));
- } catch (JMSException ignore) {}
-
- // replyto destination name
- try {
- if (message.getJMSReplyTo() != null) {
- Destination dest = message.getJMSReplyTo();
- map.put(JMSConstants.JMS_REPLY_TO,
- dest instanceof Queue ?
- ((Queue) dest).getQueueName() : ((Topic) dest).getTopicName());
- }
- } catch (JMSException ignore) {}
-
- // priority
- try {
- map.put(JMSConstants.JMS_TIMESTAMP, Long.toString(message.getJMSTimestamp()));
- } catch (JMSException ignore) {}
-
- // message type
- try {
- if (message.getJMSType() != null) {
- map.put(JMSConstants.JMS_TYPE, message.getJMSType());
- }
- } catch (JMSException ignore) {}
-
- // any other transport properties / headers
- Enumeration<?> e = null;
- try {
- e = message.getPropertyNames();
- } catch (JMSException ignore) {}
-
- if (e != null) {
- while (e.hasMoreElements()) {
- String headerName = (String) e.nextElement();
- try {
- map.put(headerName, message.getStringProperty(headerName));
- continue;
- } catch (JMSException ignore) {}
- try {
- map.put(headerName, message.getBooleanProperty(headerName));
- continue;
- } catch (JMSException ignore) {}
- try {
- map.put(headerName, message.getIntProperty(headerName));
- continue;
- } catch (JMSException ignore) {}
- try {
- map.put(headerName, message.getLongProperty(headerName));
- continue;
- } catch (JMSException ignore) {}
- try {
- map.put(headerName, message.getDoubleProperty(headerName));
- continue;
- } catch (JMSException ignore) {}
- try {
- map.put(headerName, message.getFloatProperty(headerName));
- } catch (JMSException ignore) {}
- }
- }
-
- return map;
- }
-
-
- /**
- * Create a MessageConsumer for the given Destination
- * @param session JMS Session to use
- * @param dest Destination for which the Consumer is to be created
- * @param messageSelector the message selector to be used if any
- * @return a MessageConsumer for the specified Destination
- * @throws JMSException
- */
- public static MessageConsumer createConsumer(Session session, Destination dest, String messageSelector)
- throws JMSException {
-
- if (dest instanceof Queue) {
- return ((QueueSession) session).createReceiver((Queue) dest, messageSelector);
- } else {
- return ((TopicSession) session).createSubscriber((Topic) dest, messageSelector, false);
- }
- }
-
- /**
- * Create a temp queue or topic for synchronous receipt of responses, when a reply destination
- * is not specified
- * @param session the JMS Session to use
- * @return a temporary Queue or Topic, depending on the session
- * @throws JMSException
- */
- public static Destination createTemporaryDestination(Session session) throws JMSException {
-
- if (session instanceof QueueSession) {
- return session.createTemporaryQueue();
- } else {
- return session.createTemporaryTopic();
- }
- }
-
- /**
- * Return the body length in bytes for a bytes message
- * @param bMsg the JMS BytesMessage
- * @return length of body in bytes
- */
- public static long getBodyLength(BytesMessage bMsg) {
- try {
- Method mtd = bMsg.getClass().getMethod("getBodyLength", NOARGS);
- if (mtd != null) {
- return (Long) mtd.invoke(bMsg, NOPARMS);
- }
- } catch (Exception e) {
- // JMS 1.0
- if (log.isDebugEnabled()) {
- log.debug("Error trying to determine JMS BytesMessage body length", e);
- }
- }
-
- // if JMS 1.0
- long length = 0;
- try {
- byte[] buffer = new byte[2048];
- bMsg.reset();
- for (int bytesRead = bMsg.readBytes(buffer); bytesRead != -1;
- bytesRead = bMsg.readBytes(buffer)) {
- length += bytesRead;
- }
- } catch (JMSException ignore) {}
- return length;
- }
-
- /**
- * Get the length of the message in bytes
- * @param message
- * @return message size (or approximation) in bytes
- * @throws JMSException
- */
- public static long getMessageSize(Message message) throws JMSException {
- if (message instanceof BytesMessage) {
- return JMSUtils.getBodyLength((BytesMessage) message);
- } else if (message instanceof TextMessage) {
- // TODO: Converting the whole message to a byte array is too much overhead just to determine the message size.
- // Anyway, the result is not accurate since we don't know what encoding the JMS provider uses.
- return ((TextMessage) message).getText().getBytes().length;
- } else {
- log.warn("Can't determine size of JMS message; unsupported message type : "
- + message.getClass().getName());
- return 0;
- }
- }
-
- public static <T> T lookup(Context context, Class<T> clazz, String name)
- throws NamingException {
-
- Object object = context.lookup(name);
- try {
- return clazz.cast(object);
- } catch (ClassCastException ex) {
- // Instead of a ClassCastException, throw an exception with some
- // more information.
- if (object instanceof Reference) {
- Reference ref = (Reference)object;
- handleException("JNDI failed to de-reference Reference with name " +
- name + "; is the factory " + ref.getFactoryClassName() +
- " in your classpath?");
- return null;
- } else {
- handleException("JNDI lookup of name " + name + " returned a " +
- object.getClass().getName() + " while a " + clazz + " was expected");
- return null;
- }
- }
- }
-
- /**
- * This is a JMS spec independent method to create a Connection. Please be cautious when
- * making any changes
- *
- * @param conFac the ConnectionFactory to use
- * @param user optional user name
- * @param pass optional password
- * @param jmsSpec11 should we use JMS 1.1 API ?
- * @param isQueue is this to deal with a Queue?
- * @return a JMS Connection as requested
- * @throws JMSException on errors, to be handled and logged by the caller
- */
- public static Connection createConnection(ConnectionFactory conFac,
- String user, String pass, boolean jmsSpec11, Boolean isQueue) throws JMSException {
-
- Connection connection = null;
- if (log.isDebugEnabled()) {
- log.debug("Creating a " + (isQueue == null ? "Generic" : isQueue ? "Queue" : "Topic") +
- "Connection using credentials : (" + user + "/" + pass + ")");
- }
-
- if (jmsSpec11 || isQueue == null) {
- if (user != null && pass != null) {
- connection = conFac.createConnection(user, pass);
- } else {
- connection = conFac.createConnection();
- }
-
- } else {
- QueueConnectionFactory qConFac = null;
- TopicConnectionFactory tConFac = null;
- if (isQueue) {
- qConFac = (QueueConnectionFactory) conFac;
- } else {
- tConFac = (TopicConnectionFactory) conFac;
- }
-
- if (user != null && pass != null) {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection(user, pass);
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection(user, pass);
- }
- } else {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection();
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection();
- }
- }
- }
- return connection;
- }
-
- /**
- * This is a JMS spec independent method to create a Session. Please be cautious when
- * making any changes
- *
- * @param connection the JMS Connection
- * @param transacted should the session be transacted?
- * @param ackMode the ACK mode for the session
- * @param jmsSpec11 should we use the JMS 1.1 API?
- * @param isQueue is this Session to deal with a Queue?
- * @return a Session created for the given information
- * @throws JMSException on errors, to be handled and logged by the caller
- */
- public static Session createSession(Connection connection, boolean transacted, int ackMode,
- boolean jmsSpec11, Boolean isQueue) throws JMSException {
-
- if (jmsSpec11 || isQueue == null) {
- return connection.createSession(transacted, ackMode);
-
- } else {
- if (isQueue) {
- return ((QueueConnection) connection).createQueueSession(transacted, ackMode);
- } else {
- return ((TopicConnection) connection).createTopicSession(transacted, ackMode);
- }
- }
- }
-
- /**
- * This is a JMS spec independent method to create a MessageConsumer. Please be cautious when
- * making any changes
- *
- * @param session JMS session
- * @param destination the Destination
- * @param isQueue is the Destination a queue?
- * @param subscriberName optional client name to use for a durable subscription to a topic
- * @param messageSelector optional message selector
- * @param pubSubNoLocal should we receive messages sent by us during pub-sub?
- * @param isDurable is this a durable topic subscription?
- * @param jmsSpec11 should we use JMS 1.1 API ?
- * @return a MessageConsumer to receive messages
- * @throws JMSException on errors, to be handled and logged by the caller
- */
- public static MessageConsumer createConsumer(
- Session session, Destination destination, Boolean isQueue,
- String subscriberName, String messageSelector, boolean pubSubNoLocal,
- boolean isDurable, boolean jmsSpec11) throws JMSException {
-
- if (jmsSpec11 || isQueue == null) {
- if (isDurable) {
- return session.createDurableSubscriber(
- (Topic) destination, subscriberName, messageSelector, pubSubNoLocal);
- } else {
- return session.createConsumer(destination, messageSelector, pubSubNoLocal);
- }
- } else {
- if (isQueue) {
- return ((QueueSession) session).createReceiver((Queue) destination, messageSelector);
- } else {
- if (isDurable) {
- return ((TopicSession) session).createDurableSubscriber(
- (Topic) destination, subscriberName, messageSelector, pubSubNoLocal);
- } else {
- return ((TopicSession) session).createSubscriber(
- (Topic) destination, messageSelector, pubSubNoLocal);
- }
- }
- }
- }
-
- /**
- * This is a JMS spec independent method to create a MessageProducer. Please be cautious when
- * making any changes
- *
- * @param session JMS session
- * @param destination the Destination
- * @param isQueue is the Destination a queue?
- * @param jmsSpec11 should we use JMS 1.1 API ?
- * @return a MessageProducer to send messages to the given Destination
- * @throws JMSException on errors, to be handled and logged by the caller
- */
- public static MessageProducer createProducer(
- Session session, Destination destination, Boolean isQueue, boolean jmsSpec11) throws JMSException {
-
- if (jmsSpec11 || isQueue == null) {
- return session.createProducer(destination);
- } else {
- if (isQueue) {
- return ((QueueSession) session).createSender((Queue) destination);
- } else {
- return ((TopicSession) session).createPublisher((Topic) destination);
- }
- }
- }
-
- /**
- * Return a String representation of the destination type
- * @param destType the destination type indicator int
- * @return a descriptive String
- */
- public static String getDestinationTypeAsString(int destType) {
- if (destType == JMSConstants.QUEUE) {
- return "Queue";
- } else if (destType == JMSConstants.TOPIC) {
- return "Topic";
- } else {
- return "Generic";
- }
- }
-
- /**
- * Return the JMS destination with the given destination name looked up from the context
- *
- * @param context the Context to lookup
- * @param destinationName name of the destination to be looked up
- * @param destinationType type of the destination to be looked up
- * @return the JMS destination, or null if it does not exist
- */
- public static Destination lookupDestination(Context context, String destinationName,
- String destinationType) throws NamingException {
-
- if (destinationName == null) {
- return null;
- }
-
- try {
- return JMSUtils.lookup(context, Destination.class, destinationName);
- } catch (NameNotFoundException e) {
- try {
- return JMSUtils.lookup(context, Destination.class,
- (JMSConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(destinationType) ?
- "dynamicTopics/" : "dynamicQueues/") + destinationName);
- } catch (NamingException x) {
- log.warn("Cannot locate destination : " + destinationName);
- throw x;
- }
- } catch (NamingException e) {
- log.warn("Cannot locate destination : " + destinationName, e);
- throw e;
- }
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ServiceTaskManager.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ServiceTaskManager.java
deleted file mode 100644
index 112c92b..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ServiceTaskManager.java
+++ /dev/null
@@ -1,1250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.threads.WorkerPool;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.*;
-import javax.jms.IllegalStateException;
-import javax.naming.InitialContext;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.transaction.UserTransaction;
-import javax.transaction.NotSupportedException;
-import javax.transaction.SystemException;
-import javax.transaction.Status;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Each service will have one ServiceTaskManager instance that will create, manage and also destroy
- * idle tasks created for it, for message receipt. This will also allow individual tasks to cache
- * the Connection, Session or Consumer as necessary, considering the transactionality required and
- * user preference.
- *
- * This also acts as the ExceptionListener for all JMS connections made on behalf of the service.
- * Since the ExceptionListener is notified by a JMS provider on a "serious" error, we simply try
- * to re-connect. Thus a connection failure for a single task, will re-initialize the state afresh
- * for the service, by discarding all connections.
- */
-public class ServiceTaskManager {
-
- /** The logger */
- private static final Log log = LogFactory.getLog(ServiceTaskManager.class);
-
- /** The Task manager is stopped or has not started */
- private static final int STATE_STOPPED = 0;
- /** The Task manager is started and active */
- private static final int STATE_STARTED = 1;
- /** The Task manager is paused temporarily */
- private static final int STATE_PAUSED = 2;
- /** The Task manager is started, but a shutdown has been requested */
- private static final int STATE_SHUTTING_DOWN = 3;
- /** The Task manager has encountered an error */
- private static final int STATE_FAILURE = 4;
-
- /** The name of the service managed by this instance */
- private String serviceName;
- /** The ConnectionFactory MUST refer to an XAConnectionFactory to use JTA */
- private String connFactoryJNDIName;
- /** The JNDI name of the Destination Queue or Topic */
- // TODO: this overlaps with JMSEndpoint#jndiDestinationName; needs to be clarified
- private String destinationJNDIName;
- /** JNDI location for the JTA UserTransaction */
- private String userTransactionJNDIName = "java:comp/UserTransaction";
- /** The type of destination - P2P or PubSub (or JMS 1.1 API generic?) */
- // TODO: this overlaps with JMSEndpoint#destinationType; needs to be clarified
- private int destinationType = JMSConstants.GENERIC;
- /** An optional message selector */
- private String messageSelector = null;
-
- /** Should tasks run without transactions, using transacted Sessions (i.e. local), or JTA */
- private int transactionality = BaseConstants.TRANSACTION_NONE;
- /** Should created Sessions be transactional ? - should be false when using JTA */
- private boolean sessionTransacted = true;
- /** Session acknowledgement mode when transacted Sessions (i.e. local transactions) are used */
- private int sessionAckMode = Session.AUTO_ACKNOWLEDGE;
-
- /** Is the subscription durable ? */
- private boolean subscriptionDurable = false;
- /** The name of the durable subscriber for this client */
- private String durableSubscriberName = null;
- /** In PubSub mode, should I receive messages sent by me / my connection ? */
- private boolean pubSubNoLocal = false;
- /** Number of concurrent consumers - for PubSub, this should be 1 to prevent multiple receipt */
- private int concurrentConsumers = 1;
- /** Maximum number of consumers to create - see @concurrentConsumers */
- private int maxConcurrentConsumers = 1;
- /** The number of idle (i.e. message-less) attempts to be tried before suicide, to scale down */
- private int idleTaskExecutionLimit = 10;
- /** The maximum number of successful message receipts for a task - to limit thread life span */
- private int maxMessagesPerTask = -1; // default is unlimited
- /** The default receive timeout - a negative value means wait forever, zero dont wait at all */
- private int receiveTimeout = 1000;
- /** JMS Resource cache level - Connection, Session, Consumer. Auto will select safe default */
- private int cacheLevel = JMSConstants.CACHE_AUTO;
- /** Should we cache the UserTransaction handle from JNDI - true for almost all app servers */
- private boolean cacheUserTransaction = true;
- /** Shared UserTransactionHandle */
- private UserTransaction sharedUserTransaction = null;
- /** Should this service use JMS 1.1 ? (when false, defaults to 1.0.2b) */
- private boolean jmsSpec11 = true;
-
- /** Initial duration to attempt re-connection to JMS provider after failure */
- private int initialReconnectDuration = 10000;
- /** Progression factory for geometric series that calculates re-connection times */
- private double reconnectionProgressionFactor = 2.0; // default to [bounded] exponential
- /** Upper limit on reconnection attempt duration */
- private long maxReconnectDuration = 1000 * 60 * 60; // 1 hour
-
- /** The JNDI context properties and other general properties */
- private Hashtable<String,String> jmsProperties = new Hashtable<String, String>();
- /** The JNDI Context acuired */
- private Context context = null;
- /** The ConnectionFactory to be used */
- private ConnectionFactory conFactory = null;
- /** The JMS Destination */
- private Destination destination = null;
-
- /** The list of active tasks thats managed by this instance */
- private final List<MessageListenerTask> pollingTasks =
- Collections.synchronizedList(new ArrayList<MessageListenerTask>());
- /** The per-service JMS message receiver to be invoked after receipt of messages */
- private JMSMessageReceiver jmsMessageReceiver = null;
-
- /** State of this Task Manager */
- private volatile int serviceTaskManagerState = STATE_STOPPED;
- /** Number of invoker tasks active */
- private volatile int activeTaskCount = 0;
- /** The number of existing JMS message consumers. */
- private final AtomicInteger consumerCount = new AtomicInteger();
- /** The shared thread pool from the Listener */
- private WorkerPool workerPool = null;
-
- /** The JMS Connection shared between multiple polling tasks - when enabled (reccomended) */
- private Connection sharedConnection = null;
-
- /** Is this error triggers a JMS onException ?*/
- private volatile boolean isOnExceptionError = false;
-
- /**
- * Start or re-start the Task Manager by shutting down any existing worker tasks and
- * re-creating them. However, if this is STM is PAUSED, a start request is ignored.
- * This applies for any connection failures during paused state as well, which then will
- * not try to auto recover
- */
- public synchronized void start() {
-
- if (serviceTaskManagerState == STATE_PAUSED) {
- log.info("Attempt to re-start paused TaskManager is ignored. Please use resume instead");
- return;
- }
-
- // if any tasks are running, stop whats running now
- if (!pollingTasks.isEmpty()) {
- stop();
- }
-
- if (cacheLevel == JMSConstants.CACHE_AUTO) {
- cacheLevel =
- transactionality == BaseConstants.TRANSACTION_NONE ?
- JMSConstants.CACHE_CONSUMER : JMSConstants.CACHE_NONE;
- }
- switch (cacheLevel) {
- case JMSConstants.CACHE_NONE:
- log.debug("No JMS resources will be cached/shared between poller " +
- "worker tasks of service : " + serviceName);
- break;
- case JMSConstants.CACHE_CONNECTION:
- log.debug("Only the JMS Connection will be cached and shared between *all* " +
- "poller task invocations");
- break;
- case JMSConstants.CACHE_SESSION:
- log.debug("The JMS Connection and Session will be cached and shared between " +
- "successive poller task invocations");
- break;
- case JMSConstants.CACHE_CONSUMER:
- log.debug("The JMS Connection, Session and MessageConsumer will be cached and " +
- "shared between successive poller task invocations");
- break;
- default : {
- handleException("Invalid cache level : " + cacheLevel +
- " for service : " + serviceName);
- }
- }
-
- for (int i=0; i<concurrentConsumers; i++) {
- workerPool.execute(new MessageListenerTask());
- }
-
- serviceTaskManagerState = STATE_STARTED;
- log.info("Task manager for service : " + serviceName + " [re-]initialized");
- }
-
- /**
- * Shutdown the tasks and release any shared resources
- */
- public synchronized void stop() {
-
- if (log.isDebugEnabled()) {
- log.debug("Stopping ServiceTaskManager for service : " + serviceName);
- }
-
- if (serviceTaskManagerState != STATE_FAILURE) {
- serviceTaskManagerState = STATE_SHUTTING_DOWN;
- }
-
- synchronized(pollingTasks) {
- for (MessageListenerTask lstTask : pollingTasks) {
- lstTask.requestShutdown();
- }
- }
-
- // try to wait a bit for task shutdown
- for (int i=0; i<5; i++) {
- if (activeTaskCount == 0) {
- break;
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {}
- }
-
- if (sharedConnection != null) {
- try {
- sharedConnection.close();
- } catch (JMSException e) {
- logError("Error closing shared Connection", e);
- } finally {
- sharedConnection = null;
- }
- }
-
- if (activeTaskCount > 0) {
- log.warn("Unable to shutdown all polling tasks of service : " + serviceName);
- }
-
- if (serviceTaskManagerState != STATE_FAILURE) {
- serviceTaskManagerState = STATE_STOPPED;
- }
- log.info("Task manager for service : " + serviceName + " shutdown");
- }
-
- /**
- * Temporarily suspend receipt and processing of messages. Accomplished by stopping the
- * connection / or connections used by the poller tasks
- */
- public synchronized void pause() {
- for (MessageListenerTask lstTask : pollingTasks) {
- lstTask.pause();
- }
- if (sharedConnection != null) {
- try {
- sharedConnection.stop();
- } catch (JMSException e) {
- logError("Error pausing shared Connection", e);
- }
- }
- }
-
- /**
- * Resume receipt and processing of messages of paused tasks
- */
- public synchronized void resume() {
- for (MessageListenerTask lstTask : pollingTasks) {
- lstTask.resume();
- }
- if (sharedConnection != null) {
- try {
- sharedConnection.start();
- } catch (JMSException e) {
- logError("Error resuming shared Connection", e);
- }
- }
- }
-
- /**
- * Start a new MessageListenerTask if we are still active, the threshold is not reached, and w
- * e do not have any idle tasks - i.e. scale up listening
- */
- private void scheduleNewTaskIfAppropriate() {
- if (serviceTaskManagerState == STATE_STARTED &&
- pollingTasks.size() < getMaxConcurrentConsumers() && getIdleTaskCount() == 0) {
- workerPool.execute(new MessageListenerTask());
- }
- }
-
- /**
- * Get the number of MessageListenerTasks that are currently idle
- * @return idle task count
- */
- private int getIdleTaskCount() {
- int count = 0;
- for (MessageListenerTask lstTask : pollingTasks) {
- if (lstTask.isTaskIdle()) {
- count++;
- }
- }
- return count;
- }
-
- /**
- * Get the number of MessageListenerTasks that are currently connected to the JMS provider
- * @return connected task count
- */
- private int getConnectedTaskCount() {
- int count = 0;
- for (MessageListenerTask lstTask : pollingTasks) {
- if (lstTask.isConnected()) {
- count++;
- }
- }
- return count;
- }
-
- /**
- * The actual threads/tasks that perform message polling
- */
- private class MessageListenerTask implements Runnable, ExceptionListener {
-
- /** The Connection used by the polling task */
- private Connection connection = null;
- /** The Sesson used by the polling task */
- private Session session = null;
- /** The MessageConsumer used by the polling task */
- private MessageConsumer consumer = null;
- /** State of the worker polling task */
- private volatile int workerState = STATE_STOPPED;
- /** The number of idle (i.e. without fetching a message) polls for this task */
- private int idleExecutionCount = 0;
- /** Is this task idle right now? */
- private volatile boolean idle = false;
- /** Is this task connected to the JMS provider successfully? */
- private volatile boolean connected = false;
-
- /** As soon as we create a new polling task, add it to the STM for control later */
- MessageListenerTask() {
- synchronized(pollingTasks) {
- pollingTasks.add(this);
- }
- }
-
- /**
- * Pause this polling worker task
- */
- public void pause() {
- if (isActive()) {
- if (connection != null && cacheLevel < JMSConstants.CACHE_CONNECTION) {
- try {
- connection.stop();
- } catch (JMSException e) {
- log.warn("Error pausing Message Listener task for service : " + serviceName);
- }
- }
- workerState = STATE_PAUSED;
- }
- }
-
- /**
- * Resume this polling task
- */
- public void resume() {
- if (connection != null && cacheLevel < JMSConstants.CACHE_CONNECTION) {
- try {
- connection.start();
- } catch (JMSException e) {
- log.warn("Error resuming Message Listener task for service : " + serviceName);
- }
- }
- workerState = STATE_STARTED;
- }
-
- /**
- * Execute the polling worker task
- */
- public void run() {
- workerState = STATE_STARTED;
- activeTaskCount++;
- int messageCount = 0;
-
- if (log.isDebugEnabled()) {
- log.debug("New poll task starting : thread id = " + Thread.currentThread().getId());
- }
-
- try {
- while (isActive() &&
- (getMaxMessagesPerTask() < 0 || messageCount < getMaxMessagesPerTask()) &&
- (getConcurrentConsumers() == 1 || idleExecutionCount < getIdleTaskExecutionLimit())) {
-
- UserTransaction ut = null;
- try {
- if (transactionality == BaseConstants.TRANSACTION_JTA) {
- ut = getUserTransaction();
- // We will only create a new tx if there is no tx alive
- if (ut.getStatus() == Status.STATUS_NO_TRANSACTION) {
- ut.begin();
- }
- }
- } catch (NotSupportedException e) {
- handleException("Listener Task is already associated with a transaction", e);
- } catch (SystemException e) {
- handleException("Error starting a JTA transaction", e);
- }
-
- // Get a message by polling, or receive null
- Message message = receiveMessage();
-
- if (log.isTraceEnabled()) {
- if (message != null) {
- try {
- log.trace("<<<<<<< READ message with Message ID : " +
- message.getJMSMessageID() + " from : " + destination +
- " by Thread ID : " + Thread.currentThread().getId());
- } catch (JMSException ignore) {}
- } else {
- log.trace("No message received by Thread ID : " +
- Thread.currentThread().getId() + " for destination : " + destination);
- }
- }
-
- if (message != null) {
- idle = false;
- idleExecutionCount = 0;
- messageCount++;
- // I will be busy now while processing this message, so start another if needed
- scheduleNewTaskIfAppropriate();
- handleMessage(message, ut);
-
- } else {
- idle = true;
- idleExecutionCount++;
- }
- }
-
- } finally {
-
- if (log.isTraceEnabled()) {
- log.trace("Listener task with Thread ID : " + Thread.currentThread().getId() +
- " is stopping after processing : " + messageCount + " messages :: " +
- " isActive : " + isActive() + " maxMessagesPerTask : " +
- getMaxMessagesPerTask() + " concurrentConsumers : " + getConcurrentConsumers() +
- " idleExecutionCount : " + idleExecutionCount + " idleTaskExecutionLimit : " +
- getIdleTaskExecutionLimit());
- } else if (log.isDebugEnabled()) {
- log.debug("Listener task with Thread ID : " + Thread.currentThread().getId() +
- " is stopping after processing : " + messageCount + " messages");
- }
-
- // Close the consumer and session before decrementing activeTaskCount.
- // (If we have a shared connection, Qpid deadlocks if the shared connection
- // is closed on another thread while closing the session)
- closeConsumer(true);
- closeSession(true);
- closeConnection();
-
- workerState = STATE_STOPPED;
- activeTaskCount--;
- synchronized(pollingTasks) {
- pollingTasks.remove(this);
- }
-
- // if this is a JMS onException, ServiceTaskManager#onException will schedule
- // a new polling task
- if (!isOnExceptionError) {
- // My time is up, so if I am going away, create another
- scheduleNewTaskIfAppropriate();
- }
- }
-
- }
-
- /**
- * Poll for and return a message if available
- *
- * @return a message read, or null
- */
- private Message receiveMessage() {
-
- // get a new connection, session and consumer to prevent a conflict.
- // If idle, it means we can re-use what we already have
- if (consumer == null) {
- connection = getConnection();
- session = getSession();
- consumer = getMessageConsumer();
- if (log.isDebugEnabled()) {
- log.debug("Preparing a Connection, Session and Consumer to read messages");
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Waiting for a message for service : " + serviceName + " - duration : "
- + (getReceiveTimeout() < 0 ? "unlimited" : (getReceiveTimeout() + "ms")));
- }
-
- try {
- if (getReceiveTimeout() < 0) {
- return consumer.receive();
- } else {
- return consumer.receive(getReceiveTimeout());
- }
- } catch (IllegalStateException ignore) {
- // probably the consumer (shared) was closed.. which is still ok.. as we didn't read
- } catch (JMSException e) {
- logError("Error receiving message for service : " + serviceName, e);
- }
- return null;
- }
-
- /**
- * Invoke ultimate message handler/listener and ack message and/or
- * commit/rollback transactions
- * @param message the JMS message received
- * @param ut the UserTransaction used to receive this message, or null
- */
- private void handleMessage(Message message, UserTransaction ut) {
-
- String messageId = null;
- try {
- messageId = message.getJMSMessageID();
- } catch (JMSException ignore) {}
-
- boolean commitOrAck = true;
- try {
- commitOrAck = jmsMessageReceiver.onMessage(message, ut);
-
- } finally {
-
- // if client acknowledgement is selected, and processing requested ACK
- if (commitOrAck && getSessionAckMode() == Session.CLIENT_ACKNOWLEDGE) {
- try {
- message.acknowledge();
- if (log.isDebugEnabled()) {
- log.debug("Message : " + messageId + " acknowledged");
- }
- } catch (JMSException e) {
- logError("Error acknowledging message : " + messageId, e);
- }
- }
-
- // if session was transacted, commit it or rollback
- try {
- if (session.getTransacted()) {
- if (commitOrAck) {
- session.commit();
- if (log.isDebugEnabled()) {
- log.debug("Session for message : " + messageId + " committed");
- }
- } else {
- session.rollback();
- if (log.isDebugEnabled()) {
- log.debug("Session for message : " + messageId + " rolled back");
- }
- }
- }
- } catch (JMSException e) {
- logError("Error " + (commitOrAck ? "committing" : "rolling back") +
- " local session txn for message : " + messageId, e);
- }
-
- // if a JTA transaction was being used, commit it or rollback
- try {
- if (ut != null) {
- if (commitOrAck) {
- ut.commit();
- if (log.isDebugEnabled()) {
- log.debug("JTA txn for message : " + messageId + " committed");
- }
- } else {
- ut.rollback();
- if (log.isDebugEnabled()) {
- log.debug("JTA txn for message : " + messageId + " rolled back");
- }
- }
- }
- } catch (Exception e) {
- logError("Error " + (commitOrAck ? "committing" : "rolling back") +
- " JTA txn for message : " + messageId + " from the session", e);
- }
-
- // close the consumer
- closeConsumer(false);
-
- closeSession(false);
- closeConnection();
- }
- }
-
- /** Handle JMS Connection exceptions by re-initializing. A single connection failure could
- * cause re-initialization of multiple MessageListenerTasks / Connections
- */
- public void onException(JMSException j) {
-
- isOnExceptionError = true;
-
- if (!isSTMActive()) {
- requestShutdown();
- return;
- }
-
- log.warn("JMS Connection failure : " + j.getMessage());
- setConnected(false);
-
- if (cacheLevel < JMSConstants.CACHE_CONNECTION) {
- // failed Connection was not shared, thus no need to restart the whole STM
- requestShutdown();
- return;
- }
-
- // if we failed while active, update state to show failure
- setServiceTaskManagerState(STATE_FAILURE);
- log.error("JMS Connection failed : " + j.getMessage() + " - shutting down worker tasks");
-
- int r = 1;
- long retryDuration = initialReconnectDuration;
-
- do {
- try {
- log.info("Reconnection attempt : " + r + " for service : " + serviceName);
- start();
- } catch (Exception ignore) {}
-
- boolean connected = false;
- for (int i=0; i<5; i++) {
- if (getConnectedTaskCount() == concurrentConsumers) {
- connected = true;
- break;
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {}
- }
-
- if (!connected) {
- retryDuration = (long) (retryDuration * reconnectionProgressionFactor);
- log.error("Reconnection attempt : " + (r++) + " for service : " + serviceName +
- " failed. Next retry in " + (retryDuration/1000) + "seconds");
- if (retryDuration > maxReconnectDuration) {
- retryDuration = maxReconnectDuration;
- }
-
- try {
- Thread.sleep(retryDuration);
- } catch (InterruptedException ignore) {}
- } else {
- isOnExceptionError = false;
- log.info("Reconnection attempt: " + r + " for service: " + serviceName +
- " was successful!");
- }
-
- } while (!isSTMActive() || getConnectedTaskCount() < concurrentConsumers);
- }
-
- protected void requestShutdown() {
- workerState = STATE_SHUTTING_DOWN;
- }
-
- private boolean isActive() {
- return workerState == STATE_STARTED;
- }
-
- protected boolean isTaskIdle() {
- return idle;
- }
-
- public boolean isConnected() {
- return connected;
- }
-
- public void setConnected(boolean connected) {
- this.connected = connected;
- }
-
- /**
- * Get a Connection that could/should be used by this task - depends on the cache level to reuse
- * @return the shared Connection if cache level is higher than CACHE_NONE, or a new Connection
- */
- private Connection getConnection() {
- if (cacheLevel < JMSConstants.CACHE_CONNECTION) {
- // Connection is not shared
- if (connection == null) {
- connection = createConnection();
- setConnected(true);
- }
-
- } else if (connection == null) {
- // Connection is shared, but may not have been created
-
- synchronized(ServiceTaskManager.this) {
- if (sharedConnection == null) {
- sharedConnection = createConnection();
- }
- }
- connection = sharedConnection;
- setConnected(true);
-
- }
- // else: Connection is shared and is already referenced by this.connection
-
- return connection;
- }
-
- /**
- * Get a Session that could/should be used by this task - depends on the cache level to reuse
- * @param connection the connection (could be the shared connection) to use to create a Session
- * @return the shared Session if cache level is higher than CACHE_CONNECTION, or a new Session
- * created using the Connection passed, or a new/shared connection
- */
- private Session getSession() {
- if (session == null || cacheLevel < JMSConstants.CACHE_SESSION) {
- session = createSession();
- }
- return session;
- }
-
- /**
- * Get a MessageConsumer that chould/should be used by this task - depends on the cache
- * level to reuse
- * @param connection option Connection to be used
- * @param session optional Session to be used
- * @return the shared MessageConsumer if cache level is higher than CACHE_SESSION, or a new
- * MessageConsumer possibly using the Connection and Session passed in
- */
- private MessageConsumer getMessageConsumer() {
- if (consumer == null || cacheLevel < JMSConstants.CACHE_CONSUMER) {
- consumer = createConsumer();
- }
- return consumer;
- }
-
- /**
- * Close the given Connection, hiding exceptions if any which are logged
- * @param connection the Connection to be closed
- */
- private void closeConnection() {
- if (connection != null &&
- cacheLevel < JMSConstants.CACHE_CONNECTION) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Closing non-shared JMS connection for service : " + serviceName);
- }
- connection.close();
- } catch (JMSException e) {
- logError("Error closing JMS connection", e);
- } finally {
- connection = null;
- }
- }
- }
-
- /**
- * Close the given Session, hiding exceptions if any which are logged
- * @param session the Session to be closed
- */
- private void closeSession(boolean forced) {
- if (session != null &&
- (cacheLevel < JMSConstants.CACHE_SESSION || forced)) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Closing non-shared JMS session for service : " + serviceName);
- }
- session.close();
- } catch (JMSException e) {
- logError("Error closing JMS session", e);
- } finally {
- session = null;
- }
- }
- }
-
- /**
- * Close the given Consumer, hiding exceptions if any which are logged
- * @param consumer the Consumer to be closed
- */
- private void closeConsumer(boolean forced) {
- if (consumer != null &&
- (cacheLevel < JMSConstants.CACHE_CONSUMER || forced)) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Closing non-shared JMS consumer for service : " + serviceName);
- }
- consumerCount.decrementAndGet();
- consumer.close();
- } catch (JMSException e) {
- logError("Error closing JMS consumer", e);
- } finally {
- consumer = null;
- }
- }
- }
-
- /**
- * Create a new Connection for this STM, using JNDI properties and credentials provided
- * @return a new Connection for this STM, using JNDI properties and credentials provided
- */
- private Connection createConnection() {
-
- try {
- conFactory = JMSUtils.lookup(
- getInitialContext(), ConnectionFactory.class, getConnFactoryJNDIName());
- log.debug("Connected to the JMS connection factory : " + getConnFactoryJNDIName());
- } catch (NamingException e) {
- handleException("Error looking up connection factory : " + getConnFactoryJNDIName() +
- " using JNDI properties : " + jmsProperties, e);
- }
-
- Connection connection = null;
- try {
- connection = JMSUtils.createConnection(
- conFactory,
- jmsProperties.get(JMSConstants.PARAM_JMS_USERNAME),
- jmsProperties.get(JMSConstants.PARAM_JMS_PASSWORD),
- isJmsSpec11(), isQueue());
-
- connection.setExceptionListener(this);
- connection.start();
- log.debug("JMS Connection for service : " + serviceName + " created and started");
-
- } catch (JMSException e) {
- handleException("Error acquiring a JMS connection to : " + getConnFactoryJNDIName() +
- " using JNDI properties : " + jmsProperties, e);
- }
- return connection;
- }
-
- /**
- * Create a new Session for this STM
- * @param connection the Connection to be used
- * @return a new Session created using the Connection passed in
- */
- private Session createSession() {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Creating a new JMS Session for service : " + serviceName);
- }
- return JMSUtils.createSession(
- connection, isSessionTransacted(), getSessionAckMode(), isJmsSpec11(), isQueue());
-
- } catch (JMSException e) {
- handleException("Error creating JMS session for service : " + serviceName, e);
- }
- return null;
- }
-
- /**
- * Create a new MessageConsumer for this STM
- * @param session the Session to be used
- * @return a new MessageConsumer created using the Session passed in
- */
- private MessageConsumer createConsumer() {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Creating a new JMS MessageConsumer for service : " + serviceName);
- }
-
- MessageConsumer consumer = JMSUtils.createConsumer(
- session, getDestination(session), isQueue(),
- (isSubscriptionDurable() && getDurableSubscriberName() == null ?
- getDurableSubscriberName() : serviceName),
- getMessageSelector(), isPubSubNoLocal(), isSubscriptionDurable(), isJmsSpec11());
- consumerCount.incrementAndGet();
- return consumer;
-
- } catch (JMSException e) {
- handleException("Error creating JMS consumer for service : " + serviceName,e);
- }
- return null;
- }
- }
-
- // -------------- mundane private methods ----------------
- /**
- * Get the InitialContext for lookup using the JNDI parameters applicable to the service
- * @return the InitialContext to be used
- * @throws NamingException
- */
- private Context getInitialContext() throws NamingException {
- if (context == null) {
- context = new InitialContext(jmsProperties);
- }
- return context;
- }
-
- /**
- * Return the JMS Destination for the JNDI name of the Destination from the InitialContext
- * @param session which is used to create the destinations if not present and if possible
- * @return the JMS Destination to which this STM listens for messages
- */
- private Destination getDestination(Session session) {
- if (destination == null) {
- try {
- context = getInitialContext();
- destination = JMSUtils.lookupDestination(context, getDestinationJNDIName(),
- JMSUtils.getDestinationTypeAsString(destinationType));
- if (log.isDebugEnabled()) {
- log.debug("JMS Destination with JNDI name : " + getDestinationJNDIName() +
- " found for service " + serviceName);
- }
- } catch (NamingException e) {
- try {
- switch (destinationType) {
- case JMSConstants.QUEUE: {
- destination = session.createQueue(getDestinationJNDIName());
- break;
- }
- case JMSConstants.TOPIC: {
- destination = session.createTopic(getDestinationJNDIName());
- break;
- }
- default: {
- handleException("Error looking up JMS destination : " +
- getDestinationJNDIName() + " using JNDI properties : " +
- jmsProperties, e);
- }
- }
- } catch (JMSException j) {
- handleException("Error looking up JMS destination and auto " +
- "creating JMS destination : " + getDestinationJNDIName() +
- " using JNDI properties : " + jmsProperties, e);
- }
- }
- }
- return destination;
- }
-
- /**
- * The UserTransaction to be used, looked up from the JNDI
- * @return The UserTransaction to be used, looked up from the JNDI
- */
- private UserTransaction getUserTransaction() {
- if (!cacheUserTransaction) {
- if (log.isDebugEnabled()) {
- log.debug("Acquiring a new UserTransaction for service : " + serviceName);
- }
-
- try {
- context = getInitialContext();
- return
- JMSUtils.lookup(context, UserTransaction.class, getUserTransactionJNDIName());
- } catch (NamingException e) {
- handleException("Error looking up UserTransaction : " + getUserTransactionJNDIName() +
- " using JNDI properties : " + jmsProperties, e);
- }
- }
-
- if (sharedUserTransaction == null) {
- try {
- context = getInitialContext();
- sharedUserTransaction =
- JMSUtils.lookup(context, UserTransaction.class, getUserTransactionJNDIName());
- if (log.isDebugEnabled()) {
- log.debug("Acquired shared UserTransaction for service : " + serviceName);
- }
- } catch (NamingException e) {
- handleException("Error looking up UserTransaction : " + getUserTransactionJNDIName() +
- " using JNDI properties : " + jmsProperties, e);
- }
- }
- return sharedUserTransaction;
- }
-
- // -------------------- trivial methods ---------------------
- private boolean isSTMActive() {
- return serviceTaskManagerState == STATE_STARTED;
- }
-
- /**
- * Is this STM bound to a Queue, Topic or a JMS 1.1 Generic Destination?
- * @return TRUE for a Queue, FALSE for a Topic and NULL for a Generic Destination
- */
- private Boolean isQueue() {
- if (destinationType == JMSConstants.GENERIC) {
- return null;
- } else {
- return destinationType == JMSConstants.QUEUE;
- }
- }
-
- private void logError(String msg, Exception e) {
- log.error(msg, e);
- }
-
- private void handleException(String msg, Exception e) {
- log.error(msg, e);
- throw new AxisJMSException(msg, e);
- }
-
- private void handleException(String msg) {
- log.error(msg);
- throw new AxisJMSException(msg);
- }
-
- // -------------- getters and setters ------------------
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- public String getConnFactoryJNDIName() {
- return connFactoryJNDIName;
- }
-
- public void setConnFactoryJNDIName(String connFactoryJNDIName) {
- this.connFactoryJNDIName = connFactoryJNDIName;
- }
-
- public String getDestinationJNDIName() {
- return destinationJNDIName;
- }
-
- public void setDestinationJNDIName(String destinationJNDIName) {
- this.destinationJNDIName = destinationJNDIName;
- }
-
- public int getDestinationType() {
- return destinationType;
- }
-
- public void setDestinationType(int destinationType) {
- this.destinationType = destinationType;
- }
-
- public String getMessageSelector() {
- return messageSelector;
- }
-
- public void setMessageSelector(String messageSelector) {
- this.messageSelector = messageSelector;
- }
-
- public int getTransactionality() {
- return transactionality;
- }
-
- public void setTransactionality(int transactionality) {
- this.transactionality = transactionality;
- sessionTransacted = (transactionality == BaseConstants.TRANSACTION_LOCAL);
- }
-
- public boolean isSessionTransacted() {
- return sessionTransacted;
- }
-
- public void setSessionTransacted(Boolean sessionTransacted) {
- if (sessionTransacted != null) {
- this.sessionTransacted = sessionTransacted;
- // sesstionTransacted means local transactions are used, however !sessionTransacted does
- // not mean that JTA is used
- if (sessionTransacted) {
- transactionality = BaseConstants.TRANSACTION_LOCAL;
- }
- }
- }
-
- public int getSessionAckMode() {
- return sessionAckMode;
- }
-
- public void setSessionAckMode(int sessionAckMode) {
- this.sessionAckMode = sessionAckMode;
- }
-
- public boolean isSubscriptionDurable() {
- return subscriptionDurable;
- }
-
- public void setSubscriptionDurable(Boolean subscriptionDurable) {
- if (subscriptionDurable != null) {
- this.subscriptionDurable = subscriptionDurable;
- }
- }
-
- public String getDurableSubscriberName() {
- return durableSubscriberName;
- }
-
- public void setDurableSubscriberName(String durableSubscriberName) {
- this.durableSubscriberName = durableSubscriberName;
- }
-
- public boolean isPubSubNoLocal() {
- return pubSubNoLocal;
- }
-
- public void setPubSubNoLocal(Boolean pubSubNoLocal) {
- if (pubSubNoLocal != null) {
- this.pubSubNoLocal = pubSubNoLocal;
- }
- }
-
- public int getConcurrentConsumers() {
- return concurrentConsumers;
- }
-
- public void setConcurrentConsumers(int concurrentConsumers) {
- this.concurrentConsumers = concurrentConsumers;
- }
-
- public int getMaxConcurrentConsumers() {
- return maxConcurrentConsumers;
- }
-
- public void setMaxConcurrentConsumers(int maxConcurrentConsumers) {
- this.maxConcurrentConsumers = maxConcurrentConsumers;
- }
-
- public int getIdleTaskExecutionLimit() {
- return idleTaskExecutionLimit;
- }
-
- public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit) {
- this.idleTaskExecutionLimit = idleTaskExecutionLimit;
- }
-
- public int getReceiveTimeout() {
- return receiveTimeout;
- }
-
- public void setReceiveTimeout(int receiveTimeout) {
- this.receiveTimeout = receiveTimeout;
- }
-
- public int getCacheLevel() {
- return cacheLevel;
- }
-
- public void setCacheLevel(int cacheLevel) {
- this.cacheLevel = cacheLevel;
- }
-
- public int getInitialReconnectDuration() {
- return initialReconnectDuration;
- }
-
- public void setInitialReconnectDuration(int initialReconnectDuration) {
- this.initialReconnectDuration = initialReconnectDuration;
- }
-
- public double getReconnectionProgressionFactor() {
- return reconnectionProgressionFactor;
- }
-
- public void setReconnectionProgressionFactor(double reconnectionProgressionFactor) {
- this.reconnectionProgressionFactor = reconnectionProgressionFactor;
- }
-
- public long getMaxReconnectDuration() {
- return maxReconnectDuration;
- }
-
- public void setMaxReconnectDuration(long maxReconnectDuration) {
- this.maxReconnectDuration = maxReconnectDuration;
- }
-
- public int getMaxMessagesPerTask() {
- return maxMessagesPerTask;
- }
-
- public void setMaxMessagesPerTask(int maxMessagesPerTask) {
- this.maxMessagesPerTask = maxMessagesPerTask;
- }
-
- public String getUserTransactionJNDIName() {
- return userTransactionJNDIName;
- }
-
- public void setUserTransactionJNDIName(String userTransactionJNDIName) {
- if (userTransactionJNDIName != null) {
- this.userTransactionJNDIName = userTransactionJNDIName;
- }
- }
-
- public boolean isCacheUserTransaction() {
- return cacheUserTransaction;
- }
-
- public void setCacheUserTransaction(Boolean cacheUserTransaction) {
- if (cacheUserTransaction != null) {
- this.cacheUserTransaction = cacheUserTransaction;
- }
- }
-
- public boolean isJmsSpec11() {
- return jmsSpec11;
- }
-
- public void setJmsSpec11(boolean jmsSpec11) {
- this.jmsSpec11 = jmsSpec11;
- }
-
- public Hashtable<String, String> getJmsProperties() {
- return jmsProperties;
- }
-
- public void addJmsProperties(Map<String, String> jmsProperties) {
- this.jmsProperties.putAll(jmsProperties);
- }
-
- public void removeJmsProperties(String key) {
- this.jmsProperties.remove(key);
- }
-
- public Context getContext() {
- return context;
- }
-
- public ConnectionFactory getConnectionFactory() {
- return conFactory;
- }
-
- public List<MessageListenerTask> getPollingTasks() {
- return pollingTasks;
- }
-
- public void setJmsMessageReceiver(JMSMessageReceiver jmsMessageReceiver) {
- this.jmsMessageReceiver = jmsMessageReceiver;
- }
-
- public void setWorkerPool(WorkerPool workerPool) {
- this.workerPool = workerPool;
- }
-
- public int getActiveTaskCount() {
- return activeTaskCount;
- }
-
- /**
- * Get the number of existing JMS message consumers.
- *
- * @return the number of consumers
- */
- public int getConsumerCount() {
- return consumerCount.get();
- }
-
- public void setServiceTaskManagerState(int serviceTaskManagerState) {
- this.serviceTaskManagerState = serviceTaskManagerState;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ServiceTaskManagerFactory.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ServiceTaskManagerFactory.java
deleted file mode 100644
index 9f986de..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ServiceTaskManagerFactory.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.Session;
-
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.threads.WorkerPool;
-
-public class ServiceTaskManagerFactory {
- private ServiceTaskManagerFactory() {}
-
- /**
- * Create a ServiceTaskManager for the service passed in and its corresponding JMSConnectionFactory
- * @param jcf
- * @param service
- * @param workerPool
- * @return
- */
- public static ServiceTaskManager createTaskManagerForService(JMSConnectionFactory jcf,
- AxisService service, WorkerPool workerPool) {
-
- String name = service.getName();
- Map<String, String> svc = getServiceStringParameters(service.getParameters());
- Map<String, String> cf = jcf.getParameters();
-
- ServiceTaskManager stm = new ServiceTaskManager();
-
- stm.setServiceName(name);
- stm.addJmsProperties(cf);
- stm.addJmsProperties(svc);
-
- stm.setConnFactoryJNDIName(
- getRqdStringProperty(JMSConstants.PARAM_CONFAC_JNDI_NAME, svc, cf));
- String destName = getOptionalStringProperty(JMSConstants.PARAM_DESTINATION, svc, cf);
- if (destName == null) {
- destName = service.getName();
- }
- stm.setDestinationJNDIName(destName);
- stm.setDestinationType(getDestinationType(svc, cf));
-
- stm.setJmsSpec11(
- getJMSSpecVersion(svc, cf));
- stm.setTransactionality(
- getTransactionality(svc, cf));
- stm.setCacheUserTransaction(
- getOptionalBooleanProperty(BaseConstants.PARAM_CACHE_USER_TXN, svc, cf));
- stm.setUserTransactionJNDIName(
- getOptionalStringProperty(BaseConstants.PARAM_USER_TXN_JNDI_NAME, svc, cf));
- stm.setSessionTransacted(
- getOptionalBooleanProperty(JMSConstants.PARAM_SESSION_TRANSACTED, svc, cf));
- stm.setSessionAckMode(
- getSessionAck(svc, cf));
- stm.setMessageSelector(
- getOptionalStringProperty(JMSConstants.PARAM_MSG_SELECTOR, svc, cf));
- stm.setSubscriptionDurable(
- getOptionalBooleanProperty(JMSConstants.PARAM_SUB_DURABLE, svc, cf));
- stm.setDurableSubscriberName(
- getOptionalStringProperty(JMSConstants.PARAM_DURABLE_SUB_NAME, svc, cf));
-
- stm.setCacheLevel(
- getCacheLevel(svc, cf));
- stm.setPubSubNoLocal(
- getOptionalBooleanProperty(JMSConstants.PARAM_PUBSUB_NO_LOCAL, svc, cf));
-
- Integer value = getOptionalIntProperty(JMSConstants.PARAM_RCV_TIMEOUT, svc, cf);
- if (value != null) {
- stm.setReceiveTimeout(value);
- }
- value = getOptionalIntProperty(JMSConstants.PARAM_CONCURRENT_CONSUMERS, svc, cf);
- if (value != null) {
- stm.setConcurrentConsumers(value);
- }
- value = getOptionalIntProperty(JMSConstants.PARAM_MAX_CONSUMERS, svc, cf);
- if (value != null) {
- stm.setMaxConcurrentConsumers(value);
- }
- value = getOptionalIntProperty(JMSConstants.PARAM_IDLE_TASK_LIMIT, svc, cf);
- if (value != null) {
- stm.setIdleTaskExecutionLimit(value);
- }
- value = getOptionalIntProperty(JMSConstants.PARAM_MAX_MSGS_PER_TASK, svc, cf);
- if (value != null) {
- stm.setMaxMessagesPerTask(value);
- }
-
- value = getOptionalIntProperty(JMSConstants.PARAM_RECON_INIT_DURATION, svc, cf);
- if (value != null) {
- stm.setInitialReconnectDuration(value);
- }
- value = getOptionalIntProperty(JMSConstants.PARAM_RECON_MAX_DURATION, svc, cf);
- if (value != null) {
- stm.setMaxReconnectDuration(value);
- }
- Double dValue = getOptionalDoubleProperty(JMSConstants.PARAM_RECON_FACTOR, svc, cf);
- if (dValue != null) {
- stm.setReconnectionProgressionFactor(dValue);
- }
-
- stm.setWorkerPool(workerPool);
-
- // remove processed properties from property bag
- stm.removeJmsProperties(JMSConstants.PARAM_CONFAC_JNDI_NAME);
- stm.removeJmsProperties(JMSConstants.PARAM_DESTINATION);
- stm.removeJmsProperties(JMSConstants.PARAM_JMS_SPEC_VER);
- stm.removeJmsProperties(BaseConstants.PARAM_TRANSACTIONALITY);
- stm.removeJmsProperties(BaseConstants.PARAM_CACHE_USER_TXN);
- stm.removeJmsProperties(BaseConstants.PARAM_USER_TXN_JNDI_NAME);
- stm.removeJmsProperties(JMSConstants.PARAM_SESSION_TRANSACTED);
- stm.removeJmsProperties(JMSConstants.PARAM_MSG_SELECTOR);
- stm.removeJmsProperties(JMSConstants.PARAM_SUB_DURABLE);
- stm.removeJmsProperties(JMSConstants.PARAM_DURABLE_SUB_NAME);
- stm.removeJmsProperties(JMSConstants.PARAM_CACHE_LEVEL);
- stm.removeJmsProperties(JMSConstants.PARAM_PUBSUB_NO_LOCAL);
- stm.removeJmsProperties(JMSConstants.PARAM_RCV_TIMEOUT);
- stm.removeJmsProperties(JMSConstants.PARAM_CONCURRENT_CONSUMERS);
- stm.removeJmsProperties(JMSConstants.PARAM_MAX_CONSUMERS);
- stm.removeJmsProperties(JMSConstants.PARAM_IDLE_TASK_LIMIT);
- stm.removeJmsProperties(JMSConstants.PARAM_MAX_MSGS_PER_TASK);
- stm.removeJmsProperties(JMSConstants.PARAM_RECON_INIT_DURATION);
- stm.removeJmsProperties(JMSConstants.PARAM_RECON_MAX_DURATION);
- stm.removeJmsProperties(JMSConstants.PARAM_RECON_FACTOR);
-
- return stm;
- }
-
- private static Map<String, String> getServiceStringParameters(List<Parameter> list) {
-
- Map<String, String> map = new HashMap<String, String>();
- for (Parameter p : list) {
- if (p.getValue() instanceof String) {
- map.put(p.getName(), (String) p.getValue());
- }
- }
- return map;
- }
-
- private static String getRqdStringProperty(String key, Map<String,String> svcMap,
- Map<String,String> cfMap) {
-
- String value = svcMap.get(key);
- if (value == null) {
- value = cfMap.get(key);
- }
- if (value == null) {
- throw new AxisJMSException("Service/connection factory property : " + key);
- }
- return value;
- }
-
- private static String getOptionalStringProperty(String key, Map<String,String> svcMap,
- Map<String,String> cfMap) {
-
- String value = svcMap.get(key);
- if (value == null) {
- value = cfMap.get(key);
- }
- return value;
- }
-
- private static Boolean getOptionalBooleanProperty(String key, Map<String,String> svcMap,
- Map<String,String> cfMap) {
-
- String value = svcMap.get(key);
- if (value == null) {
- value = cfMap.get(key);
- }
- if (value == null) {
- return null;
- } else {
- return Boolean.valueOf(value);
- }
- }
-
- private static Integer getOptionalIntProperty(String key, Map<String,String> svcMap,
- Map<String,String> cfMap) {
-
- String value = svcMap.get(key);
- if (value == null) {
- value = cfMap.get(key);
- }
- if (value != null) {
- try {
- return Integer.parseInt(value);
- } catch (NumberFormatException e) {
- throw new AxisJMSException("Invalid value : " + value + " for " + key);
- }
- }
- return null;
- }
-
- private static Double getOptionalDoubleProperty(String key, Map<String,String> svcMap,
- Map<String,String> cfMap) {
-
- String value = svcMap.get(key);
- if (value == null) {
- value = cfMap.get(key);
- }
- if (value != null) {
- try {
- return Double.parseDouble(value);
- } catch (NumberFormatException e) {
- throw new AxisJMSException("Invalid value : " + value + " for " + key);
- }
- }
- return null;
- }
-
- private static int getTransactionality(Map<String,String> svcMap, Map<String,String> cfMap) {
-
- String key = BaseConstants.PARAM_TRANSACTIONALITY;
- String val = svcMap.get(key);
- if (val == null) {
- val = cfMap.get(key);
- }
-
- if (val == null) {
- return BaseConstants.TRANSACTION_NONE;
-
- } else {
- if (BaseConstants.STR_TRANSACTION_JTA.equalsIgnoreCase(val)) {
- return BaseConstants.TRANSACTION_JTA;
- } else if (BaseConstants.STR_TRANSACTION_LOCAL.equalsIgnoreCase(val)) {
- return BaseConstants.TRANSACTION_LOCAL;
- } else {
- throw new AxisJMSException("Invalid option : " + val + " for parameter : " +
- BaseConstants.STR_TRANSACTION_JTA);
- }
- }
- }
-
- private static int getDestinationType(Map<String,String> svcMap, Map<String,String> cfMap) {
-
- String key = JMSConstants.PARAM_DEST_TYPE;
- String val = svcMap.get(key);
- if (val == null) {
- val = cfMap.get(key);
- }
-
- if (JMSConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(val)) {
- return JMSConstants.TOPIC;
- }
- return JMSConstants.QUEUE;
- }
-
- private static int getSessionAck(Map<String,String> svcMap, Map<String,String> cfMap) {
-
- String key = JMSConstants.PARAM_SESSION_ACK;
- String val = svcMap.get(key);
- if (val == null) {
- val = cfMap.get(key);
- }
-
- if (val == null || "AUTO_ACKNOWLEDGE".equalsIgnoreCase(val)) {
- return Session.AUTO_ACKNOWLEDGE;
- } else if ("CLIENT_ACKNOWLEDGE".equalsIgnoreCase(val)) {
- return Session.CLIENT_ACKNOWLEDGE;
- } else if ("DUPS_OK_ACKNOWLEDGE".equals(val)){
- return Session.DUPS_OK_ACKNOWLEDGE;
- } else if ("SESSION_TRANSACTED".equals(val)) {
- return 0; //Session.SESSION_TRANSACTED;
- } else {
- try {
- return Integer.parseInt(val);
- } catch (NumberFormatException ignore) {
- throw new AxisJMSException("Invalid session acknowledgement mode : " + val);
- }
- }
- }
-
- private static int getCacheLevel(Map<String,String> svcMap, Map<String,String> cfMap) {
-
- String key = JMSConstants.PARAM_CACHE_LEVEL;
- String val = svcMap.get(key);
- if (val == null) {
- val = cfMap.get(key);
- }
-
- if ("none".equalsIgnoreCase(val)) {
- return JMSConstants.CACHE_NONE;
- } else if ("connection".equalsIgnoreCase(val)) {
- return JMSConstants.CACHE_CONNECTION;
- } else if ("session".equals(val)){
- return JMSConstants.CACHE_SESSION;
- } else if ("consumer".equals(val)) {
- return JMSConstants.CACHE_CONSUMER;
- } else if ("producer".equals(val)) {
- return JMSConstants.CACHE_PRODUCER;
- } else if (val != null) {
- throw new AxisJMSException("Invalid cache level : " + val);
- }
- return JMSConstants.CACHE_AUTO;
- }
-
- private static boolean getJMSSpecVersion(Map<String,String> svcMap, Map<String,String> cfMap) {
-
- String key = JMSConstants.PARAM_JMS_SPEC_VER;
- String val = svcMap.get(key);
- if (val == null) {
- val = cfMap.get(key);
- }
-
- if (val == null || "1.1".equals(val)) {
- return true;
- } else {
- return false;
- }
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeInfo.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeInfo.java
deleted file mode 100644
index 1bdf0a2..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeInfo.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-/**
- * Class encapsulating the content type information for a given message.
- */
-public class ContentTypeInfo {
- private final String propertyName;
- private final String contentType;
-
- public ContentTypeInfo(String propertyName, String contentType) {
- this.propertyName = propertyName;
- this.contentType = contentType;
- }
-
- /**
- * Get the name of the message property from which the content type
- * has been extracted.
- *
- * @return the property name or null if the content type was not determined
- * by extracting it from a message property
- */
- public String getPropertyName() {
- return propertyName;
- }
-
- /**
- * Get the content type of the message.
- *
- * @return The content type of the message. The return value is never null.
- */
- public String getContentType() {
- return contentType;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRule.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRule.java
deleted file mode 100644
index 90eccdc..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRule.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-/**
- * Interface implemented by content type rules.
- */
-public interface ContentTypeRule {
- /**
- * Attempt to determine the content type of the given JMS message.
- *
- * @param message the message
- * @return If the rule matches, the return value encapsulates the content type of the
- * message and the message property name from which is was extracted
- * (if applicable). If the rule doesn't match, the method returns null.
- * @throws JMSException
- */
- ContentTypeInfo getContentType(Message message) throws JMSException;
-
- /**
- * Get the name of the message property used to extract the content type from,
- * if applicable.
- *
- * @return the property name or null if not applicable
- */
- String getExpectedContentTypeProperty();
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleFactory.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleFactory.java
deleted file mode 100644
index 2792a1a..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-import java.util.Iterator;
-
-import javax.jms.BytesMessage;
-import javax.jms.TextMessage;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.Parameter;
-
-/**
- * Utility class to create content type rules and rule sets from XML.
- */
-public class ContentTypeRuleFactory {
- private ContentTypeRuleFactory() {}
-
- public static ContentTypeRule parse(OMElement element) throws AxisFault {
- String name = element.getLocalName();
- String value = element.getText();
- if (name.equals("jmsProperty")) {
- return new PropertyRule(value);
- } else if (name.equals("textMessage")) {
- return new MessageTypeRule(TextMessage.class, value);
- } else if (name.equals("bytesMessage")) {
- return new MessageTypeRule(BytesMessage.class, value);
- } else if (name.equals("default")) {
- return new DefaultRule(value);
- } else {
- throw new AxisFault("Unknown content rule type '" + name + "'");
- }
- }
-
- public static ContentTypeRuleSet parse(Parameter param) throws AxisFault {
- ContentTypeRuleSet ruleSet = new ContentTypeRuleSet();
- Object value = param.getValue();
- if (value instanceof OMElement) {
- OMElement element = (OMElement)value;
- if (element.getLocalName().equals("rules")) {
- for (Iterator it = element.getChildElements(); it.hasNext(); ) {
- ruleSet.addRule(parse((OMElement)it.next()));
- }
- } else {
- throw new AxisFault("Expected <rules> element");
- }
- } else {
- ruleSet.addRule(new DefaultRule((String)value));
- }
- return ruleSet;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleSet.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleSet.java
deleted file mode 100644
index fb271cb..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleSet.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-/**
- * A set of content type rules.
- */
-public class ContentTypeRuleSet {
- private final List<ContentTypeRule> rules = new ArrayList<ContentTypeRule>();
- private String defaultContentTypeProperty;
-
- /**
- * Add a content type rule to this set.
- *
- * @param rule the rule to add
- */
- public void addRule(ContentTypeRule rule) {
- rules.add(rule);
- if (defaultContentTypeProperty == null) {
- defaultContentTypeProperty = rule.getExpectedContentTypeProperty();
- }
- }
-
- /**
- * Determine the content type of the given message.
- * This method will try the registered rules in turn until the first rule matches.
- *
- * @param message the message
- * @return the content type information for the message or null if none of the rules matches
- * @throws JMSException
- */
- public ContentTypeInfo getContentTypeInfo(Message message) throws JMSException {
- for (ContentTypeRule rule : rules) {
- ContentTypeInfo contentTypeInfo = rule.getContentType(message);
- if (contentTypeInfo != null) {
- return contentTypeInfo;
- }
- }
- return null;
- }
-
- public String getDefaultContentTypeProperty() {
- return defaultContentTypeProperty;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/DefaultRule.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/DefaultRule.java
deleted file mode 100644
index 6ff3c41..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/DefaultRule.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-import javax.jms.Message;
-
-/**
- * Content type rule that always matches and that returns a fixed (default) content type.
- */
-public class DefaultRule implements ContentTypeRule {
- private final String contentType;
-
- public DefaultRule(String contentType) {
- this.contentType = contentType;
- }
-
- public ContentTypeInfo getContentType(Message message) {
- return new ContentTypeInfo(null, contentType);
- }
-
- public String getExpectedContentTypeProperty() {
- return null;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/MessageTypeRule.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/MessageTypeRule.java
deleted file mode 100644
index 64edcad..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/MessageTypeRule.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-import javax.jms.Message;
-
-/**
- * Content type rule that matches a given message type and returns a fixed content type.
- */
-public class MessageTypeRule implements ContentTypeRule {
- private final Class<? extends Message> messageType;
- private final String contentType;
-
- public MessageTypeRule(Class<? extends Message> messageType, String contentType) {
- this.messageType = messageType;
- this.contentType = contentType;
- }
-
- public ContentTypeInfo getContentType(Message message) {
- return messageType.isInstance(message) ? new ContentTypeInfo(null, contentType) : null;
- }
-
- public String getExpectedContentTypeProperty() {
- return null;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/PropertyRule.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/PropertyRule.java
deleted file mode 100644
index 8ab8e5d..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/PropertyRule.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-/**
- * Content type rule that attempts to extract the content type from a message property.
- */
-public class PropertyRule implements ContentTypeRule {
- private final String propertyName;
-
- public PropertyRule(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public ContentTypeInfo getContentType(Message message) throws JMSException {
- String value = message.getStringProperty(propertyName);
- return value == null ? null : new ContentTypeInfo(propertyName, value);
- }
-
- public String getExpectedContentTypeProperty() {
- return propertyName;
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/package-info.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/package-info.java
deleted file mode 100644
index 4f50c48..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/ctype/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-/**
- * Provides classes and interfaces to define content type rules.
- *
- * Content type rules are used to determine the content type of a
- * received message based on JMS properties, message type, etc.
- */
-package org.apache.axis2.transport.jms.ctype;
\ No newline at end of file
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageDataSource.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageDataSource.java
deleted file mode 100644
index f181e77..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageDataSource.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.iowrappers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-
-import org.apache.axiom.ext.activation.SizeAwareDataSource;
-
-/**
- * Data source implementation wrapping a JMS {@link BytesMessage}.
- * <p>
- * Note that two input streams created by the same instance of this
- * class can not be used at the same time.
- */
-public class BytesMessageDataSource implements SizeAwareDataSource {
- private final BytesMessage message;
- private final String contentType;
-
- public BytesMessageDataSource(BytesMessage message, String contentType) {
- this.message = message;
- this.contentType = contentType;
- }
-
- public BytesMessageDataSource(BytesMessage message) {
- this(message, "application/octet-stream");
- }
-
- public long getSize() {
- try {
- return message.getBodyLength();
- } catch (JMSException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public InputStream getInputStream() throws IOException {
- try {
- message.reset();
- } catch (JMSException ex) {
- throw new JMSExceptionWrapper(ex);
- }
- return new BytesMessageInputStream(message);
- }
-
- public String getName() {
- return null;
- }
-
- public OutputStream getOutputStream() throws IOException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageInputStream.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageInputStream.java
deleted file mode 100644
index 2b170d0..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageInputStream.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.iowrappers;
-
-import java.io.InputStream;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.MessageEOFException;
-
-/**
- * Input stream that reads data from a JMS {@link BytesMessage}.
- * Note that since the current position in the message is managed by
- * the underlying {@link BytesMessage} object, it is not possible to
- * use several instances of this class operating on a single
- * {@link BytesMessage} at the same time.
- */
-public class BytesMessageInputStream extends InputStream {
- private final BytesMessage message;
-
- public BytesMessageInputStream(BytesMessage message) {
- this.message = message;
- }
-
- @Override
- public int read() throws JMSExceptionWrapper {
- try {
- return message.readByte() & 0xFF;
- } catch (MessageEOFException ex) {
- return -1;
- } catch (JMSException ex) {
- throw new JMSExceptionWrapper(ex);
- }
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws JMSExceptionWrapper {
- if (off == 0) {
- try {
- return message.readBytes(b, len);
- } catch (JMSException ex) {
- throw new JMSExceptionWrapper(ex);
- }
- } else {
- byte[] b2 = new byte[len];
- int c = read(b2);
- if (c > 0) {
- System.arraycopy(b2, 0, b, off, c);
- }
- return c;
- }
- }
-
- @Override
- public int read(byte[] b) throws JMSExceptionWrapper {
- try {
- return message.readBytes(b);
- } catch (JMSException ex) {
- throw new JMSExceptionWrapper(ex);
- }
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageOutputStream.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageOutputStream.java
deleted file mode 100644
index 9a9c5ef..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/BytesMessageOutputStream.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.iowrappers;
-
-import java.io.OutputStream;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-
-public class BytesMessageOutputStream extends OutputStream {
- private final BytesMessage message;
-
- public BytesMessageOutputStream(BytesMessage message) {
- this.message = message;
- }
-
- @Override
- public void write(int b) throws JMSExceptionWrapper {
- try {
- message.writeByte((byte)b);
- } catch (JMSException ex) {
- throw new JMSExceptionWrapper(ex);
- }
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws JMSExceptionWrapper {
- try {
- message.writeBytes(b, off, len);
- } catch (JMSException ex) {
- throw new JMSExceptionWrapper(ex);
- }
- }
-
- @Override
- public void write(byte[] b) throws JMSExceptionWrapper {
- try {
- message.writeBytes(b);
- } catch (JMSException ex) {
- throw new JMSExceptionWrapper(ex);
- }
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/JMSExceptionWrapper.java b/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/JMSExceptionWrapper.java
deleted file mode 100644
index 0e4d956..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/iowrappers/JMSExceptionWrapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.iowrappers;
-
-import java.io.IOException;
-
-import javax.jms.JMSException;
-
-public class JMSExceptionWrapper extends IOException {
- private static final long serialVersionUID = 852441109009079511L;
-
- public JMSExceptionWrapper(JMSException ex) {
- initCause(ex);
- }
-}
diff --git a/modules/jms/src/main/java/org/apache/axis2/transport/jms/package.html b/modules/jms/src/main/java/org/apache/axis2/transport/jms/package.html
deleted file mode 100644
index b95b49e..0000000
--- a/modules/jms/src/main/java/org/apache/axis2/transport/jms/package.html
+++ /dev/null
@@ -1,356 +0,0 @@
-<html>
-<title>JMS Transport Configuration</title>
-<body>
-
-<h2>JMS Listener Configuration (axis2.xml)</h2>
-
-e.g:
-
-<pre>
- <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
- <parameter name="myTopicConnectionFactory">
- <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
- <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
- <parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</parameter>
- <parameter name="transport.jms.ConnectionFactoryType">topic</parameter>
- <parameter name="transport.jms.JMSSpecVersion">1.0.2b</parameter>
- </parameter>
-
- <parameter name="myQueueConnectionFactory">
- <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
- <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
- <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>
- <parameter name="transport.jms.ConnectionFactoryType">queue</parameter>
- <parameter name="transport.jms.JMSSpecVersion">1.1</parameter>
- </parameter>
-
- <parameter name="default">
- <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
- <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
- <parameter name="transport.jms.ConnectionFactoryJNDIName">ConnectionFactory</parameter>
- </parameter>
- </transportReceiver>
-
- <transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender">
- <parameter name="myTopicConnectionFactory">
- <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
- <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
- <parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</parameter>
- <parameter name="transport.jms.JMSSpecVersion">1.0.2b</parameter>
- <parameter name="transport.jms.CacheLevel">producer</parameter>
- </parameter>
-
- <parameter name="myQueueConnectionFactory">
- <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
- <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
- <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>
- <parameter name="transport.jms.JMSSpecVersion">1.0.2b</parameter>
- <parameter name="transport.jms.CacheLevel">producer</parameter>
- </parameter>
-
- <parameter name="default">
- <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
- <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
- <parameter name="transport.jms.ConnectionFactoryJNDIName">ConnectionFactory</parameter>
- <parameter name="transport.jms.CacheLevel">connection</parameter>
- </parameter>
- </transportSender>
-</pre>
-
-<p>
- The Transport Listener and Sender both allows the user to configure one or more logical JMS Connection
- Factories, which are named definitions as shown above. Any remaining parameters maybe defined at the
- service level via the services.xml. The applicable set of parameters for a service would be the
- union of the properties from the services.xml and the corresponding logical connection factory.
-</p>
-
-<TABLE WIDTH="100%" BORDER=1 BORDERCOLOR="#000000" CELLPADDING=4 CELLSPACING=0>
- <COL WIDTH="10%">
- <COL WIDTH="20%">
- <COL WIDTH="60%">
- <COL WIDTH="5%">
- <COL WIDTH="5%">
- <tr>
- <td>Transport level</td>
- <td><BR></td>
- <td><BR></td>
- <td>Listening</td>
- <td>Sending</td>
- </tr>
- <tr>
- <td>JNDI</td>
- <td>java.naming.factory.initial</td>
- <td>The JNDI InitialContext factory class</td>
- <td>Required</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>java.naming.provider.url</td>
- <td>JNDI Provider URL</td>
- <td>Required</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>java.naming.security.principal</td>
- <td>Username for JNDI access</td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>java.naming.security.credentials</td>
- <td>Password for JNDI access</td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td>Transactions</td>
- <td>transport.Transactionality</td>
- <td>Desired transactionality. One of none / local / jta</td>
- <td>Defaults to <B>none</B></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.UserTxnJNDIName</td>
- <td>JNDI name to be used to obtain a UserTransaction</td>
- <td>Defaults to "java:comp/UserTransaction"</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.CacheUserTxn</td>
- <td>Generally its safe and more efficient to cache the
- UserTransaction reference from JNDI. One of true/ false</td>
- <td>Defaults to <B>true</B></td>
- <td><BR></td>
- </tr>
-
- <tr>
- <td><BR></td>
- <td>transport.jms.SessionTransacted</td>
- <td>Should the JMS Session be transacted. One of true/ false</td>
- <td>Defaults to <B>true</B> when local transactions are used</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.SessionAcknowledgement</td>
- <td>JMS Session acknowledgement mode to be used. One of AUTO_ACKNOWLEDGE | CLIENT_ACKNOWLEDGE | DUPS_OK_ACKNOWLEDGE | SESSION_TRANSACTED</td>
- <td>Defaults to <B>AUTO_ACKNOWLEDGE</B></td>
- <td><BR></td>
- </tr>
-
- <tr>
- <td>Connection</td>
- <td>transport.jms.ConnectionFactory</td>
- <td>Name of the logical connection factory this service will use</td>
- <td>Defaults to "default"</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.ConnectionFactoryJNDIName</td>
- <td>The JNDI name of the JMS ConnectionFactory</td>
- <td>Required</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.ConnectionFactoryType</td>
- <td> Type of ConnectionFactory – queue / topic</td>
- <td>Suggested to be specified</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.JMSSpecVersion</td>
- <td>JMS API Version One of "1.1" or "1.0.2b"</td>
- <td>Defaults to 1.1</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.UserName</td>
- <td>The JMS connection username</td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.Password</td>
- <td>The JMS connection password</td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td>Destinations</td>
- <td>transport.jms.Destination</td>
- <td>JNDI Name of the Destination </td>
- <td>Defaults to Service name</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.DestinationType</td>
- <td>Type of Destination – queue / topic</td>
- <td>Defaults to a queue</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.DefaultReplyDestination</td>
- <td>JNDI Name of the default reply Destination</td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.DefaultReplyDestinationType</td>
- <td>Type of the reply Destination – queue / topic</td>
- <td>Same type as of Destination</td>
- <td><BR></td>
- </tr>
- <tr>
- <td>Advanced</td>
- <td>transport.jms.MessageSelector</td>
- <td>Optional message selector to be applied</td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.SubscriptionDurable</td>
- <td>Is the subscription durable? (For Topics) – true / false</td>
- <td>Defaults to <B>false</B></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.DurableSubscriberName</td>
- <td>Name to be used for the durable subscription</td>
- <td>Required when subscription is durable</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.PubSubNoLocal</td>
- <td>Should messages published by the same connection (for Topics)
- be received? – true / false</td>
- <td>Defaults to <B>false</B></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.CacheLevel</td>
- <td>The JMS resource cache level. One of none / connection /
- session / consumer / producer / auto</td>
- <td>Defaults to <B>auto</B> </td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.ReceiveTimeout</td>
- <td>Time to wait for a JMS message during polling. Negative means
- wait forever, while 0 means do not wait at all. Anything else, is
- a millisecond value for the poll</td>
- <td>Defaults to 1000ms</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.ConcurrentConsumers</td>
- <td>Number of concurrent consumer tasks (~threads) to be started to
- poll for messages for this service. For Topics, this should be
- always 1, to prevent the same message being processed multiple
- times</td>
- <td>Defaults to <B>1</B></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.MaxConcurrentConsumers</td>
- <td>Will dynamically scale the number of concurrent consumer tasks
- (~threads) until this value; as the load increases. Should always
- be 1 for Topics.</td>
- <td>Defaults to <B>1</B></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.IdleTaskLimit</td>
- <td>The number of idle (i.e. poll without receipt of a message)
- runs per task, before it dies – to recycle resources, and to
- allow dynamic scale down.</td>
- <td>Defaults to 10</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.MaxMessagesPerTask</td>
- <td>The maximum number of successful message receipts to limit per
- Task lifetime. </td>
- <td>Defaults to <B>–1</B> which implies unlimited messages</td>
- <td><BR></td>
- </tr>
- <tr>
- <td>Reconnection</td>
- <td>transport.jms.InitialReconnectDuration</td>
- <td>Initial reconnection attempt duration</td>
- <td>Defaults to 10,000ms</td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.ReconnectProgressFactor</td>
- <td>Factor used to compute consecutive reconnection attempt
- durations, in a geometric series</td>
- <td>Defaults to <B>2 (i.e. exponential)</B></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.MaxReconnectDuration</td>
- <td>Maximum limit for a reconnection duration</td>
- <td>Defaults to <B>1 hour</B></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>transport.jms.PublishEPR</td>
- <td>One or more JMS URL's to be showed as the JMS EPRs on the WSDL
- for the service. Allows the specification of a custom EPR, and/or
- hiding of internal properties from a public EPR (e.g.
- credentials). Add one as LEGACY to retain auto generated EPR, when
- adding new EPRs</td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td><BR></td>
- <td><BR></td>
- <td><BR></td>
- <td><BR></td>
- </tr>
- <tr>
- <td>Legacy Mode and Payload handling</td>
- <td>Wrapper</td>
- <td>Binary and Text payload wrapper element to be specified as "{ns}name" where ns refers to a namespace and name the name of the element</td>
- <td>Default binary wrapper<ul><li>{http://ws.apache.org/commons/ns/payload}binary</li></ul>
- Default text wrapper <ul><li>{http://ws.apache.org/commons/ns/payload}text</li></ul></td>
- <td><BR></td>
- </tr>
- <tr>
- <td><BR></td>
- <td>Operation</td>
- <td>operation name to be specified as "{ns}name" where ns refers to the namespace and name the name of the operation</td>
- <td>Defaults to urn:mediate</td>
- <td><BR></td>
- </tr>
-</TABLE>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/modules/jms/src/test/conf/qpid/config.xml b/modules/jms/src/test/conf/qpid/config.xml
deleted file mode 100644
index 2cf0ee2..0000000
--- a/modules/jms/src/test/conf/qpid/config.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<broker>
- <conf>src/test/conf/qpid</conf>
- <security>
- <pd-auth-manager>
- <principal-database>
- <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
- <attributes>
- <attribute>
- <name>passwordFile</name>
- <value>${conf}/passwd</value>
- </attribute>
- </attributes>
- </principal-database>
- </pd-auth-manager>
- <msg-auth>false</msg-auth>
- </security>
- <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
-</broker>
\ No newline at end of file
diff --git a/modules/jms/src/test/conf/qpid/log4j.xml b/modules/jms/src/test/conf/qpid/log4j.xml
deleted file mode 100644
index c2dcf01..0000000
--- a/modules/jms/src/test/conf/qpid/log4j.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration>
- <!-- This file is intentionally empty; we configure log4j elsewhere before starting qpid. -->
-</log4j:configuration>
\ No newline at end of file
diff --git a/modules/jms/src/test/conf/qpid/passwd b/modules/jms/src/test/conf/qpid/passwd
deleted file mode 100644
index 966a161..0000000
--- a/modules/jms/src/test/conf/qpid/passwd
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-guest:guest
diff --git a/modules/jms/src/test/conf/qpid/virtualhosts.xml b/modules/jms/src/test/conf/qpid/virtualhosts.xml
deleted file mode 100644
index 5d0d6bd..0000000
--- a/modules/jms/src/test/conf/qpid/virtualhosts.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<virtualhosts>
- <default>test</default>
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- <queues>
- <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
- <maximumMessageCount>50</maximumMessageCount>
- <queue>
- <name>queue</name>
- <queue>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </queue>
- </queue>
- <queue>
- <name>ping</name>
- <ping>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </ping>
- </queue>
- </queues>
- </test>
- </virtualhost>
-</virtualhosts>
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java
deleted file mode 100644
index c7feb6b..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-@Name("ActiveMQ")
-public class ActiveMQTestEnvironment extends JMSTestEnvironment {
- private static final String BROKER_NAME = "test";
-
- private @Transient BrokerService broker;
-
- @Setup @SuppressWarnings("unused")
- private void setUp() throws Exception {
- broker = new BrokerService();
- broker.setBrokerName(BROKER_NAME);
- broker.setDataDirectory("target/activemq-data");
- broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
- broker.start();
- connectionFactory = new ActiveMQConnectionFactory("vm://" + BROKER_NAME);
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- broker.stop();
- }
-
- @Override
- public Queue createQueue(String name) {
- return new ActiveMQQueue(name);
- }
-
- @Override
- public Topic createTopic(String name) {
- return new ActiveMQTopic(name);
- }
-
- @Override
- public void deleteDestination(Destination destination) throws Exception {
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/ContentTypeMode.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/ContentTypeMode.java
deleted file mode 100644
index 89a951e..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/ContentTypeMode.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-/**
- * Enumeration specifying how a transport listener determines the content type
- * of a message.
- */
-public enum ContentTypeMode {
- /**
- * The content type information is sent by the client using some feature
- * of the transport protocol. Example are the Content-Type header of the HTTP
- * protocol or a JMS message property.
- */
- TRANSPORT,
-
- /**
- * The content type is statically configured on the service.
- */
- SERVICE
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAsyncChannel.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAsyncChannel.java
deleted file mode 100644
index f4cb426..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAsyncChannel.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-
-public class JMSAsyncChannel extends JMSChannel implements AsyncChannel {
- public JMSAsyncChannel(String name, String destinationType, ContentTypeMode contentTypeMode) {
- super(name, destinationType, contentTypeMode);
- }
-
- public JMSAsyncChannel(String destinationType, ContentTypeMode contentTypeMode) {
- super(destinationType, contentTypeMode);
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAsyncClient.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAsyncClient.java
deleted file mode 100644
index 6423a06..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAsyncClient.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-
-public class JMSAsyncClient<T> extends JMSClient<T> implements AsyncTestClient<T> {
- public JMSAsyncClient(JMSMessageFactory<T> jmsMessageFactory) {
- super(jmsMessageFactory);
- }
-
- public void sendMessage(ClientOptions options, ContentType contentType, T message) throws Exception {
- doSendMessage(options, contentType, message);
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAxisTestClientConfigurator.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAxisTestClientConfigurator.java
deleted file mode 100644
index 0b17dc1..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSAxisTestClientConfigurator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator;
-import org.apache.axis2.transport.testkit.name.Key;
-
-public class JMSAxisTestClientConfigurator implements AxisTestClientConfigurator {
- private final String jmsMessageType;
-
- public JMSAxisTestClientConfigurator(String jmsMessageType) {
- this.jmsMessageType = jmsMessageType;
- }
-
- @Key(JMSConstants.JMS_MESSAGE_TYPE)
- public String getJmsMessageType() {
- return jmsMessageType;
- }
-
- public void setupRequestMessageContext(MessageContext msgContext) throws AxisFault {
- msgContext.setProperty(JMSConstants.JMS_MESSAGE_TYPE, jmsMessageType);
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSBytesMessageFactory.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSBytesMessageFactory.java
deleted file mode 100644
index 1c56cc2..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSBytesMessageFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("bytes")
-public class JMSBytesMessageFactory implements JMSMessageFactory<byte[]> {
- public static final JMSBytesMessageFactory INSTANCE = new JMSBytesMessageFactory();
-
- private JMSBytesMessageFactory() {}
-
- public Message createMessage(Session session, byte[] data) throws JMSException {
- BytesMessage message = session.createBytesMessage();
- message.writeBytes(data);
- return message;
- }
-
- public byte[] parseMessage(Message message) throws JMSException {
- BytesMessage bytesMessage = (BytesMessage)message;
- byte[] data = new byte[(int)bytesMessage.getBodyLength()];
- bytesMessage.readBytes(data);
- return data;
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java
deleted file mode 100644
index 88f9fe6..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import java.util.Enumeration;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import javax.naming.Context;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.transport.testkit.axis2.AxisServiceConfigurator;
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-public abstract class JMSChannel implements AxisServiceConfigurator {
- private final String name;
- private final String destinationType;
- private final ContentTypeMode contentTypeMode;
- protected @Transient JMSTestEnvironment env;
- protected @Transient Context context;
- private @Transient String destinationName;
- private @Transient String jndiName;
- private @Transient Destination destination;
- private @Transient String connectionFactoryName;
- private @Transient String connectionFactoryJNDIName;
-
- public JMSChannel(String name, String destinationType, ContentTypeMode contentTypeMode) {
- this.name = name;
- this.destinationType = destinationType;
- this.contentTypeMode = contentTypeMode;
- }
-
- public JMSChannel(String destinationType, ContentTypeMode contentTypeMode) {
- this(null, destinationType, contentTypeMode);
- }
-
- protected String buildDestinationName(String direction, String destinationType) {
- StringBuilder destinationName = new StringBuilder();
- if (name != null) {
- destinationName.append(name);
- destinationName.append(Character.toUpperCase(direction.charAt(0)));
- destinationName.append(direction.substring(1));
- } else {
- destinationName.append(direction);
- }
- destinationName.append(destinationType == JMSConstants.DESTINATION_TYPE_QUEUE ? 'Q' : 'T');
- return destinationName.toString();
- }
-
- protected String buildJndiName(String direction, String destinationType) {
- return "jms/" + buildDestinationName(direction, destinationType);
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(JMSTestEnvironment env, JNDIEnvironment jndiEnvironment, JMSTransportDescriptionFactory tdf) throws Exception {
- this.env = env;
- context = jndiEnvironment.getContext();
- destinationName = buildDestinationName("request", destinationType);
- jndiName = buildJndiName("request", destinationType);
- destination = env.createDestination(destinationType, destinationName);
- context.bind(jndiName, destination);
- connectionFactoryName = tdf.getConnectionFactoryName(destinationType);
- connectionFactoryJNDIName = tdf.getConnectionFactoryJNDIName(destinationType);
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- context.unbind(jndiName);
- env.deleteDestination(destination);
- }
-
- @Key("destType")
- public String getDestinationType() {
- return destinationType;
- }
-
- public String getDestinationName() {
- return destinationName;
- }
-
- public Destination getDestination() {
- return destination;
- }
-
- @Key("contentTypeMode")
- public ContentTypeMode getContentTypeMode() {
- return contentTypeMode;
- }
-
- public int getMessageCount() throws JMSException {
- Connection connection = env.getConnectionFactory().createConnection();
- try {
- connection.start();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- QueueBrowser browser = session.createBrowser((Queue)destination);
- int count = 0;
- for (Enumeration<?> e = browser.getEnumeration(); e.hasMoreElements(); e.nextElement()) {
- count++;
- }
- return count;
- } finally {
- connection.close();
- }
- }
-
- public EndpointReference getEndpointReference() throws Exception {
- return new EndpointReference(
- "jms:/" + jndiName + "?transport.jms.DestinationType=" + destinationType +
- "&java.naming.factory.initial=org.mockejb.jndi.MockContextFactory" +
- "&transport.jms.ConnectionFactoryJNDIName=" + connectionFactoryJNDIName +
- "&" + JMSConstants.CONTENT_TYPE_PROPERTY_PARAM + "=Content-Type");
- }
-
- public void setupService(AxisService service, boolean isClientSide) throws Exception {
- service.addParameter(JMSConstants.PARAM_JMS_CONFAC, connectionFactoryName);
- service.addParameter(JMSConstants.PARAM_DEST_TYPE, destinationType);
- service.addParameter(JMSConstants.PARAM_DESTINATION, jndiName);
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSClient.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSClient.java
deleted file mode 100644
index a4479ce..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSClient.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.TestClient;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.name.Named;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-@Name("jms")
-public class JMSClient<T> implements TestClient {
- protected final JMSMessageFactory<T> jmsMessageFactory;
-
- private @Transient Connection connection;
- private @Transient Session session;
- private @Transient MessageProducer producer;
- private @Transient ContentTypeMode contentTypeMode;
-
- public JMSClient(JMSMessageFactory<T> jmsMessageFactory) {
- this.jmsMessageFactory = jmsMessageFactory;
- }
-
- @Named
- public JMSMessageFactory<T> getJmsMessageFactory() {
- return jmsMessageFactory;
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(JMSTestEnvironment env, JMSChannel channel) throws Exception {
- Destination destination = channel.getDestination();
- ConnectionFactory connectionFactory = env.getConnectionFactory();
- connection = connectionFactory.createConnection();
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- producer = session.createProducer(destination);
- contentTypeMode = channel.getContentTypeMode();
- }
-
- protected String doSendMessage(ClientOptions options, ContentType contentType, T message) throws Exception {
- Message jmsMessage = jmsMessageFactory.createMessage(session, message);
- if (contentTypeMode == ContentTypeMode.TRANSPORT) {
- jmsMessage.setStringProperty(BaseConstants.CONTENT_TYPE, contentType.toString());
- }
- producer.send(jmsMessage);
- return jmsMessage.getJMSMessageID();
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- producer.close();
- session.close();
- connection.close();
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSMessageFactory.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSMessageFactory.java
deleted file mode 100644
index c7d856e..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSMessageFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-
-import org.apache.axis2.transport.testkit.name.Key;
-
-@Key("jmsType")
-public interface JMSMessageFactory<T> {
- Message createMessage(Session session, T data) throws JMSException;
- T parseMessage(Message message) throws JMSException;
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java
deleted file mode 100644
index cddb6dc..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.Destination;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator;
-import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-public class JMSRequestResponseChannel extends JMSChannel implements RequestResponseChannel, AxisTestClientConfigurator {
- private final String replyDestinationType;
- private @Transient String replyDestinationName;
- private @Transient String replyJndiName;
- private @Transient Destination replyDestination;
-
- public JMSRequestResponseChannel(String name, String destinationType, String replyDestinationType, ContentTypeMode contentTypeMode) {
- super(name, destinationType, contentTypeMode);
- this.replyDestinationType = replyDestinationType;
- }
-
- public JMSRequestResponseChannel(String destinationType, String replyDestinationType, ContentTypeMode contentTypeMode) {
- this(null, destinationType, replyDestinationType, contentTypeMode);
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(JMSTestEnvironment env) throws Exception {
- replyDestinationName = buildDestinationName("response", replyDestinationType);
- replyJndiName = buildJndiName("response", replyDestinationType);
- replyDestination = env.createDestination(replyDestinationType, replyDestinationName);
- context.bind(replyJndiName, replyDestination);
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- context.unbind(replyJndiName);
- env.deleteDestination(replyDestination);
- }
-
- @Override
- public void setupService(AxisService service, boolean isClientSide) throws Exception {
- super.setupService(service, isClientSide);
- service.addParameter(JMSConstants.PARAM_REPLY_DEST_TYPE, replyDestinationType);
- service.addParameter(JMSConstants.PARAM_REPLY_DESTINATION, replyJndiName);
- }
-
- public void setupRequestMessageContext(MessageContext msgContext) {
-// msgContext.setProperty(JMSConstants.JMS_REPLY_TO, replyDestinationName);
- }
-
- @Override
- public EndpointReference getEndpointReference() throws Exception {
- String address = super.getEndpointReference().getAddress();
- return new EndpointReference(address + "&" + JMSConstants.PARAM_REPLY_DEST_TYPE + "=" + replyDestinationType + "&" + JMSConstants.PARAM_REPLY_DESTINATION + "=" + replyJndiName);
- }
-
- @Key("replyDestType")
- public String getReplyDestinationType() {
- return replyDestinationType;
- }
-
- public Destination getReplyDestination() {
- return replyDestination;
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java
deleted file mode 100644
index e3f6a81..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-public class JMSRequestResponseClient<T> extends JMSClient<T> implements RequestResponseTestClient<T,T> {
- private @Transient Destination replyDestination;
- private @Transient Connection replyConnection;
- private @Transient Session replySession;
-
- public JMSRequestResponseClient(JMSMessageFactory<T> jmsMessageFactory) {
- super(jmsMessageFactory);
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(JMSTestEnvironment env, JMSRequestResponseChannel channel) throws Exception {
- replyDestination = channel.getReplyDestination();
- ConnectionFactory connectionFactory = env.getConnectionFactory();
- replyConnection = connectionFactory.createConnection();
- replyConnection.start();
- replySession = replyConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- }
-
- public IncomingMessage<T> sendMessage(ClientOptions options, ContentType contentType, T message) throws Exception {
- String correlationId = doSendMessage(options, contentType, message);
- MessageConsumer consumer = replySession.createConsumer(replyDestination, "JMSCorrelationID = '" + correlationId + "'");
- try {
- Message replyMessage = consumer.receive(8000);
- return new IncomingMessage<T>(new ContentType(replyMessage.getStringProperty("Content-Type")),
- jmsMessageFactory.parseMessage(replyMessage));
- } finally {
- consumer.close();
- }
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- replySession.close();
- replyConnection.close();
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java
deleted file mode 100644
index 49b07aa..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.Topic;
-
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-@Key("broker")
-public abstract class JMSTestEnvironment {
- protected @Transient ConnectionFactory connectionFactory;
-
- public Destination createDestination(String destinationType, String name) throws Exception {
- if (destinationType.equals(JMSConstants.DESTINATION_TYPE_TOPIC)) {
- return createTopic(name);
- } else {
- return createQueue(name);
- }
- }
-
- public abstract Queue createQueue(String name) throws Exception;
- public abstract Topic createTopic(String name) throws Exception;
-
- public abstract void deleteDestination(Destination destination) throws Exception;
-
- public ConnectionFactory getConnectionFactory() {
- return connectionFactory;
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTextMessageFactory.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTextMessageFactory.java
deleted file mode 100644
index 40d5fa7..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTextMessageFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("text")
-public class JMSTextMessageFactory implements JMSMessageFactory<String> {
- public static final JMSTextMessageFactory INSTANCE = new JMSTextMessageFactory();
-
- private JMSTextMessageFactory() {}
-
- public Message createMessage(Session session, String data) throws JMSException {
- TextMessage message = session.createTextMessage();
- message.setText(data);
- return message;
- }
-
- public String parseMessage(Message message) throws JMSException {
- return ((TextMessage)message).getText();
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTransportDescriptionFactory.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTransportDescriptionFactory.java
deleted file mode 100644
index 06fcaf3..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTransportDescriptionFactory.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.ConnectionFactory;
-import javax.naming.Context;
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.mockejb.jndi.MockContextFactory;
-
-public class JMSTransportDescriptionFactory implements TransportDescriptionFactory {
- public static final String CONNECTION_FACTORY = "ConnectionFactory";
- public static final String QUEUE_CONNECTION_FACTORY = "QueueConnectionFactory";
- public static final String TOPIC_CONNECTION_FACTORY = "TopicConnectionFactory";
-
- private static final OMFactory factory = OMAbstractFactory.getOMFactory();
-
- private final boolean singleCF;
- private final boolean cfOnSender;
- private final int concurrentConsumers;
- private @Transient Context context;
-
- /**
- * Constructor.
- * @param singleCF True if a single connection factory for all types of destinations
- * (queues and topics) should be used. Otherwise, separate connection
- * factories will be configured.
- * @param cfOnSender Determine whether the connection factories (JMS providers)
- * should also be configured on the sender. This switch allows
- * us to build regression tests for SYNAPSE-448.
- */
- public JMSTransportDescriptionFactory(boolean singleCF, boolean cfOnSender, int concurrentConsumers) {
- this.singleCF = singleCF;
- this.cfOnSender = cfOnSender;
- this.concurrentConsumers = concurrentConsumers;
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(JMSTestEnvironment env, JNDIEnvironment jndiEnvironment) throws Exception {
- context = jndiEnvironment.getContext();
- ConnectionFactory connectionFactory = env.getConnectionFactory();
- if (singleCF) {
- context.bind(CONNECTION_FACTORY, connectionFactory);
- } else {
- context.bind(QUEUE_CONNECTION_FACTORY, connectionFactory);
- context.bind(TOPIC_CONNECTION_FACTORY, connectionFactory);
- }
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- if (singleCF) {
- context.unbind(CONNECTION_FACTORY);
- } else {
- context.unbind(QUEUE_CONNECTION_FACTORY);
- context.unbind(TOPIC_CONNECTION_FACTORY);
- }
- }
-
- @Key("singleCF")
- public boolean isSingleCF() {
- return singleCF;
- }
-
- @Key("cfOnSender")
- public boolean isCfOnSender() {
- return cfOnSender;
- }
-
- private OMElement createParameterElement(String name, String value) {
- OMElement element = factory.createOMElement(new QName("parameter"));
- element.addAttribute("name", name, null);
- if (value != null) {
- element.setText(value);
- }
- return element;
- }
-
- private void setupConnectionFactoryConfig(ParameterInclude trpDesc, String name, String connFactName, String type) throws AxisFault {
- OMElement element = createParameterElement(JMSConstants.DEFAULT_CONFAC_NAME, null);
- element.addChild(createParameterElement(Context.INITIAL_CONTEXT_FACTORY,
- MockContextFactory.class.getName()));
- element.addChild(createParameterElement(JMSConstants.PARAM_CONFAC_JNDI_NAME,
- connFactName));
- if (type != null) {
- element.addChild(createParameterElement(JMSConstants.PARAM_CONFAC_TYPE, type));
- }
- element.addChild(createParameterElement(JMSConstants.PARAM_CONCURRENT_CONSUMERS,
- Integer.toString(concurrentConsumers)));
- Parameter parameter = new Parameter();
- parameter.setName(name);
- parameter.setParameterElement(element);
- trpDesc.addParameter(parameter);
- }
-
- private void setupTransport(ParameterInclude trpDesc) throws AxisFault {
- if (singleCF) {
- // TODO: setting the type to "queue" is nonsense, but required by the transport (see SYNAPSE-439)
- setupConnectionFactoryConfig(trpDesc, "default", CONNECTION_FACTORY, null);
- } else {
- setupConnectionFactoryConfig(trpDesc, "queue", QUEUE_CONNECTION_FACTORY, "queue");
- setupConnectionFactoryConfig(trpDesc, "topic", TOPIC_CONNECTION_FACTORY, "topic");
- }
- }
-
- public TransportInDescription createTransportInDescription() throws Exception {
- TransportInDescription trpInDesc = new TransportInDescription(JMSListener.TRANSPORT_NAME);
- setupTransport(trpInDesc);
- trpInDesc.setReceiver(new JMSListener());
- return trpInDesc;
- }
-
- public TransportOutDescription createTransportOutDescription() throws Exception {
- TransportOutDescription trpOutDesc = new TransportOutDescription(JMSSender.TRANSPORT_NAME);
- if (cfOnSender) {
- setupTransport(trpOutDesc);
- }
- trpOutDesc.setSender(new JMSSender());
- return trpOutDesc;
- }
-
- public String getConnectionFactoryName(String destinationType) {
- return singleCF ? "default" : destinationType;
- }
-
- public String getConnectionFactoryJNDIName(String destinationType) {
- if (singleCF) {
- return CONNECTION_FACTORY;
- } else {
- return destinationType.equals("queue") ? QUEUE_CONNECTION_FACTORY
- : TOPIC_CONNECTION_FACTORY;
- }
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java
deleted file mode 100644
index e611813..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.testkit.ManagedTestSuite;
-import org.apache.axis2.transport.testkit.TransportTestSuiteBuilder;
-import org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient;
-import org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.tests.misc.MinConcurrencyTest;
-
-public class JMSTransportTest extends TestCase {
- public static TestSuite suite() throws Exception {
- ManagedTestSuite suite = new ManagedTestSuite(JMSTransportTest.class);
-
- // SwA doesn't make sense with text messages
- suite.addExclude("(&(test=AsyncSwA)(client=jms)(jmsType=text))");
-
- // Don't execute all possible test combinations:
- // * Use a single setup to execute tests with all message types.
- // * Only use a small set of message types for the other setups.
- suite.addExclude("(!(|(&(broker=ActiveMQ)(singleCF=false)(cfOnSender=false)(!(|(destType=topic)(replyDestType=topic))))" +
- "(&(test=AsyncXML)(messageType=SOAP11)(data=ASCII))" +
- "(&(test=EchoXML)(messageType=POX)(data=ASCII))" +
- "(test=MinConcurrency)))");
-
- // SYNAPSE-436:
- suite.addExclude("(&(test=EchoXML)(replyDestType=topic)(endpoint=axis))");
-
- // Although Qpid is compiled for Java 1.5, it uses classes only present in 1.6.
- if (System.getProperty("java.version").startsWith("1.5.")) {
- System.out.println("Excluding Qpid tests; please run the build with Java 1.6 to include them");
- suite.addExclude("(broker=qpid)");
- }
-
- // Example to run a few use cases.. please leave these commented out - asankha
- //suite.addExclude("(|(test=AsyncXML)(test=MinConcurrency)(destType=topic)(broker=qpid)(destType=topic)(replyDestType=topic)(client=jms)(endpoint=mock)(cfOnSender=true))");
- //suite.addExclude("(|(test=EchoXML)(destType=queue)(broker=qpid)(cfOnSender=true)(singleCF=false)(destType=queue)(client=jms)(endpoint=mock))");
- //suite.addExclude("(|(test=EchoXML)(test=AsyncXML)(test=AsyncSwA)(test=AsyncTextPlain)(test=AsyncBinary)(test=AsyncSOAPLarge)(broker=qpid))");
-
- TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
-
- JMSTestEnvironment[] environments = new JMSTestEnvironment[] { new QpidTestEnvironment(), new ActiveMQTestEnvironment() };
- for (boolean singleCF : new boolean[] { false, true }) {
- for (boolean cfOnSender : new boolean[] { false, true }) {
- for (JMSTestEnvironment env : environments) {
- builder.addEnvironment(env, new JMSTransportDescriptionFactory(singleCF, cfOnSender, 1));
- }
- }
- }
-
- builder.addAsyncChannel(new JMSAsyncChannel(JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT));
- builder.addAsyncChannel(new JMSAsyncChannel(JMSConstants.DESTINATION_TYPE_TOPIC, ContentTypeMode.TRANSPORT));
-
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), new JMSAxisTestClientConfigurator(JMSConstants.JMS_BYTE_MESSAGE));
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), new JMSAxisTestClientConfigurator(JMSConstants.JMS_TEXT_MESSAGE));
- builder.addByteArrayAsyncTestClient(new JMSAsyncClient<byte[]>(JMSBytesMessageFactory.INSTANCE));
- builder.addStringAsyncTestClient(new JMSAsyncClient<String>(JMSTextMessageFactory.INSTANCE));
-
- builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
-
- builder.addRequestResponseChannel(new JMSRequestResponseChannel(JMSConstants.DESTINATION_TYPE_QUEUE, JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT));
-
- AxisTestClientConfigurator timeoutConfigurator = new AxisTestClientConfigurator() {
- public void setupRequestMessageContext(MessageContext msgContext) throws AxisFault {
- msgContext.setProperty(JMSConstants.JMS_WAIT_REPLY, "5000");
- }
- };
-
- builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient(), timeoutConfigurator);
- builder.addStringRequestResponseTestClient(new JMSRequestResponseClient<String>(JMSTextMessageFactory.INSTANCE));
-
- builder.addEchoEndpoint(new MockEchoEndpoint());
- builder.addEchoEndpoint(new AxisEchoEndpoint());
-
- for (JMSTestEnvironment env : new JMSTestEnvironment[] { new QpidTestEnvironment(), new ActiveMQTestEnvironment() }) {
- suite.addTest(new MinConcurrencyTest(new AsyncChannel[] {
- new JMSAsyncChannel("endpoint1", JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT),
- new JMSAsyncChannel("endpoint2", JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT) },
- 2, false, env, new JMSTransportDescriptionFactory(false, false, 2)));
- }
-
-
- builder.build();
-
- return suite;
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JNDIEnvironment.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/JNDIEnvironment.java
deleted file mode 100644
index 4080a4e..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/JNDIEnvironment.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.mockejb.jndi.MockContextFactory;
-
-public class JNDIEnvironment {
- public static final JNDIEnvironment INSTANCE = new JNDIEnvironment();
-
- private @Transient Context context;
-
- private JNDIEnvironment() {}
-
- @Setup @SuppressWarnings("unused")
- private void setUp() throws Exception {
- MockContextFactory.setAsInitial();
- context = new InitialContext();
- }
-
- public Context getContext() {
- return context;
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/LogAspect.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/LogAspect.java
deleted file mode 100644
index 611c132..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/LogAspect.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.Enumeration;
-
-import javax.jms.BytesMessage;
-import javax.jms.Message;
-import javax.jms.TextMessage;
-
-import org.apache.axis2.transport.jms.iowrappers.BytesMessageInputStream;
-import org.apache.axis2.transport.testkit.util.LogManager;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-
-@Aspect
-public class LogAspect {
- private static final Log log = LogFactory.getLog(LogAspect.class);
-
- @Before("(call(void javax.jms.MessageProducer.send(javax.jms.Message)) ||" +
- " call(void javax.jms.TopicPublisher.publish(javax.jms.Message))) && args(message)")
- public void beforeSend(Message message) {
- try {
- OutputStream out = LogManager.INSTANCE.createLog("jms");
- try {
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(out), false);
- pw.println("Type: " + message.getClass().getName());
- pw.println("JMS message ID: " + message.getJMSMessageID());
- pw.println("JMS correlation ID: " + message.getJMSCorrelationID());
- pw.println("JMS reply to: " + message.getJMSReplyTo());
- for (Enumeration<?> e = message.getPropertyNames(); e.hasMoreElements(); ) {
- String name = (String)e.nextElement();
- pw.print(name);
- pw.print(": ");
- pw.println(message.getStringProperty(name));
- }
- pw.println();
- pw.flush();
- if (message instanceof BytesMessage) {
- BytesMessage bytesMessage = (BytesMessage)message;
- bytesMessage.reset();
- IOUtils.copy(new BytesMessageInputStream(bytesMessage), out);
- } else if (message instanceof TextMessage) {
- pw.print(((TextMessage)message).getText());
- pw.flush();
- }
- } finally {
- out.close();
- }
- } catch (Throwable ex) {
- log.error("Failed to dump JMS message", ex);
- }
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
deleted file mode 100644
index a878603..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.jms.iowrappers.BytesMessageInputStream;
-import org.apache.axis2.transport.jms.iowrappers.BytesMessageOutputStream;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpointSupport;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-@Name("mock")
-public class MockEchoEndpoint extends InOutEndpointSupport implements InOutEndpoint, ExceptionListener {
- static Log log = LogFactory.getLog(MockEchoEndpoint.class);
-
- private @Transient Connection connection;
- private @Transient Connection replyConnection;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(JMSTestEnvironment env, JMSRequestResponseChannel channel) throws Exception {
- Destination destination = channel.getDestination();
- Destination replyDestination = channel.getReplyDestination();
- connection = env.getConnectionFactory().createConnection();
- connection.setExceptionListener(this);
- connection.start();
- replyConnection = env.getConnectionFactory().createConnection();
- replyConnection.setExceptionListener(this);
- final Session replySession = replyConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- final MessageProducer producer = replySession.createProducer(replyDestination);
- MessageConsumer consumer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(destination);
- consumer.setMessageListener(new MessageListener() {
- public void onMessage(Message message) {
- try {
- log.info("Message received: ID = " + message.getJMSMessageID());
- Message reply;
- if (message instanceof BytesMessage) {
- reply = replySession.createBytesMessage();
- IOUtils.copy(new BytesMessageInputStream((BytesMessage)message), new BytesMessageOutputStream((BytesMessage)reply));
- } else if (message instanceof TextMessage) {
- reply = replySession.createTextMessage();
- ((TextMessage)reply).setText(((TextMessage)message).getText());
- } else {
- // TODO
- throw new UnsupportedOperationException("Unsupported message type");
- }
- reply.setJMSCorrelationID(message.getJMSMessageID());
- reply.setStringProperty(BaseConstants.CONTENT_TYPE, message.getStringProperty(BaseConstants.CONTENT_TYPE));
- producer.send(reply);
- log.info("Message sent: ID = " + reply.getJMSMessageID());
- } catch (Throwable ex) {
- fireEndpointError(ex);
- }
- }
- });
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- connection.close();
- replyConnection.close();
- }
-
- public void onException(JMSException ex) {
- log.error("Exception received by JMS exception listener", ex);
- fireEndpointError(ex);
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java
deleted file mode 100644
index 894e91c..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.Topic;
-
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.PortAllocator;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.server.Broker;
-import org.apache.qpid.server.BrokerOptions;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-
-@Name("qpid")
-public class QpidTestEnvironment extends JMSTestEnvironment {
- private @Transient PortAllocator portAllocator;
- private @Transient Broker broker;
- private @Transient VirtualHost virtualHost;
- private int port;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(PortAllocator portAllocator) throws Exception {
- this.portAllocator = portAllocator;
- port = portAllocator.allocatePort();
- broker = new Broker();
- BrokerOptions options = new BrokerOptions();
- options.setConfigFile("src/test/conf/qpid/config.xml");
- options.setLogConfigFile("src/test/conf/qpid/log4j.xml");
- options.addPort(port);
- broker.startup(options);
- // null means the default virtual host
- virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost(null);
- connectionFactory = new AMQConnectionFactory("amqp://guest:guest@clientid/" + virtualHost.getName() + "?brokerlist='tcp://localhost:" + port + "'");
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- broker.shutdown();
- portAllocator.releasePort(port);
- }
-
- @Override
- public Queue createQueue(String name) throws AMQException {
- QpidUtil.createQueue(virtualHost, ExchangeDefaults.DIRECT_EXCHANGE_NAME, name);
- return new AMQQueue(ExchangeDefaults.DIRECT_EXCHANGE_NAME, name);
- }
-
- @Override
- public Topic createTopic(String name) throws AMQException {
- QpidUtil.createQueue(virtualHost, ExchangeDefaults.TOPIC_EXCHANGE_NAME, name);
- return new AMQTopic(ExchangeDefaults.TOPIC_EXCHANGE_NAME, name);
- }
-
- @Override
- public void deleteDestination(Destination destination) throws Exception {
- QpidUtil.deleteQueue(virtualHost, ((AMQDestination)destination).getRoutingKey().asString());
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java
deleted file mode 100644
index 7255fd1..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.jms;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.AMQQueueFactory;
-import org.apache.qpid.server.queue.QueueRegistry;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-
-public class QpidUtil {
- private QpidUtil() {}
-
- public static void createQueue(VirtualHost virtualHost, AMQShortString exchangeName, String name) throws AMQException {
- QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
- if (queueRegistry.getQueue(name) != null) {
- throw new IllegalStateException("Queue " + name + " already exists");
- }
- AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateQueueUUID(name, virtualHost.getName()), name, false, null, false, false, virtualHost, null);
- queueRegistry.registerQueue(queue);
- virtualHost.getBindingFactory().addBinding(name, queue, virtualHost.getExchangeRegistry().getExchange(exchangeName), null);
- }
-
- public static void deleteQueue(VirtualHost virtualHost, String name) throws AMQException {
- AMQShortString _name = new AMQShortString(name);
- AMQQueue queue = virtualHost.getQueueRegistry().getQueue(_name);
- if (queue == null) {
- throw new IllegalArgumentException("Queue " + name + " doesn't exist");
- }
- queue.delete();
- }
-}
diff --git a/modules/jms/src/test/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleTest.java b/modules/jms/src/test/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleTest.java
deleted file mode 100644
index 144010f..0000000
--- a/modules/jms/src/test/java/org/apache/axis2/transport/jms/ctype/ContentTypeRuleTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.transport.jms.ctype;
-
-import java.io.InputStream;
-
-import javax.jms.Message;
-
-import junit.framework.TestCase;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.deployment.ServiceBuilder;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.mockejb.jms.BytesMessageImpl;
-import org.mockejb.jms.ObjectMessageImpl;
-import org.mockejb.jms.TextMessageImpl;
-
-public class ContentTypeRuleTest extends TestCase {
- private ContentTypeRuleSet ruleSet;
-
- @Override
- public void setUp() throws Exception {
- AxisConfiguration axisCfg = new AxisConfiguration();
- ConfigurationContext cfgCtx = new ConfigurationContext(axisCfg);
- AxisService service = new AxisService();
-
- InputStream in = ContentTypeRuleTest.class.getResourceAsStream(getName() + ".xml");
- try {
- OMElement element = new StAXOMBuilder(in).getDocumentElement();
- new ServiceBuilder(cfgCtx, service).populateService(element);
- } finally {
- in.close();
- }
-
- ruleSet = ContentTypeRuleFactory.parse(service.getParameter("test"));
- }
-
- private void assertContentTypeInfo(String propertyName, String contentType, Message message)
- throws Exception {
-
- ContentTypeInfo contentTypeInfo = ruleSet.getContentTypeInfo(message);
- assertEquals(propertyName, contentTypeInfo.getPropertyName());
- assertEquals(contentType, contentTypeInfo.getContentType());
- }
-
- public void test1() throws Exception {
- Message message = new BytesMessageImpl();
- message.setStringProperty("contentType", "application/xml");
- assertContentTypeInfo("contentType", "application/xml", message);
-
- assertContentTypeInfo(null, "text/plain", new TextMessageImpl());
- assertContentTypeInfo(null, "application/octet-stream", new BytesMessageImpl());
- assertEquals(null, ruleSet.getContentTypeInfo(new ObjectMessageImpl()));
- }
-
- public void test2() throws Exception {
- Message message = new BytesMessageImpl();
- message.setStringProperty("contentType", "application/xml");
- assertContentTypeInfo("contentType", "application/xml", message);
-
- message = new TextMessageImpl();
- message.setStringProperty("ctype", "application/xml");
- assertContentTypeInfo("ctype", "application/xml", message);
-
- assertContentTypeInfo(null, "text/xml", new TextMessageImpl());
- assertContentTypeInfo(null, "text/xml", new BytesMessageImpl());
- }
-}
diff --git a/modules/jms/src/test/resources/META-INF/aop.xml b/modules/jms/src/test/resources/META-INF/aop.xml
deleted file mode 100644
index 49f787f..0000000
--- a/modules/jms/src/test/resources/META-INF/aop.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<aspectj>
- <aspects>
- <aspect name="org.apache.axis2.transport.jms.LogAspect"/>
- </aspects>
- <weaver options="-showWeaveInfo">
- <include within="org.apache.axis2.transport..*"/>
- </weaver>
-</aspectj>
diff --git a/modules/jms/src/test/resources/org/apache/axis2/transport/jms/ctype/test1.xml b/modules/jms/src/test/resources/org/apache/axis2/transport/jms/ctype/test1.xml
deleted file mode 100644
index 3f887de..0000000
--- a/modules/jms/src/test/resources/org/apache/axis2/transport/jms/ctype/test1.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<service>
- <parameter name="test">
- <rules>
- <jmsProperty>contentType</jmsProperty>
- <textMessage>text/plain</textMessage>
- <bytesMessage>application/octet-stream</bytesMessage>
- </rules>
- </parameter>
-</service>
\ No newline at end of file
diff --git a/modules/jms/src/test/resources/org/apache/axis2/transport/jms/ctype/test2.xml b/modules/jms/src/test/resources/org/apache/axis2/transport/jms/ctype/test2.xml
deleted file mode 100644
index 4631cca..0000000
--- a/modules/jms/src/test/resources/org/apache/axis2/transport/jms/ctype/test2.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<service>
- <parameter name="test">
- <rules>
- <jmsProperty>contentType</jmsProperty>
- <jmsProperty>ctype</jmsProperty>
- <default>text/xml</default>
- </rules>
- </parameter>
-</service>
\ No newline at end of file
diff --git a/modules/mail/pom.xml b/modules/mail/pom.xml
deleted file mode 100644
index 38e1339..0000000
--- a/modules/mail/pom.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transports</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-mail</artifactId>
- <name>Apache Axis2 - Transport - Mail</name>
- <description>Apache Axis2 - Mail Transport</description>
- <packaging>bundle</packaging>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/mail</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/mail</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/mail</url>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
- <Bundle-Description>${project.description}</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.apache.axis2.transport.mail.*;-split-package:=merge-last,
- </Export-Package>
- <Import-Package>
- !javax.xml.namespace,
- javax.xml.namespace; version=0.0.0,
- *; resolution:=optional
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.0</version>
- <executions>
- <execution>
- <id>copy</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <stripVersion>true</stripVersion>
- <artifactItems>
- <artifactItem>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjweaver</artifactId>
- <outputDirectory>target/lib</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>log4j.configuration</name>
- <value>file:../../log4j.properties</value>
- </property>
- <property>
- <name>net.sourceforge.cobertura.datafile</name>
- <value>target/cobertura.ser</value>
- </property>
- </systemProperties>
- <argLine>-javaagent:target/lib/aspectjweaver.jar -Xms64m -Xmx128m</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <!-- We want to choose the JavaMail implementation ourselves -->
- <exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-javamail_1.4_spec</artifactId>
- </exclusion>
- </exclusions>
-
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-testkit</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <exclusions>
- <!-- We want to choose the JavaMail implementation ourselves -->
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.icegreen</groupId>
- <artifactId>greenmail</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- <exclusions>
- <!-- We want to choose the JavaMail implementation ourselves -->
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-</project>
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/LogWriter.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/LogWriter.java
deleted file mode 100644
index 0e9a432..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/LogWriter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-
-/**
- * {@link Writer} implementation that redirects to a logger.
- */
-public class LogWriter extends Writer {
- private final Log log;
- private final String endOfLine;
- private final StringBuffer lineBuffer = new StringBuffer();
- private int endOfLineMatch;
-
- public LogWriter(Log log, String endOfLine) {
- this.log = log;
- this.endOfLine = endOfLine;
- }
-
- public LogWriter(Log log) {
- this(log, System.getProperty("line.separator"));
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) {
- int start = off;
- for (int i=off; i<off+len; i++) {
- if (cbuf[i] == endOfLine.charAt(endOfLineMatch)) {
- endOfLineMatch++;
- if (endOfLineMatch == endOfLine.length()) {
- lineBuffer.append(cbuf, start, i-start+1);
- lineBuffer.setLength(lineBuffer.length()-endOfLine.length());
- flushLineBuffer();
- start = i+1;
- endOfLineMatch = 0;
- }
- } else {
- endOfLineMatch = 0;
- }
- }
- lineBuffer.append(cbuf, start, off+len-start);
- }
-
- @Override
- public void close() {
- if (lineBuffer.length() > 0) {
- flushLineBuffer();
- }
- }
-
- @Override
- public void flush() {
- // Nothing to do
- }
-
- private void flushLineBuffer() {
- log.info(lineBuffer.toString());
- lineBuffer.setLength(0);
- }
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java
deleted file mode 100644
index f2ef861..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import javax.mail.Session;
-
-public class MailConstants {
-
- public static final String TRANSPORT_NAME = "mailto";
- public static final String TRANSPORT_PREFIX = "mailto:";
-
- public static final String TEXT_PLAIN = "text/plain";
- public static final String APPLICATION_BINARY = "application/binary";
-
- public static String DEFAULT_FOLDER = "INBOX";
- public static final String MAIL_POP3 = "pop3";
- public static final String MAIL_IMAP = "imap";
-
- public static final String TRANSPORT_MAIL_ACTION_AFTER_PROCESS = "transport.mail.ActionAfterProcess";
- public static final String TRANSPORT_MAIL_ACTION_AFTER_FAILURE = "transport.mail.ActionAfterFailure";
-
- public static final String TRANSPORT_MAIL_MOVE_AFTER_PROCESS = "transport.mail.MoveAfterProcess";
- public static final String TRANSPORT_MAIL_MOVE_AFTER_FAILURE = "transport.mail.MoveAfterFailure";
-
- public static final String TRANSPORT_MAIL_PROCESS_IN_PARALLEL = "transport.mail.ProcessInParallel";
-
- public static final String MAX_RETRY_COUNT = "transport.mail.MaxRetryCount";
- public static final String RECONNECT_TIMEOUT = "transport.mail.ReconnectTimeout";
-
- public static final int DEFAULT_MAX_RETRY_COUNT = 3;
- public static final long DEFAULT_RECONNECT_TIMEOUT = 30000;
-
- public static final String TRANSPORT_MAIL_ADDRESS = "transport.mail.Address";
-
- public static final String TRANSPORT_MAIL_DEBUG = "transport.mail.Debug";
-
- /**
- * Key for the mail store protocol parameter.
- * The mail store protocol identifier is used in calls to {@link Session#getStore()}.
- */
- public static final String TRANSPORT_MAIL_PROTOCOL = "transport.mail.Protocol";
-
- public static final String TRANSPORT_MAIL_FORMAT = "transport.mail.Format";
- public static final String TRANSPORT_FORMAT_TEXT = "Text";
- public static final String TRANSPORT_FORMAT_MP = "Multipart";
- public static final String TRANSPORT_FORMAT_ATTACHMENT = "Attachment";
- public static final String TRANSPORT_FORMAT_ATTACHMENT_FILE = "AttachmentFile";
-
- public static final String TRANSPORT_MAIL_FOLDER = "transport.mail.Folder";
- public static final String TRANSPORT_MAIL_CONTENT_TYPE = "transport.mail.ContentType";
- public static final String TRANSPORT_MAIL_REPLY_ADDRESS = "transport.mail.ReplyAddress";
-
- public static final String TRANSPORT_MAIL_PRESERVE_HEADERS = "transport.mail.PreserveHeaders";
- public static final String TRANSPORT_MAIL_REMOVE_HEADERS = "transport.mail.RemoveHeaders";
-
- // POP3 and IMAP properties
- public static final String MAIL_POP3_USERNAME = "mail.pop3.user";
- public static final String MAIL_POP3_PASSWORD = "mail.pop3.password";
- public static final String MAIL_IMAP_USERNAME = "mail.imap.user";
- public static final String MAIL_IMAP_PASSWORD = "mail.imap.password";
-
- // SMTP properties
- public static final String MAIL_SMTP_FROM = "mail.smtp.from";
- public static final String MAIL_SMTP_USERNAME = "mail.smtp.user";
- public static final String MAIL_SMTP_PASSWORD = "mail.smtp.password";
- public static final String MAIL_SMTP_BCC = "transport.mail.SMTPBccAddresses";
-
- // transport / mail headers
- public static final String MAIL_HEADER_TO = "To";
- public static final String MAIL_HEADER_FROM = "From";
- public static final String MAIL_HEADER_CC = "Cc";
- public static final String MAIL_HEADER_BCC = "Bcc";
- public static final String MAIL_HEADER_REPLY_TO = "Reply-To";
- public static final String MAIL_HEADER_IN_REPLY_TO = "In-Reply-To";
- public static final String MAIL_HEADER_SUBJECT = "Subject";
- public static final String MAIL_HEADER_MESSAGE_ID = "Message-ID";
- public static final String MAIL_HEADER_REFERENCES = "References";
-
- // Custom headers
- /** @see org.apache.axis2.transport.mail.WSMimeMessage */
- public static final String MAIL_HEADER_X_MESSAGE_ID= "X-Message-ID";
- public static final String TRANSPORT_MAIL_CUSTOM_HEADERS = "transport.mail.custom.headers";
-
- public static final String MAIL_SENT_DATE = "sent-date";
- public static final String MAIL_RECEIVED_DATE = "received-date";
-
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailOutTransportInfo.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailOutTransportInfo.java
deleted file mode 100644
index efcb089..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailOutTransportInfo.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import org.apache.axis2.transport.OutTransportInfo;
-
-import javax.mail.internet.InternetAddress;
-
-/**
- * The Mail OutTransportInfo is a holder of information to send an outgoing message
- * (e.g. a Response or a request) to a Mail destination. Thus at a minimum a
- * destination email address is held
- */
-public class MailOutTransportInfo implements OutTransportInfo {
-
- /** The address of the destination */
- private InternetAddress[] targetAddresses = null;
- /** The address of the service that is replying */
- private InternetAddress fromAddress = null;
- /** A list of email addresses to which the reply must be copied */
- private InternetAddress[] ccAddresses = null;
- /** The subject for the reply message */
- private String subject = null;
- /** The message ID of the request message, when this refers to a reply to it */
- private String requestMessageID = null;
-
- MailOutTransportInfo(InternetAddress fromAddress) {
- this.fromAddress = fromAddress;
- }
-
- public void setContentType(String contentType) {
- }
-
- public InternetAddress[] getTargetAddresses() {
- return targetAddresses;
- }
-
- public void setTargetAddresses(InternetAddress[] targetAddresses) {
- this.targetAddresses = targetAddresses;
- }
-
- public InternetAddress getFromAddress() {
- return fromAddress;
- }
-
- public InternetAddress[] getCcAddresses() {
- return ccAddresses;
- }
-
- public void setCcAddresses(InternetAddress[] ccAddresses) {
- this.ccAddresses = ccAddresses;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public void setSubject(String subject) {
- this.subject = subject;
- }
-
- public String getRequestMessageID() {
- return requestMessageID;
- }
-
- public void setRequestMessageID(String requestMessageID) {
- this.requestMessageID = requestMessageID;
- }
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailRequestResponseTransport.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailRequestResponseTransport.java
deleted file mode 100644
index 7c19f4f..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailRequestResponseTransport.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.transport.mail;
-
-import org.apache.axis2.transport.RequestResponseTransport;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.AxisFault;
-
-/**
- * this class is not generally used with the SMTP transport. this is added to work
- * this smtp transport with Sandesah2.
- */
-
-public class MailRequestResponseTransport implements RequestResponseTransport {
-
- RequestResponseTransportStatus status = RequestResponseTransportStatus.WAITING;
-
- public void acknowledgeMessage(MessageContext messageContext) throws AxisFault {
- }
-
- public void awaitResponse() throws InterruptedException, AxisFault {
- }
-
- public void signalResponseReady() {
- }
-
- public void signalFaultReady(AxisFault axisFault) {
- }
-
- public RequestResponseTransportStatus getStatus() {
- return status;
- }
-
- public boolean isResponseWritten() {
- return false;
- }
-
- public void setResponseWritten(boolean b) {
- }
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
deleted file mode 100644
index bfa31d7..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.transport.RequestResponseTransport;
-import org.apache.axis2.transport.base.AbstractPollingTransportListener;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.ManagementSupport;
-import org.apache.axis2.transport.base.event.TransportErrorListener;
-import org.apache.axis2.transport.base.event.TransportErrorSource;
-import org.apache.axis2.transport.base.event.TransportErrorSourceSupport;
-
-import javax.mail.*;
-import javax.mail.internet.ContentType;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.ParseException;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-import java.lang.reflect.Method;
-
-/**
- * This mail transport lister implementation uses the base transport framework and is a polling
- * transport. i.e. a service can register itself with custom a custom mail configuration (i.e.
- * pop3 or imap) and specify its polling duration, and what action to be taken after processing
- * messages. The transport always deletes processed mails from the folder they were fetched from
- * and can be configured to be optionally moved to a different folder, if the server supports it
- * (e.g. with imap). When checking for new mail, the transport ignores messages already flaged as
- * SEEN and DELETED
- */
-
-public class MailTransportListener extends AbstractPollingTransportListener<PollTableEntry>
- implements ManagementSupport, TransportErrorSource {
-
- public static final String DELETE = "DELETE";
- public static final String MOVE = "MOVE";
-
- private final TransportErrorSourceSupport tess = new TransportErrorSourceSupport(this);
-
- @Override
- protected void doInit() throws AxisFault {
- super.doInit();
- // set the synchronise callback table
- if (cfgCtx.getProperty(BaseConstants.CALLBACK_TABLE) == null){
- cfgCtx.setProperty(BaseConstants.CALLBACK_TABLE, new ConcurrentHashMap());
- }
- }
-
- @Override
- protected void poll(PollTableEntry entry) {
- checkMail(entry, entry.getEmailAddress());
- }
-
- /**
- * Check mail for a particular service that has registered with the mail transport
- *
- * @param entry the poll table entry that stores service specific informaiton
- * @param emailAddress the email address checked
- */
- private void checkMail(final PollTableEntry entry, InternetAddress emailAddress) {
-
- if (log.isDebugEnabled()) {
- log.debug("Checking mail for account : " + emailAddress);
- }
-
- boolean connected = false;
- int retryCount = 0;
- int maxRetryCount = entry.getMaxRetryCount();
- long reconnectionTimeout = entry.getReconnectTimeout();
- Session session = entry.getSession();
- Store store = null;
- Folder folder = null;
- boolean mailProcessingStarted = false;
-
- while (!connected) {
- try {
- retryCount++;
- if (log.isDebugEnabled()) {
- log.debug("Attempting to connect to POP3/IMAP server for : " +
- entry.getEmailAddress() + " using " + session.getProperties());
- }
-
- store = session.getStore(entry.getProtocol());
-
- if (entry.getUserName() != null && entry.getPassword() != null) {
- store.connect(entry.getUserName(), entry.getPassword());
- } else {
- handleException("Unable to locate username and password for mail login", null);
- }
-
- // were we able to connect?
- connected = store.isConnected();
-
- if (connected) {
- if (entry.getFolder() != null) {
- folder = store.getFolder(entry.getFolder());
- } else {
- folder = store.getFolder(MailConstants.DEFAULT_FOLDER);
- }
- if (folder == null) {
- folder = store.getDefaultFolder();
- }
- }
-
- } catch (Exception e) {
- log.error("Error connecting to mail server for address : " + emailAddress, e);
- if (maxRetryCount <= retryCount) {
- processFailure("Error connecting to mail server for address : " +
- emailAddress + " :: " + e.getMessage(), e, entry);
- return;
- }
- }
-
- if (!connected) {
- try {
- log.warn("Connection to mail server for account : " + entry.getEmailAddress() +
- " failed. Retrying in : " + reconnectionTimeout / 1000 + " seconds");
- Thread.sleep(reconnectionTimeout);
- } catch (InterruptedException ignore) {
- }
- }
- }
-
- if (connected && folder != null) {
-
- CountDownLatch latch = null;
- Runnable onCompletion = new MailCheckCompletionTask(folder, store, emailAddress, entry);
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("Connecting to folder : " + folder.getName() +
- " of email account : " + emailAddress);
- }
-
- folder.open(Folder.READ_WRITE);
- int total = folder.getMessageCount();
- Message[] messages = folder.getMessages();
-
- if (log.isDebugEnabled()) {
- log.debug(messages.length + " messgaes in folder : " + folder);
- }
-
- latch = new CountDownLatch(total);
- for (int i = 0; i < total; i++) {
-
- try {
- String[] status = messages[i].getHeader("Status");
- if (status != null && status.length == 1 && status[0].equals("RO")) {
- // some times the mail server sends a special mail message which is
- // not relavent in processing. ignore this message.
- if (log.isDebugEnabled()) {
- log.debug("Skipping message # : " + messages[i].getMessageNumber()
- + " : " + messages[i].getSubject() + " - Status: RO");
- }
- latch.countDown();
- } else if (messages[i].isSet(Flags.Flag.SEEN)) {
- if (log.isDebugEnabled()) {
- log.debug("Skipping message # : " + messages[i].getMessageNumber()
- + " : " + messages[i].getSubject() + " - already marked SEEN");
- }
- latch.countDown();
- } else if (messages[i].isSet(Flags.Flag.DELETED)) {
- if (log.isDebugEnabled()) {
- log.debug("Skipping message # : " + messages[i].getMessageNumber()
- + " : " + messages[i].getSubject() + " - already marked DELETED");
- }
- latch.countDown();
-
- } else {
- processMail(entry, folder, store, messages[i], latch, onCompletion);
- mailProcessingStarted = true;
- }
- } catch (MessageRemovedException ignore) {
- // while reading the meta information, this mail was deleted, thats ok
- if (log.isDebugEnabled()) {
- log.debug("Skipping message # : " + messages[i].getMessageNumber() +
- " as it has been DELETED by another thread after processing");
- }
- latch.countDown();
- }
- }
-
- if (!mailProcessingStarted) {
- // if we didnt process any mail in this run, the onCompletion will not
- // run from the mail processor by default
- onCompletion.run();
- }
-
- } catch (MessagingException me) {
- processFailure("Error checking mail for account : " +
- emailAddress + " :: " + me.getMessage(), me, entry);
- }
-
- } else {
- processFailure("Unable to access mail folder", null, entry);
- }
- }
-
- /**
- * Invoke the actual message processor in the current thread or another worker thread
- * @param entry PolltableEntry
- * @param folder mail folder
- * @param store mail store, to move or delete after processing
- * @param message message to process
- * @param pos the message position seen initially
- * @param mp the MailProcessor object
- * @param latch the completion latch to notify
- * @param onCompletion the tasks to run on the completion of mail processing
- */
- private void processMail(PollTableEntry entry, Folder folder, Store store, Message message,
- CountDownLatch latch, Runnable onCompletion) {
-
- MailProcessor mp = new MailProcessor(entry, message, store, folder, latch, onCompletion);
-
- // should messages be processed in parallel?
- if (entry.isConcurrentPollingAllowed()) {
-
- // try to locate the UID of the message
- String uid = getMessageUID(folder, message);
-
- if (uid != null) {
- if (entry.isProcessingUID(uid)) {
- if (log.isDebugEnabled()) {
- log.debug("Skipping message # : " + message.getMessageNumber() + " : UIDL " +
- uid + " - already being processed by another thread");
- }
- latch.countDown();
-
- } else {
- entry.processingUID(uid);
- mp.setUID(uid);
-
- if (entry.isProcessingMailInParallel()) {
- if (log.isDebugEnabled()) {
- log.debug("Processing message # : " + message.getMessageNumber() +
- " with UID : " + uid + " with a worker thread");
- }
- workerPool.execute(mp);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Processing message # : " + message.getMessageNumber() +
- " with UID : " + uid + " in same thread");
- }
- mp.run();
- }
- }
- } else {
- log.warn("Cannot process mail in parallel as the " +
- "folder does not support UIDs. Processing message # : " +
- message.getMessageNumber() + " in the same thread");
- entry.setConcurrentPollingAllowed(false);
- mp.run();
- }
-
- } else {
- if (entry.isProcessingMailInParallel()) {
- if (log.isDebugEnabled()) {
- log.debug("Processing message # : " + message.getMessageNumber() +
- " with a worker thread");
- }
- workerPool.execute(mp);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Processing message # : " + message.getMessageNumber() + " in same thread");
- }
- mp.run();
- }
- }
- }
-
- /**
- * Handle processing of a message, possibly in a new thread
- */
- private class MailProcessor implements Runnable {
-
- private PollTableEntry entry = null;
- private Message message = null;
- private Store store = null;
- private Folder folder = null;
- private String uid = null;
- private CountDownLatch doneSignal = null;
- private Runnable onCompletion = null;
-
- MailProcessor(PollTableEntry entry, Message message, Store store, Folder folder,
- CountDownLatch doneSignal, Runnable onCompletion) {
- this.entry = entry;
- this.message = message;
- this.store = store;
- this.folder = folder;
- this.doneSignal = doneSignal;
- this.onCompletion = onCompletion;
- }
-
- public void setUID(String uid) {
- this.uid = uid;
- }
-
- public void run() {
-
- entry.setLastPollState(PollTableEntry.NONE);
- try {
- processMail(message, entry);
- entry.setLastPollState(PollTableEntry.SUCCSESSFUL);
- metrics.incrementMessagesReceived();
-
- } catch (Exception e) {
- log.error("Failed to process message", e);
- entry.setLastPollState(PollTableEntry.FAILED);
- metrics.incrementFaultsReceiving();
- tess.error(entry.getService(), e);
-
- } finally {
- if (uid != null) {
- entry.removeUID(uid);
- }
- }
- try {
- moveOrDeleteAfterProcessing(entry, store, folder, message);
- } catch (Exception e) {
- log.error("Failed to move or delete email message", e);
- tess.error(entry.getService(), e);
- }
-
- doneSignal.countDown();
-
- if (doneSignal.getCount() == 0) {
- onCompletion.run();
- }
- }
- }
-
- /**
- * Handle optional logic of the mail transport, that needs to happen once all messages in
- * a check mail cycle has ended.
- */
- private class MailCheckCompletionTask implements Runnable {
- private final Folder folder;
- private final Store store;
- private final InternetAddress emailAddress;
- private final PollTableEntry entry;
- private boolean taskStarted = false;
-
- public MailCheckCompletionTask(Folder folder, Store store,
- InternetAddress emailAddress, PollTableEntry entry) {
- this.folder = folder;
- this.store = store;
- this.emailAddress = emailAddress;
- this.entry = entry;
- }
-
- public void run() {
- synchronized(this) {
- if (taskStarted) {
- return;
- } else {
- taskStarted = true;
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Executing onCompletion task for the mail download of : " + emailAddress);
- }
-
- if (folder != null) {
- try {
- folder.close(true /** expunge messages flagged as DELETED*/);
- if (log.isDebugEnabled()) {
- log.debug("Mail folder closed, and deleted mail expunged");
- }
- } catch (MessagingException e) {
- log.warn("Error closing mail folder : " +
- folder + " for account : " + emailAddress + " :: "+ e.getMessage());
- }
- }
-
- if (store != null) {
- try {
- store.close();
- if (log.isDebugEnabled()) {
- log.debug("Mail store closed for : " + emailAddress);
- }
- } catch (MessagingException e) {
- log.warn("Error closing mail store for account : " +
- emailAddress + " :: " + e.getMessage(), e);
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Scheduling next poll for : " + emailAddress);
- }
- onPollCompletion(entry);
- }
- }
-
- /**
- * Process a mail message through Axis2
- *
- * @param message the email message
- * @param entry the poll table entry
- * @throws MessagingException on error
- * @throws IOException on error
- */
- private void processMail(Message message, PollTableEntry entry)
- throws MessagingException, IOException {
-
- updateMetrics(message);
-
- // populate transport headers using the mail headers
- Map trpHeaders = getTransportHeaders(message, entry);
-
- // Allow the content type to be overridden by configuration.
- String contentType = entry.getContentType();
- Part messagePart;
- if (contentType != null) {
- messagePart = message;
- } else {
- messagePart = getMessagePart(message, cfgCtx.getAxisConfiguration());
- contentType = messagePart.getContentType();
- }
-
- // FIXME: remove this ugly hack when Axis2 has learned that content types are case insensitive...
- int idx = contentType.indexOf(';');
- if (idx == -1) {
- contentType = contentType.toLowerCase();
- } else {
- contentType = contentType.substring(0, idx).toLowerCase() + contentType.substring(idx);
- }
-
- // if the content type was not found, we have an error
- if (contentType == null) {
- processFailure("Unable to determine Content-type for message : " +
- message.getMessageNumber() + " :: " + message.getSubject(), null, entry);
- return;
- } else if (log.isDebugEnabled()) {
- log.debug("Processing message as Content-Type : " + contentType);
- }
-
- MessageContext msgContext = entry.createMessageContext();
-
- // Extract the charset encoding from the configured content type and
- // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
- String charSetEnc;
- try {
- charSetEnc = new ContentType(contentType).getParameter("charset");
- } catch (ParseException ex) {
- // ignore
- charSetEnc = null;
- }
- msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
-
- MailOutTransportInfo outInfo = buildOutTransportInfo(message, entry);
-
- // save out transport information
- msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outInfo);
- // this property only useful for supporting smtp with Sandesha2.
- msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL, new MailRequestResponseTransport());
-
- // set message context From
- if (outInfo.getFromAddress() != null) {
- msgContext.setFrom(
- new EndpointReference(MailConstants.TRANSPORT_PREFIX +
- outInfo.getFromAddress().getAddress()));
- }
-
- // save original mail message id message context MessageID
- msgContext.setMessageID(outInfo.getRequestMessageID());
-
- //Set the Sent date and received date.
- if(message.getSentDate() != null) {
- Calendar sentDate = Calendar.getInstance();
- sentDate.setTime(message.getSentDate());
- msgContext.setProperty(MailConstants.MAIL_SENT_DATE,sentDate);
- }
-
- msgContext.setProperty(MailConstants.MAIL_RECEIVED_DATE,Calendar.getInstance());
-
- // set the message payload to the message context
- InputStream in = messagePart.getInputStream();
- try {
- try {
- msgContext.setEnvelope(TransportUtils.createSOAPMessage(msgContext, in, contentType));
- } catch (XMLStreamException ex) {
- handleException("Error parsing message", ex);
- }
-
- String soapAction = (String) trpHeaders.get(BaseConstants.SOAPACTION);
- if (soapAction == null && message.getSubject() != null &&
- message.getSubject().startsWith(BaseConstants.SOAPACTION)) {
- soapAction = message.getSubject().substring(BaseConstants.SOAPACTION.length());
- if (soapAction.startsWith(":")) {
- soapAction = soapAction.substring(1).trim();
- }
- }
-
- handleIncomingMessage(
- msgContext,
- trpHeaders,
- soapAction,
- contentType
- );
- } finally {
- in.close();
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Processed message : " + message.getMessageNumber() +
- " :: " + message.getSubject());
- }
- }
-
- private void updateMetrics(Message message) throws IOException, MessagingException {
- if (message instanceof MimeMessage) {
- MimeMessage mimeMessage = (MimeMessage) message;
- if (mimeMessage.getContent() instanceof Multipart) {
- Multipart mp = (Multipart) mimeMessage.getContent();
- for (int i=0; i<mp.getCount(); i++) {
- MimeBodyPart mbp = (MimeBodyPart) mp.getBodyPart(i);
- int size = mbp.getSize();
- if (size != -1) {
- metrics.incrementBytesReceived(size);
- }
- }
- } else {
- int size = mimeMessage.getSize();
- if (size != -1) {
- metrics.incrementBytesReceived(size);
- }
- }
- }
- }
-
- private Map getTransportHeaders(Message message, PollTableEntry entry) {
-
- //use a comaprator to ignore the case for headers.
- Comparator comparator = new Comparator(){
- public int compare(Object o1, Object o2) {
- String string1 = (String) o1;
- String string2 = (String) o2;
- return string1.compareToIgnoreCase(string2);
- }
- };
-
- Map trpHeaders = new TreeMap(comparator);
- try {
- Enumeration e = message.getAllHeaders();
- while (e.hasMoreElements()) {
- Header h = (Header) e.nextElement();
- if (entry.retainHeader(h.getName())) {
- trpHeaders.put(h.getName(), h.getValue());
- }
- }
- } catch (MessagingException ignore) {}
- return trpHeaders;
- }
-
- /**
- * Extract the part from the mail that contains the message to be processed.
- * This method supports multipart/mixed messages that contain a text/plain
- * part alongside the message.
- *
- * @param message
- * @return
- * @throws MessagingException
- * @throws IOException
- */
- private Part getMessagePart(Message message, AxisConfiguration axisCfg)
- throws MessagingException, IOException {
-
- ContentType contentType = new ContentType(message.getContentType());
- if (contentType.getBaseType().equalsIgnoreCase("multipart/mixed")) {
- Multipart multipart = (Multipart)message.getContent();
- Part textMainPart = null;
- for (int i=0; i<multipart.getCount(); i++) {
- MimeBodyPart bodyPart = (MimeBodyPart)multipart.getBodyPart(i);
- ContentType partContentType = new ContentType(bodyPart.getContentType());
- if (axisCfg.getMessageBuilder(partContentType.getBaseType()) != null) {
- if (partContentType.getBaseType().equalsIgnoreCase("text/plain")) {
- // If it's a text/plain part, remember it. We will return
- // it later if we don't find something more interesting.
- textMainPart = bodyPart;
- } else {
- return bodyPart;
- }
- }
- }
- if (textMainPart != null) {
- return textMainPart;
- } else {
- // We have nothing else to return!
- return message;
- }
- } else {
- return message;
- }
- }
-
- private MailOutTransportInfo buildOutTransportInfo(Message message,
- PollTableEntry entry) throws MessagingException {
- MailOutTransportInfo outInfo = new MailOutTransportInfo(entry.getEmailAddress());
-
- // determine reply address
- if (message.getReplyTo() != null) {
- outInfo.setTargetAddresses((InternetAddress[]) message.getReplyTo());
- } else if (message.getFrom() != null) {
- outInfo.setTargetAddresses((InternetAddress[]) message.getFrom());
- } else {
- // does the service specify a default reply address ?
- InternetAddress replyAddress = entry.getReplyAddress();
- if (replyAddress != null) {
- outInfo.setTargetAddresses(new InternetAddress[] { replyAddress });
- }
- }
-
- // save CC addresses
- if (message.getRecipients(Message.RecipientType.CC) != null) {
- outInfo.setCcAddresses(
- (InternetAddress[]) message.getRecipients(Message.RecipientType.CC));
- }
-
- // determine and subject for the reply message
- if (message.getSubject() != null) {
- outInfo.setSubject("Re: " + message.getSubject());
- }
-
- // save original message ID if one exists, so that replies can be correlated
- if (message.getHeader(MailConstants.MAIL_HEADER_X_MESSAGE_ID) != null) {
- outInfo.setRequestMessageID(message.getHeader(MailConstants.MAIL_HEADER_X_MESSAGE_ID)[0]);
- } else if (message instanceof MimeMessage && ((MimeMessage) message).getMessageID() != null) {
- outInfo.setRequestMessageID(((MimeMessage) message).getMessageID());
- }
- return outInfo;
- }
-
- /**
- * Take specified action to either move or delete the processed email
- *
- * @param entry the PollTableEntry for the email that has been processed
- * @param store the mail store
- * @param folder mail folder
- * @param message the email message to be moved or deleted
- */
- private void moveOrDeleteAfterProcessing(final PollTableEntry entry, Store store,
- Folder folder, Message message) {
-
- String moveToFolder = null;
- try {
- switch (entry.getLastPollState()) {
- case PollTableEntry.SUCCSESSFUL:
- if (entry.getActionAfterProcess() == PollTableEntry.MOVE) {
- moveToFolder = entry.getMoveAfterProcess();
- }
- break;
-
- case PollTableEntry.FAILED:
- if (entry.getActionAfterFailure() == PollTableEntry.MOVE) {
- moveToFolder = entry.getMoveAfterFailure();
- }
- break;
- case PollTableEntry.NONE:
- return;
- }
-
- if (moveToFolder != null) {
- if (log.isDebugEnabled()) {
- log.debug("Moving processed email to folder :" + moveToFolder);
- }
- Folder dFolder = store.getFolder(moveToFolder);
- if (!dFolder.exists()) {
- dFolder.create(Folder.HOLDS_MESSAGES);
- }
- folder.copyMessages(new Message[]{message}, dFolder);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Deleting email :" + message.getMessageNumber());
- }
-
- message.setFlag(Flags.Flag.DELETED, true);
-
- } catch (MessagingException e) {
- log.error("Error deleting or resolving folder to move after processing : "
- + moveToFolder, e);
- }
- }
-
- @Override
- protected PollTableEntry createEndpoint() {
- return new PollTableEntry(log);
- }
-
- public void addErrorListener(TransportErrorListener listener) {
- tess.addErrorListener(listener);
- }
-
- public void removeErrorListener(TransportErrorListener listener) {
- tess.removeErrorListener(listener);
- }
-
- /**
- * Return the UID of a message from the given folder
- * @param folder the POP3 or IMAP folder
- * @param message the message
- * @return UID as a String (long is converted to a String) or null
- */
- private String getMessageUID(Folder folder, Message message) {
- String uid = null;
- if (folder instanceof UIDFolder) {
- try {
- uid = Long.toString(((UIDFolder) folder).getUID(message));
- } catch (MessagingException ignore) {}
- } else {
- try {
- Method m = folder.getClass().getMethod(
- "getUID", Message.class);
- Object o = m.invoke(folder, new Object[]{message});
- if (o != null && o instanceof Long) {
- uid = Long.toString((Long) o);
- } else if (o != null && o instanceof String) {
- uid = (String) o;
- }
- } catch (Exception ignore) {}
- }
- return uid;
- }
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java
deleted file mode 100644
index a85317a..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import org.apache.axis2.format.MessageFormatterEx;
-import org.apache.axis2.format.MessageFormatterExAdapter;
-import org.apache.axis2.transport.base.*;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.*;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.util.CommonUtils;
-
-import javax.mail.*;
-import javax.mail.internet.*;
-import javax.activation.DataHandler;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.io.IOException;
-
-/**
- * The mail transport sender sends mail using an SMTP server configuration defined
- * in the axis2.xml's transport sender definition
- */
-
-public class MailTransportSender extends AbstractTransportSender
- implements ManagementSupport {
-
- private String smtpUsername = null;
- private String smtpPassword = null;
- /** Default from address for outgoing messages */
- private InternetAddress smtpFromAddress = null;
- /** A set of custom Bcc address for all outgoing messages */
- private InternetAddress[] smtpBccAddresses = null;
- /** Default mail format */
- private String defaultMailFormat = "Text";
- /** The default Session which can be safely shared */
- private Session session = null;
-
- /**
- * The public constructor
- */
- public MailTransportSender() {
- log = LogFactory.getLog(MailTransportSender.class);
- }
-
- /**
- * Initialize the Mail sender and be ready to send messages
- * @param cfgCtx the axis2 configuration context
- * @param transportOut the transport-out description
- * @throws org.apache.axis2.AxisFault on error
- */
- public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
- super.init(cfgCtx, transportOut);
-
- // initialize SMTP session
- Properties props = new Properties();
- List<Parameter> params = transportOut.getParameters();
- for (Parameter p : params) {
- props.put(p.getName(), p.getValue());
- }
-
- if (props.containsKey(MailConstants.MAIL_SMTP_FROM)) {
- try {
- smtpFromAddress = new InternetAddress(
- (String) props.get(MailConstants.MAIL_SMTP_FROM));
- } catch (AddressException e) {
- handleException("Invalid default 'From' address : " +
- props.get(MailConstants.MAIL_SMTP_FROM), e);
- }
- }
-
- if (props.containsKey(MailConstants.MAIL_SMTP_BCC)) {
- try {
- smtpBccAddresses = InternetAddress.parse(
- (String) props.get(MailConstants.MAIL_SMTP_BCC));
- } catch (AddressException e) {
- handleException("Invalid default 'Bcc' address : " +
- props.get(MailConstants.MAIL_SMTP_BCC), e);
- }
- }
-
- if (props.containsKey(MailConstants.TRANSPORT_MAIL_FORMAT)) {
- defaultMailFormat = (String) props.get(MailConstants.TRANSPORT_MAIL_FORMAT);
- }
-
- smtpUsername = (String) props.get(MailConstants.MAIL_SMTP_USERNAME);
- smtpPassword = (String) props.get(MailConstants.MAIL_SMTP_PASSWORD);
-
- if (smtpUsername != null && smtpPassword != null) {
- session = Session.getInstance(props, new Authenticator() {
- public PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(smtpUsername, smtpPassword);
- }
- });
- } else {
- session = Session.getInstance(props, null);
- }
-
- MailUtils.setupLogging(session, log, transportOut);
-
- // set the synchronise callback table
- if (cfgCtx.getProperty(BaseConstants.CALLBACK_TABLE) == null){
- cfgCtx.setProperty(BaseConstants.CALLBACK_TABLE, new ConcurrentHashMap());
- }
- }
-
- /**
- * Send the given message over the Mail transport
- *
- * @param msgCtx the axis2 message context
- * @throws AxisFault on error
- */
- public void sendMessage(MessageContext msgCtx, String targetAddress,
- OutTransportInfo outTransportInfo) throws AxisFault {
-
- MailOutTransportInfo mailOutInfo = null;
-
- if (targetAddress != null) {
- if (targetAddress.startsWith(MailConstants.TRANSPORT_NAME)) {
- targetAddress = targetAddress.substring(MailConstants.TRANSPORT_NAME.length()+1);
- }
-
- if (msgCtx.getReplyTo() != null &&
- !AddressingConstants.Final.WSA_NONE_URI.equals(msgCtx.getReplyTo().getAddress()) &&
- !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(msgCtx.getReplyTo().getAddress())) {
-
- String replyTo = msgCtx.getReplyTo().getAddress();
- if (replyTo.startsWith(MailConstants.TRANSPORT_NAME)) {
- replyTo = replyTo.substring(MailConstants.TRANSPORT_NAME.length()+1);
- }
- try {
- mailOutInfo = new MailOutTransportInfo(new InternetAddress(replyTo));
- } catch (AddressException e) {
- handleException("Invalid reply address/es : " + replyTo, e);
- }
- } else {
- mailOutInfo = new MailOutTransportInfo(smtpFromAddress);
- }
-
- try {
- mailOutInfo.setTargetAddresses(InternetAddress.parse(targetAddress));
- } catch (AddressException e) {
- handleException("Invalid target address/es : " + targetAddress, e);
- }
- } else if (outTransportInfo != null && outTransportInfo instanceof MailOutTransportInfo) {
- mailOutInfo = (MailOutTransportInfo) outTransportInfo;
- }
-
- if (mailOutInfo != null) {
- try {
- String messageID = sendMail(mailOutInfo, msgCtx);
- // this is important in axis2 client side if the mail transport uses anonymous addressing
- // the sender have to wait util the response comes.
- if (!msgCtx.getOptions().isUseSeparateListener() && !msgCtx.isServerSide()){
- waitForReply(msgCtx, messageID);
- }
- } catch (MessagingException e) {
- handleException("Error generating mail message", e);
- } catch (IOException e) {
- handleException("Error generating mail message", e);
- }
- } else {
- handleException("Unable to determine out transport information to send message");
- }
- }
-
- private void waitForReply(MessageContext msgContext, String mailMessageID) throws AxisFault {
- // piggy back message constant is used to pass a piggy back
- // message context in asnych model
- if (!(msgContext.getAxisOperation() instanceof OutInAxisOperation) &&
- (msgContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null)) {
- return;
- }
-
- ConfigurationContext configContext = msgContext.getConfigurationContext();
- // if the mail message listner has not started we need to start it
- if (!configContext.getListenerManager().isListenerRunning(MailConstants.TRANSPORT_NAME)) {
- TransportInDescription mailTo =
- configContext.getAxisConfiguration().getTransportIn(MailConstants.TRANSPORT_NAME);
- if (mailTo == null) {
- handleException("Could not find the transport receiver for " +
- MailConstants.TRANSPORT_NAME);
- }
- configContext.getListenerManager().addListener(mailTo, false);
- }
-
- SynchronousCallback synchronousCallback = new SynchronousCallback(msgContext);
- Map callBackMap = (Map) msgContext.getConfigurationContext().
- getProperty(BaseConstants.CALLBACK_TABLE);
- callBackMap.put(mailMessageID, synchronousCallback);
- synchronized (synchronousCallback) {
- try {
- synchronousCallback.wait(msgContext.getOptions().getTimeOutInMilliSeconds());
- } catch (InterruptedException e) {
- handleException("Error occured while waiting ..", e);
- }
- }
-
- if (!synchronousCallback.isComplete()){
- // when timeout occurs remove this entry.
- callBackMap.remove(mailMessageID);
- handleException("Timeout while waiting for a response");
- }
- }
-
- /**
- * Populate email with a SOAP formatted message
- * @param outInfo the out transport information holder
- * @param msgContext the message context that holds the message to be written
- * @throws AxisFault on error
- * @return id of the send mail message
- */
- private String sendMail(MailOutTransportInfo outInfo, MessageContext msgContext)
- throws AxisFault, MessagingException, IOException {
-
- OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
- // Make sure that non textual attachements are sent with base64 transfer encoding
- // instead of binary.
- format.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS, true);
-
- MessageFormatter messageFormatter = BaseUtils.getMessageFormatter(msgContext);
-
- if (log.isDebugEnabled()) {
- log.debug("Creating MIME message using message formatter " +
- messageFormatter.getClass().getSimpleName());
- }
-
- WSMimeMessage message = null;
- if (outInfo.getFromAddress() != null) {
- message = new WSMimeMessage(session, outInfo.getFromAddress().getAddress());
- } else {
- message = new WSMimeMessage(session, "");
- }
-
-
- Map trpHeaders = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
- if (log.isDebugEnabled() && trpHeaders != null) {
- log.debug("Using transport headers: " + trpHeaders);
- }
-
- // set From address - first check if this is a reply, then use from address from the
- // transport out, else if any custom transport headers set on this message, or default
- // to the transport senders default From address
- if (outInfo.getTargetAddresses() != null && outInfo.getFromAddress() != null) {
- if (log.isDebugEnabled()) {
- log.debug("Setting From header to " + outInfo.getFromAddress().getAddress() +
- " from OutTransportInfo");
- }
- message.setFrom(outInfo.getFromAddress());
- message.setReplyTo((new Address []{outInfo.getFromAddress()}));
- } else if (trpHeaders != null && trpHeaders.containsKey(MailConstants.MAIL_HEADER_FROM)) {
- InternetAddress from =
- new InternetAddress((String) trpHeaders.get(MailConstants.MAIL_HEADER_FROM));
- if (log.isDebugEnabled()) {
- log.debug("Setting From header to " + from.getAddress() +
- " from transport headers");
- }
- message.setFrom(from);
- message.setReplyTo(new Address[] { from });
- } else {
- if (smtpFromAddress != null) {
- if (log.isDebugEnabled()) {
- log.debug("Setting From header to " + smtpFromAddress.getAddress() +
- " from transport configuration");
- }
- message.setFrom(smtpFromAddress);
- message.setReplyTo(new Address[] {smtpFromAddress});
- } else {
- handleException("From address for outgoing message cannot be determined");
- }
- }
-
- // set To address/es to any custom transport header set on the message, else use the reply
- // address from the out transport information
- if (trpHeaders != null && trpHeaders.containsKey(MailConstants.MAIL_HEADER_TO)) {
- Address[] to =
- InternetAddress.parse((String) trpHeaders.get(MailConstants.MAIL_HEADER_TO));
- if (log.isDebugEnabled()) {
- log.debug("Setting To header to " + InternetAddress.toString(to) +
- " from transport headers");
- }
- message.setRecipients(Message.RecipientType.TO, to);
- } else if (outInfo.getTargetAddresses() != null) {
- if (log.isDebugEnabled()) {
- log.debug("Setting To header to " + InternetAddress.toString(
- outInfo.getTargetAddresses()) + " from OutTransportInfo");
- }
- message.setRecipients(Message.RecipientType.TO, outInfo.getTargetAddresses());
- } else {
- handleException("To address for outgoing message cannot be determined");
- }
-
- // set Cc address/es to any custom transport header set on the message, else use the
- // Cc list from original request message
- if (trpHeaders != null && trpHeaders.containsKey(MailConstants.MAIL_HEADER_CC)) {
- Address[] cc =
- InternetAddress.parse((String) trpHeaders.get(MailConstants.MAIL_HEADER_CC));
- if (log.isDebugEnabled()) {
- log.debug("Setting Cc header to " + InternetAddress.toString(cc) +
- " from transport headers");
- }
- message.setRecipients(Message.RecipientType.CC, cc);
- } else if (outInfo.getCcAddresses() != null) {
- if (log.isDebugEnabled()) {
- log.debug("Setting Cc header to " + InternetAddress.toString(
- outInfo.getCcAddresses()) + " from OutTransportInfo");
- }
- message.setRecipients(Message.RecipientType.CC, outInfo.getCcAddresses());
- }
-
- // set Bcc address/es to any custom addresses set at the transport sender level + any
- // custom transport header
- if (trpHeaders != null && trpHeaders.containsKey(MailConstants.MAIL_HEADER_BCC)) {
- InternetAddress[] bcc =
- InternetAddress.parse((String) trpHeaders.get(MailConstants.MAIL_HEADER_BCC));
- if (log.isDebugEnabled()) {
- log.debug("Adding Bcc header values " + InternetAddress.toString(bcc) +
- " from transport headers");
- }
- message.addRecipients(Message.RecipientType.BCC, bcc);
- }
- if (smtpBccAddresses != null) {
- if (log.isDebugEnabled()) {
- log.debug("Adding Bcc header values " + InternetAddress.toString(smtpBccAddresses) +
- " from transport configuration");
- }
- message.addRecipients(Message.RecipientType.BCC, smtpBccAddresses);
- }
-
- // set subject
- if (trpHeaders != null && trpHeaders.containsKey(MailConstants.MAIL_HEADER_SUBJECT)) {
- if (log.isDebugEnabled()) {
- log.debug("Setting Subject header to '" + trpHeaders.get(
- MailConstants.MAIL_HEADER_SUBJECT) + "' from transport headers");
- }
- message.setSubject((String) trpHeaders.get(MailConstants.MAIL_HEADER_SUBJECT));
- } else if (outInfo.getSubject() != null) {
- if (log.isDebugEnabled()) {
- log.debug("Setting Subject header to '" + outInfo.getSubject() +
- "' from transport headers");
- }
- message.setSubject(outInfo.getSubject());
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Generating default Subject header from SOAP action");
- }
- message.setSubject(BaseConstants.SOAPACTION + ": " + msgContext.getSoapAction());
- }
-
- //TODO: use a combined message id for smtp so that it generates a unique id while
- // being able to support asynchronous communication.
- // if a custom message id is set, use it
-// if (msgContext.getMessageID() != null) {
-// message.setHeader(MailConstants.MAIL_HEADER_MESSAGE_ID, msgContext.getMessageID());
-// message.setHeader(MailConstants.MAIL_HEADER_X_MESSAGE_ID, msgContext.getMessageID());
-// }
-
- // if this is a reply, set reference to original message
- if (outInfo.getRequestMessageID() != null) {
- message.setHeader(MailConstants.MAIL_HEADER_IN_REPLY_TO, outInfo.getRequestMessageID());
- message.setHeader(MailConstants.MAIL_HEADER_REFERENCES, outInfo.getRequestMessageID());
-
- } else {
- if (trpHeaders != null &&
- trpHeaders.containsKey(MailConstants.MAIL_HEADER_IN_REPLY_TO)) {
- message.setHeader(MailConstants.MAIL_HEADER_IN_REPLY_TO,
- (String) trpHeaders.get(MailConstants.MAIL_HEADER_IN_REPLY_TO));
- }
- if (trpHeaders != null && trpHeaders.containsKey(MailConstants.MAIL_HEADER_REFERENCES)) {
- message.setHeader(MailConstants.MAIL_HEADER_REFERENCES,
- (String) trpHeaders.get(MailConstants.MAIL_HEADER_REFERENCES));
- }
- }
-
- // set Date
- message.setSentDate(new Date());
-
-
- // set SOAPAction header
- message.setHeader(BaseConstants.SOAPACTION, msgContext.getSoapAction());
-
- // write body
- MessageFormatterEx messageFormatterEx;
- if (messageFormatter instanceof MessageFormatterEx) {
- messageFormatterEx = (MessageFormatterEx)messageFormatter;
- } else {
- messageFormatterEx = new MessageFormatterExAdapter(messageFormatter);
- }
-
- DataHandler dataHandler = new DataHandler(messageFormatterEx.getDataSource(msgContext, format, msgContext.getSoapAction()));
-
- MimeMultipart mimeMultiPart = null;
-
- String mFormat = (String) msgContext.getProperty(MailConstants.TRANSPORT_MAIL_FORMAT);
- if (mFormat == null) {
- mFormat = defaultMailFormat;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Using mail format '" + mFormat + "'");
- }
-
- MimePart mainPart;
- if (MailConstants.TRANSPORT_FORMAT_MP.equals(mFormat)) {
- mimeMultiPart = new MimeMultipart();
- MimeBodyPart mimeBodyPart1 = new MimeBodyPart();
- mimeBodyPart1.setContent("Web Service Message Attached","text/plain");
- MimeBodyPart mimeBodyPart2 = new MimeBodyPart();
- mimeMultiPart.addBodyPart(mimeBodyPart1);
- mimeMultiPart.addBodyPart(mimeBodyPart2);
- message.setContent(mimeMultiPart);
- mainPart = mimeBodyPart2;
- } else if (MailConstants.TRANSPORT_FORMAT_ATTACHMENT.equals(mFormat)) {
- mimeMultiPart = new MimeMultipart();
- MimeBodyPart mimeBodyPart1 = new MimeBodyPart();
- mimeBodyPart1.setContent("Web Service Message Attached","text/plain");
- MimeBodyPart mimeBodyPart2 = new MimeBodyPart();
- mimeMultiPart.addBodyPart(mimeBodyPart1);
- mimeMultiPart.addBodyPart(mimeBodyPart2);
- message.setContent(mimeMultiPart);
-
- String fileName = (String) msgContext.getProperty(
- MailConstants.TRANSPORT_FORMAT_ATTACHMENT_FILE);
- if (fileName != null) {
- mimeBodyPart2.setFileName(fileName);
- } else {
- mimeBodyPart2.setFileName("attachment");
- }
-
- mainPart = mimeBodyPart2;
- } else {
- mainPart = message;
- }
-
- try {
- mainPart.setHeader(BaseConstants.SOAPACTION, msgContext.getSoapAction());
- mainPart.setDataHandler(dataHandler);
-
- // AXIOM's idea of what is textual also includes application/xml and
- // application/soap+xml (which JavaMail considers as binary). For these content types
- // always use quoted-printable transfer encoding. Note that JavaMail is a bit smarter
- // here because it can choose between 7bit and quoted-printable automatically, but it
- // needs to scan the entire content to determine this.
- if (msgContext.getOptions().getProperty("Content-Transfer-Encoding") != null) {
- mainPart.setHeader("Content-Transfer-Encoding",
- (String) msgContext.getOptions().getProperty("Content-Transfer-Encoding"));
- } else {
- String contentType = dataHandler.getContentType().toLowerCase();
- if (!contentType.startsWith("multipart/") && CommonUtils.isTextualPart(contentType)) {
- mainPart.setHeader("Content-Transfer-Encoding", "quoted-printable");
- }
- }
-
- //setting any custom headers defined by the user
- if (msgContext.getOptions().getProperty(MailConstants.TRANSPORT_MAIL_CUSTOM_HEADERS) != null) {
- Map customTransportHeaders = (Map)msgContext.getOptions().getProperty(MailConstants.TRANSPORT_MAIL_CUSTOM_HEADERS);
- for (Object header: customTransportHeaders.keySet()){
- mainPart.setHeader((String)header,(String)customTransportHeaders.get(header));
- }
- }
-
-
-
- log.debug("Sending message");
- Transport.send(message);
-
- // update metrics
- metrics.incrementMessagesSent(msgContext);
- long bytesSent = message.getBytesSent();
- if (bytesSent != -1) {
- metrics.incrementBytesSent(msgContext, bytesSent);
- }
-
- } catch (MessagingException e) {
- metrics.incrementFaultsSending();
- handleException("Error creating mail message or sending it to the configured server", e);
-
- }
- return message.getMessageID();
- }
-
- @Override
- public void stop() {
- super.stop();
- metrics.reset();
- smtpUsername = null;
- smtpPassword = null;
- smtpBccAddresses = null;
- smtpFromAddress = null;
- session = null;
- }
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailUtils.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailUtils.java
deleted file mode 100644
index b759e93..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailUtils.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.io.PrintStream;
-
-import javax.mail.Session;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.transport.base.ParamUtils;
-import org.apache.commons.io.output.WriterOutputStream;
-import org.apache.commons.logging.Log;
-
-public class MailUtils {
- private MailUtils() {}
-
- public static void setupLogging(Session session, Log log, ParameterInclude params) throws AxisFault {
- // Note that debugging might already be enabled by the mail.debug property and we should
- // take care to override it.
- if (log.isTraceEnabled()) {
- // This is the old behavior: just set debug to true
- session.setDebug(true);
- }
- if (ParamUtils.getOptionalParamBoolean(params, MailConstants.TRANSPORT_MAIL_DEBUG, false)) {
- // Redirect debug output to where it belongs, namely to the logs!
- session.setDebugOut(new PrintStream(new WriterOutputStream(new LogWriter(log)), true));
- // Only enable debug afterwards since the call to setDebug might already cause debug output
- session.setDebug(true);
- }
- }
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java
deleted file mode 100644
index 66cce59..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.Collections;
-
-import javax.mail.Session;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.transport.base.AbstractPollTableEntry;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.ParamUtils;
-import org.apache.commons.logging.Log;
-
-/**
- * Holds information about an entry in the VFS transport poll table used by the
- * VFS Transport Listener
- */
-public class PollTableEntry extends AbstractPollTableEntry {
- private final Log log;
-
- // operation after mail check
- public static final int DELETE = 0;
- public static final int MOVE = 1;
-
- /** The email address mapped to the service */
- private InternetAddress emailAddress = null;
-
- /** account username to check mail */
- private String userName = null;
- /** account password to check mail */
- private String password = null;
- /** The protocol to be used - pop3 or imap */
- private String protocol = null;
- /** The JavaMail session used to connect to the mail store */
- private Session session;
-
- /** The mail folder from which to check mail */
- private String folder;
- /** X-Service-Path custom header */
- // FIXME: this value of this property is never set nor retrieved
- private String xServicePath;
- /** Content-Type to use for the message */
- private String contentType;
- /** default reply address */
- private InternetAddress replyAddress = null;
-
- /** list of mail headers to be preserved into the Axis2 message as transport headers */
- private List<String> preserveHeaders = null;
- /** list of mail headers to be removed from the Axis2 message transport headers */
- private List<String> removeHeaders = null;
-
- /** action to take after a successful poll */
- private int actionAfterProcess = DELETE;
- /** action to take after a failed poll */
- private int actionAfterFailure = DELETE;
-
- /** folder to move the email after processing */
- private String moveAfterProcess;
- /** folder to move the email after failure */
- private String moveAfterFailure;
- /** Should mail be processed in parallel? e.g. with IMAP */
- private boolean processingMailInParallel = false;
- /** UIDs of messages currently being processed */
- private List<String> uidList = Collections.synchronizedList(new ArrayList<String>());
-
- private int maxRetryCount;
- private long reconnectTimeout;
-
- public PollTableEntry(Log log) {
- this.log = log;
- }
-
- @Override
- public EndpointReference[] getEndpointReferences(AxisService service, String ip) {
- return new EndpointReference[] { new EndpointReference(MailConstants.TRANSPORT_PREFIX
- + emailAddress) };
- }
-
- public InternetAddress getEmailAddress() {
- return emailAddress;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getXServicePath() {
- return xServicePath;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public int getActionAfterProcess() {
- return actionAfterProcess;
- }
-
- public int getActionAfterFailure() {
- return actionAfterFailure;
- }
-
- public String getMoveAfterProcess() {
- return moveAfterProcess;
- }
-
- public String getMoveAfterFailure() {
- return moveAfterFailure;
- }
-
- public int getMaxRetryCount() {
- return maxRetryCount;
- }
-
- public long getReconnectTimeout() {
- return reconnectTimeout;
- }
-
- public String getFolder() {
- return folder;
- }
-
- public InternetAddress getReplyAddress() {
- return replyAddress;
- }
-
- /**
- * Get the mail store protocol.
- * This protocol identifier is used in calls to {@link Session#getStore()}.
- *
- * @return the mail store protocol
- */
- public String getProtocol() {
- return protocol;
- }
-
- public Session getSession() {
- return session;
- }
-
- private void addPreserveHeaders(String headerList) {
- if (headerList == null) return;
- StringTokenizer st = new StringTokenizer(headerList, " ,");
- preserveHeaders = new ArrayList<String>();
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
- if (token.length() != 0) {
- preserveHeaders.add(token);
- }
- }
- }
-
- private void addRemoveHeaders(String headerList) {
- if (headerList == null) return;
- StringTokenizer st = new StringTokenizer(headerList, " ,");
- removeHeaders = new ArrayList<String>();
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
- if (token.length() != 0) {
- removeHeaders.add(token);
- }
- }
- }
-
- public boolean retainHeader(String name) {
- if (preserveHeaders != null) {
- return preserveHeaders.contains(name);
- } else if (removeHeaders != null) {
- return !removeHeaders.contains(name);
- } else {
- return true;
- }
- }
-
- public boolean isProcessingMailInParallel() {
- return processingMailInParallel;
- }
-
- @Override
- public boolean loadConfiguration(ParameterInclude paramIncl) throws AxisFault {
- String address =
- ParamUtils.getOptionalParam(paramIncl, MailConstants.TRANSPORT_MAIL_ADDRESS);
- if (address == null) {
- return false;
- } else {
- try {
- emailAddress = new InternetAddress(address);
- } catch (AddressException e) {
- throw new AxisFault("Invalid email address specified by '" +
- MailConstants.TRANSPORT_MAIL_ADDRESS + "' parameter :: " + e.getMessage());
- }
-
- List<Parameter> params = paramIncl.getParameters();
- Properties props = new Properties();
- for (Parameter p : params) {
- if (p.getName().startsWith("mail.")) {
- props.setProperty(p.getName(), (String) p.getValue());
- }
-
- if (MailConstants.MAIL_POP3_USERNAME.equals(p.getName()) ||
- MailConstants.MAIL_IMAP_USERNAME.equals(p.getName())) {
- userName = (String) p.getValue();
- }
- if (MailConstants.MAIL_POP3_PASSWORD.equals(p.getName()) ||
- MailConstants.MAIL_IMAP_PASSWORD.equals(p.getName())) {
- password = (String) p.getValue();
- }
- if (MailConstants.TRANSPORT_MAIL_PROTOCOL.equals(p.getName())) {
- protocol = (String) p.getValue();
- }
- }
-
- session = Session.getInstance(props, null);
- MailUtils.setupLogging(session, log, paramIncl);
-
- contentType =
- ParamUtils.getOptionalParam(paramIncl, MailConstants.TRANSPORT_MAIL_CONTENT_TYPE);
- try {
- String replyAddress =
- ParamUtils.getOptionalParam(paramIncl, MailConstants.TRANSPORT_MAIL_REPLY_ADDRESS);
- if (replyAddress != null) {
- this.replyAddress = new InternetAddress(replyAddress);
- }
- } catch (AddressException e) {
- throw new AxisFault("Invalid email address specified by '" +
- MailConstants.TRANSPORT_MAIL_REPLY_ADDRESS + "' parameter :: " +
- e.getMessage());
- }
-
- folder =
- ParamUtils.getOptionalParam(paramIncl, MailConstants.TRANSPORT_MAIL_FOLDER);
-
- addPreserveHeaders(
- ParamUtils.getOptionalParam(paramIncl, MailConstants.TRANSPORT_MAIL_PRESERVE_HEADERS));
- addRemoveHeaders(
- ParamUtils.getOptionalParam(paramIncl, MailConstants.TRANSPORT_MAIL_REMOVE_HEADERS));
-
- String option = ParamUtils.getOptionalParam(
- paramIncl, MailConstants.TRANSPORT_MAIL_ACTION_AFTER_PROCESS);
- actionAfterProcess =
- MailTransportListener.MOVE.equals(option) ? PollTableEntry.MOVE : PollTableEntry.DELETE;
- option = ParamUtils.getOptionalParam(
- paramIncl, MailConstants.TRANSPORT_MAIL_ACTION_AFTER_FAILURE);
- actionAfterFailure =
- MailTransportListener.MOVE.equals(option) ? PollTableEntry.MOVE : PollTableEntry.DELETE;
-
- moveAfterProcess = ParamUtils.getOptionalParam(
- paramIncl, MailConstants.TRANSPORT_MAIL_MOVE_AFTER_PROCESS);
- moveAfterFailure = ParamUtils.getOptionalParam(
- paramIncl, MailConstants.TRANSPORT_MAIL_MOVE_AFTER_FAILURE);
-
- String processInParallel = ParamUtils.getOptionalParam(
- paramIncl, MailConstants.TRANSPORT_MAIL_PROCESS_IN_PARALLEL);
- if (processInParallel != null) {
- processingMailInParallel = Boolean.parseBoolean(processInParallel);
- if (log.isDebugEnabled() && processingMailInParallel) {
- log.debug("Parallel mail processing enabled for : " + address);
- }
- }
-
- String pollInParallel = ParamUtils.getOptionalParam(
- paramIncl, BaseConstants.TRANSPORT_POLL_IN_PARALLEL);
- if (pollInParallel != null) {
- setConcurrentPollingAllowed(Boolean.parseBoolean(pollInParallel));
- if (log.isDebugEnabled() && isConcurrentPollingAllowed()) {
- log.debug("Concurrent mail polling enabled for : " + address);
- }
- }
-
- String strMaxRetryCount = ParamUtils.getOptionalParam(
- paramIncl, MailConstants.MAX_RETRY_COUNT);
- if (strMaxRetryCount != null) {
- maxRetryCount = Integer.parseInt(strMaxRetryCount);
- }
-
- String strReconnectTimeout = ParamUtils.getOptionalParam(
- paramIncl, MailConstants.RECONNECT_TIMEOUT);
- if (strReconnectTimeout != null) {
- reconnectTimeout = Integer.parseInt(strReconnectTimeout) * 1000;
- }
-
- return super.loadConfiguration(paramIncl);
- }
- }
-
- public synchronized void processingUID(String uid) {
- this.uidList.add(uid);
- }
-
- public synchronized boolean isProcessingUID(String uid) {
- return this.uidList.contains(uid);
- }
-
- public synchronized void removeUID(String uid) {
- this.uidList.remove(uid);
- }
-}
diff --git a/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java b/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java
deleted file mode 100644
index deed3df..0000000
--- a/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.axiom.util.UIDGenerator;
-import org.apache.commons.io.output.CountingOutputStream;
-
-import javax.mail.internet.MimeMessage;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-
-/**
- * The default MimeMessage does not let us set a custom MessageID on a message being
- * sent. This class allows us to overcome this limitation, but SMTP servers such as
- * GMail, re-writes this to an ID they define. Thats why the custom header defined by
- * MailConstants.MAIL_HEADER_X_MESSAGE_ID has been introduced, so that a client can
- * find out the relationship of a response to his request
- */
-public class WSMimeMessage extends MimeMessage {
- private long bytesSent = -1;
- private String fromAddress;
-
- WSMimeMessage(Session session, String fromAddress) {
- super(session);
- this.fromAddress = fromAddress;
- }
-
- @Override
- protected void updateMessageID() throws MessagingException {
- // although MailConstants.MAIL_HEADER_X_MESSAGE_ID solves the gmail problem with axis2-axis2
- // invocations it is not a generic solution.
- // we can over come gmail problem by setting the message id as follows with a valid gmail address
- // <xxxx@gmail.com> this can be achived by appending from address at the end of uuid
- if (getHeader(MailConstants.MAIL_HEADER_MESSAGE_ID) == null) {
- String id = "<" + UIDGenerator.generateUID() + fromAddress +">";
- setHeader(MailConstants.MAIL_HEADER_MESSAGE_ID, id);
- }
- }
-
- @Override
- public void writeTo(OutputStream out, String[] ignoreHeaders)
- throws MessagingException, IOException {
- if (bytesSent == -1) {
- CountingOutputStream countingOut = new CountingOutputStream(out);
- super.writeTo(countingOut, ignoreHeaders);
- bytesSent = countingOut.getByteCount();
- } else {
- super.writeTo(out, ignoreHeaders);
- }
- }
-
- public long getBytesSent() {
- return bytesSent;
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/FlatLayout.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/FlatLayout.java
deleted file mode 100644
index 54f4a48..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/FlatLayout.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import javax.activation.DataHandler;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("flat")
-public class FlatLayout implements MessageLayout {
- public void setupMessage(MimeMessage msg, DataHandler dh) throws Exception {
- msg.setDataHandler(dh);
- }
-}
\ No newline at end of file
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/GreenMailTestEnvironment.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/GreenMailTestEnvironment.java
deleted file mode 100644
index 1504cf0..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/GreenMailTestEnvironment.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.Flags;
-
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.LogManager;
-import org.apache.axis2.transport.testkit.util.PortAllocator;
-import org.apache.axis2.transport.testkit.util.ServerUtil;
-import org.apache.axis2.transport.testkit.util.tcpmon.Tunnel;
-
-import com.icegreen.greenmail.store.FolderListener;
-import com.icegreen.greenmail.store.MailFolder;
-import com.icegreen.greenmail.store.StoredMessage;
-import com.icegreen.greenmail.user.GreenMailUser;
-import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetup;
-
-@Name("greenmail")
-public class GreenMailTestEnvironment extends MailTestEnvironment {
- private final String protocol;
- private @Transient PortAllocator portAllocator;
- private @Transient ServerSetup smtpServerSetup;
- private @Transient ServerSetup storeServerSetup;
- private @Transient LogManager logManager;
- private @Transient GreenMail greenMail;
- private @Transient Tunnel smtpTunnel;
- private int accountNumber;
- private @Transient List<Account> unallocatedAccounts;
-
- public GreenMailTestEnvironment(String protocol) {
- this.protocol = protocol;
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(LogManager logManager, PortAllocator portAllocator) throws Exception {
- this.logManager = logManager;
- this.portAllocator = portAllocator;
- smtpServerSetup = new ServerSetup(portAllocator.allocatePort(), "127.0.0.1", ServerSetup.PROTOCOL_SMTP);
- storeServerSetup = new ServerSetup(portAllocator.allocatePort(), "127.0.0.1", protocol);
- greenMail = new GreenMail(new ServerSetup[] { smtpServerSetup, storeServerSetup });
- greenMail.start();
- smtpTunnel = new Tunnel(new InetSocketAddress("127.0.0.1", smtpServerSetup.getPort()));
- smtpTunnel.start();
- unallocatedAccounts = new LinkedList<Account>();
- ServerUtil.waitForServer(smtpServerSetup.getPort());
- ServerUtil.waitForServer(storeServerSetup.getPort());
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- greenMail.stop();
- accountNumber = 1;
- portAllocator.releasePort(smtpServerSetup.getPort());
- portAllocator.releasePort(storeServerSetup.getPort());
- }
-
- @Override
- @Key("protocol")
- public String getProtocol() {
- return protocol;
- }
-
- @Override
- public Account allocateAccount() throws Exception {
- if (unallocatedAccounts.isEmpty()) {
- String login = "test" + accountNumber++;
- GreenMailUser user = greenMail.setUser(login + "@localhost", login, "password");
- final MailFolder inbox = greenMail.getManagers().getImapHostManager().getInbox(user);
- inbox.addListener(new FolderListener() {
- public void added(int msn) {
- StoredMessage storedMessage = (StoredMessage)inbox.getMessages().get(msn-1);
- try {
- OutputStream out = logManager.createLog("greenmail");
- try {
- storedMessage.getMimeMessage().writeTo(out);
- } finally {
- out.close();
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- public void expunged(int msn) {}
- public void flagsUpdated(int msn, Flags flags, Long uid) {}
- public void mailboxDeleted() {}
- });
- return new Account(user.getEmail(), user.getLogin(), user.getPassword());
- } else {
- return unallocatedAccounts.remove(0);
- }
- }
-
- @Override
- public void freeAccount(Account account) {
- unallocatedAccounts.add(account);
- }
-
- @Override
- public Map<String,String> getInProperties(Account account) {
- Map<String,String> props = new HashMap<String,String>();
- props.put("mail." + protocol + ".host", "localhost");
- props.put("mail." + protocol + ".port", String.valueOf(storeServerSetup.getPort()));
- props.put("mail." + protocol + ".user", account.getLogin());
- props.put("mail." + protocol + ".password", account.getPassword());
- return props;
- }
-
- @Override
- public Map<String,String> getOutProperties() {
- Map<String,String> props = new HashMap<String,String>();
- props.put("mail.smtp.host", "localhost");
- props.put("mail.smtp.port", String.valueOf(smtpTunnel.getPort()));
- return props;
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/LogAspect.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/LogAspect.java
deleted file mode 100644
index 3e5d72d..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/LogAspect.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.io.OutputStream;
-
-import javax.mail.Message;
-
-import org.apache.axis2.transport.testkit.util.LogManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-
-@Aspect
-public class LogAspect {
- private static final Log log = LogFactory.getLog(LogAspect.class);
-
- @Before("call(void javax.mail.Transport.send(javax.mail.Message)) && args(message)")
- public void beforeSend(Message message) {
- try {
- OutputStream out = LogManager.INSTANCE.createLog("javamail");
- try {
- message.writeTo(out);
- } finally {
- out.close();
- }
- } catch (Throwable ex) {
- log.error("Failed to dump mail message", ex);
- }
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailAsyncClient.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailAsyncClient.java
deleted file mode 100644
index 371163f..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailAsyncClient.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-
-public class MailAsyncClient extends MailClient implements AsyncTestClient<byte[]> {
- public MailAsyncClient(MessageLayout layout) {
- super(layout);
- }
-
- public void sendMessage(ClientOptions options, ContentType contentType, byte[] message) throws Exception {
- sendMessage(contentType, message);
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailAxisTestClientConfigurator.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailAxisTestClientConfigurator.java
deleted file mode 100644
index 2458e62..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailAxisTestClientConfigurator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator;
-import org.apache.axis2.transport.testkit.name.Key;
-
-public class MailAxisTestClientConfigurator implements AxisTestClientConfigurator {
- private final String transportFormat;
-
- public MailAxisTestClientConfigurator(String transportFormat) {
- this.transportFormat = transportFormat;
- }
-
- @Key("layout")
- public String getTransportFormat() {
- return MailConstants.TRANSPORT_FORMAT_MP.equals(transportFormat) ? "multipart" : "flat";
- }
-
- public void setupRequestMessageContext(MessageContext msgContext) throws AxisFault {
- msgContext.setProperty(MailConstants.TRANSPORT_MAIL_FORMAT, transportFormat);
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailChannel.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailChannel.java
deleted file mode 100644
index cbd4f8b..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailChannel.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.mail.Session;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.transport.testkit.axis2.AxisServiceConfigurator;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-public class MailChannel implements AsyncChannel, RequestResponseChannel, AxisTestClientConfigurator, AxisServiceConfigurator {
- private @Transient MailTestEnvironment env;
- private @Transient MailTestEnvironment.Account sender;
- private @Transient MailTestEnvironment.Account recipient;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MailTestEnvironment env) throws Exception {
- this.env = env;
- sender = env.allocateAccount();
- recipient = env.allocateAccount();
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() {
- env.freeAccount(sender);
- env.freeAccount(recipient);
- }
-
- public MailTestEnvironment.Account getSender() {
- return sender;
- }
-
- public MailTestEnvironment.Account getRecipient() {
- return recipient;
- }
-
- public Session getReplySession() {
- Properties props = new Properties();
- props.putAll(env.getInProperties(sender));
- return Session.getInstance(props);
- }
-
- public EndpointReference getEndpointReference() throws Exception {
- return new EndpointReference("mailto:" + recipient.getAddress());
- }
-
- public void setupService(AxisService service, boolean isClientSide) throws Exception {
- env.setupPoll(service, isClientSide ? sender : recipient);
- }
-
- public void setupRequestMessageContext(MessageContext msgContext) {
- Map<String,String> trpHeaders = new HashMap<String,String>();
- trpHeaders.put(MailConstants.MAIL_HEADER_FROM, sender.getAddress());
- msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, trpHeaders);
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailClient.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailClient.java
deleted file mode 100644
index 7936c42..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailClient.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.util.Date;
-import java.util.Properties;
-
-import javax.activation.DataHandler;
-import javax.mail.Message;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.ContentType;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.mail.util.ByteArrayDataSource;
-
-import org.apache.axiom.util.UIDGenerator;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.TestClient;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.name.Named;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-@Name("javamail")
-public abstract class MailClient implements TestClient {
- private final MessageLayout layout;
- private @Transient MailChannel channel;
- private @Transient Session session;
-
- public MailClient(MessageLayout layout) {
- this.layout = layout;
- }
-
- @Named
- public MessageLayout getLayout() {
- return layout;
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MailTestEnvironment env, MailChannel channel) throws Exception {
- Properties props = new Properties();
- props.putAll(env.getOutProperties());
- session = Session.getInstance(props);
- this.channel = channel;
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- protected String sendMessage(ContentType contentType, byte[] message) throws Exception {
- String msgId = UIDGenerator.generateUID() + "@localhost";
- MimeMessage msg = new MimeMessage(session);
- msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(channel.getRecipient().getAddress()));
- msg.setFrom(new InternetAddress(channel.getSender().getAddress()));
- msg.setSentDate(new Date());
- msg.setHeader(MailConstants.MAIL_HEADER_MESSAGE_ID, msgId);
- msg.setHeader(MailConstants.MAIL_HEADER_X_MESSAGE_ID, msgId);
- DataHandler dh = new DataHandler(new ByteArrayDataSource(message, contentType.toString()));
- layout.setupMessage(msg, dh);
- Transport.send(msg);
- return msgId;
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailMessageContextValidator.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailMessageContextValidator.java
deleted file mode 100644
index 6c40a96..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailMessageContextValidator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.util.Map;
-
-import junit.framework.Assert;
-
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.testkit.axis2.MessageContextValidator;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-public class MailMessageContextValidator extends Assert implements MessageContextValidator {
- public static final MailMessageContextValidator INSTANCE = new MailMessageContextValidator();
-
- private @Transient MailChannel channel;
-
- private MailMessageContextValidator() {}
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MailChannel channel) {
- this.channel = channel;
- }
-
- public void validate(MessageContext msgContext, boolean isResponse) throws Exception {
- Map<?,?> trpHeaders = (Map<?,?>)msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
- String from = (String)trpHeaders.get(MailConstants.MAIL_HEADER_FROM);
- String to = (String)trpHeaders.get(MailConstants.MAIL_HEADER_TO);
- if (isResponse) {
- // TODO: The transport headers in the response message context are not set correctly.
- // There are two issues:
- // * SynchronousCallback doesn't propagate the transport headers
- // * OutInAxisOperation#send(MessageContext) overwrites the TRANSPORT_HEADERS
- // property with the value from the request message context.
-// assertEquals(channel.getSender().getAddress(), to);
-// assertEquals(channel.getRecipient().getAddress(), from);
- } else {
- assertEquals(channel.getSender().getAddress(), from);
- assertEquals(channel.getRecipient().getAddress(), to);
- }
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailRequestResponseClient.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailRequestResponseClient.java
deleted file mode 100644
index d97ea05..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailRequestResponseClient.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-
-import javax.mail.Flags;
-import javax.mail.Folder;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.Store;
-import javax.mail.internet.ContentType;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-import junit.framework.Assert;
-
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class MailRequestResponseClient extends MailClient implements RequestResponseTestClient<byte[],byte[]> {
- private static final Log log = LogFactory.getLog(MailRequestResponseClient.class);
-
- private @Transient MailChannel channel;
- private @Transient Store store;
-
- public MailRequestResponseClient(MessageLayout layout) {
- super(layout);
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MailTestEnvironment env, MailChannel channel) throws MessagingException {
- this.channel = channel;
- Session session = channel.getReplySession();
- session.setDebug(log.isTraceEnabled());
- store = session.getStore(env.getProtocol());
- MailTestEnvironment.Account sender = channel.getSender();
- store.connect(sender.getLogin(), sender.getPassword());
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws MessagingException {
- store.close();
- }
-
- public IncomingMessage<byte[]> sendMessage(ClientOptions options, ContentType contentType, byte[] message) throws Exception {
- String msgId = sendMessage(contentType, message);
- Message reply = waitForReply(msgId);
- Assert.assertNotNull("No response received", reply);
- Assert.assertEquals(channel.getSender().getAddress(),
- ((InternetAddress)reply.getRecipients(Message.RecipientType.TO)[0]).getAddress());
- Assert.assertEquals(channel.getRecipient().getAddress(),
- ((InternetAddress)reply.getFrom()[0]).getAddress());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- reply.getDataHandler().writeTo(baos);
- return new IncomingMessage<byte[]>(new ContentType(reply.getContentType()), baos.toByteArray());
- }
-
- private Message waitForReply(String msgId) throws Exception {
- Thread.yield();
- Thread.sleep(100);
-
- Message reply = null;
- boolean replyNotFound = true;
- int retryCount = 50;
- while (replyNotFound) {
- log.debug("Checking for response ... with MessageID : " + msgId);
- reply = getMessage(msgId);
- if (reply != null) {
- replyNotFound = false;
- } else {
- if (retryCount-- > 0) {
- Thread.sleep(100);
- } else {
- break;
- }
- }
- }
- return reply;
- }
-
- private Message getMessage(String requestMsgId) throws Exception {
- MimeMessage response = null;
- Folder folder = store.getFolder(MailConstants.DEFAULT_FOLDER);
- folder.open(Folder.READ_WRITE);
- Message[] msgs = folder.getMessages();
- log.debug(msgs.length + " messages in mailbox");
- loop: for (Message m : msgs) {
- MimeMessage mimeMessage = (MimeMessage)m;
- String[] inReplyTo = mimeMessage.getHeader(MailConstants.MAIL_HEADER_IN_REPLY_TO);
- log.debug("Found message " + mimeMessage.getMessageID() + " in reply to " + Arrays.toString(inReplyTo));
- if (inReplyTo != null && inReplyTo.length > 0) {
- for (int j=0; j<inReplyTo.length; j++) {
- if (requestMsgId.equals(inReplyTo[j])) {
- log.debug("Identified message " + mimeMessage.getMessageID() + " as the response to " + requestMsgId + "; retrieving it from the store");
- // We need to create a copy so that we can delete the original and close the folder
- response = new MimeMessage(mimeMessage);
- log.debug("Flagging message " + mimeMessage.getMessageID() + " for deletion");
- mimeMessage.setFlag(Flags.Flag.DELETED, true);
- break loop;
- }
- }
- }
- log.warn("Don't know what to do with message " + mimeMessage.getMessageID() + "; skipping");
- }
- folder.close(true);
- return response;
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailTestEnvironment.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailTestEnvironment.java
deleted file mode 100644
index 4bfd012..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailTestEnvironment.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import java.util.Map;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
-import org.apache.axis2.transport.testkit.name.Key;
-
-@Key("server")
-public abstract class MailTestEnvironment implements TransportDescriptionFactory {
- public static class Account {
- private final String address;
- private final String login;
- private final String password;
-
- public Account(String address, String login, String password) {
- this.address = address;
- this.login = login;
- this.password = password;
- }
-
- public String getAddress() {
- return address;
- }
-
- public String getLogin() {
- return login;
- }
-
- public String getPassword() {
- return password;
- }
- };
-
- public abstract String getProtocol();
-
- public abstract Account allocateAccount() throws Exception;
-
- public abstract void freeAccount(Account account);
-
- public abstract Map<String,String> getInProperties(Account account);
-
- public abstract Map<String,String> getOutProperties();
-
- public TransportInDescription createTransportInDescription() throws Exception {
- TransportInDescription trpInDesc = new TransportInDescription(MailConstants.TRANSPORT_NAME);
- trpInDesc.setReceiver(new MailTransportListener());
- return trpInDesc;
- }
-
- public TransportOutDescription createTransportOutDescription() throws Exception {
- TransportOutDescription trpOutDesc = new TransportOutDescription(MailConstants.TRANSPORT_NAME);
- trpOutDesc.setSender(new MailTransportSender());
- trpOutDesc.addParameter(new Parameter(MailConstants.TRANSPORT_MAIL_DEBUG, "true"));
- for (Map.Entry<String,String> prop : getOutProperties().entrySet()) {
- trpOutDesc.addParameter(new Parameter(prop.getKey(), prop.getValue()));
- }
- return trpOutDesc;
- }
-
- public void setupPoll(ParameterInclude params, Account account) throws AxisFault {
- params.addParameter(new Parameter(MailConstants.TRANSPORT_MAIL_DEBUG, "true"));
- params.addParameter(new Parameter("transport.mail.Protocol", getProtocol()));
- params.addParameter(new Parameter("transport.mail.Address", account.getAddress()));
- params.addParameter(new Parameter("transport.PollInterval", "50ms"));
- for (Map.Entry<String,String> prop : getInProperties(account).entrySet()) {
- params.addParameter(new Parameter(prop.getKey(), prop.getValue()));
- }
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailTransportTest.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailTransportTest.java
deleted file mode 100644
index 9027203..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MailTransportTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.axis2.transport.testkit.ManagedTestSuite;
-import org.apache.axis2.transport.testkit.TransportTestSuiteBuilder;
-import org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient;
-import org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint;
-import org.apache.axis2.transport.testkit.tests.misc.MinConcurrencyTest;
-
-public class MailTransportTest extends TestCase {
- public static TestSuite suite() throws Exception {
- ManagedTestSuite suite = new ManagedTestSuite(MailTransportTest.class);
-
- // SwA doesn't work with the mock client because attachments are sent with
- // "Content-Transfer-Encoding: binary" and mail servers don't like that.
- suite.addExclude("(&(test=AsyncSwA)(client=javamail))");
- // There seems to be a problem with Sun's IMAP client or GreenMail's IMAP server
- // in this particular case:
- suite.addExclude("(&(protocol=imap)(test=AsyncSwA))");
- // SYNAPSE-434
- suite.addExclude("(test=MinConcurrency)");
-
- TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
-
- builder.addEnvironment(new GreenMailTestEnvironment("pop3"), MailMessageContextValidator.INSTANCE);
- builder.addEnvironment(new GreenMailTestEnvironment("imap"), MailMessageContextValidator.INSTANCE);
-
- MailChannel channel = new MailChannel();
-
- builder.addAsyncChannel(channel);
-
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), new MailAxisTestClientConfigurator(MailConstants.TRANSPORT_FORMAT_TEXT));
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), new MailAxisTestClientConfigurator(MailConstants.TRANSPORT_FORMAT_MP));
- builder.addByteArrayAsyncTestClient(new MailAsyncClient(new FlatLayout()));
- builder.addByteArrayAsyncTestClient(new MailAsyncClient(new MultipartLayout()));
-
- builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
-
- builder.addRequestResponseChannel(channel);
-
- // TODO: this doesn't work because of WSCOMMONS-544
-// builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient(), new ResponseListenerConfigurator());
- builder.addByteArrayRequestResponseTestClient(new MailRequestResponseClient(new FlatLayout()));
- builder.addByteArrayRequestResponseTestClient(new MailRequestResponseClient(new MultipartLayout()));
-
- builder.addEchoEndpoint(new AxisEchoEndpoint());
-
- builder.build();
-
- suite.addTest(new MinConcurrencyTest(new MailChannel[] { new MailChannel(), new MailChannel() }, 2, true, new GreenMailTestEnvironment("pop3")));
- return suite;
- }
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MessageLayout.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MessageLayout.java
deleted file mode 100644
index ddf9d32..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MessageLayout.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import javax.activation.DataHandler;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.axis2.transport.testkit.name.Key;
-
-@Key("layout")
-public interface MessageLayout {
- void setupMessage(MimeMessage msg, DataHandler dh) throws Exception;
-}
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MultipartLayout.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/MultipartLayout.java
deleted file mode 100644
index f3dcec8..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/MultipartLayout.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import javax.activation.DataHandler;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("multipart")
-public class MultipartLayout implements MessageLayout {
- public void setupMessage(MimeMessage msg, DataHandler dh) throws Exception {
- MimeMultipart multipart = new MimeMultipart();
- MimeBodyPart part1 = new MimeBodyPart();
- part1.setContent("This is an automated message.", "text/plain");
- multipart.addBodyPart(part1);
- MimeBodyPart part2 = new MimeBodyPart();
- part2.setDataHandler(dh);
- multipart.addBodyPart(part2);
- msg.setContent(multipart);
- }
-}
\ No newline at end of file
diff --git a/modules/mail/src/test/java/org/apache/axis2/transport/mail/ResponseListenerConfigurator.java b/modules/mail/src/test/java/org/apache/axis2/transport/mail/ResponseListenerConfigurator.java
deleted file mode 100644
index 8eb9866..0000000
--- a/modules/mail/src/test/java/org/apache/axis2/transport/mail/ResponseListenerConfigurator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.mail;
-
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientContextConfigurator;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-public class ResponseListenerConfigurator implements AxisTestClientContextConfigurator {
- private @Transient MailTestEnvironment env;
- private @Transient MailTestEnvironment.Account sender;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MailTestEnvironment env, MailChannel channel) {
- this.env = env;
- sender = channel.getSender();
- }
-
- public boolean isTransportListenerRequired() {
- return true;
- }
-
- public void setupTransport(TransportInDescription trpInDesc,
- TransportOutDescription trpOutDesc) throws Exception{
-
- env.setupPoll(trpInDesc, sender);
- }
-}
diff --git a/modules/mail/src/test/resources/META-INF/aop.xml b/modules/mail/src/test/resources/META-INF/aop.xml
deleted file mode 100644
index e2c0f8e..0000000
--- a/modules/mail/src/test/resources/META-INF/aop.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<aspectj>
- <aspects>
- <aspect name="org.apache.axis2.transport.mail.LogAspect"/>
- </aspects>
- <weaver options="-showWeaveInfo">
- <include within="org.apache.axis2.transport..*"/>
- </weaver>
-</aspectj>
diff --git a/modules/tcp/conf/axis2.xml b/modules/tcp/conf/axis2.xml
deleted file mode 100644
index db7dbea..0000000
--- a/modules/tcp/conf/axis2.xml
+++ /dev/null
@@ -1,261 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<axisconfig name="AxisJava2.0">
- <!-- ================================================= -->
- <!-- Parameters -->
- <!-- ================================================= -->
- <parameter name="hotdeployment">true</parameter>
- <parameter name="hotupdate">false</parameter>
- <parameter name="enableMTOM">false</parameter>
-
- <!--If turned on with use the Accept header of the request to determine the contentType of the
- response-->
- <parameter name="httpContentNegotiation">false</parameter>
-
- <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
- <!--that behaviour.-->
- <parameter name="sendStacktraceDetailsWithFaults">true</parameter>
-
- <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
- <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
- <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
- <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
- <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
-
- <!--This is the user name and password of admin console-->
- <parameter name="userName">admin</parameter>
- <parameter name="password">axis2</parameter>
-
- <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
- <!--ServicesDirectory only works on the following cases-->
- <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
- <!---When creating URL Based configurator with URL “file://” -->
- <!--- War based configurator with expanded case , -->
-
- <!--All the other scenarios it will be ignored.-->
- <!--<parameter name="ServicesDirectory">service</parameter>-->
- <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
- <!--<parameter name="ModulesDirectory">modules</parameter>-->
-
- <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
- <!--root which can configured using the following contextRoot parameter-->
- <!--<parameter name="contextRoot">axis2</parameter>-->
-
- <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguish those endpoints-->
- <!--<parameter name="servicePath">services</parameter>-->
- <!--<parameter name="restPath">rest</parameter>-->
-
- <!-- Following parameter will completely disable REST handling in Axis2-->
- <parameter name="disableREST" locked="false">false</parameter>
-
- <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
- <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
- <deployer extension=".jar" directory="transports" class="org.apache.axis2.deployment.TransportDeployer"/>
-
- <!-- Following parameter will set the host name for the epr-->
- <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
-
- <!-- ================================================= -->
- <!-- Deployers -->
- <!-- ================================================= -->
-
- <!--Service deployer , this will alow users to deploy AAR or exploded AAR as axis2 services-->
- <deployer extension=".aar" directory="services" class="org.apache.axis2.deployment.ServiceDeployer">
- <serviceBuilderExtension name ="jwsbuilderExt" class="org.apache.axis2.jaxws.framework.JAXWSServiceBuilderExtension"/>
- <serviceBuilderExtension name ="wsdlbuilderExt" class="org.apache.axis2.deployment.WSDLServiceBuilderExtension"/>
- </deployer>
-
- <!-- ================================================= -->
- <!-- Message Receivers -->
- <!-- ================================================= -->
- <!--This is the Default Message Receiver for the system , if you want to have MessageReceivers for -->
- <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
- <!--any operation -->
- <!--Note : You can override this for particular service by adding the same element with your requirement-->
- <messageReceivers>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- </messageReceivers>
-
- <!-- ================================================= -->
- <!-- Message Formatter -->
- <!-- ================================================= -->
- <!--Following content type to message formatter mapping can be used to implement support for different message -->
- <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageFormatters>
- <messageFormatter contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
- <messageFormatter contentType="multipart/form-data"
- class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
- <messageFormatter contentType="application/xml"
- class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
- <messageFormatter contentType="text/xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- <messageFormatter contentType="application/soap+xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- </messageFormatters>
-
- <!-- ================================================= -->
- <!-- Message Builders -->
- <!-- ================================================= -->
- <!--Following content type to builder mapping can be used to implement support for different message -->
- <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageBuilders>
- <messageBuilder contentType="application/xml"
- class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
- <messageBuilder contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
- <!--Left commented because it adds the depandancy of servlet-api to other modules.
- Please uncomment to Receive messages in multipart/form-data format-->
- <!--<messageBuilder contentType="multipart/form-data"-->
- <!--class="org.apache.axis2.builder.MultipartFormDataBuilder"/>-->
- </messageBuilders>
-
- <module ref="addressing"/>
-
- <!-- ================================================= -->
- <!-- Target Resolvers -->
- <!-- ================================================= -->
- <!-- Uncomment the following and specify the class name for your TargetResolver to add -->
- <!-- a TargetResolver. TargetResolvers are used to process the To EPR for example to -->
- <!-- choose a server in a cluster -->
- <!--<targetResolvers>-->
- <!--<targetResolver class="" />-->
- <!--</targetResolvers>-->
-
- <transportReceiver name="tcp"
- class="org.apache.axis2.transport.tcp.TCPTransportListener">
- <parameter name="transport.tcp.port">5555</parameter>
- <!--If you want to give your own host address for EPR generation-->
- <!--uncommet following paramter , and set as you required.-->
- <!--<parameter name="transport.tcp.hostname">tcp://myApp.com/ws</parameter>-->
- <!--parameter name="transport.tcp.contentType">text/xml</parameter-->
- <!--<parameter name="transport.tcp.backlog">50</parameter>-->
- </transportReceiver>
-
- <transportSender name="tcp"
- class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
-
-
- <!-- ================================================= -->
- <!-- SOAP Role Configuration -->
- <!-- ================================================= -->
- <!-- Use the following pattern to configure this axis2
- instance to act in particular roles. Note that in
- the absence of any configuration, Axis2 will act
- only in the ultimate receiver role -->
- <!--
- <SOAPRoleConfiguration isUltimateReceiver="true">
- <role>http://my/custom/role</role>
- </SOAPRoleConfiguration>
- -->
-
- <!-- ================================================= -->
- <!-- Phases -->
- <!-- ================================================= -->
- <phaseOrder type="InFlow">
- <!-- System pre-defined phases -->
- <phase name="Transport">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- </phase>
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- System pre defined phases -->
- <!-- After Postdispatch phase module author or or service author can add any phase he want -->
- <phase name="OperationInPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutPhase"/>
- <!--system predefined phase-->
- <!--these phase will run irrespective of the service-->
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
- <phaseOrder type="InFaultFlow">
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- user can add his own phases to this area -->
- <phase name="OperationInFaultPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFaultFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutFaultPhase"/>
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
-</axisconfig>
diff --git a/modules/tcp/conf/client_axis2.xml b/modules/tcp/conf/client_axis2.xml
deleted file mode 100644
index 7822d78..0000000
--- a/modules/tcp/conf/client_axis2.xml
+++ /dev/null
@@ -1,256 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<axisconfig name="AxisJava2.0">
- <!-- ================================================= -->
- <!-- Parameters -->
- <!-- ================================================= -->
- <parameter name="hotdeployment">true</parameter>
- <parameter name="hotupdate">false</parameter>
- <parameter name="enableMTOM">false</parameter>
-
- <!--If turned on with use the Accept header of the request to determine the contentType of the
- response-->
- <parameter name="httpContentNegotiation">false</parameter>
-
- <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
- <!--that behaviour.-->
- <parameter name="sendStacktraceDetailsWithFaults">true</parameter>
-
- <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
- <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
- <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
- <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
- <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
-
- <!--This is the user name and password of admin console-->
- <parameter name="userName">admin</parameter>
- <parameter name="password">axis2</parameter>
-
- <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
- <!--ServicesDirectory only works on the following cases-->
- <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
- <!---When creating URL Based configurator with URL “file://” -->
- <!--- War based configurator with expanded case , -->
-
- <!--All the other scenarios it will be ignored.-->
- <!--<parameter name="ServicesDirectory">service</parameter>-->
- <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
- <!--<parameter name="ModulesDirectory">modules</parameter>-->
-
- <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
- <!--root which can configured using the following contextRoot parameter-->
- <!--<parameter name="contextRoot">axis2</parameter>-->
-
- <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguish those endpoints-->
- <!--<parameter name="servicePath">services</parameter>-->
- <!--<parameter name="restPath">rest</parameter>-->
-
- <!-- Following parameter will completely disable REST handling in Axis2-->
- <parameter name="disableREST" locked="false">false</parameter>
-
- <!-- ================================================= -->
- <!-- Deployers -->
- <!-- ================================================= -->
-
- <!--Service deployer , this will alow users to deploy AAR or exploded AAR as axis2 services-->
- <deployer extension=".aar" directory="services" class="org.apache.axis2.deployment.ServiceDeployer">
- <serviceBuilderExtension name ="jwsbuilderExt" class="org.apache.axis2.jaxws.framework.JAXWSServiceBuilderExtension"/>
- <serviceBuilderExtension name ="wsdlbuilderExt" class="org.apache.axis2.deployment.WSDLServiceBuilderExtension"/>
- </deployer>
-
- <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
- <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
- <deployer extension=".jar" directory="transports" class="org.apache.axis2.deployment.TransportDeployer"/>
-
- <!-- Following parameter will set the host name for the epr-->
- <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
-
- <!-- ================================================= -->
- <!-- Message Receivers -->
- <!-- ================================================= -->
- <!--This is the Default Message Receiver for the system , if you want to have MessageReceivers for -->
- <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
- <!--any operation -->
- <!--Note : You can override this for particular service by adding the same element with your requirement-->
- <messageReceivers>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- </messageReceivers>
-
- <!-- ================================================= -->
- <!-- Message Formatter -->
- <!-- ================================================= -->
- <!--Following content type to message formatter mapping can be used to implement support for different message -->
- <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageFormatters>
- <messageFormatter contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
- <messageFormatter contentType="multipart/form-data"
- class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
- <messageFormatter contentType="application/xml"
- class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
- <messageFormatter contentType="text/xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- <messageFormatter contentType="application/soap+xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- </messageFormatters>
-
- <!-- ================================================= -->
- <!-- Message Builders -->
- <!-- ================================================= -->
- <!--Following content type to builder mapping can be used to implement support for different message -->
- <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageBuilders>
- <messageBuilder contentType="application/xml"
- class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
- <messageBuilder contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
- <!--Left commented because it adds the depandancy of servlet-api to other modules.
- Please uncomment to Receive messages in multipart/form-data format-->
- <!--<messageBuilder contentType="multipart/form-data"-->
- <!--class="org.apache.axis2.builder.MultipartFormDataBuilder"/>-->
- </messageBuilders>
-
- <module ref="addressing"/>
-
- <!-- ================================================= -->
- <!-- Target Resolvers -->
- <!-- ================================================= -->
- <!-- Uncomment the following and specify the class name for your TargetResolver to add -->
- <!-- a TargetResolver. TargetResolvers are used to process the To EPR for example to -->
- <!-- choose a server in a cluster -->
- <!--<targetResolvers>-->
- <!--<targetResolver class="" />-->
- <!--</targetResolvers>-->
-
- <transportReceiver name="tcp"
- class="org.apache.axis2.transport.tcp.TCPTransportListener">
- <parameter name="transport.tcp.port">5556</parameter>
- </transportReceiver>
-
- <transportSender name="tcp"
- class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
-
-
- <!-- ================================================= -->
- <!-- SOAP Role Configuration -->
- <!-- ================================================= -->
- <!-- Use the following pattern to configure this axis2
- instance to act in particular roles. Note that in
- the absence of any configuration, Axis2 will act
- only in the ultimate receiver role -->
- <!--
- <SOAPRoleConfiguration isUltimateReceiver="true">
- <role>http://my/custom/role</role>
- </SOAPRoleConfiguration>
- -->
-
- <!-- ================================================= -->
- <!-- Phases -->
- <!-- ================================================= -->
- <phaseOrder type="InFlow">
- <!-- System pre-defined phases -->
- <phase name="Transport">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- </phase>
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- System pre defined phases -->
- <!-- After Postdispatch phase module author or or service author can add any phase he want -->
- <phase name="OperationInPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutPhase"/>
- <!--system predefined phase-->
- <!--these phase will run irrespective of the service-->
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
- <phaseOrder type="InFaultFlow">
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- user can add his own phases to this area -->
- <phase name="OperationInFaultPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFaultFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutFaultPhase"/>
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
-</axisconfig>
diff --git a/modules/tcp/pom.xml b/modules/tcp/pom.xml
deleted file mode 100644
index 2f79c90..0000000
--- a/modules/tcp/pom.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transports</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <artifactId>axis2-transport-tcp</artifactId>
- <name>Apache Axis2 - Transport - TCP</name>
- <description>This inclues all the available transports in Axis2</description>
- <packaging>bundle</packaging>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/tcp</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/tcp</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/tcp</url>
- </scm>
-
- <build>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>log4j.configuration</name>
- <value>file:../../log4j.properties</value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>build-repo</id>
- <phase>test-compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="target/test-resources/samples/modules" />
- <mkdir dir="target/test-resources/samples/conf" />
- <copy file="${settings.localRepository}/org/apache/axis2/addressing/${axis2.version}/addressing-${axis2.version}.mar" tofile="target/test-resources/samples/modules/addressing.mar" />
- <copy file="conf/axis2.xml" tofile="target/test-resources/samples/conf/axis2.xml" />
- <copy file="conf/client_axis2.xml" tofile="target/test-resources/samples/conf/client_axis2.xml" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
- <Bundle-Description>${project.description}</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.apache.axis2.transport.tcp.*;-split-package:=merge-last,
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>conf</directory>
- <excludes>
- <exclude>**/*.properties</exclude>
- </excludes>
- <filtering>false</filtering>
- </resource>
- <resource>
- <directory>src</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>addressing</artifactId>
- <version>${axis2.version}</version>
- <type>mar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPConstants.java b/modules/tcp/src/org/apache/axis2/transport/tcp/TCPConstants.java
deleted file mode 100644
index 0ab00d9..0000000
--- a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPConstants.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-public class TCPConstants {
-
- public static final String PARAM_PORT = "transport.tcp.port";
- public static final String PARAM_HOST = "transport.tcp.hostname";
- public static final String PARAM_BACKLOG = "transport.tcp.backlog";
- public static final String PARAM_CONTENT_TYPE = "transport.tcp.contentType";
-
- public static final int TCP_DEFAULT_BACKLOG = 50;
- public static final String TCP_DEFAULT_CONTENT_TYPE = "text/xml";
-
- public static final String TCP_OUTPUT_SOCKET = "transport.tcp.outputSocket";
-}
diff --git a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPEndpoint.java b/modules/tcp/src/org/apache/axis2/transport/tcp/TCPEndpoint.java
deleted file mode 100644
index eeb17bd..0000000
--- a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPEndpoint.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axis2.transport.base.ProtocolEndpoint;
-import org.apache.axis2.transport.base.ParamUtils;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.util.Utils;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.AxisService;
-
-import java.net.SocketException;
-
-public class TCPEndpoint extends ProtocolEndpoint {
-
- private String host = null;
- private int port = -1;
- private int backlog = TCPConstants.TCP_DEFAULT_BACKLOG;
- private String contentType;
-
- public TCPEndpoint() {
-
- }
-
- public TCPEndpoint(String host, int port, int backlog) {
- this.host = host;
- this.port = port;
- this.backlog = backlog;
- }
-
- public int getPort() {
- return port;
- }
-
- public String getHost() {
- return host;
- }
-
- public int getBacklog() {
- return backlog;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
- port = ParamUtils.getOptionalParamInt(params, TCPConstants.PARAM_PORT, -1);
- if (port == -1) {
- return false;
- }
-
- contentType = ParamUtils.getOptionalParam(params, TCPConstants.PARAM_CONTENT_TYPE);
- if (contentType == null) {
- contentType = TCPConstants.TCP_DEFAULT_CONTENT_TYPE;
- }
-
- host = ParamUtils.getOptionalParam(params, TCPConstants.PARAM_HOST);
- backlog = ParamUtils.getOptionalParamInt(params, TCPConstants.PARAM_BACKLOG,
- TCPConstants.TCP_DEFAULT_BACKLOG);
- return true;
- }
-
- public EndpointReference[] getEndpointReferences(AxisService service,
- String ip) throws AxisFault {
- if (host == null && ip == null) {
- try {
- ip = Utils.getIpAddress(getListener().getConfigurationContext().
- getAxisConfiguration());
- } catch (SocketException ex) {
- throw new AxisFault("Unable to determine the host's IP address", ex);
- }
- }
-
- String url = "tcp://" + (host != null ? host : ip) + ":" + port;
- String context = getListener().getConfigurationContext().getServiceContextPath();
- url += (context.startsWith("/") ? "" : "/") + context +
- (context.endsWith("/") ? "" : "/") +
- (getService() == null ? service.getName() : getServiceName());
-
- if (!contentType.equals(TCPConstants.TCP_DEFAULT_CONTENT_TYPE)) {
- url += "?contentType=" + contentType;
- }
-
- return new EndpointReference[] { new EndpointReference(url) };
- }
-
-}
diff --git a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPOutTransportInfo.java b/modules/tcp/src/org/apache/axis2/transport/tcp/TCPOutTransportInfo.java
deleted file mode 100644
index 085a646..0000000
--- a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPOutTransportInfo.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axis2.transport.OutTransportInfo;
-
-import java.io.OutputStream;
-import java.net.Socket;
-
-public class TCPOutTransportInfo implements OutTransportInfo {
-
- private Socket socket;
- private String contentType;
-
- public Socket getSocket() {
- return socket;
- }
-
- public void setSocket(Socket socket) {
- this.socket = socket;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public String getContentType() {
- return contentType;
- }
-}
diff --git a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPServer.java b/modules/tcp/src/org/apache/axis2/transport/tcp/TCPServer.java
deleted file mode 100644
index fe97a8b..0000000
--- a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPServer.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axis2.transport.base.threads.WorkerPool;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
-
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.InetAddress;
-import java.io.IOException;
-
-public class TCPServer implements Runnable {
-
- private TCPEndpoint endpoint;
- private ServerSocket serverSocket;
- private WorkerPool workerPool;
- private boolean started = false;
-
- private static final Log log = LogFactory.getLog(TCPServer.class);
-
- public TCPServer(TCPEndpoint endpoint, WorkerPool workerPool) {
- this.endpoint = endpoint;
- this.workerPool = workerPool;
- }
-
- public void run() {
- while (started) {
- Socket socket = null;
-
- try {
- socket = serverSocket.accept();
- } catch (java.io.InterruptedIOException ignored) {
-
- } catch (Exception e) {
- log.debug(e);
- break;
- }
-
- if (socket != null) {
- workerPool.execute(new TCPWorker(endpoint, socket));
- }
- }
- }
-
- public void startServer() throws IOException {
- if (serverSocket == null) {
- if (endpoint.getHost() != null) {
- InetAddress address = InetAddress.getByName(endpoint.getHost());
- serverSocket = new ServerSocket(endpoint.getPort(), endpoint.getBacklog(), address);
- } else {
- serverSocket = new ServerSocket(endpoint.getPort(), endpoint.getBacklog());
- }
- }
- started = true;
- endpoint.getListener().getConfigurationContext().getThreadPool().execute(this);
- log.info("TCP server started on port : " + endpoint.getPort());
- }
-
- public void stopServer() throws IOException {
- started = false;
- serverSocket.close();
- serverSocket = null;
- log.info("TCP server stopped on port : " + endpoint.getPort());
- }
-}
diff --git a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPTransportListener.java b/modules/tcp/src/org/apache/axis2/transport/tcp/TCPTransportListener.java
deleted file mode 100644
index a827de1..0000000
--- a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPTransportListener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axis2.transport.base.AbstractTransportListenerEx;
-import org.apache.axis2.AxisFault;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class TCPTransportListener extends AbstractTransportListenerEx<TCPEndpoint> {
-
- private Map<TCPEndpoint, TCPServer> serverTable = new ConcurrentHashMap<TCPEndpoint, TCPServer>();
-
- protected void doInit() throws AxisFault {
-
- }
-
- protected TCPEndpoint createEndpoint() {
- return new TCPEndpoint();
- }
-
- protected void startEndpoint(TCPEndpoint endpoint) throws AxisFault {
- try {
- TCPServer server = new TCPServer(endpoint, workerPool);
- server.startServer();
- serverTable.put(endpoint, server);
- } catch (IOException e) {
- handleException("Error while starting the TCP endpoint", e);
- }
- }
-
- protected void stopEndpoint(TCPEndpoint endpoint) {
- try {
- TCPServer server = serverTable.get(endpoint);
- if (server != null) {
- server.stopServer();
- }
- } catch (IOException e) {
- log.error("Error while stopping the TCP endpoint", e);
- } finally {
- serverTable.remove(endpoint);
- }
- }
-}
diff --git a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPTransportSender.java b/modules/tcp/src/org/apache/axis2/transport/tcp/TCPTransportSender.java
deleted file mode 100644
index ef868b3..0000000
--- a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPTransportSender.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.base.AbstractTransportSender;
-import org.apache.axis2.transport.base.BaseUtils;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axis2.util.MessageProcessorSelector;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.HashMap;
-
-public class TCPTransportSender extends AbstractTransportSender {
-
- public void sendMessage(MessageContext msgContext, String targetEPR,
- OutTransportInfo outTransportInfo) throws AxisFault {
-
- if (targetEPR != null) {
- Map<String,String> params = getURLParameters(targetEPR);
- int timeout = -1;
- if (params.containsKey("timeout")) {
- timeout = Integer.parseInt(params.get("timeout"));
- }
- Socket socket = openTCPConnection(targetEPR, timeout);
- msgContext.setProperty(TCPConstants.TCP_OUTPUT_SOCKET, socket);
-
- String contentType = params.get("contentType");
- if (contentType == null) {
- contentType = TCPConstants.TCP_DEFAULT_CONTENT_TYPE;
- }
-
- try {
- writeOut(msgContext, socket, contentType);
- if (!msgContext.getOptions().isUseSeparateListener() && !msgContext.isServerSide()){
- waitForReply(msgContext, socket, contentType);
- }
- } catch (IOException e) {
- handleException("Error while sending a TCP request", e);
- }
-
- } else if (outTransportInfo != null && (outTransportInfo instanceof TCPOutTransportInfo)) {
- TCPOutTransportInfo outInfo = (TCPOutTransportInfo) outTransportInfo;
- try {
- writeOut(msgContext, outInfo.getSocket(), outInfo.getContentType());
- } catch (IOException e) {
- handleException("Error while sending a TCP response", e);
- } finally {
- closeConnection(outInfo.getSocket());
- }
- }
- }
-
- private void writeOut(MessageContext msgContext, Socket socket,
- String contentType) throws IOException {
- MessageFormatter messageFormatter = MessageProcessorSelector.getMessageFormatter(msgContext);
- OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
- format.setContentType(contentType);
- byte[] payload = messageFormatter.getBytes(msgContext, format);
- OutputStream out = socket.getOutputStream();
- out.write(payload);
- out.flush();
- }
-
- @Override
- public void cleanup(MessageContext msgContext) throws AxisFault {
- Object socketObj = msgContext.getProperty(TCPConstants.TCP_OUTPUT_SOCKET);
- if (socketObj != null) {
- closeConnection((Socket) socketObj);
- }
- }
-
- private void waitForReply(MessageContext msgContext, Socket socket,
- String contentType) throws AxisFault {
-
- if (!(msgContext.getAxisOperation() instanceof OutInAxisOperation) &&
- msgContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null) {
- return;
- }
-
- try {
- MessageContext responseMsgCtx = createResponseMessageContext(msgContext);
- SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext,
- socket.getInputStream(), contentType);
- responseMsgCtx.setEnvelope(envelope);
- AxisEngine.receive(responseMsgCtx);
- } catch (Exception e) {
- handleException("Error while processing response", e);
- }
- }
-
- private Map<String,String> getURLParameters(String url) throws AxisFault {
- try {
- Map<String,String> params = new HashMap<String,String>();
- URI tcpUrl = new URI(url);
- String query = tcpUrl.getQuery();
- if (query != null) {
- String[] paramStrings = query.split("&");
- for (String p : paramStrings) {
- int index = p.indexOf('=');
- params.put(p.substring(0, index), p.substring(index+1));
- }
- }
- return params;
- } catch (URISyntaxException e) {
- handleException("Malformed tcp url", e);
- }
- return null;
- }
-
- private Socket openTCPConnection(String url, int timeout) throws AxisFault {
- try {
- URI tcpUrl = new URI(url);
- if (!tcpUrl.getScheme().equals("tcp")) {
- throw new Exception("Invalid protocol prefix : " + tcpUrl.getScheme());
- }
- SocketAddress address = new InetSocketAddress(tcpUrl.getHost(), tcpUrl.getPort());
- Socket socket = new Socket();
- if (timeout != -1) {
- socket.setSoTimeout(timeout);
- }
- socket.connect(address);
- return socket;
- } catch (Exception e) {
- handleException("Error while opening TCP connection to : " + url, e);
- }
- return null;
- }
-
- private void closeConnection(Socket socket) {
- try {
- socket.close();
- } catch (IOException e) {
- log.error("Error while closing a TCP socket", e);
- }
- }
-}
diff --git a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPWorker.java b/modules/tcp/src/org/apache/axis2/transport/tcp/TCPWorker.java
deleted file mode 100644
index cd1ae9b..0000000
--- a/modules/tcp/src/org/apache/axis2/transport/tcp/TCPWorker.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.Constants;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.util.MessageContextBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.IOException;
-import java.net.Socket;
-
-/**
- * This Class is the work hoarse of the TCP request, this process the incomming SOAP Message.
- */
-public class TCPWorker implements Runnable {
-
- private static final Log log = LogFactory.getLog(TCPWorker.class);
-
- private TCPEndpoint endpoint;
- private Socket socket;
-
- public TCPWorker(TCPEndpoint endpoint, Socket socket) {
- this.endpoint = endpoint;
- this.socket = socket;
- }
-
- public void run() {
-
- MessageContext msgContext = null;
-
- try {
- msgContext = endpoint.createMessageContext();
- msgContext.setIncomingTransportName(Constants.TRANSPORT_TCP);
- //msgContext.setTransportIn(endpoint.getListener().getTransportInDescription());
-
- TCPOutTransportInfo outInfo = new TCPOutTransportInfo();
- outInfo.setSocket(socket);
- outInfo.setContentType(endpoint.getContentType());
- msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outInfo);
-
- // create the SOAP Envelope
- SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext,
- socket.getInputStream(), endpoint.getContentType());
- msgContext.setEnvelope(envelope);
-
- AxisEngine.receive(msgContext);
-
- } catch (Exception e) {
- sendFault(msgContext, e);
-
- } finally {
- try {
- socket.close();
- } catch (IOException e) {
- log.error("Error while closing a TCP socket", e);
- }
- }
- }
-
- private void sendFault(MessageContext msgContext, Exception fault) {
- log.error("Error while processing TCP request through the Axis2 engine", fault);
- try {
- if (msgContext != null) {
- msgContext.setProperty(MessageContext.TRANSPORT_OUT, socket.getOutputStream());
-
- MessageContext faultContext =
- MessageContextBuilder.createFaultMessageContext(msgContext, fault);
-
- AxisEngine.sendFault(faultContext);
- }
- } catch (Exception e) {
- log.error("Error while sending the fault response", e);
- }
- }
-}
diff --git a/modules/tcp/test/org/apache/axis2/transport/tcp/Echo.java b/modules/tcp/test/org/apache/axis2/transport/tcp/Echo.java
deleted file mode 100644
index cedc97a..0000000
--- a/modules/tcp/test/org/apache/axis2/transport/tcp/Echo.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMText;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class Echo {
-
- private static final Log log = LogFactory.getLog(Echo.class);
- public static final String SERVICE_NAME = "EchoXMLService";
- public static final String ECHO_OM_ELEMENT_OP_NAME = "echoOMElement";
-
- public Echo() {
- }
-
- public void echoVoid() {
- log.info("echo Service Called");
- }
-
- public void echoOMElementNoResponse(OMElement omEle) {
- log.info("echoOMElementNoResponse service called.");
- }
-
- public OMElement echoOMElement(OMElement omEle) {
- omEle.buildWithAttachments();
- omEle.setLocalName(omEle.getLocalName() + "Response");
- if (omEle.getFirstElement().getText().trim().startsWith("fault")) {
- throw new RuntimeException("fault string found in echoOMElement");
- }
- return omEle;
- }
-
- public OMElement echoOM(OMElement omEle) {
- return omEle;
- }
-
- public String echoString(String in) {
- return in;
- }
-
- public int echoInt(int in) {
- return in;
- }
-
- public OMElement echoMTOMtoBase64(OMElement omEle) {
- OMText omText = (OMText)(omEle.getFirstElement()).getFirstOMChild();
- omText.setOptimize(false);
- return omEle;
- }
-}
\ No newline at end of file
diff --git a/modules/tcp/test/org/apache/axis2/transport/tcp/TCPEchoRawXMLTest.java b/modules/tcp/test/org/apache/axis2/transport/tcp/TCPEchoRawXMLTest.java
deleted file mode 100644
index ede2239..0000000
--- a/modules/tcp/test/org/apache/axis2/transport/tcp/TCPEchoRawXMLTest.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.OperationClient;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.client.async.AxisCallback;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.util.Utils;
-import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-
-public class TCPEchoRawXMLTest extends TestCase {
- private EndpointReference targetEPR =
- new EndpointReference("tcp://127.0.0.1:"
- + (UtilsTCPServer.TESTING_PORT)
- + "/axis2/services/EchoXMLService/echoOMElement");
- private QName serviceName = new QName("EchoXMLService");
- private QName operationName = new QName("echoOMElement");
-
- private AxisService service;
- private AxisService clientService;
- private ConfigurationContext configContext;
-
- private boolean finish = false;
- private static final Log log = LogFactory.getLog(TCPEchoRawXMLTest.class);
-
- public TCPEchoRawXMLTest() {
- super(TCPEchoRawXMLTest.class.getName());
- }
-
- public TCPEchoRawXMLTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- UtilsTCPServer.start();
-
- //create and deploy the service
- service =
- Utils.createSimpleService(serviceName,
- Echo.class.getName(),
- operationName);
- UtilsTCPServer.deployService(service);
- clientService = Utils.createSimpleServiceforClient(serviceName,
- Echo.class.getName(),
- operationName);
- configContext = UtilsTCPServer.createClientConfigurationContext();
- }
-
- protected void tearDown() throws Exception {
- UtilsTCPServer.stop();
- configContext.getListenerManager().destroy();
- }
-
- private OMElement createPayload() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
- OMElement method = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.addChild(
- fac.createOMText(value, "Isaac Asimov, The Foundation Trilogy"));
- method.addChild(value);
-
- return method;
- }
-
- public void testEchoXMLASync() throws Exception {
- OMElement payload = createPayload();
- Options options = new Options();
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_TCP);
- options.setAction(Constants.AXIS2_NAMESPACE_URI + "/" + operationName.getLocalPart());
-
- AxisCallback callback = new AxisCallback() {
- public void onComplete(MessageContext msgCtx) {
- try {
- msgCtx.getEnvelope().serialize(StAXUtils
- .createXMLStreamWriter(System.out));
- } catch (XMLStreamException e) {
- onError(e);
- } finally {
- finish = true;
- }
- }
-
- public void onError(Exception e) {
- log.info(e.getMessage());
- finish = true;
- }
-
- public void onComplete() {
-
- }
-
- public void onFault(MessageContext msgCtx) {
- onComplete(msgCtx);
- }
-
- public void onMessage(MessageContext msgCtx) {
- onComplete(msgCtx);
- }
- };
-
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
-
- sender.sendReceiveNonBlocking(operationName, payload, callback);
-
- int index = 0;
- while (!finish) {
- Thread.sleep(1000);
- index++;
- if (index > 10) {
- throw new AxisFault(
- "Server was shutdown as the async response take too long to complete");
- }
- }
- sender.cleanup();
- }
-
- public void testEchoXMLSync() throws Exception {
- OMElement payload = createPayload();
-
- Options options = new Options();
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_TCP);
- options.setAction(Constants.AXIS2_NAMESPACE_URI+"/"+operationName.getLocalPart());
-
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
- OMElement result = sender.sendReceive(operationName, payload);
-
- result.serialize(StAXUtils.createXMLStreamWriter(
- System.out));
- sender.cleanup();
- }
-
- public void testEchoXMLCompleteSync() throws Exception {
- OMFactory fac = OMAbstractFactory.getOMFactory();
-
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
- OMElement payloadElement = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.setText("Isaac Asimov, The Foundation Trilogy");
- payloadElement.addChild(value);
-
- Options options = new Options();
- options.setTo(targetEPR);
- options.setAction(Constants.AXIS2_NAMESPACE_URI+"/"+operationName.getLocalPart());
- options.setTransportInProtocol(Constants.TRANSPORT_TCP);
- options.setUseSeparateListener(true);
-
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
- OMElement result = sender.sendReceive(operationName, payloadElement);
-
- result.serialize(StAXUtils.createXMLStreamWriter(
- System.out));
- sender.cleanup();
-
- }
-
- public void testEchoXMLSyncMC() throws Exception {
- AxisOperation opdesc = new OutInAxisOperation(new QName("echoOMElement"));
- Options options = new Options();
- options.setTo(targetEPR);
- options.setAction(operationName.getLocalPart());
- options.setTransportInProtocol(Constants.TRANSPORT_TCP);
-
- OMFactory fac = OMAbstractFactory.getOMFactory();
-
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
- OMElement method = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.setText("Isaac Asimov, The Foundation Trilogy");
- method.addChild(value);
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- envelope.getBody().addChild(method);
-
- MessageContext requestContext = new MessageContext();
- requestContext.setConfigurationContext(configContext);
- requestContext.setAxisService(clientService);
- requestContext.setAxisOperation(opdesc);
- requestContext.setEnvelope(envelope);
-
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
- OperationClient opClient = sender.createClient(new QName("echoOMElement"));
- opClient.addMessageContext(requestContext);
- opClient.setOptions(options);
- opClient.execute(true);
-
- MessageContext response = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- SOAPEnvelope env = response.getEnvelope();
- assertNotNull(env);
- env.getBody().serialize(StAXUtils.createXMLStreamWriter(
- System.out));
- sender.cleanup();
- }
-
-
-}
diff --git a/modules/tcp/test/org/apache/axis2/transport/tcp/TCPTwoChannelEchoRawXMLTest.java b/modules/tcp/test/org/apache/axis2/transport/tcp/TCPTwoChannelEchoRawXMLTest.java
deleted file mode 100644
index ecd7b70..0000000
--- a/modules/tcp/test/org/apache/axis2/transport/tcp/TCPTwoChannelEchoRawXMLTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.client.async.AxisCallback;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.util.Utils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-
-public class TCPTwoChannelEchoRawXMLTest extends TestCase {
- private EndpointReference targetEPR =
- new EndpointReference("tcp://127.0.0.1:"
- + (UtilsTCPServer.TESTING_PORT)
- + "/axis2/services/EchoXMLService/echoOMElement");
- private QName serviceName = new QName("EchoXMLService");
- private QName operationName = new QName("echoOMElement");
- private AxisService service;
- private ConfigurationContext configContext;
-
- private static final Log log = LogFactory.getLog(TCPTwoChannelEchoRawXMLTest.class);
-
- private boolean finish = false;
-
- public TCPTwoChannelEchoRawXMLTest() {
- super(TCPTwoChannelEchoRawXMLTest.class.getName());
- }
-
- public TCPTwoChannelEchoRawXMLTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- UtilsTCPServer.start();
-
- //create and deploy the service
- service =
- Utils.createSimpleService(serviceName,
- Echo.class.getName(),
- operationName);
- UtilsTCPServer.deployService(service);
-
- configContext = UtilsTCPServer.createClientConfigurationContext();
- }
-
- protected void tearDown() throws Exception {
- UtilsTCPServer.stop();
- configContext.getListenerManager().destroy();
- }
-
- public void testEchoXMLCompleteASync() throws Exception {
- OMFactory fac = OMAbstractFactory.getOMFactory();
-
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
- OMElement method = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.setText("Isaac Asimov, The Foundation Trilogy");
- method.addChild(value);
-
- ServiceClient sender;
-
- try {
- Options options = new Options();
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_TCP);
- options.setUseSeparateListener(true);
- options.setAction(operationName.getLocalPart());
- AxisCallback callback = new AxisCallback() {
- public void onComplete(MessageContext msgCtx) {
- try {
- msgCtx.getEnvelope().serializeAndConsume(StAXUtils
- .createXMLStreamWriter(System.out));
- } catch (XMLStreamException e) {
- onError(e);
- } finally {
- finish = true;
- }
- }
-
- public void onError(Exception e) {
- log.info(e.getMessage());
- finish = true;
- }
-
- public void onComplete() {
-
- }
-
- public void onFault(MessageContext msgCtx) {
- onComplete(msgCtx);
- }
-
- public void onMessage(MessageContext msgCtx) {
- onComplete(msgCtx);
- }
- };
-
- AxisService serviceClient =
- Utils.createSimpleServiceforClient(serviceName,
- Echo.class.getName(),
- operationName);
-
- sender = new ServiceClient(configContext, serviceClient);
- sender.setOptions(options);
-
- sender.sendReceiveNonBlocking(operationName, method, callback);
-
- int index = 0;
- while (!finish) {
- Thread.sleep(1000);
- index++;
- if (index > 10) {
- throw new AxisFault(
- "Server was shutdown as the async response take too long to complete");
- }
- }
- } finally {
- if (finish) {
- }
- }
-
- }
-}
diff --git a/modules/tcp/test/org/apache/axis2/transport/tcp/UtilsTCPServer.java b/modules/tcp/test/org/apache/axis2/transport/tcp/UtilsTCPServer.java
deleted file mode 100644
index dca0b67..0000000
--- a/modules/tcp/test/org/apache/axis2/transport/tcp/UtilsTCPServer.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.tcp;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.description.AxisService;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.io.File;
-
-public class UtilsTCPServer {
- private static int count = 0;
-
- private static TCPTransportListener receiver;
-
- public static final int TESTING_PORT = 5555;
-
- public static final String FAILURE_MESSAGE = "Intentional Failure";
-
- private static final Log log = LogFactory.getLog(UtilsTCPServer.class);
-
- public static synchronized void deployService(AxisService service)
- throws AxisFault {
-
- receiver.getConfigurationContext().getAxisConfiguration().addService(service);
- receiver.getConfigurationContext().createServiceGroupContext(service.getAxisServiceGroup());
- }
-
- public static synchronized void unDeployService(QName service)
- throws AxisFault {
- receiver.getConfigurationContext().getAxisConfiguration().removeService(
- service.getLocalPart());
- }
-
- public static synchronized void start() throws Exception {
- if (count == 0) {
-
- // start tcp server
- File file = new File(prefixBaseDirectory(Constants.TESTING_REPOSITORY));
- System.out.println(file.getAbsoluteFile());
- if (!file.exists()) {
- throw new Exception("Repository directory does not exist");
- }
- ConfigurationContext er =
- ConfigurationContextFactory.createConfigurationContextFromFileSystem(
- file.getAbsolutePath(), file.getAbsolutePath() + "/conf/axis2.xml");
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e1) {
- throw new AxisFault("Thread interuptted", e1);
- }
- receiver = new TCPTransportListener();
- receiver.init(er, er.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_TCP));
- receiver.start();
- }
- count++;
- }
-
- public static synchronized void stop() throws AxisFault {
- try {
- if (count == 1) {
- receiver.stop();
- receiver.destroy();
- count = 0;
- System.out.print("Server stopped .....");
- } else {
- count--;
- }
- } catch (AxisFault e) {
- log.error(e.getMessage(), e);
- }
- receiver.getConfigurationContext().terminate();
- }
-
- public static ConfigurationContext createClientConfigurationContext() throws Exception {
- File file = new File(prefixBaseDirectory(Constants.TESTING_REPOSITORY));
- ConfigurationContext configContext =
- ConfigurationContextFactory.createConfigurationContextFromFileSystem(
- file.getAbsolutePath(), file.getAbsolutePath() + "/conf/client_axis2.xml");
- return configContext;
- }
-
- public static String prefixBaseDirectory(String path) {
- String baseDir;
- try {
- baseDir = new File(System.getProperty("basedir", ".")).getCanonicalPath();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return baseDir + "/" + path;
- }
-
-}
diff --git a/modules/testkit/pom.xml b/modules/testkit/pom.xml
deleted file mode 100644
index bc58c66..0000000
--- a/modules/testkit/pom.xml
+++ /dev/null
@@ -1,217 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transports</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <artifactId>axis2-transport-testkit</artifactId>
- <name>Apache Axis2 - Transport - testkit</name>
- <description>Framework to build test suites for Axis2 transports</description>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/testkit</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/testkit</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/testkit</url>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-kernel</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>addressing</artifactId>
- <type>mar</type>
- <version>${axis2.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.directory.shared</groupId>
- <artifactId>shared-ldap</artifactId>
- <version>0.9.11</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.3.0</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.13</version>
- </dependency>
- <dependency>
- <groupId>jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>5.1.10</version>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>default-tools.jar</id>
- <activation>
- <property>
- <name>java.vendor</name>
- <value>Sun Microsystems Inc.</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.5.0</version>
- <scope>system</scope>
- <systemPath>${java.home}/../lib/tools.jar</systemPath>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>default-tools.jar-2</id>
- <activation>
- <property>
- <name>java.vendor</name>
- <value>IBM Corporation</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.5.0</version>
- <scope>system</scope>
- <systemPath>${java.home}/../lib/tools.jar</systemPath>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <directory>target/generated-resources</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.0</version>
- <executions>
- <execution>
- <id>copy</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <stripVersion>true</stripVersion>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.axis2</groupId>
- <artifactId>addressing</artifactId>
- <version>${axis2.version}</version>
- <type>mar</type>
- <outputDirectory>
- target/generated-resources/org/apache/axis2/transport/repo/modules
- </outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <executions>
- <execution>
- <id>extract-resource-info</id>
- <phase>pre-site</phase>
- <goals>
- <goal>javadoc</goal>
- </goals>
- <configuration>
- <docletArtifacts>
- <docletArtifact>
- <groupId>${project.groupId}</groupId>
- <artifactId>${project.artifactId}</artifactId>
- <version>${project.version}</version>
- </docletArtifact>
- </docletArtifacts>
- <doclet>org.apache.axis2.transport.testkit.doclet.ResourceInfoDoclet</doclet>
- <useStandardDocletOptions>false</useStandardDocletOptions>
- <show>private</show>
- <additionalparam>-out ${project.build.directory}/resource-info.dat</additionalparam>
- </configuration>
- </execution>
- <execution>
- <id>generate-javadoc</id>
- <phase>site</phase>
- <goals>
- <goal>javadoc</goal>
- </goals>
- <configuration>
- <docletArtifacts>
- <docletArtifact>
- <groupId>${project.groupId}</groupId>
- <artifactId>${project.artifactId}</artifactId>
- <version>${project.version}</version>
- </docletArtifact>
- </docletArtifacts>
- <doclet>org.apache.axis2.transport.testkit.doclet.TestkitJavadocDoclet</doclet>
- <useStandardDocletOptions>true</useStandardDocletOptions>
- <additionalparam>
- -resource-info ${project.build.directory}/resource-info.dat
- -link http://java.sun.com/j2se/1.5.0/docs/api/
- -link http://java.sun.com/j2ee/1.4/docs/api/
- -link http://ws.apache.org/axis2/1_4_1/api/
- -link http://ws.apache.org/commons/axiom/apidocs/
- -link http://junit.org/junit/javadoc/3.8.1/
- -link http://www.eclipse.org/aspectj/doc/released/runtime-api/
- </additionalparam>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/AbstractTransportTest.java b/modules/testkit/src/main/java/org/apache/axis2/transport/AbstractTransportTest.java
deleted file mode 100644
index c885024..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/AbstractTransportTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport;
-
-import javax.xml.stream.XMLStreamReader;
-
-import junit.framework.TestCase;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.UtilsTransportServer;
-
-public abstract class AbstractTransportTest extends TestCase {
-
- private UtilsTransportServer server;
-
- protected void setUp() throws Exception {
- // Temporarily change jmx.agent.name system property to avoid collisions
- // between MBeans registered by the server context and those registered
- // by the client context
- String agentName = System.getProperty("jmx.agent.name", "org.apache.synapse");
- System.setProperty("jmx.agent.name", agentName + "-server");
- server = createServer();
- server.start();
- System.setProperty("jmx.agent.name", agentName);
- }
-
- protected void tearDown() throws Exception {
- server.stop();
- server = null;
- }
-
- protected abstract UtilsTransportServer createServer() throws Exception;
-
- /**
- * Create the payload for an echoOMElement request
- * @return
- */
- protected OMElement createPayload(String textValue) {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://localhost/axis2/services/EchoXMLService", "my");
- OMElement method = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.addChild(fac.createOMText(value, textValue));
- method.addChild(value);
- return method;
- }
-
- protected OMElement createPayload() {
- return createPayload("omTextValue");
- }
-
- protected void assertEchoResponse(String textValue, OMElement element) {
- assertEquals("echoOMElementResponse", element.getLocalName());
- assertEquals("http://localhost/axis2/services/EchoXMLService",
- element.getNamespace().getNamespaceURI());
- OMElement valueElement = element.getFirstElement();
- assertEquals("myValue", valueElement.getLocalName());
- assertEquals("http://localhost/axis2/services/EchoXMLService",
- valueElement.getNamespace().getNamespaceURI());
- assertEquals(textValue, valueElement.getText());
- }
-
- protected void assertEchoResponse(OMElement element) {
- assertEchoResponse("omTextValue", element);
- }
-
- protected void assertSOAPEchoResponse(String textValue, XMLStreamReader reader) {
- SOAPEnvelope env = new StAXSOAPModelBuilder(reader).getSOAPEnvelope();
- assertEchoResponse(textValue, env.getBody().getFirstElement());
- }
-
- protected void assertSOAPEchoResponse(XMLStreamReader reader) {
- assertSOAPEchoResponse("omTextValue", reader);
- }
-
- /**
- * Get the default axis2 configuration context for a client
- * @return
- * @throws Exception
- */
- protected ConfigurationContext getClientCfgCtx() throws Exception {
- AxisConfiguration axisCfg = new AxisConfiguration();
- ConfigurationContext cfgCtx = new ConfigurationContext(axisCfg);
- return cfgCtx;
- }
-
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/CustomAxisConfigurator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/CustomAxisConfigurator.java
deleted file mode 100644
index 51cace3..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/CustomAxisConfigurator.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.deployment.DeploymentEngine;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.AxisConfigurator;
-import org.apache.axis2.util.Loader;
-
-public class CustomAxisConfigurator extends DeploymentEngine implements AxisConfigurator {
- public AxisConfiguration getAxisConfiguration() throws AxisFault {
- InputStream configStream = Loader.getResourceAsStream("org/apache/axis2/transport/axis2.xml");
- try {
- axisConfig = populateAxisConfiguration(configStream);
- } finally {
- try {
- configStream.close();
- } catch (IOException ex) {
- throw AxisFault.makeFault(ex);
- }
- }
- try {
- loadRepositoryFromURL(new URL(Loader.getResource("org/apache/axis2/transport/repo/__root__"), "."));
- } catch (MalformedURLException ex) {
- throw AxisFault.makeFault(ex);
- }
- axisConfig.setConfigurator(this);
- return axisConfig;
- }
-
- public void loadServices() {
- // We don't have any services.
- }
-
- public void engageGlobalModules() throws AxisFault {
- engageModules();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/Echo.java b/modules/testkit/src/main/java/org/apache/axis2/transport/Echo.java
deleted file mode 100644
index 3533ef7..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/Echo.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMText;
-
-public class Echo {
-
- private static final Log log = LogFactory.getLog(Echo.class);
- public static final String SERVICE_NAME = "EchoXMLService";
- public static final String ECHO_OM_ELEMENT_OP_NAME = "echoOMElement";
-
- public void echoVoid() {
- log.info("echo Service Called");
- }
-
- public void echoOMElementNoResponse(OMElement omEle) {
- log.info("echoOMElementNoResponse service called.");
- }
-
- public OMElement echoOMElement(OMElement omEle) {
- omEle.buildWithAttachments();
- omEle.setLocalName(omEle.getLocalName() + "Response");
- if (omEle.getFirstElement().getText().trim().startsWith("fault")) {
- throw new RuntimeException("fault string found in echoOMElement");
- }
- return omEle;
- }
-
- public OMElement echoOM(OMElement omEle) {
- return omEle;
- }
-
- public String echoString(String in) {
- return in;
- }
-
- public int echoInt(int in) {
- return in;
- }
-
- public OMElement echoMTOMtoBase64(OMElement omEle) {
- OMText omText = (OMText)(omEle.getFirstElement()).getFirstOMChild();
- omText.setOptimize(false);
- return omEle;
- }
-}
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/UtilsTransportServer.java b/modules/testkit/src/main/java/org/apache/axis2/transport/UtilsTransportServer.java
deleted file mode 100644
index d2af8fa..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/UtilsTransportServer.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport;
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.InOutAxisOperation;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.ListenerManager;
-import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
-import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
-import org.apache.axis2.wsdl.WSDLConstants;
-
-/**
- * Base class for transport util servers used in unit testing
- */
-public class UtilsTransportServer {
-
- private final ListenerManager listnMgr;
- private final ConfigurationContext cfgCtx;
-
- public UtilsTransportServer() throws AxisFault {
- cfgCtx = ConfigurationContextFactory.
- createConfigurationContext(new CustomAxisConfigurator());
-
- // create listener manager
- listnMgr = new ListenerManager();
- cfgCtx.setTransportManager(listnMgr);
- }
-
- public void addTransport(TransportInDescription trpInDesc,
- TransportOutDescription trpDescOut) throws AxisFault {
- cfgCtx.getAxisConfiguration().addTransportIn(trpInDesc);
- if (trpDescOut != null) {
- trpDescOut.getSender().init(cfgCtx, trpDescOut);
- cfgCtx.getAxisConfiguration().addTransportOut(trpDescOut);
- }
- }
-
- public void addTransport(TransportInDescription trpInDesc) throws AxisFault {
- addTransport(trpInDesc, null);
- }
-
- public void start() throws Exception {
- listnMgr.init(cfgCtx);
- listnMgr.start();
- }
-
- public void stop() throws Exception {
- listnMgr.stop();
- listnMgr.destroy();
- }
-
- public void enableAddressing() throws AxisFault {
- cfgCtx.getAxisConfiguration().engageModule("addressing");
- }
-
- public ConfigurationContext getConfigurationContext() {
- return cfgCtx;
- }
-
- public AxisConfiguration getAxisConfiguration() {
- return cfgCtx.getAxisConfiguration();
- }
-
- /**
- * Deploy the standard Echo service with the custom parameters passed in
- * @param name the service name to assign
- * @param parameters the parameters for the service
- * @throws Exception
- */
- public void deployEchoService(String name, List<Parameter> parameters) throws Exception {
-
- AxisService service = new AxisService(name);
- service.setClassLoader(Thread.currentThread().getContextClassLoader());
- service.addParameter(new Parameter(Constants.SERVICE_CLASS, Echo.class.getName()));
-
- // add operation echoOMElement
- AxisOperation axisOp = new InOutAxisOperation(new QName("echoOMElement"));
- axisOp.setMessageReceiver(new RawXMLINOutMessageReceiver());
- axisOp.setStyle(WSDLConstants.STYLE_RPC);
- service.addOperation(axisOp);
- service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/echoOMElement", axisOp);
-
- // add operation echoOMElementNoResponse
- axisOp = new InOutAxisOperation(new QName("echoOMElementNoResponse"));
- axisOp.setMessageReceiver(new RawXMLINOnlyMessageReceiver());
- axisOp.setStyle(WSDLConstants.STYLE_RPC);
- service.addOperation(axisOp);
- service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/echoOMElementNoResponse", axisOp);
-
- for (Parameter parameter : parameters) {
- service.addParameter(parameter);
- }
-
- cfgCtx.getAxisConfiguration().addService(service);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/Adapter.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/Adapter.java
deleted file mode 100644
index 3a89339..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/Adapter.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit;
-
-public interface Adapter {
- Object getTarget();
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/AdapterUtils.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/AdapterUtils.java
deleted file mode 100644
index ef51eba..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/AdapterUtils.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit;
-
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.AsyncTestClientAdapter;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClientAdapter;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpointAdapter;
-import org.apache.axis2.transport.testkit.message.MessageDecoder;
-import org.apache.axis2.transport.testkit.message.MessageEncoder;
-
-public class AdapterUtils {
- public static <M,N> AsyncTestClient<M> adapt(AsyncTestClient<N> target, MessageEncoder<M,N> encoder) {
- return new AsyncTestClientAdapter<M,N>(target, encoder);
- }
-
- public static <M,N,O,P> RequestResponseTestClient<M,O> adapt(RequestResponseTestClient<N,P> target, MessageEncoder<M,N> encoder, MessageDecoder<P,O> decoder) {
- return new RequestResponseTestClientAdapter<M,N,O,P>(target, encoder, decoder);
- }
-
- public static <M,N> AsyncEndpoint<M> adapt(AsyncEndpoint<N> target, MessageDecoder<N,M> decoder) {
- return new AsyncEndpointAdapter<M,N>(target, decoder);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java
deleted file mode 100644
index e352432..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit;
-
-import java.text.ParseException;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-
-import org.apache.axis2.transport.testkit.filter.FilterExpression;
-import org.apache.axis2.transport.testkit.filter.FilterExpressionParser;
-import org.apache.axis2.transport.testkit.tests.TestResourceSet;
-import org.apache.axis2.transport.testkit.tests.TestResourceSetTransition;
-import org.apache.axis2.transport.testkit.tests.ManagedTestCase;
-import org.apache.axis2.transport.testkit.util.LogManager;
-import org.apache.commons.lang.StringUtils;
-
-public class ManagedTestSuite extends TestSuite {
- private final Class<?> testClass;
- private final List<FilterExpression> excludes = new LinkedList<FilterExpression>();
- private final boolean reuseResources;
- private boolean invertExcludes;
- private int nextId = 1;
-
- public ManagedTestSuite(Class<?> testClass, boolean reuseResources) {
- this.testClass = testClass;
- this.reuseResources = reuseResources;
- }
-
- public ManagedTestSuite(Class<?> testClass) {
- this(testClass, true);
- }
-
- public Class<?> getTestClass() {
- return testClass;
- }
-
- public void addExclude(String filter) throws ParseException {
- excludes.add(FilterExpressionParser.parse(filter));
- }
-
- public void setInvertExcludes(boolean invertExcludes) {
- this.invertExcludes = invertExcludes;
- }
-
- @Override
- public void addTest(Test test) {
- if (test instanceof ManagedTestCase) {
- ManagedTestCase ttest = (ManagedTestCase)test;
- Map<String,String> map = ttest.getNameComponents();
- boolean excluded = false;
- for (FilterExpression exclude : excludes) {
- if (exclude.matches(map)) {
- excluded = true;
- break;
- }
- }
- if (excluded != invertExcludes) {
- return;
- }
- ttest.init(StringUtils.leftPad(String.valueOf(nextId++), 4, '0'),
- reuseResources, testClass);
- ttest.getResourceSet().resolve();
- }
- super.addTest(test);
- }
-
- @Override
- public void run(TestResult result) {
- LogManager logManager = LogManager.INSTANCE;
- if (!reuseResources) {
- super.run(result);
- } else {
- TestResourceSet resourceSet = null;
- for (Enumeration<?> e = tests(); e.hasMoreElements(); ) {
- Test test = (Test)e.nextElement();
- if (test instanceof ManagedTestCase) {
- ManagedTestCase ttest = (ManagedTestCase)test;
- TestResourceSet newResourceSet = ttest.getResourceSet();
- try {
- if (resourceSet == null) {
- logManager.setTestCase(ttest);
- newResourceSet.setUp();
- } else {
- TestResourceSetTransition transition = new TestResourceSetTransition(resourceSet, newResourceSet);
- transition.tearDown();
- logManager.setTestCase(ttest);
- transition.setUp();
- }
- } catch (Throwable t) {
- result.addError(this, t);
- return;
- }
- resourceSet = newResourceSet;
- }
- runTest(test, result);
- }
- if (resourceSet != null) {
- try {
- resourceSet.tearDown();
- logManager.setTestCase(null);
- } catch (Throwable t) {
- result.addError(this, t);
- return;
- }
- }
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/MessageExchangeValidator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/MessageExchangeValidator.java
deleted file mode 100644
index ba7ceb9..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/MessageExchangeValidator.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit;
-
-public interface MessageExchangeValidator {
- void beforeSend() throws Exception;
- void afterReceive() throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/MessageTestData.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/MessageTestData.java
deleted file mode 100644
index ad5bd8b..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/MessageTestData.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit;
-
-import org.apache.axis2.transport.testkit.name.Key;
-
-public class MessageTestData {
- private final String name;
- private final String text;
- private final String charset;
-
- public MessageTestData(String name, String text, String charset) {
- this.name = name;
- this.text = text;
- this.charset = charset;
- }
-
- @Key("data")
- public String getName() {
- return name;
- }
-
- public String getText() {
- return text;
- }
-
- public String getCharset() {
- return charset;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
deleted file mode 100644
index e57bc45..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit;
-
-import static org.apache.axis2.transport.testkit.AdapterUtils.adapt;
-
-import java.text.ParseException;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
-import org.apache.axis2.transport.testkit.endpoint.TestEndpoint;
-import org.apache.axis2.transport.testkit.message.AxisMessage;
-import org.apache.axis2.transport.testkit.message.MessageDecoder;
-import org.apache.axis2.transport.testkit.message.MessageEncoder;
-import org.apache.axis2.transport.testkit.message.RESTMessage;
-import org.apache.axis2.transport.testkit.message.XMLMessage;
-import org.apache.axis2.transport.testkit.message.RESTMessage.Parameter;
-import org.apache.axis2.transport.testkit.tests.async.BinaryTestCase;
-import org.apache.axis2.transport.testkit.tests.async.LargeSOAPAsyncMessageTestCase;
-import org.apache.axis2.transport.testkit.tests.async.RESTTestCase;
-import org.apache.axis2.transport.testkit.tests.async.SwATestCase;
-import org.apache.axis2.transport.testkit.tests.async.TextPlainTestCase;
-import org.apache.axis2.transport.testkit.tests.async.XMLAsyncMessageTestCase;
-import org.apache.axis2.transport.testkit.tests.echo.XMLRequestResponseMessageTestCase;
-
-public class TransportTestSuiteBuilder {
- static class ResourceRelation<T> {
- private final T primaryResource;
- private final Object[] relatedResources;
-
- public ResourceRelation(T primaryResource, Object... relatedResources) {
- this.primaryResource = primaryResource;
- this.relatedResources = relatedResources;
- }
-
- public T getPrimaryResource() {
- return primaryResource;
- }
-
- public Object[] getRelatedResources() {
- return relatedResources;
- }
- }
-
- static class ResourceList<T> implements Iterable<ResourceRelation<T>> {
- private final List<ResourceRelation<T>> list = new LinkedList<ResourceRelation<T>>();
-
- public void add(T primaryResource, Object... relatedResources) {
- list.add(new ResourceRelation<T>(primaryResource, relatedResources));
- }
-
- public Iterator<ResourceRelation<T>> iterator() {
- return list.iterator();
- }
- }
-
- public static final String testString = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre";
-
- public static final MessageTestData ASCII_TEST_DATA = new MessageTestData("ASCII", "test string", "us-ascii");
- public static final MessageTestData UTF8_TEST_DATA = new MessageTestData("UTF8", testString, "UTF-8");
- public static final MessageTestData LATIN1_TEST_DATA = new MessageTestData("Latin1", testString, "ISO-8859-1");
-
- private static final MessageTestData[] messageTestData = new MessageTestData[] {
- ASCII_TEST_DATA,
- UTF8_TEST_DATA,
- LATIN1_TEST_DATA,
- };
-
- private static final RESTMessage restTestMessage1 = new RESTMessage(new Parameter[] {
- new Parameter("param1", "value1"),
- new Parameter("param2", "value2"),
- });
-
- private static final RESTMessage restTestMessage2 = new RESTMessage(new Parameter[] {
- new Parameter("param", "value1"),
- new Parameter("param", "value2"),
- });
-
- private final ManagedTestSuite suite;
-
- private final List<Object[]> environments = new LinkedList<Object[]>();
-
- private final ResourceList<AsyncChannel> asyncChannels = new ResourceList<AsyncChannel>();
-
- private final ResourceList<AsyncTestClient<byte[]>> byteAsyncClients = new ResourceList<AsyncTestClient<byte[]>>();
- private final ResourceList<AsyncTestClient<XMLMessage>> xmlAsyncClients = new ResourceList<AsyncTestClient<XMLMessage>>();
- private final ResourceList<AsyncTestClient<RESTMessage>> restAsyncClients = new ResourceList<AsyncTestClient<RESTMessage>>();
- private final ResourceList<AsyncTestClient<String>> stringAsyncClients = new ResourceList<AsyncTestClient<String>>();
-
- private final ResourceList<AsyncEndpoint<byte[]>> byteAsyncEndpoints = new ResourceList<AsyncEndpoint<byte[]>>();
- private final ResourceList<AsyncEndpoint<XMLMessage>> xmlAsyncEndpoints = new ResourceList<AsyncEndpoint<XMLMessage>>();
- private final ResourceList<AsyncEndpoint<RESTMessage>> restAsyncEndpoints = new ResourceList<AsyncEndpoint<RESTMessage>>();
- private final ResourceList<AsyncEndpoint<String>> stringAsyncEndpoints = new ResourceList<AsyncEndpoint<String>>();
-
- private final ResourceList<RequestResponseChannel> requestResponseChannels = new ResourceList<RequestResponseChannel>();
-
- private final ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>> xmlRequestResponseClients = new ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>>();
-
- private final ResourceList<InOutEndpoint> echoEndpoints = new ResourceList<InOutEndpoint>();
-
- public TransportTestSuiteBuilder(ManagedTestSuite suite) {
- this.suite = suite;
- try {
- // We only want tests with client and/or endpoint based on Axis
- suite.addExclude("(&(client=*)(endpoint=*)(!(|(client=axis)(endpoint=axis))))");
- } catch (ParseException ex) {
- throw new Error(ex);
- }
- }
-
- public void addEnvironment(Object... resources) {
- environments.add(resources);
- }
-
- public void addAsyncChannel(AsyncChannel channel, Object... relatedResources) {
- asyncChannels.add(channel, relatedResources);
- }
-
- public void addAxisAsyncTestClient(AsyncTestClient<AxisMessage> client, Object... relatedResources) {
- byteAsyncClients.add(adapt(client, MessageEncoder.BINARY_WRAPPER), relatedResources);
- xmlAsyncClients.add(adapt(client, MessageEncoder.XML_TO_AXIS), relatedResources);
- stringAsyncClients.add(adapt(client, MessageEncoder.TEXT_WRAPPER), relatedResources);
- }
-
- public void addByteArrayAsyncTestClient(AsyncTestClient<byte[]> client, Object... relatedResources) {
- byteAsyncClients.add(client, relatedResources);
- xmlAsyncClients.add(adapt(client, MessageEncoder.XML_TO_BYTE), relatedResources);
- stringAsyncClients.add(adapt(client, MessageEncoder.STRING_TO_BYTE), relatedResources);
- }
-
- public void addRESTAsyncTestClient(AsyncTestClient<RESTMessage> client, Object... relatedResources) {
- restAsyncClients.add(client, relatedResources);
- }
-
- public void addStringAsyncTestClient(AsyncTestClient<String> client, Object... relatedResources) {
- xmlAsyncClients.add(adapt(client, MessageEncoder.XML_TO_STRING), relatedResources);
- stringAsyncClients.add(client, relatedResources);
- }
-
- public void addAxisAsyncEndpoint(AsyncEndpoint<AxisMessage> endpoint, Object... relatedResources) {
- byteAsyncEndpoints.add(adapt(endpoint, MessageDecoder.AXIS_TO_BYTE), relatedResources);
- xmlAsyncEndpoints.add(adapt(endpoint, MessageDecoder.AXIS_TO_XML), relatedResources);
- restAsyncEndpoints.add(adapt(endpoint, MessageDecoder.AXIS_TO_REST), relatedResources);
- stringAsyncEndpoints.add(adapt(endpoint, MessageDecoder.AXIS_TO_STRING), relatedResources);
- }
-
- public void addByteArrayAsyncEndpoint(AsyncEndpoint<byte[]> endpoint, Object... relatedResources) {
- byteAsyncEndpoints.add(endpoint, relatedResources);
- xmlAsyncEndpoints.add(adapt(endpoint, MessageDecoder.BYTE_TO_XML), relatedResources);
- stringAsyncEndpoints.add(adapt(endpoint, MessageDecoder.BYTE_TO_STRING), relatedResources);
- }
-
- public void addRESTAsyncEndpoint(AsyncEndpoint<RESTMessage> endpoint, Object... relatedResources) {
- restAsyncEndpoints.add(endpoint, relatedResources);
- }
-
- public void addRequestResponseChannel(RequestResponseChannel channel, Object... relatedResources) {
- requestResponseChannels.add(channel, relatedResources);
- }
-
- public void addAxisRequestResponseTestClient(RequestResponseTestClient<AxisMessage,AxisMessage> client, Object... relatedResources) {
- xmlRequestResponseClients.add(adapt(client, MessageEncoder.XML_TO_AXIS, MessageDecoder.AXIS_TO_XML), relatedResources);
- }
-
- public void addByteArrayRequestResponseTestClient(RequestResponseTestClient<byte[],byte[]> client, Object... relatedResources) {
- xmlRequestResponseClients.add(adapt(client, MessageEncoder.XML_TO_BYTE, MessageDecoder.BYTE_TO_XML), relatedResources);
- }
-
- public void addStringRequestResponseTestClient(RequestResponseTestClient<String,String> client, Object... relatedResources) {
- xmlRequestResponseClients.add(adapt(client, MessageEncoder.XML_TO_STRING, MessageDecoder.STRING_TO_XML), relatedResources);
- }
-
- public void addEchoEndpoint(InOutEndpoint endpoint, Object... relatedResources) {
- echoEndpoints.add(endpoint, relatedResources);
- }
-
- private Object[] merge(Object[] environment, ResourceRelation<?>... resourceRelations) {
- Set<Object> resources = new LinkedHashSet<Object>();
- resources.addAll(Arrays.asList(environment));
- for (ResourceRelation<?> resourceRelation : resourceRelations) {
- resources.addAll(Arrays.asList(resourceRelation.getRelatedResources()));
- }
- return resources.toArray();
- }
-
- private void build(Object[] env) {
- for (ResourceRelation<AsyncChannel> channel : asyncChannels) {
- for (ResourceRelation<AsyncTestClient<XMLMessage>> client : xmlAsyncClients) {
- for (ResourceRelation<AsyncEndpoint<XMLMessage>> endpoint : xmlAsyncEndpoints) {
- Object[] resources = merge(env, channel, client, endpoint);
- for (MessageTestData data : messageTestData) {
- for (XMLMessage.Type type : XMLMessage.Type.values()) {
- if (type != XMLMessage.Type.SWA) {
- suite.addTest(new XMLAsyncMessageTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), type, data, resources));
- }
- }
- }
- suite.addTest(new SwATestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), resources));
- // Regression test for SYNAPSE-423:
- suite.addTest(new LargeSOAPAsyncMessageTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), resources));
- }
- }
- for (ResourceRelation<AsyncTestClient<String>> client : stringAsyncClients) {
- for (ResourceRelation<AsyncEndpoint<String>> endpoint : stringAsyncEndpoints) {
- Object[] resources = merge(env, channel, client, endpoint);
- for (MessageTestData data : messageTestData) {
- suite.addTest(new TextPlainTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), data, resources));
- }
- }
- }
- for (ResourceRelation<AsyncTestClient<byte[]>> client : byteAsyncClients) {
- for (ResourceRelation<AsyncEndpoint<byte[]>> endpoint : byteAsyncEndpoints) {
- Object[] resources = merge(env, channel, client, endpoint);
- suite.addTest(new BinaryTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), resources));
- }
- }
- for (ResourceRelation<AsyncTestClient<RESTMessage>> client : restAsyncClients) {
- for (ResourceRelation<AsyncEndpoint<RESTMessage>> endpoint : restAsyncEndpoints) {
- Object[] resources = merge(env, channel, client, endpoint);
- suite.addTest(new RESTTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), restTestMessage1, resources));
- // TODO: regression test for SYNAPSE-431
-// addTest(new RESTTestCase(env, channel, client, endpoint, restTestMessage2));
- }
- }
- }
- for (ResourceRelation<RequestResponseChannel> channel : requestResponseChannels) {
- for (ResourceRelation<RequestResponseTestClient<XMLMessage,XMLMessage>> client : xmlRequestResponseClients) {
- for (ResourceRelation<InOutEndpoint> endpoint : echoEndpoints) {
- Object[] resources = merge(env, channel, client, endpoint);
- for (MessageTestData data : messageTestData) {
- for (XMLMessage.Type type : XMLMessage.Type.values()) {
- if (type != XMLMessage.Type.SWA) {
- suite.addTest(new XMLRequestResponseMessageTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), type, data, resources));
- }
- }
- }
- }
- }
- }
- }
-
- public void build() {
- if (environments.isEmpty()) {
- build(new Object[0]);
- } else {
- for (Object[] env : environments) {
- build(env);
- }
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/AxisServiceConfigurator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/AxisServiceConfigurator.java
deleted file mode 100644
index 9ccbf52..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/AxisServiceConfigurator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2;
-
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-
-public interface AxisServiceConfigurator {
- /**
- * Set up the service so that it can receive messages through the transport under test.
- * Implementations will typically call {@link AxisService#addParameter(Parameter)} to
- * setup the service parameters required by the transport.
- * The default implementation does nothing.
- *
- * @param service
- * @param isClientSide TODO
- * @throws Exception
- */
- void setupService(AxisService service, boolean isClientSide) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java
deleted file mode 100644
index f62cccb..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.activation.DataSource;
-
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.testkit.util.LogManager;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.input.TeeInputStream;
-import org.apache.commons.io.output.TeeOutputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.AfterReturning;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-
-@Aspect
-public class LogAspect {
- private static final Log log = LogFactory.getLog(LogAspect.class);
-
- @Around("call(void org.apache.axis2.transport.MessageFormatter.writeTo(" +
- " org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat," +
- " java.io.OutputStream, boolean))" +
- " && args(msgContext, format, out, preserve)")
- public void aroundWriteTo(ProceedingJoinPoint proceedingJoinPoint,
- MessageContext msgContext, OMOutputFormat format, OutputStream out, boolean preserve)
- throws Throwable {
- OutputStream log = LogManager.INSTANCE.createLog("formatter");
- try {
- OutputStream tee = new TeeOutputStream(out, log);
- proceedingJoinPoint.proceed(new Object[] { msgContext, format, tee, preserve });
- } finally {
- log.close();
- }
- }
-
- @AfterReturning(
- pointcut="call(javax.activation.DataSource org.apache.axis2.format.MessageFormatterEx.getDataSource(..))",
- returning="dataSource")
- public void afterGetDataSource(DataSource dataSource) {
- try {
- OutputStream out = LogManager.INSTANCE.createLog("formatter");
- try {
- InputStream in = dataSource.getInputStream();
- try {
- IOUtils.copy(in, out);
- } finally {
- in.close();
- }
- } finally {
- out.close();
- }
- } catch (Throwable ex) {
- log.error("Unable to dump message", ex);
- }
- }
-
- @Around("call(org.apache.axiom.om.OMElement org.apache.axis2.builder.Builder.processDocument(" +
- " java.io.InputStream, java.lang.String, org.apache.axis2.context.MessageContext))" +
- " && args(in, contentType, msgContext)")
- public Object aroundProcessDocument(ProceedingJoinPoint proceedingJoinPoint,
- InputStream in, String contentType, MessageContext msgContext) throws Throwable {
- InputStream tee;
- if (in == null) {
- tee = null;
- } else {
- OutputStream log = LogManager.INSTANCE.createLog("builder");
- // Note: We can't close the log right after the method execution because the
- // message builder may use streaming. LogManager will take care of closing the
- // log for us if anything goes wrong.
- tee = new TeeInputStream(in, log, true);
- }
- return proceedingJoinPoint.proceed(new Object[] { tee, contentType, msgContext });
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/MessageContextValidator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/MessageContextValidator.java
deleted file mode 100644
index 74abca7..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/MessageContextValidator.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2;
-
-import org.apache.axis2.context.MessageContext;
-
-public interface MessageContextValidator {
- void validate(MessageContext msgContext, boolean isResponse) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/SimpleTransportDescriptionFactory.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/SimpleTransportDescriptionFactory.java
deleted file mode 100644
index 6d4972f..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/SimpleTransportDescriptionFactory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2;
-
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.TransportSender;
-
-public class SimpleTransportDescriptionFactory implements TransportDescriptionFactory {
- private final String name;
- private final Class<? extends TransportListener> listenerClass;
- private final Class<? extends TransportSender> senderClass;
-
- public SimpleTransportDescriptionFactory(String name,
- Class<? extends TransportListener> listenerClass,
- Class<? extends TransportSender> senderClass) {
- this.name = name;
- this.listenerClass = listenerClass;
- this.senderClass = senderClass;
- }
-
- public TransportInDescription createTransportInDescription() throws Exception {
- TransportInDescription trpInDesc = new TransportInDescription(name);
- trpInDesc.setReceiver(listenerClass.newInstance());
- return trpInDesc;
- }
-
- public TransportOutDescription createTransportOutDescription() throws Exception {
- TransportOutDescription trpOutDesc = new TransportOutDescription(name);
- trpOutDesc.setSender(senderClass.newInstance());
- return trpOutDesc;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java
deleted file mode 100644
index f5d3561..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2;
-
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientContextConfigurator;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpointContextConfigurator;
-
-/**
- * Resource used to create the {@link TransportInDescription} and
- * {@link TransportOutDescription} objects for a transport under test.
- * <p>
- * Note that this resource is used on both client and server side.
- * If the transport needs different configurations on client and server side,
- * use {@link AxisTestClientContextConfigurator} and/or
- * {@link AxisTestEndpointContextConfigurator}.
- */
-public interface TransportDescriptionFactory {
- TransportOutDescription createTransportOutDescription() throws Exception;
-
- /**
- * Create a TransportInDescription for the transport under test.
- *
- * @return the transport description
- * @throws Exception
- */
- TransportInDescription createTransportInDescription() throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisAsyncTestClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisAsyncTestClient.java
deleted file mode 100644
index c1a9423..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisAsyncTestClient.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.client;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.message.AxisMessage;
-
-public class AxisAsyncTestClient extends AxisTestClient implements AsyncTestClient<AxisMessage> {
- private final boolean block;
-
- public AxisAsyncTestClient(boolean block) {
- this.block = block;
- }
-
- public AxisAsyncTestClient() {
- this(true);
- }
-
- public void sendMessage(ClientOptions options, ContentType contentType, AxisMessage message) throws Exception {
- send(options, message, ServiceClient.ANON_OUT_ONLY_OP, block, null);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisRequestResponseTestClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisRequestResponseTestClient.java
deleted file mode 100644
index c0dc1fb..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisRequestResponseTestClient.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.client;
-
-import javax.mail.internet.ContentType;
-
-import junit.framework.Assert;
-
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.testkit.axis2.MessageContextValidator;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.message.AxisMessage;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.wsdl.WSDLConstants;
-
-public class AxisRequestResponseTestClient extends AxisTestClient implements RequestResponseTestClient<AxisMessage,AxisMessage> {
- private @Transient MessageContextValidator[] validators;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MessageContextValidator[] validators) {
- this.validators = validators;
- }
-
- public IncomingMessage<AxisMessage> sendMessage(ClientOptions options, ContentType contentType, AxisMessage message) throws Exception {
- MessageContext responseMsgContext = send(options, message, ServiceClient.ANON_OUT_IN_OP,
- true, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- Assert.assertFalse(responseMsgContext.isServerSide());
- for (MessageContextValidator validator : validators) {
- validator.validate(responseMsgContext, true);
- }
- return new IncomingMessage<AxisMessage>(null, new AxisMessage(responseMsgContext));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClient.java
deleted file mode 100644
index bd6ace1..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClient.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.client;
-
-import javax.mail.internet.ContentType;
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
-
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axis2.Constants;
-import org.apache.axis2.client.OperationClient;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.TransportSender;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.base.ManagementSupport;
-import org.apache.axis2.transport.testkit.MessageExchangeValidator;
-import org.apache.axis2.transport.testkit.axis2.util.MessageLevelMetricsCollectorImpl;
-import org.apache.axis2.transport.testkit.channel.Channel;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.TestClient;
-import org.apache.axis2.transport.testkit.message.AxisMessage;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.ContentTypeUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-@Name("axis")
-public class AxisTestClient implements TestClient, MessageExchangeValidator {
- private static final Log log = LogFactory.getLog(AxisTestClient.class);
-
- private @Transient AxisTestClientConfigurator[] configurators;
- private @Transient TransportSender sender;
- protected @Transient ServiceClient serviceClient;
- protected @Transient Options axisOptions;
- private long messagesSent;
- private long bytesSent;
- private MessageLevelMetricsCollectorImpl metrics;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(AxisTestClientContext context, Channel channel, AxisTestClientConfigurator[] configurators) throws Exception {
- this.configurators = configurators;
- sender = context.getSender();
- serviceClient = new ServiceClient(context.getConfigurationContext(), null);
- axisOptions = new Options();
- axisOptions.setTo(channel.getEndpointReference());
- serviceClient.setOptions(axisOptions);
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- serviceClient.cleanup();
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- // TODO: this may be incorrect in some cases
- String charset = options.getCharset();
- if (charset == null) {
- return contentType;
- } else {
- return ContentTypeUtil.addCharset(contentType, options.getCharset());
- }
- }
-
- public void beforeSend() throws Exception {
- if (sender instanceof ManagementSupport) {
- ManagementSupport sender = (ManagementSupport)this.sender;
- messagesSent = sender.getMessagesSent();
- bytesSent = sender.getBytesSent();
- metrics = new MessageLevelMetricsCollectorImpl();
- } else {
- metrics = null;
- }
- }
-
- protected MessageContext send(ClientOptions options, AxisMessage message, QName operationQName,
- boolean block, String resultMessageLabel) throws Exception {
-
- OperationClient mepClient = serviceClient.createClient(operationQName);
- MessageContext mc = new MessageContext();
- mc.setProperty(Constants.Configuration.MESSAGE_TYPE, message.getMessageType());
- mc.setEnvelope(message.getEnvelope());
- Attachments attachments = message.getAttachments();
- if (attachments != null) {
- mc.setAttachmentMap(attachments);
- mc.setDoingSwA(true);
- mc.setProperty(Constants.Configuration.ENABLE_SWA, true);
- }
- for (AxisTestClientConfigurator configurator : configurators) {
- configurator.setupRequestMessageContext(mc);
- }
- mc.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, options.getCharset());
- mc.setServiceContext(serviceClient.getServiceContext());
- if (metrics != null) {
- mc.setProperty(BaseConstants.METRICS_COLLECTOR, metrics);
- }
- mepClient.addMessageContext(mc);
- mepClient.getOptions().setAction("");
-
- mepClient.execute(block);
-// mepClient.complete(mc);
- return resultMessageLabel == null ? null : mepClient.getMessageContext(resultMessageLabel);
- }
-
- public void afterReceive() throws Exception {
- if (sender instanceof ManagementSupport) {
- ManagementSupport sender = (ManagementSupport)this.sender;
- synchronized (metrics) {
- long start = System.currentTimeMillis();
- while (true) {
- try {
- Assert.assertEquals(1, metrics.getMessagesSent());
- Assert.assertEquals(messagesSent+1, sender.getMessagesSent());
- long thisBytesSent = metrics.getBytesSent();
- Assert.assertTrue("No increase in bytes sent in message level metrics", thisBytesSent != 0);
- long newBytesSent = sender.getBytesSent();
- Assert.assertTrue("No increase in bytes sent in transport level metrics", newBytesSent > bytesSent);
- Assert.assertEquals("Mismatch between message and transport level metrics", thisBytesSent, newBytesSent - bytesSent);
- break;
- } catch (AssertionFailedError ex) {
- // SYNAPSE-491: Maybe the transport sender didn't finish updating the
- // metrics yet. We give it a couple of seconds to do so.
- long remaining = start + 5000 - System.currentTimeMillis();
- if (remaining <= 0) {
- throw ex;
- } else {
- log.debug("The transport sender didn't update the metrics yet ("
- + ex.getMessage() + "). Waiting for " + remaining + " ms.");
- metrics.wait(remaining);
- }
- }
- }
- }
- log.debug("Message level metrics check OK");
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientConfigurator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientConfigurator.java
deleted file mode 100644
index 8108fdc..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientConfigurator.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.client;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-
-public interface AxisTestClientConfigurator {
- void setupRequestMessageContext(MessageContext msgContext) throws AxisFault;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java
deleted file mode 100644
index a3dad7b..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.client;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.ListenerManager;
-import org.apache.axis2.transport.CustomAxisConfigurator;
-import org.apache.axis2.transport.TransportSender;
-import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-/**
- * Resource maintaining the {@link ConfigurationContext} for {@link AxisTestClient}
- * instances.
- * <p>
- * Dependencies:
- * <dl>
- * <dt>{@link TransportDescriptionFactory} (1)</dt>
- * <dd>Used to create transport descriptions.</dd>
- * <dt>{@link AxisTestClientContextConfigurator} (0..*)</dt>
- * <dd>Used to determine whether a transport listener is required and to
- * configure the transport.</dd>
- * </dl>
- */
-public class AxisTestClientContext {
- public static final AxisTestClientContext INSTANCE = new AxisTestClientContext();
-
- private @Transient TransportSender sender;
- private @Transient ConfigurationContext cfgCtx;
- private @Transient ListenerManager listenerManager;
-
- private AxisTestClientContext() {}
-
- @Setup @SuppressWarnings("unused")
- private void setUp(TransportDescriptionFactory tdf, AxisTestClientContextConfigurator[] configurators) throws Exception {
- cfgCtx = ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
- AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
-
- TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
- axisCfg.addTransportOut(trpOutDesc);
- sender = trpOutDesc.getSender();
- sender.init(cfgCtx, trpOutDesc);
-
- boolean useListener = false;
- for (AxisTestClientContextConfigurator configurator : configurators) {
- if (configurator.isTransportListenerRequired()) {
- useListener = true;
- break;
- }
- }
-
- TransportInDescription trpInDesc;
- if (useListener) {
- trpInDesc = tdf.createTransportInDescription();
- } else {
- trpInDesc = null;
- }
-
- for (AxisTestClientContextConfigurator configurator : configurators) {
- configurator.setupTransport(trpInDesc, trpOutDesc);
- }
-
- if (useListener) {
- listenerManager = new ListenerManager();
- listenerManager.init(cfgCtx);
- cfgCtx.setTransportManager(listenerManager);
- listenerManager.addListener(trpInDesc, false);
- listenerManager.start();
- }
- }
-
- public TransportSender getSender() {
- return sender;
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- sender.stop();
- if (listenerManager != null) {
- listenerManager.stop();
- listenerManager.destroy();
- }
- cfgCtx.terminate();
- }
-
- public ConfigurationContext getConfigurationContext() {
- return cfgCtx;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java
deleted file mode 100644
index 96598d0..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.client;
-
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-
-public interface AxisTestClientContextConfigurator {
- /**
- * Determine whether a transport listener is required on client side.
- *
- * @return true if a transport listener instance is required
- */
- boolean isTransportListenerRequired();
-
- /**
- * Setup the transport on client side.
- *
- * @param trpInDesc
- * @param trpOutDesc
- */
- void setupTransport(TransportInDescription trpInDesc, TransportOutDescription trpOutDesc) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java
deleted file mode 100644
index 5af1c5e..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.endpoint;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.InOnlyAxisOperation;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.transport.testkit.axis2.MessageContextValidator;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.endpoint.InOnlyEndpointSupport;
-import org.apache.axis2.transport.testkit.message.AxisMessage;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class AxisAsyncEndpoint extends AxisTestEndpoint implements AsyncEndpoint<AxisMessage> {
- private static Log log = LogFactory.getLog(AxisAsyncEndpoint.class);
-
- private @Transient AxisTestEndpointContext context;
- private @Transient MessageContextValidator[] validators;
- private @Transient InOnlyEndpointSupport<AxisMessage> support;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(AxisTestEndpointContext context, MessageContextValidator[] validators) {
- this.context = context;
- this.validators = validators;
- support = new InOnlyEndpointSupport<AxisMessage>();
- }
-
- @Override
- protected InOnlyAxisOperation createOperation() {
- InOnlyAxisOperation operation = new InOnlyAxisOperation(new QName("default"));
- operation.setMessageReceiver(new MessageReceiver() {
- public void receive(MessageContext messageCtx) throws AxisFault {
- AxisAsyncEndpoint.this.receive(messageCtx);
- }
- });
- return operation;
- }
-
- void receive(MessageContext messageCtx) throws AxisFault {
- log.debug("MessageReceiver has been invoked");
- final AxisMessage messageData;
- try {
- Assert.assertTrue(messageCtx.isServerSide());
-
- TransportInDescription transportIn = messageCtx.getTransportIn();
- Assert.assertNotNull("transportIn not set on message context", transportIn);
- Assert.assertEquals(context.getTransportName(), transportIn.getName());
-
- Assert.assertEquals(context.getTransportName(), messageCtx.getIncomingTransportName());
-
- for (MessageContextValidator validator : validators) {
- validator.validate(messageCtx, false);
- }
- messageData = new AxisMessage(messageCtx);
- }
- catch (Throwable ex) {
- support.putException(ex);
- return;
- }
- support.putMessage(null, messageData);
- }
-
- @Override
- protected void onTransportError(Throwable ex) {
- support.putException(ex);
- }
-
- public void clear() throws Exception {
- support.clear();
- }
-
- public IncomingMessage<AxisMessage> waitForMessage(int timeout) throws Throwable {
- return support.waitForMessage(timeout);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java
deleted file mode 100644
index 253e4a3..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.endpoint;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.InOutAxisOperation;
-import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
-import org.apache.axis2.transport.testkit.endpoint.EndpointErrorListener;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpointSupport;
-
-public class AxisEchoEndpoint extends AxisTestEndpoint implements InOutEndpoint {
- private final InOutEndpointSupport support = new InOutEndpointSupport();
-
- @Override
- protected InOutAxisOperation createOperation() {
- InOutAxisOperation operation = new InOutAxisOperation(new QName("echo"));
- operation.setMessageReceiver(new AbstractInOutMessageReceiver() {
- @Override
- public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
- outMessage.setEnvelope(inMessage.getEnvelope());
- }
- });
- return operation;
- }
-
- @Override
- protected void onTransportError(Throwable ex) {
- support.fireEndpointError(ex);
- }
-
- public void addEndpointErrorListener(EndpointErrorListener listener) {
- support.addEndpointErrorListener(listener);
- }
-
- public void removeEndpointErrorListener(EndpointErrorListener listener) {
- support.removeEndpointErrorListener(listener);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java
deleted file mode 100644
index 825bd0e..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.endpoint;
-
-import java.io.PrintWriter;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.UUID;
-
-import junit.framework.Assert;
-
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.base.BaseUtils;
-import org.apache.axis2.transport.base.event.TransportError;
-import org.apache.axis2.transport.base.event.TransportErrorListener;
-import org.apache.axis2.transport.base.event.TransportErrorSource;
-import org.apache.axis2.transport.testkit.axis2.AxisServiceConfigurator;
-import org.apache.axis2.transport.testkit.channel.Channel;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.LogManager;
-
-/**
- * Base class for Axis2 based test endpoints.
- */
-@Name("axis")
-public abstract class AxisTestEndpoint {
- private @Transient AxisTestEndpointContext context;
- private @Transient TransportErrorSource transportErrorSource;
- private @Transient TransportErrorListener errorListener;
- @Transient AxisService service;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(LogManager logManager, AxisTestEndpointContext context, Channel channel,
- AxisServiceConfigurator[] configurators) throws Exception {
-
- this.context = context;
-
- TransportListener listener = context.getTransportListener();
- if (listener instanceof TransportErrorSource) {
- transportErrorSource = (TransportErrorSource)listener;
- errorListener = new TransportErrorListener() {
- public void error(TransportError error) {
- AxisService s = error.getService();
- if (s == null || s == service) {
- onTransportError(error.getException());
- }
- }
- };
- transportErrorSource.addErrorListener(errorListener);
- } else {
- transportErrorSource = null;
- }
-
- String path;
- try {
- path = new URI(channel.getEndpointReference().getAddress()).getPath();
- } catch (URISyntaxException ex) {
- path = null;
- }
- String serviceName;
- if (path != null && path.startsWith(Channel.CONTEXT_PATH + "/")) {
- serviceName = path.substring(Channel.CONTEXT_PATH.length()+1);
- } else {
- serviceName = "TestService-" + UUID.randomUUID();
- }
- service = new AxisService(serviceName);
- service.addOperation(createOperation());
- if (configurators != null) {
- for (AxisServiceConfigurator configurator : configurators) {
- configurator.setupService(service, false);
- }
- }
-
- // Output service parameters to log file
- // FIXME: This actually doesn't give the expected result because the AxisTestEndpoint might be reused
- // by several test cases and in that case the log file is only produced once
- List<Parameter> params = (List<Parameter>)service.getParameters();
- if (!params.isEmpty()) {
- PrintWriter log = new PrintWriter(logManager.createLog("service-parameters"), false);
- try {
- for (Parameter param : params) {
- log.print(param.getName());
- log.print("=");
- log.println(param.getValue());
- }
- } finally {
- log.close();
- }
- }
-
- // We want to receive all messages through the same operation:
- service.addParameter(AxisService.SUPPORT_SINGLE_OP, true);
-
- context.getAxisConfiguration().addService(service);
-
- // The transport may disable the service. In that case, fail directly.
- if (!BaseUtils.isUsingTransport(service, context.getTransportName())) {
- Assert.fail("The service has been disabled by the transport");
- }
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- if (transportErrorSource != null) {
- transportErrorSource.removeErrorListener(errorListener);
- }
- context.getAxisConfiguration().removeService(service.getName());
- }
-
- /**
- * Create an operation appropriate for the message exchange pattern implemented
- * by the test endpoint. The operation returned should have a
- * {@link MessageReceiver} set.
- *
- * @return the operation
- */
- protected abstract AxisOperation createOperation();
-
- /**
- * Process a transport error. Note that this method will only be called if
- * the underlying transport supports reporting of transport errors.
- *
- * @param ex the exception describing the transport error
- */
- protected abstract void onTransportError(Throwable ex);
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java
deleted file mode 100644
index 47c2b89..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.endpoint;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.UtilsTransportServer;
-import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-/**
- * Resource maintaining the {@link ConfigurationContext} for {@link AxisTestEndpoint}
- * instances. This class provides the Axis2 server environment.
- * <p>
- * Dependencies:
- * <dl>
- * <dt>{@link TransportDescriptionFactory} (1)</dt>
- * <dd>Used to create transport descriptions.</dd>
- * <dt>{@link AxisTestEndpointContextConfigurator} (0..*)</dt>
- * <dd>Used to configure the transport.</dd>
- * </dl>
- */
-public class AxisTestEndpointContext {
- public static final AxisTestEndpointContext INSTANCE = new AxisTestEndpointContext();
-
- private @Transient TransportInDescription trpInDesc;
- private @Transient UtilsTransportServer server;
-
- private AxisTestEndpointContext() {}
-
- @Setup @SuppressWarnings("unused")
- private void setUp(TransportDescriptionFactory tdf, AxisTestEndpointContextConfigurator[] configurators) throws Exception {
-
- server = new UtilsTransportServer();
-
- TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
- trpInDesc = tdf.createTransportInDescription();
- server.addTransport(trpInDesc, trpOutDesc);
-
- for (AxisTestEndpointContextConfigurator configurator : configurators) {
- configurator.setupTransport(trpInDesc, trpOutDesc);
- }
-
- ConfigurationContext cfgCtx = server.getConfigurationContext();
-
- cfgCtx.setContextRoot("/");
- cfgCtx.setServicePath("services");
-
- AxisConfiguration axisConfiguration = server.getAxisConfiguration();
-
- server.start();
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- server.stop();
- }
-
- public AxisConfiguration getAxisConfiguration() {
- return server.getAxisConfiguration();
- }
-
- public TransportListener getTransportListener() {
- return trpInDesc.getReceiver();
- }
-
- public String getTransportName() {
- return trpInDesc.getName();
- }
-
- public String getEPR(AxisService service) throws AxisFault {
- EndpointReference[] endpointReferences =
- trpInDesc.getReceiver().getEPRsForService(service.getName(), "localhost");
- return endpointReferences != null && endpointReferences.length > 0
- ? endpointReferences[0].getAddress() : null;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java
deleted file mode 100644
index cdc0ca2..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.endpoint;
-
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-
-public interface AxisTestEndpointContextConfigurator {
- /**
- * Setup the transport on server side.
- *
- * @param trpInDesc
- * @param trpOutDesc
- */
- void setupTransport(TransportInDescription trpInDesc, TransportOutDescription trpOutDesc);
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/ContentTypeServiceConfigurator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/ContentTypeServiceConfigurator.java
deleted file mode 100644
index c48fa63..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/ContentTypeServiceConfigurator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.endpoint;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.transport.testkit.axis2.AxisServiceConfigurator;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-
-public class ContentTypeServiceConfigurator implements AxisServiceConfigurator {
- private final String parameterName;
- private @Transient ContentType contentType;
-
- public ContentTypeServiceConfigurator(String parameterName) {
- this.parameterName = parameterName;
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(ClientOptions options) throws Exception {
- contentType = options.getTransportContentType();
- }
-
- public void setupService(AxisService service, boolean isClientSide) throws Exception {
- service.addParameter(parameterName, contentType.toString());
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/util/MessageLevelMetricsCollectorImpl.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/util/MessageLevelMetricsCollectorImpl.java
deleted file mode 100644
index 0163239..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/util/MessageLevelMetricsCollectorImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.axis2.util;
-
-import org.apache.axis2.transport.base.MessageLevelMetricsCollector;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Message level metrics collector implementation used during the tests to check that
- * message level metrics collection is implemented.
- * <p>
- * On any update, all threads waiting for an instance of this class are notified.
- */
-public class MessageLevelMetricsCollectorImpl implements MessageLevelMetricsCollector {
- private static final Log log = LogFactory.getLog(MessageLevelMetricsCollectorImpl.class);
-
- private long messagesSent;
- private long bytesSent;
-
- public void incrementBytesReceived(long size) {
- }
-
- public synchronized void incrementBytesSent(long size) {
- log.debug("incrementBytesSent called with size = " + size);
- bytesSent += size;
- notifyAll();
- }
-
- public void incrementFaultsReceiving(int errorCode) {
- }
-
- public void incrementFaultsSending(int errorCode) {
- }
-
- public void incrementMessagesReceived() {
- }
-
- public synchronized void incrementMessagesSent() {
- log.debug("incrementMessagesSent called");
- messagesSent++;
- notifyAll();
- }
-
- public void incrementTimeoutsReceiving() {
- }
-
- public void incrementTimeoutsSending() {
- }
-
- public void notifyReceivedMessageSize(long size) {
- }
-
- public void notifySentMessageSize(long size) {
- }
-
- public void reportReceivingFault(int errorCode) {
- }
-
- public void reportResponseCode(int respCode) {
- }
-
- public void reportSendingFault(int errorCode) {
- }
-
- public synchronized long getMessagesSent() {
- return messagesSent;
- }
-
- public synchronized long getBytesSent() {
- return bytesSent;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/AsyncChannel.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/AsyncChannel.java
deleted file mode 100644
index bfae593..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/AsyncChannel.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.channel;
-
-public interface AsyncChannel extends Channel {
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/Channel.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/Channel.java
deleted file mode 100644
index 46743b5..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/Channel.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.channel;
-
-import org.apache.axis2.addressing.EndpointReference;
-
-public interface Channel {
- String CONTEXT_PATH = "/services";
-
- EndpointReference getEndpointReference() throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/RequestResponseChannel.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/RequestResponseChannel.java
deleted file mode 100644
index 333c155..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/channel/RequestResponseChannel.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.channel;
-
-public interface RequestResponseChannel extends Channel {
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/AsyncTestClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/AsyncTestClient.java
deleted file mode 100644
index 23c5b91..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/AsyncTestClient.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.client;
-
-import javax.mail.internet.ContentType;
-
-public interface AsyncTestClient<M> extends TestClient {
- void sendMessage(ClientOptions options, ContentType contentType, M message) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/AsyncTestClientAdapter.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/AsyncTestClientAdapter.java
deleted file mode 100644
index 4ab8dce..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/AsyncTestClientAdapter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.client;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.Adapter;
-import org.apache.axis2.transport.testkit.message.MessageEncoder;
-
-public class AsyncTestClientAdapter<M,N> implements AsyncTestClient<M>, Adapter {
- private final AsyncTestClient<N> target;
- private final MessageEncoder<M,N> encoder;
-
- public AsyncTestClientAdapter(AsyncTestClient<N> target, MessageEncoder<M,N> encoder) {
- this.target = target;
- this.encoder = encoder;
- }
-
- public AsyncTestClient<N> getTarget() {
- return target;
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception {
- return target.getContentType(options, encoder.getContentType(options, contentType));
- }
-
- public void sendMessage(ClientOptions options, ContentType contentType, M message) throws Exception {
- target.sendMessage(options, encoder.getContentType(options, contentType), encoder.encode(options, message));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/ClientOptions.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/ClientOptions.java
deleted file mode 100644
index 5253cdb..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/ClientOptions.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.client;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axiom.util.UIDGenerator;
-
-public class ClientOptions {
- private final ContentType transportContentType;
- private final String charset;
- private String mimeBoundary;
- private String rootContentId;
-
- // TODO: this is ugly; find a better solution
- public ClientOptions(TestClient client, ContentType baseContentType, String charset) throws Exception {
- this.charset = charset;
- transportContentType = client.getContentType(this, baseContentType);
- }
-
- public ContentType getTransportContentType() {
- return transportContentType;
- }
-
- public String getCharset() {
- return charset;
- }
-
- public String getMimeBoundary() {
- if (mimeBoundary == null) {
- mimeBoundary = UIDGenerator.generateMimeBoundary();
- }
- return mimeBoundary;
- }
-
- public String getRootContentId() {
- if (rootContentId == null) {
- rootContentId = UIDGenerator.generateContentId();
- }
- return rootContentId;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/RequestResponseTestClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/RequestResponseTestClient.java
deleted file mode 100644
index 21c22d1..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/RequestResponseTestClient.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.client;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-
-public interface RequestResponseTestClient<M,N> extends TestClient {
- IncomingMessage<N> sendMessage(ClientOptions options, ContentType contentType, M message) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/RequestResponseTestClientAdapter.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/RequestResponseTestClientAdapter.java
deleted file mode 100644
index 936ae31..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/RequestResponseTestClientAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.client;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.Adapter;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.message.MessageDecoder;
-import org.apache.axis2.transport.testkit.message.MessageEncoder;
-
-public class RequestResponseTestClientAdapter<M,N,O,P> implements RequestResponseTestClient<M,O>, Adapter {
- private final RequestResponseTestClient<N,P> target;
- private final MessageEncoder<M,N> encoder;
- private final MessageDecoder<P,O> decoder;
-
- public RequestResponseTestClientAdapter(RequestResponseTestClient<N,P> target,
- MessageEncoder<M,N> encoder,
- MessageDecoder<P,O> decoder) {
- this.target = target;
- this.encoder = encoder;
- this.decoder = decoder;
- }
-
- public RequestResponseTestClient<N,P> getTarget() {
- return target;
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception {
- return target.getContentType(options, encoder.getContentType(options, contentType));
- }
-
- public IncomingMessage<O> sendMessage(ClientOptions options, ContentType contentType, M message) throws Exception {
- IncomingMessage<P> response = target.sendMessage(options, encoder.getContentType(options, contentType), encoder.encode(options, message));
- ContentType responseContentType = response.getContentType();
- return new IncomingMessage<O>(responseContentType, decoder.decode(responseContentType, response.getData()));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/TestClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/TestClient.java
deleted file mode 100644
index 9a0d195..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/client/TestClient.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.client;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.name.Key;
-
-@Key("client")
-public interface TestClient {
- ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception;
-}
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/Dependency.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/Dependency.java
deleted file mode 100644
index a346e59..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/Dependency.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.doclet;
-
-import java.io.Serializable;
-
-public class Dependency implements Serializable {
- private static final long serialVersionUID = -3576630956376161332L;
-
- private final String type;
- private final String multiplicity;
- private final String comment;
-
- public Dependency(String type, String multiplicity, String comment) {
- this.type = type;
- this.multiplicity = multiplicity;
- this.comment = comment;
- }
-
- public String getType() {
- return type;
- }
-
- public String getMultiplicity() {
- return multiplicity;
- }
-
- public String getComment() {
- return comment;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/Resource.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/Resource.java
deleted file mode 100644
index 50cd5b6..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/Resource.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.doclet;
-
-import java.io.Serializable;
-import java.util.LinkedList;
-import java.util.List;
-
-public class Resource implements Serializable {
- private static final long serialVersionUID = 8381629721839692917L;
-
- private final String type;
- private List<Dependency> dependencies;
-
- public Resource(String type) {
- this.type = type;
- }
-
- public String getType() {
- return type;
- }
-
- public void addDependency(String type, String multiplicity, String comment) {
- if (dependencies == null) {
- dependencies = new LinkedList<Dependency>();
- }
- dependencies.add(new Dependency(type, multiplicity, comment));
- }
-
- public List<Dependency> getDependencies() {
- return dependencies;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/ResourceInfo.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/ResourceInfo.java
deleted file mode 100644
index b38b54c..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/ResourceInfo.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.doclet;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-public class ResourceInfo implements Serializable {
- private static final long serialVersionUID = -3590562573639276912L;
-
- private final Map<String,Resource> resources = new HashMap<String,Resource>();
-
- public void addResource(Resource resource) {
- resources.put(resource.getType(), resource);
- }
-
- public Resource getResource(String type) {
- return resources.get(type);
- }
-
- public List<Resource> getUsedBy(String type) {
- List<Resource> result = null;
- for (Resource resource : resources.values()) {
- List<Dependency> dependencies = resource.getDependencies();
- if (dependencies != null) {
- for (Dependency dependency : dependencies) {
- if (dependency.getType().equals(type)) {
- if (result == null) {
- result = new LinkedList<Resource>();
- }
- result.add(resource);
- break;
- }
- }
- }
- }
- return result;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/ResourceInfoDoclet.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/ResourceInfoDoclet.java
deleted file mode 100644
index dc5fef8..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/ResourceInfoDoclet.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.doclet;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
-import com.sun.javadoc.AnnotationDesc;
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.Doc;
-import com.sun.javadoc.DocErrorReporter;
-import com.sun.javadoc.MethodDoc;
-import com.sun.javadoc.ParamTag;
-import com.sun.javadoc.Parameter;
-import com.sun.javadoc.ProgramElementDoc;
-import com.sun.javadoc.RootDoc;
-import com.sun.javadoc.SeeTag;
-import com.sun.javadoc.Tag;
-import com.sun.javadoc.Type;
-
-public class ResourceInfoDoclet {
- private static File outFile;
-
- public static boolean start(RootDoc root) throws IOException {
- parseOptions(root.options());
- ResourceInfo resourceInfo = new ResourceInfo();
- for (ClassDoc clazz : root.classes()) {
- Resource resource = null;
- for (MethodDoc method : clazz.methods()) {
- if (getAnnotation(method, "org.apache.axis2.transport.testkit.tests.Setup") != null) {
- if (resource == null) {
- resource = new Resource(clazz.qualifiedName());
- }
- ParamTag[] paramTags = method.paramTags();
- for (Parameter parameter : method.parameters()) {
- Type type = parameter.type();
- String name = parameter.name();
- String comment = null;
- for (ParamTag paramTag : paramTags) {
- if (paramTag.parameterName().equals(name)) {
- comment = paramTag.parameterComment();
- break;
- }
- }
- if (comment == null) {
- comment = getFirstSentence(root.classNamed(type.qualifiedTypeName()));
- }
- resource.addDependency(type.qualifiedTypeName(),
- type.dimension().equals("[]") ? "0..*" : "1",
- comment);
- }
- }
- }
- if (resource != null) {
- resourceInfo.addResource(resource);
- }
- }
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(outFile));
- out.writeObject(resourceInfo);
- out.close();
- return true;
- }
-
- private static AnnotationDesc getAnnotation(ProgramElementDoc doc, String qualifiedName) {
- for (AnnotationDesc annotation : doc.annotations()) {
- if (annotation.annotationType().qualifiedName().equals(qualifiedName)) {
- return annotation;
- }
- }
- return null;
- }
-
- private static String getFirstSentence(Doc doc) {
- Tag[] tags = doc.firstSentenceTags();
- if (tags.length == 0) {
- return null;
- }
- StringBuilder buffer = new StringBuilder();
- for (Tag tag : tags) {
- if (tag instanceof SeeTag) {
- buffer.append("{");
- buffer.append(tag.name());
- buffer.append(" ");
- buffer.append(((SeeTag)tag).referencedClassName());
- buffer.append("}");
- } else {
- buffer.append(tag.text());
- }
- }
- return buffer.toString();
- }
-
- private static void parseOptions(String[][] options) {
- for (String[] option : options) {
- if (option[0].equals("-out")) {
- outFile = new File(option[1]);
- System.out.println("Output is going to " + outFile);
- }
- }
- }
-
- public static int optionLength(String option) {
- if (option.equals("-out")) {
- return 2;
- } else {
- return 0;
- }
- }
-
- public static boolean validOptions(String options[][], DocErrorReporter reporter) {
- boolean hasOut = false;
- for (String[] option : options) {
- String opt = option[0];
- if (opt.equals("-out")) {
- hasOut = true;
- }
- }
- if (!hasOut) {
- reporter.printError("No output file specified: -out <output file>");
- return false;
- } else {
- return true;
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/TestkitJavadocDoclet.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/TestkitJavadocDoclet.java
deleted file mode 100644
index 994df56..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/doclet/TestkitJavadocDoclet.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.doclet;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.ObjectInputStream;
-import java.util.List;
-
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.DocErrorReporter;
-import com.sun.javadoc.LanguageVersion;
-import com.sun.javadoc.RootDoc;
-import com.sun.tools.doclets.standard.Standard;
-
-public class TestkitJavadocDoclet {
- private static File resourceInfoFile;
-
- public static LanguageVersion languageVersion() {
- return Standard.languageVersion();
- }
-
- public static int optionLength(String option) {
- if (option.equals("-resource-info")) {
- return 2;
- } else {
- return Standard.optionLength(option);
- }
- }
-
- public static boolean validOptions(String options[][], DocErrorReporter reporter) {
- return Standard.validOptions(options, reporter);
- }
-
- public static boolean start(RootDoc root) throws Exception {
- parseOptions(root.options());
- ObjectInputStream in = new ObjectInputStream(new FileInputStream(resourceInfoFile));
- ResourceInfo resourceInfo = (ResourceInfo)in.readObject();
- in.close();
- for (ClassDoc clazz : root.classes()) {
- String qualifiedName = clazz.qualifiedName();
- List<Resource> usedBy = resourceInfo.getUsedBy(qualifiedName);
- Resource resource = resourceInfo.getResource(qualifiedName);
- List<Dependency> dependencies = resource == null ? null : resource.getDependencies();
- if (dependencies != null || usedBy != null) {
- StringBuilder buffer = new StringBuilder(clazz.getRawCommentText());
- buffer.append("<h2>Resource information</h2>");
- if (usedBy != null) {
- buffer.append("This resource is used by: ");
- boolean first = true;
- for (Resource r : usedBy) {
- if (first) {
- first = false;
- } else {
- buffer.append(", ");
- }
- buffer.append("{@link ");
- buffer.append(r.getType());
- buffer.append("}");
- }
- }
- if (dependencies != null) {
- buffer.append("<h3>Dependencies</h3>");
- buffer.append("<dl>");
- for (Dependency dependency : dependencies) {
- buffer.append("<dt>{@link ");
- buffer.append(dependency.getType());
- buffer.append("} (");
- buffer.append(dependency.getMultiplicity());
- buffer.append(")</dt><dd>");
- String comment = dependency.getComment();
- if (comment == null) {
- buffer.append("(no documentation available)");
- } else {
- buffer.append(comment);
- }
- buffer.append("</dd>");
- }
- buffer.append("</dl>");
- }
- clazz.setRawCommentText(buffer.toString());
- }
- }
- return Standard.start(root);
- }
-
- private static void parseOptions(String[][] options) {
- for (String[] option : options) {
- if (option[0].equals("-resource-info")) {
- resourceInfoFile = new File(option[1]);
- System.out.println("Resource information is read from " + resourceInfoFile);
- }
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpoint.java
deleted file mode 100644
index 8e7c569..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpoint.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.endpoint;
-
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.name.Key;
-
-/**
- * Interface implemented by in-only test endpoints.
- * <p>
- * The endpoint must be ready to receive messages immediately after it
- * has been set up. In particular implementations must not make the
- * assumption that messages are only during a call to {@link #waitForMessage(int)}.
- * Indeed, a typical test case will set up the endpoint, send a message and only
- * afterwards call {@link #waitForMessage(int)}.
- * <p>
- * There are two strategies to guarantee this behavior:
- * <ul>
- * <li>The underlying transport internally queues incoming messages.
- * In that case {@link #waitForMessage(int)} should simply poll
- * for new messages. An example of this type of transport is
- * the mail transport.</li>
- * <li>The underlying transport requires that incoming messages are
- * processed immediately. In that case the implementation should
- * set up the required receiver or message processor and add
- * incoming messages to an internal queue that is polled
- * when {@link #waitForMessage(int)} is called. An example of
- * this kind of transport is HTTP. Implementations can use
- * {@link InOnlyEndpointSupport} to manage the message queue.</li>
- * </ul>
- *
- * @see org.apache.axis2.transport.testkit.endpoint
- *
- * @param <M>
- */
-// TODO: rename this to InOnlyEndpoint
-@Key("endpoint")
-public interface AsyncEndpoint<M> {
- /**
- * Discard any pending messages.
- */
- void clear() throws Exception;
-
- IncomingMessage<M> waitForMessage(int timeout) throws Throwable;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpointAdapter.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpointAdapter.java
deleted file mode 100644
index 23c0fe1..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpointAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.endpoint;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.Adapter;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.message.MessageDecoder;
-
-public class AsyncEndpointAdapter<M,N> implements AsyncEndpoint<M>, Adapter {
- private final AsyncEndpoint<N> target;
- private final MessageDecoder<N,M> decoder;
-
- public AsyncEndpointAdapter(AsyncEndpoint<N> target, MessageDecoder<N,M> decoder) {
- this.target = target;
- this.decoder = decoder;
- }
-
- public AsyncEndpoint<N> getTarget() {
- return target;
- }
-
- public void clear() throws Exception {
- target.clear();
- }
-
- public IncomingMessage<M> waitForMessage(int timeout) throws Throwable {
- IncomingMessage<N> message = target.waitForMessage(timeout);
- if (message == null) {
- return null;
- } else {
- ContentType contentType = message.getContentType();
- return new IncomingMessage<M>(contentType,
- decoder.decode(contentType, message.getData()));
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java
deleted file mode 100644
index 041a40d..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.endpoint;
-
-public interface EndpointErrorListener {
- void error(Throwable ex);
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOnlyEndpointSupport.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOnlyEndpointSupport.java
deleted file mode 100644
index 8c0a046..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOnlyEndpointSupport.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.endpoint;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-
-public class InOnlyEndpointSupport<M> {
- private final BlockingQueue<Event<M>> queue = new LinkedBlockingQueue<Event<M>>();
-
- private interface Event<M> {
- IncomingMessage<M> process() throws Throwable;
- }
-
- public void putException(final Throwable ex) {
- queue.add(new Event<M>() {
- public IncomingMessage<M> process() throws Throwable {
- throw ex;
- }
- });
- }
-
- public void putMessage(final ContentType contentType, final M data) {
- queue.add(new Event<M>() {
- public IncomingMessage<M> process() throws Throwable {
- return new IncomingMessage<M>(contentType, data);
- }
- });
- }
-
- public void putMessage(final IncomingMessage<M> message) {
- queue.add(new Event<M>() {
- public IncomingMessage<M> process() throws Throwable {
- return message;
- }
- });
- }
-
- public void clear() {
- queue.clear();
- }
-
- public IncomingMessage<M> waitForMessage(int timeout) throws Throwable {
- Event<M> event = queue.poll(timeout, TimeUnit.MILLISECONDS);
- return event == null ? null : event.process();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java
deleted file mode 100644
index 03d7cff..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.endpoint;
-
-import org.apache.axis2.transport.testkit.name.Key;
-
-/**
- * Interface implemented by in-out test endpoints.
- *
- * @see org.apache.axis2.transport.testkit.endpoint
- */
-@Key("endpoint")
-public interface InOutEndpoint {
- void addEndpointErrorListener(EndpointErrorListener listener);
- void removeEndpointErrorListener(EndpointErrorListener listener);
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java
deleted file mode 100644
index f5729a5..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.endpoint;
-
-import java.util.LinkedList;
-import java.util.List;
-
-public class InOutEndpointSupport {
- private final List<EndpointErrorListener> listeners = new LinkedList<EndpointErrorListener>();
-
- public void fireEndpointError(Throwable ex) {
- for (EndpointErrorListener listener : listeners) {
- listener.error(ex);
- }
- }
-
- public void addEndpointErrorListener(EndpointErrorListener listener) {
- listeners.add(listener);
- }
-
- public void removeEndpointErrorListener(EndpointErrorListener listener) {
- listeners.remove(listener);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/TestEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/TestEndpoint.java
deleted file mode 100644
index 36e3a5f..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/TestEndpoint.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.endpoint;
-
-import org.apache.axis2.transport.testkit.name.Key;
-
-@Key("endpoint")
-public interface TestEndpoint {
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/package-info.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/package-info.java
deleted file mode 100644
index 032e7ab..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/package-info.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Provides interface and support classes for test endpoints.
- * <p>
- * The test kit uses in-only and in-out test endpoints. See
- * {@link org.apache.axis2.transport.testkit.endpoint.InOnlyEndpoint} and
- * {@link org.apache.axis2.transport.testkit.endpoint.InOutEndpoint} for
- * more details.
- * <p>
- * Note that an endpoint is assumed to be a lightweight test resource, i.e.
- * setting up and tearing down an endpoint should be inexpensive to
- * moderately expensive. If endpoint implementations require a server environment that is
- * expensive to set up, this environment should be provided by a different test
- * resource on which the endpoint implementations depend. This pattern is used for example
- * by {@link org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint} and its subclasses
- * which depend on {@link org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpointContext}
- * to provide the server environment.
- * <p>
- * An endpoint implementation should use a dependency on the appropriate subclass of
- * {@link org.apache.axis2.transport.testkit.channel.Channel} in order to get the
- * required information to bind the endpoint to the underlying transport protocol.
- */
-package org.apache.axis2.transport.testkit.endpoint;
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/AndExpression.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/AndExpression.java
deleted file mode 100644
index 08b7130..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/AndExpression.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>and</em> (<tt>&</tt>) operator.
- */
-public class AndExpression implements FilterExpression {
- private final FilterExpression[] operands;
-
- public AndExpression(FilterExpression[] operands) {
- this.operands = operands;
- }
-
- public boolean matches(Map<String,String> map) {
- for (FilterExpression operand : operands) {
- if (!operand.matches(map)) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/EqualityExpression.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/EqualityExpression.java
deleted file mode 100644
index afc254b..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/EqualityExpression.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>equal</em> (<tt>=</tt>) operator.
- */
-public class EqualityExpression implements FilterExpression {
- private final String key;
- private final String value;
-
- public EqualityExpression(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- public boolean matches(Map<String,String> map) {
- return value.equals(map.get(key));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpression.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpression.java
deleted file mode 100644
index 647a78c..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpression.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Interface representing an abstract filter expression.
- */
-public interface FilterExpression {
- /**
- * Evaluate the filter expression.
- *
- * @param map the data on which the filter expression is evaluated
- * @return true if the data matches the filter represented by this object
- */
- boolean matches(Map<String,String> map);
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpressionParser.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpressionParser.java
deleted file mode 100644
index 7671ff4..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpressionParser.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.text.ParseException;
-import java.util.List;
-
-import org.apache.directory.shared.ldap.filter.AndNode;
-import org.apache.directory.shared.ldap.filter.EqualityNode;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.FilterParser;
-import org.apache.directory.shared.ldap.filter.NotNode;
-import org.apache.directory.shared.ldap.filter.OrNode;
-import org.apache.directory.shared.ldap.filter.PresenceNode;
-
-/**
- * Parser for LDAP filter expressions.
- */
-public class FilterExpressionParser {
- private FilterExpressionParser() {}
-
- private static FilterExpression[] buildExpressions(List<ExprNode> nodes) {
- FilterExpression[] result = new FilterExpression[nodes.size()];
- int i = 0;
- for (ExprNode node : nodes) {
- result[i++] = buildExpression(node);
- }
- return result;
- }
-
- private static FilterExpression buildExpression(ExprNode node) {
- if (node instanceof AndNode) {
- return new AndExpression(buildExpressions(((AndNode)node).getChildren()));
- } else if (node instanceof OrNode) {
- return new OrExpression(buildExpressions(((OrNode)node).getChildren()));
- } else if (node instanceof NotNode) {
- return new NotExpression(buildExpression(((NotNode)node).getFirstChild()));
- } else if (node instanceof EqualityNode) {
- EqualityNode equalityNode = (EqualityNode)node;
- return new EqualityExpression(equalityNode.getAttribute(), equalityNode.getValue().toString());
- } else if (node instanceof PresenceNode) {
- return new PresenceExpression(((PresenceNode)node).getAttribute());
- } else {
- throw new UnsupportedOperationException("Node type " + node.getClass().getSimpleName() + " not supported");
- }
- }
-
- /**
- * Parse an LDAP filter expression.
- *
- * @param filter an LDAP filter as defined by <a href="http://www.ietf.org/rfc/rfc2254.txt">RFC2254</a>
- * @return the parsed filter
- * @throws ParseException if the filter is syntactically incorrect
- */
- public static FilterExpression parse(String filter) throws ParseException {
- return buildExpression(FilterParser.parse(filter));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/NotExpression.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/NotExpression.java
deleted file mode 100644
index ccaf475..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/NotExpression.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>not</em> (<tt>!</tt>) operator.
- */
-public class NotExpression implements FilterExpression {
- private final FilterExpression operand;
-
- public NotExpression(FilterExpression operand) {
- this.operand = operand;
- }
-
- public boolean matches(Map<String,String> map) {
- return !operand.matches(map);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/OrExpression.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/OrExpression.java
deleted file mode 100644
index 77d74c4..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/OrExpression.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>or</em> (<tt>|</tt>) operator.
- */
-public class OrExpression implements FilterExpression {
- private final FilterExpression[] operands;
-
- public OrExpression(FilterExpression[] operands) {
- this.operands = operands;
- }
-
- public boolean matches(Map<String,String> map) {
- for (FilterExpression operand : operands) {
- if (operand.matches(map)) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/PresenceExpression.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/PresenceExpression.java
deleted file mode 100644
index ccd6ef9..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/PresenceExpression.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>present</em> (<tt>=*</tt>) operator.
- */
-public class PresenceExpression implements FilterExpression {
- private final String key;
-
- public PresenceExpression(String key) {
- this.key = key;
- }
-
- public boolean matches(Map<String,String> map) {
- return map.containsKey(key);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/package-info.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/package-info.java
deleted file mode 100644
index 0a8c652..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Provides classes to evaluate LDAP filters against {@link java.util.Map} objects.
- * <p>
- * LDAP filter expressions are parsed using
- * {@link org.apache.axis2.transport.testkit.filter.FilterExpressionParser#parse(String)}.
- * The resulting {@link org.apache.axis2.transport.testkit.filter.FilterExpression} object can
- * then be used to evaluate the filter against a given {@link java.util.Map} object.
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2254.txt">RFC2254: The String Representation of LDAP Search Filters</a>
- */
-package org.apache.axis2.transport.testkit.filter;
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java
deleted file mode 100644
index 1c09955..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.net.InetSocketAddress;
-import java.util.UUID;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.tcpmon.Tunnel;
-
-public class HttpChannel implements AsyncChannel, RequestResponseChannel {
- private @Transient String serviceName;
- private @Transient Tunnel tunnel;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(HttpTestEnvironment env) throws Exception {
- serviceName = "TestService-" + UUID.randomUUID();
- tunnel = new Tunnel(new InetSocketAddress("127.0.0.1", env.getServerPort()));
- tunnel.start();
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- tunnel.stop();
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public EndpointReference getEndpointReference() throws Exception {
- return new EndpointReference("http://localhost:" + tunnel.getPort() + CONTEXT_PATH + "/" + serviceName);
- }
-}
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java
deleted file mode 100644
index 8d2db09..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.PortAllocator;
-
-public class HttpTestEnvironment {
- public static final HttpTestEnvironment INSTANCE = new HttpTestEnvironment();
-
- private @Transient PortAllocator portAllocator;
- private int serverPort;
-
- private HttpTestEnvironment() {}
-
- @Setup @SuppressWarnings("unused")
- private void setUp(PortAllocator portAllocator) throws Exception {
- this.portAllocator = portAllocator;
- serverPort = portAllocator.allocatePort();
- }
-
- public int getServerPort() {
- return serverPort;
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- portAllocator.releasePort(serverPort);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTransportTestSuiteBuilder.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTransportTestSuiteBuilder.java
deleted file mode 100644
index a2e203b..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTransportTestSuiteBuilder.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.axis2.transport.testkit.ManagedTestSuite;
-import org.apache.axis2.transport.testkit.TransportTestSuiteBuilder;
-import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
-import org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient;
-import org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.tests.misc.MinConcurrencyTest;
-
-public class HttpTransportTestSuiteBuilder {
- private final ManagedTestSuite suite;
- private final TransportDescriptionFactory tdf;
-
- private final List<AxisTestClientConfigurator> axisTestClientConfigurators = new LinkedList<AxisTestClientConfigurator>();
-
- public HttpTransportTestSuiteBuilder(ManagedTestSuite suite,
- TransportDescriptionFactory tdf) {
- this.suite = suite;
- this.tdf = tdf;
- }
-
- public void addAxisTestClientConfigurator(AxisTestClientConfigurator configurator) {
- axisTestClientConfigurators.add(configurator);
- }
-
- public void build() {
- TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
-
- builder.addEnvironment(tdf);
-
- HttpChannel channel = new HttpChannel();
-
- builder.addAsyncChannel(channel);
-
- builder.addByteArrayAsyncTestClient(new JavaNetClient());
- if (axisTestClientConfigurators.isEmpty()) {
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
- } else {
- for (AxisTestClientConfigurator configurator : axisTestClientConfigurators) {
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), configurator);
- }
- }
- builder.addRESTAsyncTestClient(new JavaNetRESTClient());
-
- builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
- builder.addByteArrayAsyncEndpoint(new JettyByteArrayAsyncEndpoint());
- builder.addRESTAsyncEndpoint(new JettyRESTAsyncEndpoint());
-
- builder.addRequestResponseChannel(channel);
-
- builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient());
-
- builder.addEchoEndpoint(new AxisEchoEndpoint());
- builder.addEchoEndpoint(new JettyEchoEndpoint());
-
- builder.build();
-
- suite.addTest(new MinConcurrencyTest(new AsyncChannel[] { new HttpChannel(), new HttpChannel() }, 2, false, tdf));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetClient.java
deleted file mode 100644
index fcafc12..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetClient.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-@Name("java.net")
-public class JavaNetClient implements AsyncTestClient<byte[]> {
- private static final Log log = LogFactory.getLog(JavaNetClient.class);
-
- private @Transient HttpChannel channel;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(HttpChannel channel) {
- this.channel = channel;
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- public void sendMessage(ClientOptions options, ContentType contentType, byte[] message) throws Exception {
- URL url = new URL(channel.getEndpointReference().getAddress());
- log.debug("Opening connection to " + url + " using " + URLConnection.class.getName());
- try {
- URLConnection connection = url.openConnection();
- connection.setDoOutput(true);
- connection.setDoInput(true);
- connection.setRequestProperty("Content-Type", contentType.toString());
- if(contentType.getBaseType().equals("text/xml")){
- connection.setRequestProperty("SOAPAction", "");
- }
- OutputStream out = connection.getOutputStream();
- out.write(message);
- out.close();
- if (connection instanceof HttpURLConnection) {
- HttpURLConnection httpConnection = (HttpURLConnection)connection;
- log.debug("Response code: " + httpConnection.getResponseCode());
- log.debug("Response message: " + httpConnection.getResponseMessage());
- int i = 0;
- String headerValue;
- while ((headerValue = httpConnection.getHeaderField(i)) != null) {
- String headerName = httpConnection.getHeaderFieldKey(i);
- if (headerName != null) {
- log.debug(headerName + ": " + headerValue);
- } else {
- log.debug(headerValue);
- }
- i++;
- }
- }
- InputStream in = connection.getInputStream();
- IOUtils.copy(in, System.out);
- in.close();
- } catch (IOException ex) {
- log.debug("Got exception", ex);
- throw ex;
- }
- }
-}
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetRESTClient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetRESTClient.java
deleted file mode 100644
index 9fbc995..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetRESTClient.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.message.RESTMessage;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.commons.io.IOUtils;
-
-@Name("java.net")
-public class JavaNetRESTClient implements AsyncTestClient<RESTMessage> {
- private @Transient HttpChannel channel;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(HttpChannel channel) {
- this.channel = channel;
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- public void sendMessage(ClientOptions options, ContentType contentType, RESTMessage message) throws Exception {
- StringBuilder url = new StringBuilder();
- url.append(channel.getEndpointReference().getAddress());
- url.append("/default");
- String queryString = message.getQueryString();
- if (queryString.length() > 0) {
- url.append('?');
- url.append(queryString);
- }
- URLConnection connection = new URL(url.toString()).openConnection();
- connection.setDoInput(true);
- InputStream in = connection.getInputStream();
- IOUtils.copy(in, System.out);
- in.close();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyAsyncEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyAsyncEndpoint.java
deleted file mode 100644
index 42cb529..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyAsyncEndpoint.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.io.IOException;
-
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.endpoint.InOnlyEndpointSupport;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.mortbay.http.HttpException;
-import org.mortbay.http.HttpRequest;
-import org.mortbay.http.HttpResponse;
-
-@Name("jetty")
-public abstract class JettyAsyncEndpoint<M> extends JettyEndpoint implements AsyncEndpoint<M> {
- private @Transient InOnlyEndpointSupport<M> support;
-
- @Setup @SuppressWarnings("unused")
- private void setUp() throws Exception {
- support = new InOnlyEndpointSupport<M>();
- }
-
- @Override
- protected void handle(String pathParams, HttpRequest request, HttpResponse response)
- throws HttpException, IOException {
-
- support.putMessage(handle(request));
- }
-
- protected abstract IncomingMessage<M> handle(HttpRequest request) throws HttpException, IOException;
-
- public void clear() throws Exception {
- support.clear();
- }
-
- public IncomingMessage<M> waitForMessage(int timeout) throws Throwable {
- return support.waitForMessage(timeout);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyByteArrayAsyncEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyByteArrayAsyncEndpoint.java
deleted file mode 100644
index b6f0409..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyByteArrayAsyncEndpoint.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.Enumeration;
-
-import javax.mail.internet.ContentType;
-import javax.mail.internet.ParseException;
-
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.LogManager;
-import org.apache.commons.io.IOUtils;
-import org.mortbay.http.HttpException;
-import org.mortbay.http.HttpRequest;
-
-public class JettyByteArrayAsyncEndpoint extends JettyAsyncEndpoint<byte[]> {
- private @Transient LogManager logManager;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(LogManager logManager) throws Exception {
- this.logManager = logManager;
- }
-
- @Override
- protected IncomingMessage<byte[]> handle(HttpRequest request) throws HttpException, IOException {
- byte[] data = IOUtils.toByteArray(request.getInputStream());
- logRequest(request, data);
- ContentType contentType;
- try {
- contentType = new ContentType(request.getContentType());
- } catch (ParseException ex) {
- throw new HttpException(500, "Unparsable Content-Type");
- }
- return new IncomingMessage<byte[]>(contentType, data);
- }
-
- private void logRequest(HttpRequest request, byte[] data) throws IOException {
- OutputStream out = logManager.createLog("jetty");
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(out), false);
- for (Enumeration<?> e = request.getFieldNames(); e.hasMoreElements(); ) {
- String name = (String)e.nextElement();
- for (Enumeration<?> e2 = request.getFieldValues(name); e2.hasMoreElements(); ) {
- pw.print(name);
- pw.print(": ");
- pw.println((String)e2.nextElement());
- }
- }
- pw.println();
- pw.flush();
- out.write(data);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java
deleted file mode 100644
index 80bf483..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.io.IOException;
-import java.util.Map;
-
-import junit.framework.Assert;
-
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.testkit.axis2.MessageContextValidator;
-import org.apache.axis2.transport.testkit.endpoint.EndpointErrorListener;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
-import org.apache.commons.io.IOUtils;
-import org.mortbay.http.HttpException;
-import org.mortbay.http.HttpRequest;
-import org.mortbay.http.HttpResponse;
-
-public class JettyEchoEndpoint extends JettyEndpoint implements InOutEndpoint, MessageContextValidator {
- @Override
- protected void handle(String pathParams, HttpRequest request,
- HttpResponse response) throws HttpException, IOException {
-
- response.setContentType(request.getContentType());
- response.addField("X-Test-Header", "test value");
- IOUtils.copy(request.getInputStream(), response.getOutputStream());
- }
-
- public void validate(MessageContext msgContext, boolean isResponse) throws Exception {
- Map<?,?> trpHeaders = (Map<?,?>)msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
- Assert.assertNotNull(trpHeaders);
- Assert.assertEquals("test value", trpHeaders.get("X-Test-Header"));
- }
-
- public void addEndpointErrorListener(EndpointErrorListener listener) {
- // Ignore this as endpoint errors are not detected yet
- }
-
- public void removeEndpointErrorListener(EndpointErrorListener listener) {
- // Ignore this as endpoint errors are not detected yet
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java
deleted file mode 100644
index 3cba81f..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.io.IOException;
-
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.mortbay.http.HttpException;
-import org.mortbay.http.HttpHandler;
-import org.mortbay.http.HttpRequest;
-import org.mortbay.http.HttpResponse;
-import org.mortbay.http.handler.AbstractHttpHandler;
-
-public abstract class JettyEndpoint {
- private @Transient JettyServer server;
- private @Transient HttpHandler handler;
-
- @Setup @SuppressWarnings({ "unused", "serial" })
- private void setUp(JettyServer server, HttpChannel channel) throws Exception {
- this.server = server;
- final String path = "/" + channel.getServiceName();
- handler = new AbstractHttpHandler() {
- public void handle(String pathInContext, String pathParams,
- HttpRequest request, HttpResponse response) throws HttpException,
- IOException {
-
- if (pathInContext.equals(path)) {
- JettyEndpoint.this.handle(pathParams, request, response);
- request.setHandled(true);
- }
- }
- };
- server.getContext().addHandler(handler);
- handler.start();
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- handler.stop();
- server.getContext().removeHandler(handler);
- }
-
- protected abstract void handle(String pathParams, HttpRequest request, HttpResponse response)
- throws HttpException, IOException;
-
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyRESTAsyncEndpoint.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyRESTAsyncEndpoint.java
deleted file mode 100644
index f4dc238..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyRESTAsyncEndpoint.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.message.RESTMessage;
-import org.apache.axis2.transport.testkit.message.RESTMessage.Parameter;
-import org.mortbay.http.HttpException;
-import org.mortbay.http.HttpRequest;
-
-public class JettyRESTAsyncEndpoint extends JettyAsyncEndpoint<RESTMessage> {
- @Override
- protected IncomingMessage<RESTMessage> handle(HttpRequest request)
- throws HttpException, IOException {
-
- List<Parameter> parameters = new LinkedList<Parameter>();
- for (Map.Entry<String,List<String>> entry :
- ((Map<String,List<String>>)request.getParameters()).entrySet()) {
- for (String value : entry.getValue()) {
- parameters.add(new Parameter(entry.getKey(), value));
- }
- }
- return new IncomingMessage<RESTMessage>(null, new RESTMessage(parameters.toArray(
- new Parameter[parameters.size()])));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java
deleted file mode 100644
index d205f3c..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.http;
-
-import org.apache.axis2.transport.testkit.channel.Channel;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.mortbay.http.HttpContext;
-import org.mortbay.http.SocketListener;
-import org.mortbay.jetty.Server;
-
-public class JettyServer {
- public static final JettyServer INSTANCE = new JettyServer();
-
- private @Transient Server server;
- private @Transient HttpContext context;
-
- private JettyServer() {}
-
- @Setup @SuppressWarnings("unused")
- private void setUp(HttpTestEnvironment env) throws Exception {
- server = new Server();
- SocketListener listener = new SocketListener();
- listener.setPort(env.getServerPort());
- server.addListener(listener);
- context = new HttpContext(server, Channel.CONTEXT_PATH + "/*");
- server.start();
- }
-
- public HttpContext getContext() {
- return context;
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- server.stop();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/AxisMessage.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/AxisMessage.java
deleted file mode 100644
index 4c384f2..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/AxisMessage.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.message;
-
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axiom.om.OMDocument;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.MessageContext;
-
-/**
- * Class encapsulating a SOAP envelope and an attachment map.
- * This class is used by {@link MockMessageReceiver} because it is not safe to
- * keep a reference to the {@link org.apache.axis2.context.MessageContext} object.
- */
-public class AxisMessage {
- private String messageType;
- private SOAPEnvelope envelope;
- private Attachments attachments;
-
- public AxisMessage() {
- }
-
- public AxisMessage(MessageContext msgContext) throws Exception {
- envelope = msgContext.getEnvelope();
- // If possible, build the parent (i.e. the OMDocument) to make sure that the entire message is read.
- // If the transport doesn't handle the end of the message properly, then this problem
- // will show up here.
- OMDocument document = (OMDocument)envelope.getParent();
- if (document != null) {
- document.build();
- } else {
- envelope.build();
- }
-
- // TODO: quick & dirty hack to force expansion of OMSourceElement payloads
- OMElement content = envelope.getBody().getFirstElement();
- if (content instanceof OMSourcedElement) {
- ((OMSourcedElement)content).getFirstOMChild();
- ((OMSourcedElement)content).build();
- }
-
- if (msgContext.isDoingSwA()) {
- // Make sure that all attachments are read
- attachments = msgContext.getAttachmentMap();
- attachments.getAllContentIDs();
- }
- messageType = (String)msgContext.getProperty(Constants.Configuration.MESSAGE_TYPE);
- }
-
- public String getMessageType() {
- return messageType;
- }
-
- public void setMessageType(String messageType) {
- this.messageType = messageType;
- }
-
- public SOAPEnvelope getEnvelope() {
- return envelope;
- }
-
- public void setEnvelope(SOAPEnvelope envelope) {
- this.envelope = envelope;
- }
-
- public Attachments getAttachments() {
- return attachments;
- }
-
- public void setAttachments(Attachments attachments) {
- this.attachments = attachments;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/IncomingMessage.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/IncomingMessage.java
deleted file mode 100644
index 26e1ee8..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/IncomingMessage.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.message;
-
-import javax.mail.internet.ContentType;
-
-public class IncomingMessage<M> {
- private final ContentType contentType;
- private final M data;
-
- public IncomingMessage(ContentType contentType, M data) {
- this.contentType = contentType;
- this.data = data;
- }
-
- public ContentType getContentType() {
- return contentType;
- }
-
- public M getData() {
- return data;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java
deleted file mode 100644
index de6e702..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.message;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.StringReader;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.activation.DataHandler;
-import javax.mail.internet.ContentType;
-
-import junit.framework.Assert;
-
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.testkit.message.RESTMessage.Parameter;
-
-public interface MessageDecoder<T,U> {
- MessageDecoder<AxisMessage,byte[]> AXIS_TO_BYTE =
- new MessageDecoder<AxisMessage,byte[]>() {
-
- public byte[] decode(ContentType contentType, AxisMessage message) throws Exception {
- SOAPEnvelope envelope = message.getEnvelope();
- OMElement wrapper = envelope.getBody().getFirstElement();
- Assert.assertEquals(BaseConstants.DEFAULT_BINARY_WRAPPER, wrapper.getQName());
- OMNode child = wrapper.getFirstOMChild();
- Assert.assertTrue(child instanceof OMText);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ((DataHandler)((OMText)child).getDataHandler()).writeTo(baos);
- return baos.toByteArray();
- }
- };
-
- MessageDecoder<AxisMessage,String> AXIS_TO_STRING =
- new MessageDecoder<AxisMessage,String>() {
-
- public String decode(ContentType contentType, AxisMessage message) throws Exception {
- SOAPEnvelope envelope = message.getEnvelope();
- OMElement wrapper = envelope.getBody().getFirstElement();
- Assert.assertEquals(BaseConstants.DEFAULT_TEXT_WRAPPER, wrapper.getQName());
- return wrapper.getText();
- }
- };
-
- MessageDecoder<AxisMessage,XMLMessage> AXIS_TO_XML =
- new MessageDecoder<AxisMessage,XMLMessage>() {
-
- public XMLMessage decode(ContentType contentType, AxisMessage message) throws Exception {
- Attachments attachments = message.getAttachments();
- XMLMessage.Type type;
- if (attachments != null) {
- type = XMLMessage.Type.SWA;
- } else {
- type = null;
- for (XMLMessage.Type candidate : XMLMessage.Type.values()) {
- if (candidate.getContentType().equals(message.getMessageType())) {
- type = candidate;
- break;
- }
- }
- if (type == null) {
- // TODO: make this an error later
- type = XMLMessage.Type.POX;
- // throw new UnsupportedOperationException("Content type " + message.getMessageType() + " not supported");
- }
- }
- return new XMLMessage(message.getEnvelope().getBody().getFirstElement(), type, attachments);
- }
- };
-
- MessageDecoder<AxisMessage,RESTMessage> AXIS_TO_REST =
- new MessageDecoder<AxisMessage,RESTMessage>() {
-
- public RESTMessage decode(ContentType contentType, AxisMessage message) throws Exception {
- List<Parameter> parameters = new LinkedList<Parameter>();
- OMElement content = message.getEnvelope().getBody().getFirstElement();
- for (Iterator<?> it = content.getChildElements(); it.hasNext(); ) {
- OMElement child = (OMElement)it.next();
- parameters.add(new Parameter(child.getLocalName(), child.getText()));
- }
- return new RESTMessage(parameters.toArray(new Parameter[parameters.size()]));
- }
- };
-
- MessageDecoder<byte[],XMLMessage> BYTE_TO_XML =
- new MessageDecoder<byte[],XMLMessage>() {
-
- public XMLMessage decode(ContentType contentType, byte[] message) throws Exception {
- XMLMessage.Type type = XMLMessage.getTypeFromContentType(contentType);
- if (type == null) {
- throw new Exception("Unrecognized content type " + contentType);
- }
- ByteArrayInputStream in = new ByteArrayInputStream(message);
- if (type == XMLMessage.Type.SWA) {
- Attachments attachments = new Attachments(in, contentType.toString());
- OMElement payload = OMXMLBuilderFactory.createSOAPModelBuilder(
- attachments.getSOAPPartInputStream(), null).getSOAPEnvelope().getBody().getFirstElement();
- return new XMLMessage(payload, type, attachments);
- } else {
- String charset = contentType.getParameter("charset");
- OMElement payload;
- if (type == XMLMessage.Type.POX) {
- payload = OMXMLBuilderFactory.createOMBuilder(in, charset).getDocumentElement();
- } else {
- payload = OMXMLBuilderFactory.createSOAPModelBuilder(in, charset).getSOAPEnvelope().getBody().getFirstElement();
- }
- return new XMLMessage(payload, type);
- }
- }
- };
-
- MessageDecoder<String,XMLMessage> STRING_TO_XML =
- new MessageDecoder<String,XMLMessage>() {
-
- public XMLMessage decode(ContentType contentType, String message) throws Exception {
- XMLMessage.Type type = XMLMessage.getTypeFromContentType(contentType);
- if (type == null) {
- throw new Exception("Unrecognized content type " + contentType);
- }
- OMElement payload;
- if (type == XMLMessage.Type.POX) {
- payload = OMXMLBuilderFactory.createOMBuilder(new StringReader(message)).getDocumentElement();
- } else {
- payload = OMXMLBuilderFactory.createSOAPModelBuilder(new StringReader(message)).getSOAPEnvelope().getBody().getFirstElement();
- }
- return new XMLMessage(payload, type);
- }
- };
-
- MessageDecoder<byte[],String> BYTE_TO_STRING =
- new MessageDecoder<byte[],String>() {
-
- public String decode(ContentType contentType, byte[] message) throws Exception {
- String charset = contentType.getParameter("charset");
- return new String(message, charset);
- }
- };
-
- U decode(ContentType contentType, T message) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java
deleted file mode 100644
index eede937..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.message;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.io.StringWriter;
-
-import javax.activation.DataHandler;
-import javax.mail.internet.ContentType;
-
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.impl.OMMultipartWriter;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.transport.base.BaseConstants;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.util.ContentTypeUtil;
-
-public interface MessageEncoder<T,U> {
- MessageEncoder<XMLMessage,AxisMessage> XML_TO_AXIS =
- new MessageEncoder<XMLMessage,AxisMessage>() {
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- public AxisMessage encode(ClientOptions options, XMLMessage message) throws Exception {
- XMLMessage.Type type = message.getType();
- AxisMessage result = new AxisMessage();
- SOAPFactory factory;
- if (type == XMLMessage.Type.SOAP12 || type == XMLMessage.Type.SWA) {
- factory = OMAbstractFactory.getSOAP12Factory();
- } else {
- factory = OMAbstractFactory.getSOAP11Factory();
- }
- result.setMessageType(type.getContentType().toString());
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- envelope.getBody().addChild(message.getPayload());
- result.setEnvelope(envelope);
- if (type == XMLMessage.Type.SWA) {
- result.setAttachments(message.getAttachments());
- }
- return result;
- }
- };
-
- MessageEncoder<XMLMessage,byte[]> XML_TO_BYTE =
- new MessageEncoder<XMLMessage,byte[]>() {
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception {
- if (contentType.getBaseType().equals(XMLMessage.Type.SWA.getContentType().getBaseType())) {
- OMOutputFormat outputFormat = new OMOutputFormat();
- outputFormat.setMimeBoundary(options.getMimeBoundary());
- outputFormat.setRootContentId(options.getRootContentId());
- return new ContentType(outputFormat.getContentTypeForSwA(SOAP12Constants.SOAP_12_CONTENT_TYPE));
- } else {
- return ContentTypeUtil.addCharset(contentType, options.getCharset());
- }
- }
-
- public byte[] encode(ClientOptions options, XMLMessage message) throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- OMOutputFormat outputFormat = new OMOutputFormat();
- outputFormat.setCharSetEncoding(options.getCharset());
- outputFormat.setIgnoreXMLDeclaration(true);
- if (message.getType() == XMLMessage.Type.SWA) {
- outputFormat.setMimeBoundary(options.getMimeBoundary());
- outputFormat.setRootContentId(options.getRootContentId());
- OMMultipartWriter mpw = new OMMultipartWriter(baos, outputFormat);
- OutputStream out = mpw.writeRootPart();
- message.getMessageElement().serializeAndConsume(out);
- out.close();
- Attachments attachments = message.getAttachments();
- for (String id : attachments.getAllContentIDs()) {
- mpw.writePart(attachments.getDataHandler(id), id);
- }
- mpw.complete();
- } else {
- message.getMessageElement().serializeAndConsume(baos, outputFormat);
- }
- return baos.toByteArray();
- }
- };
-
- MessageEncoder<XMLMessage,String> XML_TO_STRING =
- new MessageEncoder<XMLMessage,String>() {
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- public String encode(ClientOptions options, XMLMessage message) throws Exception {
- if (message.getType() == XMLMessage.Type.SWA) {
- throw new UnsupportedOperationException();
- }
- OMOutputFormat format = new OMOutputFormat();
- format.setIgnoreXMLDeclaration(true);
- StringWriter sw = new StringWriter();
- message.getMessageElement().serializeAndConsume(sw, format);
- return sw.toString();
- }
- };
-
- MessageEncoder<byte[],AxisMessage> BINARY_WRAPPER =
- new MessageEncoder<byte[],AxisMessage>() {
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- public AxisMessage encode(ClientOptions options, byte[] message) throws Exception {
- AxisMessage result = new AxisMessage();
- result.setMessageType("application/octet-stream");
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- OMElement wrapper = factory.createOMElement(BaseConstants.DEFAULT_BINARY_WRAPPER);
- DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(message));
- wrapper.addChild(factory.createOMText(dataHandler, true));
- envelope.getBody().addChild(wrapper);
- result.setEnvelope(envelope);
- return result;
- }
- };
-
- MessageEncoder<String,AxisMessage> TEXT_WRAPPER =
- new MessageEncoder<String,AxisMessage>() {
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- public AxisMessage encode(ClientOptions options, String message) throws Exception {
- AxisMessage result = new AxisMessage();
- result.setMessageType("text/plain");
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- OMElement wrapper = factory.createOMElement(BaseConstants.DEFAULT_TEXT_WRAPPER);
- wrapper.addChild(factory.createOMText(message));
- envelope.getBody().addChild(wrapper);
- result.setEnvelope(envelope);
- return result;
- }
- };
-
- MessageEncoder<String,byte[]> STRING_TO_BYTE =
- new MessageEncoder<String,byte[]>() {
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return ContentTypeUtil.addCharset(contentType, options.getCharset());
- }
-
- public byte[] encode(ClientOptions options, String message) throws Exception {
- return message.getBytes(options.getCharset());
- }
- };
-
- ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception;
- U encode(ClientOptions options, T message) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/RESTMessage.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/RESTMessage.java
deleted file mode 100644
index 1f50905..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/RESTMessage.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.message;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-
-public class RESTMessage {
- public static class Parameter {
- private final String key;
- private final String value;
-
- public Parameter(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getValue() {
- return value;
- }
-
- @Override
- public boolean equals(Object _obj) {
- if (_obj instanceof Parameter) {
- Parameter obj = (Parameter)_obj;
- return ObjectUtils.equals(key, obj.key) && ObjectUtils.equals(value, obj.value);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(key).append(value).toHashCode();
- }
-
- @Override
- public String toString() {
- return key + "=" + value;
- }
- }
-
- private final Parameter[] parameters;
-
- public RESTMessage(Parameter[] parameters) {
- this.parameters = parameters;
- }
-
- public Parameter[] getParameters() {
- return parameters;
- }
-
- public String getQueryString() {
- StringBuilder buffer = new StringBuilder();
- for (Parameter parameter : parameters) {
- if (buffer.length() > 0) {
- buffer.append('&');
- }
- buffer.append(parameter.getKey());
- buffer.append('=');
- try {
- buffer.append(URLEncoder.encode(parameter.getValue(), "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new Error("JRE doesn't know UTF-8!", e);
- }
- }
- return buffer.toString();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/XMLMessage.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/XMLMessage.java
deleted file mode 100644
index a7503ed..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/XMLMessage.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.message;
-
-import javax.mail.internet.ContentType;
-import javax.mail.internet.ParseException;
-
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.transport.http.HTTPConstants;
-
-public class XMLMessage {
- public enum Type {
- SOAP11(SOAP11Constants.SOAP_11_CONTENT_TYPE),
- SOAP12(SOAP12Constants.SOAP_12_CONTENT_TYPE),
- POX("application/xml"),
- SWA(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED);
-
- private final String contentType;
-
- private Type(String contentType) {
- this.contentType = contentType;
- }
-
- public ContentType getContentType() {
- try {
- return new ContentType(contentType);
- } catch (ParseException ex) {
- throw new Error(ex);
- }
- }
- }
-
- private final Type type;
- private final OMElement payload;
- private final Attachments attachments;
-
- public XMLMessage(OMElement payload, Type type, Attachments attachments) {
- this.payload = payload;
- this.type = type;
- this.attachments = attachments;
- }
-
- public XMLMessage(OMElement payload, Type type) {
- this(payload, type, null);
- }
-
- public Type getType() {
- return type;
- }
-
- public OMElement getPayload() {
- return payload;
- }
-
- public OMElement getMessageElement() {
- if (type == Type.POX) {
- return payload;
- } else {
- SOAPFactory factory;
- if (type == Type.SOAP11) {
- factory = OMAbstractFactory.getSOAP11Factory();
- } else {
- factory = OMAbstractFactory.getSOAP12Factory();
- }
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- envelope.getBody().addChild(payload);
- return envelope;
- }
- }
-
- public Attachments getAttachments() {
- return attachments;
- }
-
- public static Type getTypeFromContentType(ContentType contentType) {
- String baseType = contentType.getBaseType();
- Type type = null;
- for (Type candidate : Type.values()) {
- if (candidate.getContentType().getBaseType().equalsIgnoreCase(baseType)) {
- type = candidate;
- break;
- }
- }
- return type;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Key.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Key.java
deleted file mode 100644
index 1e421b4..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Key.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.name;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Key {
- String value();
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Name.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Name.java
deleted file mode 100644
index 07e53c9..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Name.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.name;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface Name {
- String value();
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/NameUtils.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/NameUtils.java
deleted file mode 100644
index 93c953c..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/NameUtils.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.name;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.axis2.transport.testkit.Adapter;
-
-public class NameUtils {
- public static Map<String,String> getNameComponents(Object object) {
- Map<String,String> result = new LinkedHashMap<String,String>();
- getNameComponents(result, object);
- return result;
- }
-
- private static <A extends Annotation> A getAnnotationInherited(Class<?> type, Class<A> annotationClass) {
- A ann = type.getAnnotation(annotationClass);
- if (ann != null) {
- return ann;
- }
- Class<?> superClass = type.getSuperclass();
- if (superClass != null) {
- ann = getAnnotationInherited(superClass, annotationClass);
- if (ann != null) {
- return ann;
- }
- }
- for (Class<?> iface : type.getInterfaces()) {
- ann = getAnnotationInherited(iface, annotationClass);
- if (ann != null) {
- return ann;
- }
- }
- return null;
- }
-
- public static void getNameComponents(Map<String,String> map, Object object) {
- while (object instanceof Adapter) {
- object = ((Adapter)object).getTarget();
- }
- Class<?> clazz = object.getClass();
- {
- Key key = getAnnotationInherited(clazz, Key.class);
- if (key != null) {
- Name name = clazz.getAnnotation(Name.class);
- if (name == null) {
- String className = clazz.getName();
- map.put(key.value(), className.substring(className.lastIndexOf('.') + 1));
- } else {
- map.put(key.value(), name.value());
- }
- }
- }
- for (Method method : clazz.getMethods()) {
- Key key = method.getAnnotation(Key.class);
- Named named = method.getAnnotation(Named.class);
- if (key != null || named != null) {
- Object relatedObject;
- try {
- method.setAccessible(true);
- relatedObject = method.invoke(object);
- } catch (Throwable ex) {
- throw new Error("Error invoking " + method, ex);
- }
- if (relatedObject != null) {
- if (key != null) {
- map.put(key.value(), relatedObject.toString());
- } else {
- getNameComponents(map, relatedObject);
- }
- }
- }
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Named.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Named.java
deleted file mode 100644
index d9823e6..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/name/Named.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.name;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Named {
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/package-info.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/package-info.java
deleted file mode 100644
index 196b9ff..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/package-info.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Transport test kit base package.
- *
- * <h2>Introduction and high level overview</h2>
- *
- * In general a good test suite for an Axis2 transport should contain test cases that
- * <ul>
- * <li>test the transport sender in isolation, i.e. with non Axis2 endpoints;</li>
- * <li>test the transport listener in isolation, i.e. with non Axis2 clients;</li>
- * <li>test the interoperability between the transport sender and the transport listener.</li>
- * </ul>
- * In addition, the test suite should cover
- * <ul>
- * <li>different message exchange patterns (at least one-way and request-response);</li>
- * <li>different content types (SOAP 1.1/1.2, POX, SOAP with attachments, MTOM, plain text, binary, etc.).</li>
- * </ul>
- * Also for some transports it is necessary to execute the tests with different transport
- * configurations or with different protocol providers. For example, HTTP transport implementations
- * are tested in HTTP 1.0 and HTTP 1.1 mode, and the JMS transport is tested with different
- * JMS providers (currently Qpid and ActiveMQ).
- * <p>
- * The test kit grew out of the idea that is should be possible to apply a common set of tests
- * (with different MEPs and content types) to several transports with a minimum of code duplication.
- * By providing non Axis2 test clients and endpoints as well as the code that sets up the
- * necessary environment as input, the framework should then be able to build a complete test suite
- * for the transport.
- * <p>
- * It is clear that since each transport protocol has its own specificities, a high level of abstraction
- * is required to achieve this goal. The following sections give a high level overview of the
- * various abstractions that have been introduced in the test kit.
- *
- * <h3>Integration with JUnit</h3>
- *
- * One of the fundamental requirements for the test kit is to integrate well with JUnit.
- * This requirement ensures that the tests can be executed easily as part of the Maven
- * build and that other available tools such as test report generators and test coverage
- * analysis tools can be used.
- * <p>
- * The usual approach to write JUnit tests is to extend {@link junit.framework.TestCase.TestCase}
- * and to define a set of methods that implement the different test cases. Since the goal of the framework
- * is to build test suites in an automated way and the number of test cases can be fairly high, this
- * approach would not be feasible. Fortunately JUnit supports another way to create a test suite
- * dynamically. Indeed JUnit scans the test code for methods with the following signature:
- *
- * <pre>public static TestSuite suite()</pre>
- *
- * A typical transport test will implement this method and use {@link org.apache.axis2.transport.testkit.TransportTestSuiteBuilder}
- * to let the framework create the test suite.
- *
- * <h3>Test case naming</h3>
- *
- * One problem that immediately arises when building a test suite dynamically is that each test
- * case must have a name (which should be unique) and that this name should be sufficiently meaningful
- * so that when it appears in a report a human should be able to get a basic idea of what the test case does.
- * The names generated by the test kit have two parts:
- * <ul>
- * <li>A numeric ID which is the sequence number of the test case in the test suite.</li>
- * <li>A set of key-value pairs describing the components that are used in the test case.</li>
- * </ul>
- * Example:
- *
- * <pre>0076:test=REST,client=java.net,endpoint=axis</pre>
- *
- * The algorithm used by the test kit to collect the key-value pairs is described in the documentation of
- * the {@link org.apache.axis2.transport.testkit.name} package.
- *
- * <h3>Resource management</h3>
- *
- * In general setting up the environment in which a given test case is executed may be quite expensive.
- * For example, running a test case for the JMS transport requires starting a message broker. Also
- * every test case requires at least an Axis2 client and/or server environment to deploy the transport.
- * Setting up and tearing down the entire environment for every single test case would be far too
- * expensive. On the other hand the environments required by different test cases in a single test suite
- * are in general very different from each other so that it would not possible to set up a common
- * environment used by all the test cases.
- * <p>
- * To overcome this difficulty, the test kit has a mechanism that allows a test case to reuse resources
- * from the previous test case. This is managed in an entirely transparent way by a lightweight
- * dependency injection container (see [TODO: need to regroup this code in a single package]), so that
- * the test case doesn't need to care about it.
- * <p>
- * The mechanism is based on a set of simple concepts: [TODO: this is too detailed for a high level overview and
- * should be moved to the Javadoc of the relevant package]
- * <ul>
- * <li><p>Every test case is linked to a set of <em>resources</em> which are plain Java objects (that are not
- * required to extend any particular class or implement any particular interface).
- * These objects define the <em>resource set</em> of the test case (which is represented
- * internally by a {@link org.apache.axis2.transport.testkit.tests.TestResourceSet}
- * object).</p></li>
- * <li><p>The lifecycle of a resource is managed through methods annotated by
- * {@link org.apache.axis2.transport.testkit.tests.Setup} and {@link org.apache.axis2.transport.testkit.tests.TearDown}.
- * These annotations identify the methods to be called when the framework sets up and tears down the resource.
- * The arguments of the methods annotated using {@link org.apache.axis2.transport.testkit.tests.Setup} also
- * define the <em>dependencies</em> of that resource.</p>
- * <p>Example:</p>
- * <pre>public class MyTestClient {
- * \@Setup
- * private void setUp(MyProtocolProvider provider) throws Exception {
- * provider.connect();
- * }
- *}</pre>
- * <p>As shown in this example, dependencies are specified by class (which may be abstract). The actual
- * instance that will be injected is selected during <em>resource resolution</em>.</p></li>
- * <li><p>Resources are (in general) resolved from the resource set of the test case. For example an instance
- * of the <code>MyTestClient</code> class can only be used as a resource for a given test case
- * if the resource set of this test case also contains an instance of <code>MyProtocolProvider</code>
- * (more precisely an object that is assignment compatible with <code>MyProtocolProvider</code>).</p></li>
- * <li><p>A resource will be reused across two test cases if it is part of the resource sets of both
- * test cases and all its dependencies (including transitive dependencies) are part of both resource sets.
- * The precise meaning of "reusing" in this context is using the same instance without calling the
- * tear down and set up methods.</p>
- * <p>For example, consider the following test cases and resource sets:</p>
- * <table border="1">
- * <tr><th>Test case</th><th>Resource set</th></tr>
- * <tr><td>T1</td><td><code>c:MyTestClient</code>, <code>p1:MyProtocolProvider</code></td></tr>
- * <tr><td>T2</td><td><code>c:MyTestClient</code>, <code>p1:MyProtocolProvider</code>, <code>r:SomeOtherResourceType</code></td></tr>
- * <tr><td>T3</td><td><code>c:MyTestClient</code>, <code>p2:MyProtocolProvider</code>, <code>r:SomeOtherResourceType</code></td></tr>
- * </table>
- * <p>Assuming that <code>SomeOtherResourceType</code> is independent of <code>MyTestClient</code> and
- * <code>MyProtocolProvider</code>, the lifecycle of the different resources will be as follows:</p>
- * <table border="1">
- * <tr><th>Transition</th><th>Lifecycle actions</th></tr>
- * <tr><td>• → T1</td><td>set up <code>p1</code>, set up <code>c</code></td></tr>
- * <tr><td>T1 → T2</td><td>set up <code>r</code></td></tr>
- * <tr><td>T2 → T3</td><td>tear down <code>c</code>, tear down <code>p1</code>, set up <code>p2</code>, set up <code>c</code></td></tr>
- * <tr><td>T3 → •</td><td>tear down <code>c</code>, tear down <code>p2</code>, tear down <code>r</code></td></tr>
- * </table>
- * <p>Even if T2 and T3 use the same instance <code>c</code> of <code>MyTestClient</code>, this resource
- * is not reused (in the sense defined above) since the <code>MyProtocolProvider</code> dependency
- * resolves to different instances.</p></li>
- * </ul>
- *
- * <h3>Resources required by a transport test case</h3>
- *
- * Every transport test case (extending {@link org.apache.axis2.transport.testkit.tests.MessageTestCase})
- * at least requires three resources:
- * <ul>
- * <li>A test client ({@link org.apache.axis2.transport.testkit.client.AsyncTestClient}
- * or {@link org.apache.axis2.transport.testkit.client.RequestResponseTestClient}) that
- * allows the test case to send messages (and receive responses).</li>
- * <li>A test endpoint ({@link org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint}
- * or {@link org.apache.axis2.transport.testkit.endpoint.InOutEndpoint}). In the one-way case,
- * this resource is used to receive requests send by the test client. In the request-response
- * case its responsibility is to generate well defined responses (typically a simple echo).</li>
- * <li>A channel ({@link org.apache.axis2.transport.testkit.channel.AsyncChannel} or
- * {@link org.apache.axis2.transport.testkit.channel.RequestResponseChannel}. This resource
- * manages everything that it necessary to transport a message from a client to an endpoint.
- * Depending on the transport this task can be fairly complex. For example, in the JMS case,
- * the channel creates the required JMS destinations and registers them in JNDI, so that
- * they can be used by the client and by the endpoint. On the other hand, for HTTP the
- * channel implementation is very simple and basically limited to the computation of the
- * endpoint reference.</li>
- * </ul>
- * <p>The test kit provides the following Axis2 based test client and endpoint implementations:</p>
- * <table border="1">
- * <tr>
- * <th></th>
- * <th>One-way</th>
- * <th>Request-response</th>
- * </tr>
- * <tr>
- * <th>Client</th>
- * <td>{@link org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient}</td>
- * <td>{@link org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient}</td>
- * </tr>
- * <tr>
- * <th>Endpoint</th>
- * <td>{@link org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint}</td>
- * <td>{@link org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint}</td>
- * </tr>
- * </table>
- *
- * <h3>Message encoders and decoders</h3>
- *
- * Different clients, endpoints and test cases may have fairly different ways to "naturally" represent
- * a message:
- * <ul>
- * <li>To test the listener of an HTTP transport, an obvious choice is to build a test client
- * that relies on standard Java classes such as {@link java.net.URLConnection}. For that
- * purpose the most natural way to represent a message is as a byte sequence.</li>
- * <li>All Axis2 based test clients and endpoints already have a canonical message
- * representation, which is the SOAP infoset retrieved by
- * {@link org.apache.axis2.context.MessageContext#getEnvelope()}.</li>
- * <li>A test case for plain text messages would naturally represent the test message
- * as a string.</li>
- * </ul>
- * Since defining a message representation that would be suitable for all clients, endpoints and test
- * cases (and make their implementation simple) is impossible, a different approach has been chosen
- * in the framework. Every client, endpoint or test case implementation chooses the Java type that is
- * considers as best suited to represent the message. When invoking the test client, a test case
- * uses a {@link org.apache.axis2.transport.testkit.message.MessageEncoder} to transform the message
- * from its own representation to the representation used by the test client. In the same way,
- * a {@link org.apache.axis2.transport.testkit.message.MessageDecoder} is used to transform the message
- * intercepted by the endpoint (in the one-way case) or the response message received by the test client
- * (in the request-response case).
- * <p>
- * [TODO: currently message encoders and decoders are chosen at compile time and the transformation is
- * is invoked indirectly by adapters; this will change in the future so that encoders and decoders are
- * selected dynamically at runtime]
- *
- * <h3>Exclusion rules</h3>
- *
- * Sometimes it is necessary to exclude particular test cases (or entire groups of test cases) from the
- * test suite generated by the test kit. There are various reasons why one would do that:
- * <ul>
- * <li>A test case fails because of some known issue in the transport. In that case it should be excluded
- * until the issue is fixed. This is necessary to distinguish this type of failure from regressions.
- * In general the tests checked in to source control should always succeed unless there is a regression.</li>
- * <li>Sometimes a particular test case doesn't make sense for a given transport. For example a test
- * case that checks that the transport is able to handle large payloads would not be applicable
- * to the UDP transport which has a message size limitation.</li>
- * <li>The test suite builder generates test cases by computing all possible combinations of MEPs, content types,
- * clients, endpoints and environment setups. For some transports this results in a very high number of test
- * cases. Since these test cases generally have a high degree of overlap, one can use exclusion rules
- * to reduce the number of test cases to a more reasonable value.</li>
- * </ul>
- * The test kit allows to specify exclusion rules using LDAP filter expressions. It takes advantage of the
- * fact that each test case has a set of key-value pairs used to build the test case name. The LDAP filters
- * are evaluated against this set.
- * For example, {@link org.apache.axis2.transport.testkit.TransportTestSuiteBuilder} defines the following
- * default exclusion rule:
- *
- * <pre>(&(client=*)(endpoint=*)(!(|(client=axis)(endpoint=axis))))</pre>
- *
- * This rule excludes all test cases that would use a non Axis2 client and a non Axis2 endpoint.
- *
- * <h3>Logging</h3>
- *
- * Transport test cases generally involve several interacting components and some of these components
- * may use multithreading. Also experience has shown that some test cases may randomly fail (often with
- * a failure probablity highly dependent on the execution platform) because of subtle problems in the
- * transport under test or in the tests themselves. All this can make debugging extremely difficult.
- * To simplify this task, the test kit collects (or provides the necessary infrastructure to collect)
- * a maximum of information during the execution of each test case.
- * <p>
- * The collected information is written to a set of log files managed by
- * {@link org.apache.axis2.transport.testkit.util.LogManager}. An instance is added automatically to
- * the resource set of every test case and other resources can acquire a reference through the dependency
- * injection mechanism described above. This is the recommended approach. Alternatively, the log manager
- * can be used as a singleton through {@link org.apache.axis2.transport.testkit.util.LogManager#INSTANCE}.
- * <p>
- * Logs files are written to subdirectories of <tt>target/testkit-logs</tt>. The directory structure has
- * a two level hierarchy identifying the test class (by its fully qualified name) and the test case
- * (by its ID). It should be noted that the test results themselves (in particular the exception in case
- * of failure) are still written to the standard JUnit/Surefire logs and that these logs should be
- * consulted first. The test kit specific log files are only meant to provide additional information.
- * <p>
- * Each test case at least produces a <tt>01-debug.log</tt> file with the messages that were logged
- * (using JCL) at level DEBUG during the execution of the test case. In addition, depending on the
- * components involved in the test, the test kit will produce the following logs (<tt>XX</tt>
- * denotes a sequence number which is generated automatically):
- * <dl>
- * <dt><tt>XX-formatter.log</tt></dt>
- * <dt><tt>XX-builder.log</tt></dt>
- * <dd><p>These files are produced when Axis2 test clients and endpoints are used.
- * <tt>XX-formatter.log</tt> will contain the payload of an incoming message as seen by the
- * {@link org.apache.axis2.transport.MessageFormatter}. <tt>XX-builder.log</tt> on the other
- * hand will contain the payload of an outgoing message as produced by the
- * {@link org.apache.axis2.builder.Builder}. Note that the number of log files depends on
- * serveral factors, such as the MEP, whether the client or endpoint is Axis2 based or not and
- * whether the transport chooses to use message builders and formatters or not.</p>
- * <p>These files provides extremely valuable information since it is very difficult to get this
- * data using other debugging techniques. Note that the files are created by
- * {@link org.apache.axis2.transport.testkit.axis2.LogAspect} which relies on Aspect/J to
- * intercept calls to message formatters and builders. This will only work if the tests are
- * run with the Aspect/J weaver.</p></dd>
- * <dt><tt>XX-service-parameters.log</tt></dt>
- * <dd><p>If the test case uses an Axis2 based endpoint, this file will contain the parameters
- * of the {@link org.apache.axis2.description.AxisService} implementing this endpoint.
- * This information is useful since the service configuration is in general determined
- * by different components involved in the test.</p></dd>
- * </dl>
- */
-package org.apache.axis2.transport.testkit;
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java
deleted file mode 100644
index acb7d96..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.name.NameUtils;
-import org.apache.axis2.transport.testkit.util.LogManager;
-
-@Key("test")
-public abstract class ManagedTestCase extends TestCase {
- private final TestResourceSet resourceSet = new TestResourceSet();
-
- private Map<String,String> nameComponents;
-
- private String id;
- private boolean managed;
- private Class<?> testClass;
-
- public ManagedTestCase(Object... resources) {
- resourceSet.addResources(resources);
- addResource(LogManager.INSTANCE);
- }
-
- protected void addResource(Object resource) {
- resourceSet.addResource(resource);
- }
-
- public Map<String,String> getNameComponents() {
- if (nameComponents == null) {
- nameComponents = new LinkedHashMap<String,String>();
- NameUtils.getNameComponents(nameComponents, this);
- resourceSet.resolve();
- for (Object resource : resourceSet.getResources()) {
- NameUtils.getNameComponents(nameComponents, resource);
- }
- }
- return nameComponents;
- }
-
- // TODO: TransportTestCase should be in the same package as TransportTestSuite and this
- // method should have package access
- public void init(String id, boolean managed, Class<?> testClass) {
- this.id = id;
- this.managed = managed;
- this.testClass = testClass;
- }
-
- public String getId() {
- return id != null ? id : getName();
- }
-
- public Class<?> getTestClass() {
- return testClass != null ? testClass : getClass();
- }
-
- @Override
- public String getName() {
- String testName = super.getName();
- if (testName == null) {
- StringBuilder buffer = new StringBuilder();
- if (id != null) {
- buffer.append(id);
- buffer.append(':');
- }
- boolean first = true;
- for (Map.Entry<String,String> entry : getNameComponents().entrySet()) {
- if (first) {
- first = false;
- } else {
- buffer.append(',');
- }
- buffer.append(entry.getKey());
- buffer.append('=');
- buffer.append(entry.getValue());
- }
- testName = buffer.toString();
- setName(testName);
- }
- return testName;
- }
-
- public TestResourceSet getResourceSet() {
- return resourceSet;
- }
-
- @Override
- protected void setUp() throws Exception {
- if (!managed) {
- LogManager.INSTANCE.setTestCase(this);
- resourceSet.setUp();
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (!managed) {
- resourceSet.tearDown();
- LogManager.INSTANCE.setTestCase(null);
- }
- }
-
- @Override
- public String toString() {
- return getName() + "(" + testClass.getName() + ")";
- }
-}
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/MessageTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/MessageTestCase.java
deleted file mode 100644
index d0deb9d..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/MessageTestCase.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.Adapter;
-import org.apache.axis2.transport.testkit.MessageExchangeValidator;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.TestClient;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class MessageTestCase extends ManagedTestCase {
- private static final Log log = LogFactory.getLog(MessageTestCase.class);
-
- protected final ContentType contentType;
- protected final ClientOptions options;
- private @Transient MessageExchangeValidator[] validators;
-
- public MessageTestCase(TestClient client, ContentType contentType, String charset, Object... resources) {
- super(resources);
- if (client instanceof Adapter) {
- addResource(((Adapter)client).getTarget());
- } else {
- addResource(client);
- }
- this.contentType = contentType;
- try {
- options = new ClientOptions(client, contentType, charset);
- } catch (Exception ex) {
- // TODO: handle this in a better way
- throw new Error(ex);
- }
- addResource(options);
- addResource(this);
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MessageExchangeValidator[] validators) {
- this.validators = validators;
- }
-
- @Override
- protected void runTest() throws Throwable {
- for (MessageExchangeValidator validator : validators) {
- validator.beforeSend();
- }
- doRunTest();
- for (MessageExchangeValidator validator : validators) {
- log.debug("Invoking message exchange validator " + validator.getClass().getName());
- validator.afterReceive();
- }
- }
-
- protected abstract void doRunTest() throws Throwable;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Setup.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Setup.java
deleted file mode 100644
index 2f9f4b9..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Setup.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation identifying methods to be called when a resource is set up.
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Setup {
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TearDown.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TearDown.java
deleted file mode 100644
index 6945cd6..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TearDown.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation identifying methods to be called when a resource is torn down.
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface TearDown {
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java
deleted file mode 100644
index 7985d6a..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.axis2.transport.testkit.Adapter;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-
-public class TestResource {
- private enum Status { UNRESOLVED, RESOLVED, SETUP, RECYCLED };
-
- private interface Invocable {
- void execute(Object object) throws Exception;
- }
-
- private static class MethodInvocation implements Invocable {
- private final Method method;
- private final Object[] args;
-
- public MethodInvocation(Method method, Object[] args) {
- this.method = method;
- this.args = args;
- }
-
- public void execute(Object object) throws Exception {
- try {
- method.invoke(object, args);
- } catch (InvocationTargetException ex) {
- Throwable cause = ex.getCause();
- if (cause instanceof Error) {
- throw (Error)cause;
- } else if (cause instanceof Exception) {
- throw (Exception)cause;
- } else {
- throw ex;
- }
- }
- }
- }
-
- private static class FieldResetter implements Invocable {
- private final Field field;
-
- public FieldResetter(Field field) {
- this.field = field;
- }
-
- public void execute(Object object) throws Exception {
- field.set(object, null);
- }
- }
-
- private final Object instance;
- private final Object target;
- private final Set<TestResource> directDependencies = new HashSet<TestResource>();
- private final LinkedList<Invocable> initializers = new LinkedList<Invocable>();
- private final List<Invocable> finalizers = new LinkedList<Invocable>();
- private Status status = Status.UNRESOLVED;
- private boolean hasHashCode;
- private int hashCode;
-
- public TestResource(Object instance) {
- this.instance = instance;
- Object target = instance;
- while (target instanceof Adapter) {
- target = ((Adapter)target).getTarget();
- }
- this.target = target;
- }
-
- public void resolve(TestResourceSet resourceSet) {
- if (status != Status.UNRESOLVED) {
- return;
- }
- for (Class<?> clazz = target.getClass(); !clazz.equals(Object.class);
- clazz = clazz.getSuperclass()) {
- for (Method method : clazz.getDeclaredMethods()) {
- if (method.getAnnotation(Setup.class) != null) {
- Type[] parameterTypes = method.getGenericParameterTypes();
- Object[] args = new Object[parameterTypes.length];
- for (int i=0; i<parameterTypes.length; i++) {
- Type parameterType = parameterTypes[i];
- if (!(parameterType instanceof Class)) {
- throw new Error("Generic parameters not supported in " + method);
- }
- Class<?> parameterClass = (Class<?>)parameterType;
- if (parameterClass.isArray()) {
- Class<?> componentType = parameterClass.getComponentType();
- TestResource[] resources = resourceSet.findResources(componentType, true);
- Object[] arg = (Object[])Array.newInstance(componentType, resources.length);
- for (int j=0; j<resources.length; j++) {
- TestResource resource = resources[j];
- directDependencies.add(resource);
- arg[j] = resource.getInstance();
- }
- args[i] = arg;
- } else {
- TestResource[] resources = resourceSet.findResources(parameterClass, true);
- if (resources.length == 0) {
- throw new Error(target.getClass().getName() + " depends on " +
- parameterClass.getName() + ", but none found");
- } else if (resources.length > 1) {
- throw new Error(target.getClass().getName() + " depends on " +
- parameterClass.getName() + ", but multiple candidates found");
-
- }
- TestResource resource = resources[0];
- directDependencies.add(resource);
- args[i] = resource.getInstance();
- }
- }
- method.setAccessible(true);
- initializers.addFirst(new MethodInvocation(method, args));
- } else if (method.getAnnotation(TearDown.class) != null && method.getParameterTypes().length == 0) {
- method.setAccessible(true);
- finalizers.add(new MethodInvocation(method, null));
- }
- }
- for (Field field : clazz.getDeclaredFields()) {
- if (field.getAnnotation(Transient.class) != null) {
- field.setAccessible(true);
- finalizers.add(new FieldResetter(field));
- }
- }
- }
- status = Status.RESOLVED;
- }
-
- public Object getInstance() {
- return instance;
- }
-
- public Object getTarget() {
- return target;
- }
-
- public boolean hasLifecycle() {
- return !(initializers.isEmpty() && finalizers.isEmpty());
- }
-
- public void setUp() throws Exception {
- if (status != Status.RESOLVED) {
- throw new IllegalStateException();
- }
- for (Invocable initializer : initializers) {
- initializer.execute(target);
- }
- status = Status.SETUP;
- }
-
- public void recycle(TestResource resource) {
- if (status != Status.RESOLVED || resource.status != Status.SETUP || !equals(resource)) {
- throw new IllegalStateException();
- }
- status = Status.SETUP;
- resource.status = Status.RECYCLED;
- }
-
- public void tearDown() throws Exception {
- if (status != Status.SETUP) {
- throw new IllegalStateException();
- }
- for (Invocable finalizer : finalizers) {
- finalizer.execute(target);
- }
- status = Status.RESOLVED;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TestResource) {
- TestResource other = (TestResource)obj;
- return target == other.target && directDependencies.equals(other.directDependencies);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- int hashCode;
- if (hasHashCode) {
- hashCode = this.hashCode;
- } else {
- hashCode = new HashCodeBuilder().append(target).append(directDependencies).toHashCode();
- if (status != Status.UNRESOLVED) {
- this.hashCode = hashCode;
- }
- }
- return hashCode;
- }
-
- @Override
- public String toString() {
- Class<?> clazz = target.getClass();
- String simpleName = clazz.getSimpleName();
- if (simpleName.length() > 0) {
- return simpleName;
- } else {
- return "<anonymous " + clazz.getSuperclass().getSimpleName() + ">";
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSet.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSet.java
deleted file mode 100644
index 9c38978..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSet.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class TestResourceSet {
- enum Status { UNRESOLVED, RESOLVED, SETUP, RECYCLED };
-
- private static Log log = LogFactory.getLog(TestResourceSet.class);
-
- private final TestResourceSet parent;
- private final List<TestResource> unresolvedResources = new LinkedList<TestResource>();
- final List<TestResource> resolvedResources = new LinkedList<TestResource>();
- Status status = Status.UNRESOLVED;
-
- public TestResourceSet(TestResourceSet parent) {
- this.parent = parent;
- }
-
- public TestResourceSet() {
- this(null);
- }
-
- public void addResource(Object resource) {
- if (status != Status.UNRESOLVED) {
- throw new IllegalStateException();
- }
- unresolvedResources.add(new TestResource(resource));
- }
-
- public void addResources(Object... resources) {
- for (Object resource : resources) {
- addResource(resource);
- }
- }
-
- public Object[] getResources() {
- if (status == Status.UNRESOLVED) {
- throw new IllegalStateException();
- }
- Object[] result = new Object[resolvedResources.size()];
- int i = 0;
- for (TestResource resource : resolvedResources) {
- result[i++] = resource.getInstance();
- }
- return result;
- }
-
- public void resolve() {
- if (status == Status.UNRESOLVED) {
- while (!unresolvedResources.isEmpty()) {
- resolveResource(unresolvedResources.get(0));
- }
- status = Status.RESOLVED;
- }
- }
-
- private void resolveResource(TestResource resource) {
- unresolvedResources.remove(resource);
- resource.resolve(this);
- resolvedResources.add(resource);
- }
-
- TestResource[] findResources(Class<?> clazz, boolean allowAutoCreate) {
- List<TestResource> result = new LinkedList<TestResource>();
- if (parent != null) {
- result.addAll(Arrays.asList(parent.findResources(clazz, false)));
- }
- for (TestResource resource : resolvedResources) {
- if (clazz.isInstance(resource.getInstance())) {
- result.add(resource);
- }
- }
- List<TestResource> unresolvedMatchingResources = new LinkedList<TestResource>();
- for (TestResource resource : unresolvedResources) {
- if (clazz.isInstance(resource.getInstance())) {
- unresolvedMatchingResources.add(resource);
- }
- }
- for (TestResource resource : unresolvedMatchingResources) {
- resolveResource(resource);
- result.add(resource);
- }
- if (allowAutoCreate && result.isEmpty()) {
- TestResource resource;
- try {
- Field field = clazz.getField("INSTANCE");
- resource = new TestResource(field.get(null));
- } catch (Throwable ex) {
- resource = null;
- }
- if (resource != null) {
- unresolvedResources.add(resource);
- resolveResource(resource);
- result.add(resource);
- }
- }
- return result.toArray(new TestResource[result.size()]);
- }
-
- public void setUp() throws Exception {
- resolve();
- if (status != Status.RESOLVED) {
- throw new IllegalStateException();
- }
- setUp(resolvedResources);
- status = Status.SETUP;
- }
-
- static List<TestResource> filterOnHasLifecycle(List<TestResource> resources) {
- List<TestResource> result = new ArrayList<TestResource>(resources.size());
- for (TestResource resource : resources) {
- if (resource.hasLifecycle()) {
- result.add(resource);
- }
- }
- return result;
- }
-
- static void setUp(List<TestResource> resources) throws Exception {
- resources = filterOnHasLifecycle(resources);
- if (!resources.isEmpty()) {
- log.info("Setting up: " + resources);
- for (TestResource resource : resources) {
- resource.setUp();
- }
- }
- }
-
- public void tearDown() throws Exception {
- if (status != Status.SETUP) {
- throw new IllegalStateException();
- }
- tearDown(resolvedResources);
- }
-
- static void tearDown(List<TestResource> resources) throws Exception {
- resources = filterOnHasLifecycle(resources);
- if (!resources.isEmpty()) {
- log.info("Tearing down: " + resources);
- for (ListIterator<TestResource> it = resources.listIterator(resources.size()); it.hasPrevious(); ) {
- it.previous().tearDown();
- }
- }
- }
-
- @Override
- public String toString() {
- return resolvedResources.toString();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSetTransition.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSetTransition.java
deleted file mode 100644
index 6c986b4..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSetTransition.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.axis2.transport.testkit.tests.TestResourceSet.Status;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class TestResourceSetTransition {
- private static final Log log = LogFactory.getLog(TestResourceSetTransition.class);
-
- private final TestResourceSet old;
- private final TestResourceSet target;
- private final List<TestResource> oldResourcesToTearDown;
- private final List<TestResource> resourcesToSetUp;
- private final List<TestResource> resourcesToKeep;
-
- public TestResourceSetTransition(TestResourceSet old, TestResourceSet target) {
- this.old = old;
- this.target = target;
- target.resolve();
- if (target.status != TestResourceSet.Status.RESOLVED) {
- throw new IllegalStateException();
- }
- if (old.status != Status.SETUP) {
- throw new IllegalStateException();
- }
- oldResourcesToTearDown = new LinkedList<TestResource>();
- resourcesToSetUp = new LinkedList<TestResource>(target.resolvedResources);
- resourcesToKeep = new LinkedList<TestResource>();
- outer: for (TestResource oldResource : TestResourceSet.filterOnHasLifecycle(old.resolvedResources)) {
- for (Iterator<TestResource> it = resourcesToSetUp.iterator(); it.hasNext(); ) {
- TestResource resource = it.next();
- if (resource.equals(oldResource)) {
- it.remove();
- resource.recycle(oldResource);
- resourcesToKeep.add(oldResource);
- continue outer;
- }
- }
- oldResourcesToTearDown.add(oldResource);
- }
- }
-
- public void tearDown() throws Exception {
- if (old.status != Status.SETUP) {
- throw new IllegalStateException();
- }
- TestResourceSet.tearDown(oldResourcesToTearDown);
- old.status = Status.RECYCLED;
- }
-
- public void setUp() throws Exception {
- if (target.status != TestResourceSet.Status.RESOLVED) {
- throw new IllegalStateException();
- }
- log.debug("Keeping: " + resourcesToKeep);
- TestResourceSet.setUp(resourcesToSetUp);
- target.status = Status.SETUP;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Transient.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Transient.java
deleted file mode 100644
index d1514e8..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Transient.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation identifying fields to be reset when a resource is torn down.
- */
-@Target({ElementType.TYPE, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Transient {
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/AsyncMessageTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/AsyncMessageTestCase.java
deleted file mode 100644
index 8e11d84..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/AsyncMessageTestCase.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.async;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.tests.MessageTestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class AsyncMessageTestCase<M> extends MessageTestCase {
- private static final Log log = LogFactory.getLog(AsyncMessageTestCase.class);
-
- private final AsyncTestClient<M> client;
- private final AsyncEndpoint<M> endpoint;
-
- // TODO: maybe we don't need an explicit AsyncChannel
- public AsyncMessageTestCase(AsyncChannel channel, AsyncTestClient<M> client, AsyncEndpoint<M> endpoint, ContentType contentType, String charset, Object... resources) {
- super(client, contentType, charset, resources);
- this.client = client;
- this.endpoint = endpoint;
- addResource(channel);
- addResource(endpoint);
- }
-
- @Override
- protected void doRunTest() throws Throwable {
- endpoint.clear();
- log.debug("Preparing message");
- M expected = prepareMessage();
-
- // Run the test.
-// contentTypeMode == ContentTypeMode.TRANSPORT ? contentType : null);
- log.debug("Sending message");
- client.sendMessage(options, contentType, expected);
- log.debug("Message sent; waiting for endpoint to receive message");
- IncomingMessage<M> actual = endpoint.waitForMessage(8000);
- if (actual == null) {
- log.debug("Message NOT received by endpoint; failing test");
- fail("Failed to get message");
- }
-
- log.debug("Message received by endpoint; checking message data");
- checkMessageData(expected, actual.getData());
- log.debug("Message received by endpoint has expected content");
- }
-
- protected abstract M prepareMessage() throws Exception;
- protected abstract void checkMessageData(M expected, M actual) throws Exception;
-}
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/BinaryTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/BinaryTestCase.java
deleted file mode 100644
index d58a724..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/BinaryTestCase.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.async;
-
-import java.util.Arrays;
-import java.util.Random;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("AsyncBinary")
-public class BinaryTestCase extends AsyncMessageTestCase<byte[]> {
- private static final Random random = new Random();
-
- public BinaryTestCase(AsyncChannel channel, AsyncTestClient<byte[]> client, AsyncEndpoint<byte[]> endpoint, Object... resources) {
- super(channel, client, endpoint, new ContentType("application", "octet-stream", null), null, resources);
- }
-
- @Override
- protected byte[] prepareMessage() throws Exception {
- byte[] content = new byte[8192];
- random.nextBytes(content);
- return content;
- }
-
- @Override
- protected void checkMessageData(byte[] expected, byte[] actual) throws Exception {
- assertTrue(Arrays.equals(expected, actual));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/LargeSOAPAsyncMessageTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/LargeSOAPAsyncMessageTestCase.java
deleted file mode 100644
index 0c3a9c9..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/LargeSOAPAsyncMessageTestCase.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.async;
-
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.message.XMLMessage;
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("AsyncSOAPLarge")
-// TODO: maybe we should use XMLUnit to construct these kind of tests
-public class LargeSOAPAsyncMessageTestCase extends AsyncMessageTestCase<XMLMessage> {
- public LargeSOAPAsyncMessageTestCase(AsyncChannel channel, AsyncTestClient<XMLMessage> client, AsyncEndpoint<XMLMessage> endpoint, Object... resources) {
- super(channel, client, endpoint, XMLMessage.Type.SOAP11.getContentType(), "UTF-8", resources);
- }
-
- @Override
- protected XMLMessage prepareMessage() throws Exception {
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMElement root = factory.createOMElement(new QName("root"));
- for (int i=0; i<1000; i++) {
- OMElement child = factory.createOMElement(new QName("child"));
- child.setText("text");
- root.addChild(child);
- }
- return new XMLMessage(root, XMLMessage.Type.SOAP11);
- }
-
- @Override
- protected void checkMessageData(XMLMessage expected, XMLMessage actual) throws Exception {
- OMElement element = actual.getPayload();
- OMElement orgElement = expected.getPayload();
- assertEquals(orgElement.getQName(), element.getQName());
- assertEquals(1000, countChildren(element));
- }
-
- private static int countChildren(OMElement element) {
- int count = 0;
- for (Iterator<?> it = element.getChildElements(); it.hasNext(); count++) {
- it.next();
- }
- return count;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/RESTTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/RESTTestCase.java
deleted file mode 100644
index 4c12753..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/RESTTestCase.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.async;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.message.RESTMessage;
-import org.apache.axis2.transport.testkit.message.RESTMessage.Parameter;
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("REST")
-public class RESTTestCase extends AsyncMessageTestCase<RESTMessage> {
- private final RESTMessage message;
-
- public RESTTestCase(AsyncChannel channel, AsyncTestClient<RESTMessage> client, AsyncEndpoint<RESTMessage> endpoint, RESTMessage message, Object... resources) {
- super(channel, client, endpoint, null, null, resources);
- this.message = message;
- }
-
- @Override
- protected RESTMessage prepareMessage() throws Exception {
- return message;
- }
-
- @Override
- protected void checkMessageData(RESTMessage expected, RESTMessage actual) throws Exception {
- Set<Parameter> expectedParameters = new HashSet<Parameter>(Arrays.asList(expected.getParameters()));
- for (Parameter actualParameter : actual.getParameters()) {
- assertTrue(expectedParameters.remove(actualParameter));
- }
- assertTrue(expectedParameters.isEmpty());
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/SwATestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/SwATestCase.java
deleted file mode 100644
index 932e392..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/SwATestCase.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.async;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-import java.util.Random;
-
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.util.UIDGenerator;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.message.XMLMessage;
-import org.apache.axis2.transport.testkit.name.Name;
-
-@Name("AsyncSwA")
-public class SwATestCase extends AsyncMessageTestCase<XMLMessage> {
- private static final Random random = new Random();
-
- private byte[] attachmentContent;
- private String contentID;
-
- public SwATestCase(AsyncChannel channel, AsyncTestClient<XMLMessage> client, AsyncEndpoint<XMLMessage> endpoint, Object... resources) {
- super(channel, client, endpoint, XMLMessage.Type.SWA.getContentType(), "UTF-8", resources);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- attachmentContent = new byte[8192];
- random.nextBytes(attachmentContent);
- contentID = UIDGenerator.generateContentId();
- }
-
- @Override
- protected XMLMessage prepareMessage() throws Exception {
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMElement payload = factory.createOMElement(new QName("root"));
- Attachments attachments = new Attachments();
- attachments.addDataHandler(contentID, new DataHandler(new ByteArrayDataSource(attachmentContent, "application/octet-stream")));
- return new XMLMessage(payload, XMLMessage.Type.SWA, attachments);
- }
-
- @Override
- protected void checkMessageData(XMLMessage expected, XMLMessage actual) throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Attachments attachments = actual.getAttachments();
- DataHandler dataHandler = attachments.getDataHandler(contentID);
- assertNotNull(dataHandler);
- dataHandler.writeTo(baos);
- assertTrue(Arrays.equals(attachmentContent, baos.toByteArray()));
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/TextPlainTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/TextPlainTestCase.java
deleted file mode 100644
index 357ab6c..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/TextPlainTestCase.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.async;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.MessageTestData;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.name.Named;
-
-@Name("AsyncTextPlain")
-public class TextPlainTestCase extends AsyncMessageTestCase<String> {
- private final MessageTestData data;
-
- public TextPlainTestCase(AsyncChannel channel, AsyncTestClient<String> client, AsyncEndpoint<String> endpoint, MessageTestData data, Object... resources) {
- super(channel, client, endpoint, new ContentType("text", "plain", null), data.getCharset(), resources);
- this.data = data;
- }
-
- @Named
- public MessageTestData getData() {
- return data;
- }
-
- @Override
- protected String prepareMessage() throws Exception {
- return data.getText();
- }
-
- @Override
- protected void checkMessageData(String expected, String actual) throws Exception {
- // Some transport protocols add a newline at the end of the payload. Therefore trim the
- // strings before comparison.
- // TODO: investigate this a bit further
- assertEquals(expected.trim(), actual.trim());
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/XMLAsyncMessageTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/XMLAsyncMessageTestCase.java
deleted file mode 100644
index 441fa81..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/XMLAsyncMessageTestCase.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.async;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axis2.transport.testkit.MessageTestData;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.message.XMLMessage;
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.name.Named;
-
-@Name("AsyncXML")
-public class XMLAsyncMessageTestCase extends AsyncMessageTestCase<XMLMessage> {
- private final XMLMessage.Type xmlMessageType;
- private final MessageTestData data;
-
- public XMLAsyncMessageTestCase(AsyncChannel channel, AsyncTestClient<XMLMessage> client, AsyncEndpoint<XMLMessage> endpoint, XMLMessage.Type xmlMessageType, MessageTestData data, Object... resources) {
- super(channel, client, endpoint, xmlMessageType.getContentType(), data.getCharset(), resources);
- this.xmlMessageType = xmlMessageType;
- this.data = data;
- }
-
- @Key("messageType")
- public XMLMessage.Type getXmlMessageType() {
- return xmlMessageType;
- }
-
- @Named
- public MessageTestData getData() {
- return data;
- }
-
- @Override
- protected XMLMessage prepareMessage() throws Exception {
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMElement orgElement = factory.createOMElement(new QName("root"));
- orgElement.setText(data.getText());
- return new XMLMessage(orgElement, xmlMessageType);
- }
-
- @Override
- protected void checkMessageData(XMLMessage expected, XMLMessage actual) throws Exception {
- OMElement element = actual.getPayload();
- OMElement orgElement = expected.getPayload();
- assertEquals(orgElement.getQName(), element.getQName());
- assertEquals(data.getText(), element.getText());
- }
-}
\ No newline at end of file
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java
deleted file mode 100644
index bb74593..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.echo;
-
-import org.apache.axis2.transport.testkit.endpoint.EndpointErrorListener;
-
-public class InterruptingEndpointErrorListener implements EndpointErrorListener {
- private final Thread thread;
- private Throwable ex;
-
- public InterruptingEndpointErrorListener(Thread thread) {
- this.thread = thread;
- }
-
- public void error(Throwable ex) {
- this.ex = ex;
- thread.interrupt();
- }
-
- public Throwable getException() {
- return ex;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java
deleted file mode 100644
index e16875c..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.echo;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
-import org.apache.axis2.transport.testkit.tests.MessageTestCase;
-
-public abstract class RequestResponseMessageTestCase<M,N> extends MessageTestCase {
- private final RequestResponseTestClient<M,N> client;
- private final InOutEndpoint endpoint;
-
- // TODO: maybe we don't need an explicit RequestResponseChannel
- public RequestResponseMessageTestCase(RequestResponseChannel channel, RequestResponseTestClient<M,N> client, InOutEndpoint endpoint, ContentType contentType, String charset, Object... resources) {
- super(client, contentType, charset, resources);
- this.client = client;
- this.endpoint = endpoint;
- addResource(channel);
- addResource(endpoint);
- }
-
- @Override
- protected void doRunTest() throws Throwable {
- M request = prepareRequest();
- InterruptingEndpointErrorListener listener = new InterruptingEndpointErrorListener(Thread.currentThread());
- N response;
- endpoint.addEndpointErrorListener(listener);
- try {
- response = client.sendMessage(options, contentType, request).getData();
- } catch (Throwable ex) {
- if (listener.getException() != null) {
- throw listener.getException();
- } else {
- throw ex;
- }
- } finally {
- endpoint.removeEndpointErrorListener(listener);
- }
- checkResponse(request, response);
- }
-
- protected abstract M prepareRequest() throws Exception;
- protected abstract void checkResponse(M request, N response) throws Exception;
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java
deleted file mode 100644
index d2fe751..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.echo;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axis2.transport.testkit.MessageTestData;
-import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
-import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
-import org.apache.axis2.transport.testkit.message.XMLMessage;
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.name.Named;
-
-@Name("EchoXML")
-public class XMLRequestResponseMessageTestCase extends RequestResponseMessageTestCase<XMLMessage,XMLMessage> {
- private final XMLMessage.Type xmlMessageType;
- private final MessageTestData data;
-
- public XMLRequestResponseMessageTestCase(RequestResponseChannel channel, RequestResponseTestClient<XMLMessage,XMLMessage> client, InOutEndpoint endpoint, XMLMessage.Type xmlMessageType, MessageTestData data, Object... resources) {
- super(channel, client, endpoint, xmlMessageType.getContentType(), data.getCharset(), resources);
- this.xmlMessageType = xmlMessageType;
- this.data = data;
- }
-
- @Key("messageType")
- public XMLMessage.Type getXmlMessageType() {
- return xmlMessageType;
- }
-
- @Named
- public MessageTestData getData() {
- return data;
- }
-
- @Override
- protected XMLMessage prepareRequest() throws Exception {
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMElement orgElement = factory.createOMElement(new QName("root"));
- orgElement.setText(data.getText());
- return new XMLMessage(orgElement, xmlMessageType);
- }
-
- @Override
- protected void checkResponse(XMLMessage request, XMLMessage response) throws Exception {
- OMElement orgElement = request.getPayload();
- OMElement element = response.getPayload();
- assertEquals(orgElement.getQName(), element.getQName());
- assertEquals(orgElement.getText(), element.getText());
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java
deleted file mode 100644
index a061e13..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.tests.misc;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.mail.internet.ContentType;
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.InOnlyAxisOperation;
-import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient;
-import org.apache.axis2.transport.testkit.axis2.client.AxisTestClientContext;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpointContext;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.message.AxisMessage;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.TestResourceSet;
-import org.apache.axis2.transport.testkit.tests.ManagedTestCase;
-
-/**
- * Generic test case to check whether a transport listener processes messages with the expected
- * level of concurrency. This test case is used to verify that the listener is able to
- * process messages simultaneously.
- * <p>
- * The test case deploys a given number of services and sends a configurable number of messages
- * to each of these services. The services are configured with a custom message receiver that
- * blocks until the expected level of concurrency (given by the number of endpoints times the
- * number of messages) is reached. If after some timeout the concurrency level is not reached,
- * the test fails.
- */
-@Name("MinConcurrency")
-public class MinConcurrencyTest extends ManagedTestCase {
- private final AsyncChannel[] channels;
- private final int messages;
- private final boolean preloadMessages;
-
- public MinConcurrencyTest(AsyncChannel[] channels, int messages,
- boolean preloadMessages, Object... resources) {
- super(resources);
- addResource(AxisTestClientContext.INSTANCE);
- addResource(AxisTestEndpointContext.INSTANCE);
- this.channels = channels;
- this.messages = messages;
- this.preloadMessages = preloadMessages;
- }
-
- private int concurrencyReached;
- private final Object concurrencyReachedLock = new Object();
- private final Object shutdownAwaitLock = new Object();
-
- @Override
- protected void runTest() throws Throwable {
- int endpointCount = channels.length;
- int expectedConcurrency = endpointCount * messages;
-
- final MessageReceiver messageReceiver = new MessageReceiver() {
- public void receive(MessageContext msgContext) throws AxisFault {
- synchronized (concurrencyReachedLock) {
- concurrencyReached++;
- concurrencyReachedLock.notifyAll();
- }
- try {
- shutdownAwaitLock.wait();
- } catch (InterruptedException ex) {
- }
- }
- };
-
- TestResourceSet[] clientResourceSets = new TestResourceSet[endpointCount];
- TestResourceSet[] endpointResourceSets = new TestResourceSet[endpointCount];
- try {
- for (int i=0; i<endpointCount; i++) {
- TestResourceSet clientResourceSet = new TestResourceSet(getResourceSet());
- AsyncChannel channel = channels[i];
- clientResourceSet.addResource(channel);
- AxisAsyncTestClient client = new AxisAsyncTestClient(false);
- clientResourceSet.addResource(client);
- clientResourceSet.setUp();
- clientResourceSets[i] = clientResourceSet;
-
- TestResourceSet endpointResourceSet = new TestResourceSet(clientResourceSet);
- endpointResourceSet.addResource(new AxisTestEndpoint() {
- @Override
- protected AxisOperation createOperation() {
- AxisOperation operation = new InOnlyAxisOperation(new QName("in"));
- operation.setMessageReceiver(messageReceiver);
- return operation;
- }
-
- @Override
- protected void onTransportError(Throwable ex) {
- // TODO Auto-generated method stub
- }
- });
-
- if (!preloadMessages) {
- endpointResourceSet.setUp();
- endpointResourceSets[i] = endpointResourceSet;
- }
- for (int j=0; j<messages; j++) {
- ClientOptions options = new ClientOptions(client, new ContentType(SOAP11Constants.SOAP_11_CONTENT_TYPE), "UTF-8");
- AxisMessage message = new AxisMessage();
- message.setMessageType(SOAP11Constants.SOAP_11_CONTENT_TYPE);
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- message.setEnvelope(envelope);
- client.sendMessage(options, new ContentType(message.getMessageType()), message);
- }
- if (preloadMessages) {
- endpointResourceSet.setUp();
- endpointResourceSets[i] = endpointResourceSet;
- }
- }
-
- long startTime = System.currentTimeMillis();
- while (concurrencyReached < expectedConcurrency
- && System.currentTimeMillis() < (startTime + 5000)) {
- synchronized(concurrencyReachedLock) {
- concurrencyReachedLock.wait(5000);
- }
- }
-
- synchronized(shutdownAwaitLock) {
- shutdownAwaitLock.notifyAll();
- }
-
- if (concurrencyReached < expectedConcurrency) {
- fail("Concurrency reached is " + concurrencyReached + ", but expected " +
- expectedConcurrency);
- }
-
- } finally {
- for (int i=0; i<endpointCount; i++) {
- if (endpointResourceSets[i] != null) {
- endpointResourceSets[i].tearDown();
- }
- if (clientResourceSets[i] != null) {
- clientResourceSets[i].tearDown();
- }
- }
- }
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/ContentTypeUtil.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/ContentTypeUtil.java
deleted file mode 100644
index abab74b..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/ContentTypeUtil.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util;
-
-import java.util.Enumeration;
-
-import javax.mail.internet.ContentType;
-import javax.mail.internet.ParameterList;
-
-public class ContentTypeUtil {
- private ContentTypeUtil() {}
-
- public static ContentType addCharset(ContentType contentType, String charset) {
- ParameterList orgParamList = contentType.getParameterList();
- ParameterList paramList = new ParameterList();
- if (orgParamList != null) {
- for (Enumeration<?> e = orgParamList.getNames(); e.hasMoreElements(); ) {
- String name = (String)e.nextElement();
- paramList.set(name, orgParamList.get(name));
- }
- }
- paramList.set("charset", charset);
- return new ContentType(contentType.getPrimaryType(), contentType.getSubType(), paramList);
- }
-
- public static ContentType removeCharset(ContentType contentType) {
- ParameterList orgParamList = contentType.getParameterList();
- ParameterList paramList = new ParameterList();
- for (Enumeration<?> e = orgParamList.getNames(); e.hasMoreElements(); ) {
- String name = (String)e.nextElement();
- if (!name.equalsIgnoreCase("charset")) {
- paramList.set(name, orgParamList.get(name));
- }
- }
- return new ContentType(contentType.getPrimaryType(), contentType.getSubType(), paramList);
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LifecycleFixTransportListenerProxy.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LifecycleFixTransportListenerProxy.java
deleted file mode 100644
index a0a1bdc..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LifecycleFixTransportListenerProxy.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.SessionContext;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.transport.TransportListener;
-
-public class LifecycleFixTransportListenerProxy implements TransportListener {
- private final TransportListener target;
- private final int port;
-
- public LifecycleFixTransportListenerProxy(TransportListener target, int port) {
- this.target = target;
- this.port = port;
- }
-
- public void destroy() {
- target.destroy();
- }
-
- @SuppressWarnings("deprecation")
- public EndpointReference[] getEPRForService(String arg0, String arg1)
- throws AxisFault {
- return target.getEPRsForService(arg0, arg1);
- }
-
- public EndpointReference[] getEPRsForService(String arg0, String arg1)
- throws AxisFault {
- return target.getEPRsForService(arg0, arg1);
- }
-
- public SessionContext getSessionContext(MessageContext arg0) {
- return target.getSessionContext(arg0);
- }
-
- public void init(ConfigurationContext arg0, TransportInDescription arg1)
- throws AxisFault {
- target.init(arg0, arg1);
- }
-
- public void start() throws AxisFault {
- target.start();
- try {
- ServerUtil.waitForServer(port);
- } catch (Exception ex) {
- throw new AxisFault("Unable to start server", ex);
- }
- }
-
- public void stop() throws AxisFault {
- target.stop();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java
deleted file mode 100644
index 1fd68ff..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.axis2.transport.testkit.tests.ManagedTestCase;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.log4j.TTCCLayout;
-import org.apache.log4j.WriterAppender;
-
-public class LogManager {
- public static final LogManager INSTANCE = new LogManager();
-
- private final File logDir;
- private File testCaseDir;
- private WriterAppender appender;
- private int sequence;
- private List<OutputStream> logs;
-
- private LogManager() {
- logDir = new File("target" + File.separator + "testkit-logs");
- }
-
- public void setTestCase(ManagedTestCase testCase) throws IOException {
- if (appender != null) {
- Logger.getRootLogger().removeAppender(appender);
- appender.close();
- appender = null;
- }
- if (logs != null) {
- for (OutputStream log : logs) {
- IOUtils.closeQuietly(log);
- }
- logs = null;
- }
- if (testCase == null) {
- testCaseDir = null;
- } else {
- File testSuiteDir = new File(logDir, testCase.getTestClass().getName());
- testCaseDir = new File(testSuiteDir, testCase.getId());
- logs = new LinkedList<OutputStream>();
- sequence = 1;
- appender = new WriterAppender(new TTCCLayout(), createLog("debug"));
- Logger.getRootLogger().addAppender(appender);
- }
- }
-
- public synchronized OutputStream createLog(String name) throws IOException {
- testCaseDir.mkdirs();
- OutputStream log = new FileOutputStream(new File(testCaseDir, StringUtils.leftPad(String.valueOf(sequence++), 2, '0') + "-" + name + ".log"));
- logs.add(log);
- return log;
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/PortAllocator.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/PortAllocator.java
deleted file mode 100644
index 9fd83cf..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/PortAllocator.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.TearDown;
-
-public class PortAllocator {
- private static final int BASE_PORT = 9000;
- private static final int BASE_PORT_INCREMENT = 10;
-
- public static final PortAllocator INSTANCE = new PortAllocator();
-
- static class PortRange {
- private final ServerSocket serverSocket;
- private final int basePort;
- private final boolean[] allocated = new boolean[BASE_PORT_INCREMENT-1];
-
- PortRange(ServerSocket serverSocket) {
- this.serverSocket = serverSocket;
- basePort = serverSocket.getLocalPort();
- }
-
- /**
- * Allocate a port in this range.
- *
- * @return the allocated port, or -1 if there are no more available ports
- */
- int allocatePort() {
- for (int i=0; i<BASE_PORT_INCREMENT-1; i++) {
- if (!allocated[i]) {
- allocated[i] = true;
- return basePort + i + 1;
- }
- }
- return -1;
- }
-
- /**
- * Determine if the given port belongs to the range.
- *
- * @return <code>true</code> if the port belongs to the range; <code>false</code> otherwise
- */
- boolean hasPort(int port) {
- return port > basePort && port < basePort + BASE_PORT_INCREMENT;
- }
-
- /**
- * Release the given port.
- *
- * @param port the number of the port to release
- */
- void releasePort(int port) {
- int i = port - basePort - 1;
- if (!allocated[i]) {
- throw new IllegalStateException("Port is not allocated");
- }
- allocated[i] = false;
- }
-
- void release() {
- try {
- serverSocket.close();
- } catch (IOException ex) {
- // Ignore
- }
- }
- }
-
- private int basePort;
- private List<PortRange> ranges;
-
- private PortAllocator() {
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp() {
- basePort = BASE_PORT;
- ranges = new ArrayList<PortRange>();
- }
-
- @TearDown @SuppressWarnings("unused")
- private void tearDown() throws Exception {
- for (PortRange range : ranges) {
- range.release();
- }
- ranges = null;
- }
-
- public synchronized int allocatePort() {
- for (PortRange range : ranges) {
- int port = range.allocatePort();
- if (port != -1) {
- return port;
- }
- }
- while (true) {
- ServerSocket serverSocket;
- try {
- serverSocket = new ServerSocket(basePort);
- } catch (IOException ex) {
- serverSocket = null;
- }
- basePort += BASE_PORT_INCREMENT;
- if (serverSocket != null) {
- PortRange range = new PortRange(serverSocket);
- ranges.add(range);
- return range.allocatePort();
- }
- }
- }
-
- public synchronized void releasePort(int port) {
- for (PortRange range : ranges) {
- if (range.hasPort(port)) {
- range.releasePort(port);
- return;
- }
- }
- throw new IllegalArgumentException("Invalid port number");
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/ServerUtil.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/ServerUtil.java
deleted file mode 100644
index 9ef9245..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/ServerUtil.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util;
-
-import java.net.ConnectException;
-import java.net.InetAddress;
-import java.net.Socket;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Utility class with methods useful when working with test servers.
- */
-public class ServerUtil {
- private static final Log log = LogFactory.getLog(ServerUtil.class);
-
- private ServerUtil() {}
-
- /**
- * Wait until the server listening on a given TCP port is ready to accept
- * connections.
- *
- * @param port The TCP port the server listens on.
- * @throws Exception
- */
- public static void waitForServer(int port) throws Exception {
- InetAddress localhost = InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 });
- int attempts = 0;
- Socket socket = null;
- while (socket == null) {
- attempts++;
- try {
- socket = new Socket(localhost, port);
- } catch (ConnectException ex) {
- if (attempts < 10) {
- Thread.sleep(50);
- } else {
- throw ex;
- }
- }
- }
- log.debug("Server on port " + port + " ready after " + attempts + " connection attempts");
- socket.close();
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Acceptor.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Acceptor.java
deleted file mode 100644
index 486c649..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Acceptor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util.tcpmon;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.concurrent.ExecutorService;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-class Acceptor implements Runnable {
- private static final Log log = LogFactory.getLog(Acceptor.class);
-
- private final ServerSocket serverSocket;
- private final ExecutorService executorService;
- private final InetSocketAddress target;
-
- public Acceptor(ServerSocket serverSocket, ExecutorService executorService, InetSocketAddress target) {
- this.serverSocket = serverSocket;
- this.executorService = executorService;
- this.target = target;
- }
-
- public void run() {
- while (true) {
- Socket socket;
- try {
- socket = serverSocket.accept();
- } catch (IOException ex) {
- break;
- }
- try {
- Socket targetSocket = new Socket(target.getAddress(), target.getPort());
- executorService.execute(new Relay(socket, targetSocket, false));
- executorService.execute(new Relay(targetSocket, socket, true));
- } catch (IOException ex) {
- log.error(ex);
- }
- }
- }
-
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Relay.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Relay.java
deleted file mode 100644
index 73a02fa..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Relay.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util.tcpmon;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-import org.apache.axis2.transport.base.datagram.Utils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-class Relay implements Runnable {
- private static final Log log = LogFactory.getLog(Relay.class);
-
- private final Socket inSocket;
- private final InputStream in;
- private final OutputStream out;
- private final String connectionSpec;
-
- public Relay(Socket inSocket, Socket outSocket, boolean isResponse) throws IOException {
- this.inSocket = inSocket;
- this.in = inSocket.getInputStream();
- this.out = outSocket.getOutputStream();
- if (isResponse) {
- connectionSpec = outSocket.getRemoteSocketAddress() + " <- " + inSocket.getRemoteSocketAddress();
- } else {
- connectionSpec = inSocket.getRemoteSocketAddress() + " -> " + outSocket.getRemoteSocketAddress();
- }
- }
-
- public void run() {
- byte buf[] = new byte[4096];
- try {
- int n;
- while ((n = in.read(buf)) > 0) {
- StringBuilder dump = new StringBuilder(connectionSpec);
- dump.append('\n');
- Utils.hexDump(dump, buf, n);
- log.debug(dump);
- out.write(buf, 0, n);
- out.flush();
- }
- } catch (IOException ex) {
- if (!inSocket.isClosed()) {
- log.error(ex);
- }
- } finally {
- IOUtils.closeQuietly(in);
- IOUtils.closeQuietly(out);
- }
- log.debug(connectionSpec + ": closed");
- }
-}
diff --git a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Tunnel.java b/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Tunnel.java
deleted file mode 100644
index 5f271a4..0000000
--- a/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/util/tcpmon/Tunnel.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.util.tcpmon;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class Tunnel {
- private final ServerSocket serverSocket;
- private final InetSocketAddress target;
- private ExecutorService executorService;
-
- public Tunnel(InetSocketAddress target) throws IOException {
- serverSocket = new ServerSocket(0);
- this.target = target;
- }
-
- public int getPort() {
- return serverSocket.getLocalPort();
- }
-
- public void start() {
- executorService = Executors.newCachedThreadPool();
- executorService.execute(new Acceptor(serverSocket, executorService, target));
- }
-
- public void stop() throws IOException {
- serverSocket.close();
- executorService.shutdown();
- }
-}
diff --git a/modules/testkit/src/main/resources/META-INF/aop.xml b/modules/testkit/src/main/resources/META-INF/aop.xml
deleted file mode 100644
index 1ddcb39..0000000
--- a/modules/testkit/src/main/resources/META-INF/aop.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<aspectj>
- <aspects>
- <aspect name="org.apache.axis2.transport.testkit.axis2.LogAspect"/>
- </aspects>
-</aspectj>
\ No newline at end of file
diff --git a/modules/testkit/src/main/resources/org/apache/axis2/transport/axis2.xml b/modules/testkit/src/main/resources/org/apache/axis2/transport/axis2.xml
deleted file mode 100644
index e0a4699..0000000
--- a/modules/testkit/src/main/resources/org/apache/axis2/transport/axis2.xml
+++ /dev/null
@@ -1,254 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<axisconfig name="AxisJava2.0">
- <!-- ================================================= -->
- <!-- Parameters -->
- <!-- ================================================= -->
- <parameter name="hotdeployment">true</parameter>
- <parameter name="hotupdate">false</parameter>
- <parameter name="enableMTOM">false</parameter>
-
- <!--If turned on with use the Accept header of the request to determine the contentType of the
- response-->
- <parameter name="httpContentNegotiation">false</parameter>
-
- <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
- <!--that behaviour.-->
- <parameter name="sendStacktraceDetailsWithFaults">true</parameter>
-
- <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
- <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
- <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
- <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
- <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
-
- <!--This is the user name and password of admin console-->
- <parameter name="userName">admin</parameter>
- <parameter name="password">axis2</parameter>
-
- <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
- <!--ServicesDirectory only works on the following cases-->
- <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
- <!---When creating URL Based configurator with URL “file://” -->
- <!--- War based configurator with expanded case , -->
-
- <!--All the other scenarios it will be ignored.-->
- <!--<parameter name="ServicesDirectory">service</parameter>-->
- <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
- <!--<parameter name="ModulesDirectory">modules</parameter>-->
-
- <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
- <!--root which can configured using the following contextRoot parameter-->
- <!--<parameter name="contextRoot">axis2</parameter>-->
-
- <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguish those endpoints-->
- <!--<parameter name="servicePath">services</parameter>-->
- <!--<parameter name="restPath">rest</parameter>-->
-
- <!-- Following parameter will completely disable REST handling in Axis2-->
- <parameter name="disableREST" locked="false">false</parameter>
-
- <!-- ================================================= -->
- <!-- Deployers -->
- <!-- ================================================= -->
-
- <!--Service deployer , this will alow users to deploy AAR or exploded AAR as axis2 services-->
- <deployer extension=".aar" directory="services" class="org.apache.axis2.deployment.ServiceDeployer">
- <serviceBuilderExtension name ="jwsbuilderExt" class="org.apache.axis2.jaxws.framework.JAXWSServiceBuilderExtension"/>
- <serviceBuilderExtension name ="wsdlbuilderExt" class="org.apache.axis2.deployment.WSDLServiceBuilderExtension"/>
- </deployer>
-
- <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
- <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
- <deployer extension=".jar" directory="transports" class="org.apache.axis2.deployment.TransportDeployer"/>
-
- <!-- Following parameter will set the host name for the epr-->
- <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
-
- <!-- ================================================= -->
- <!-- Message Receivers -->
- <!-- ================================================= -->
- <!--This is the Default Message Receiver for the system , if you want to have MessageReceivers for -->
- <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
- <!--any operation -->
- <!--Note : You can override this for particular service by adding the same element with your requirement-->
- <messageReceivers>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- </messageReceivers>
-
- <!-- ================================================= -->
- <!-- Message Formatter -->
- <!-- ================================================= -->
- <!--Following content type to message formatter mapping can be used to implement support for different message -->
- <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageFormatters>
- <messageFormatter contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
- <messageFormatter contentType="multipart/form-data"
- class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
- <messageFormatter contentType="application/xml"
- class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
- <messageFormatter contentType="text/xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- <messageFormatter contentType="application/soap+xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- <messageFormatter contentType="text/plain"
- class="org.apache.axis2.format.PlainTextFormatter"/>
- <messageFormatter contentType="application/octet-stream"
- class="org.apache.axis2.format.BinaryFormatter"/>
- </messageFormatters>
-
- <!-- ================================================= -->
- <!-- Message Builders -->
- <!-- ================================================= -->
- <!--Following content type to builder mapping can be used to implement support for different message -->
- <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageBuilders>
- <messageBuilder contentType="application/xml"
- class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
- <messageBuilder contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
- <messageBuilder contentType="text/plain"
- class="org.apache.axis2.format.PlainTextBuilder"/>
- <messageBuilder contentType="application/octet-stream"
- class="org.apache.axis2.format.BinaryBuilder"/>
- <!--Left commented because it adds the depandancy of servlet-api to other modules.
- Please uncomment to Receive messages in multipart/form-data format-->
- <!--<messageBuilder contentType="multipart/form-data"-->
- <!--class="org.apache.axis2.builder.MultipartFormDataBuilder"/>-->
- </messageBuilders>
-
- <!-- ================================================= -->
- <!-- Target Resolvers -->
- <!-- ================================================= -->
- <!-- Uncomment the following and specify the class name for your TargetResolver to add -->
- <!-- a TargetResolver. TargetResolvers are used to process the To EPR for example to -->
- <!-- choose a server in a cluster -->
- <!--<targetResolvers>-->
- <!--<targetResolver class="" />-->
- <!--</targetResolvers>-->
-
-
- <!-- ================================================= -->
- <!-- SOAP Role Configuration -->
- <!-- ================================================= -->
- <!-- Use the following pattern to configure this axis2
- instance to act in particular roles. Note that in
- the absence of any configuration, Axis2 will act
- only in the ultimate receiver role -->
- <!--
- <SOAPRoleConfiguration isUltimateReceiver="true">
- <role>http://my/custom/role</role>
- </SOAPRoleConfiguration>
- -->
-
- <!-- ================================================= -->
- <!-- Phases -->
- <!-- ================================================= -->
- <phaseOrder type="InFlow">
- <!-- System pre-defined phases -->
- <phase name="Transport">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- </phase>
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- System pre defined phases -->
- <!-- After Postdispatch phase module author or or service author can add any phase he want -->
- <phase name="OperationInPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutPhase"/>
- <!--system predefined phase-->
- <!--these phase will run irrespective of the service-->
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
- <phaseOrder type="InFaultFlow">
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- user can add his own phases to this area -->
- <phase name="OperationInFaultPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFaultFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutFaultPhase"/>
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
-</axisconfig>
\ No newline at end of file
diff --git a/modules/testkit/src/main/resources/org/apache/axis2/transport/repo/__root__ b/modules/testkit/src/main/resources/org/apache/axis2/transport/repo/__root__
deleted file mode 100644
index e69de29..0000000
--- a/modules/testkit/src/main/resources/org/apache/axis2/transport/repo/__root__
+++ /dev/null
diff --git a/modules/testkit/src/main/resources/org/apache/axis2/transport/repo/modules/modules.list b/modules/testkit/src/main/resources/org/apache/axis2/transport/repo/modules/modules.list
deleted file mode 100644
index 242a880..0000000
--- a/modules/testkit/src/main/resources/org/apache/axis2/transport/repo/modules/modules.list
+++ /dev/null
@@ -1 +0,0 @@
-addressing.mar
diff --git a/modules/udp/pom.xml b/modules/udp/pom.xml
deleted file mode 100644
index 00b0e9c..0000000
--- a/modules/udp/pom.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transports</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <artifactId>axis2-transport-udp</artifactId>
- <name>Apache Axis2 - Transport - UDP</name>
- <description>UDP transport for Axis2</description>
- <packaging>bundle</packaging>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/udp</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/udp</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/udp</url>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
- <Bundle-Description>${project.description}</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.apache.axis2.transport.udp.*;-split-package:=merge-last,
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-testkit</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java b/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java
deleted file mode 100644
index 96de979..0000000
--- a/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import java.net.SocketException;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.transport.base.ParamUtils;
-import org.apache.axis2.transport.base.datagram.DatagramEndpoint;
-import org.apache.axis2.util.Utils;
-
-/**
- * UDP endpoint description.
- */
-public class Endpoint extends DatagramEndpoint {
- private int port;
- private int maxPacketSize;
-
- public int getPort() {
- return port;
- }
-
- public int getMaxPacketSize() {
- return maxPacketSize;
- }
-
- @Override
- public String getDescription() {
- return "*:" + port;
- }
-
- @Override
- public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
- port = ParamUtils.getOptionalParamInt(params, UDPConstants.PORT_KEY, -1);
- if (port == -1) {
- return false;
- }
- maxPacketSize = ParamUtils.getOptionalParamInt(params, UDPConstants.MAX_PACKET_SIZE_KEY,
- UDPConstants.DEFAULT_MAX_PACKET_SIZE);
- return super.loadConfiguration(params);
- }
-
- @Override
- public EndpointReference[] getEndpointReferences(AxisService service, String ip) throws AxisFault {
- if (ip == null) {
- try {
- ip = Utils.getIpAddress(getListener().getConfigurationContext().getAxisConfiguration());
- } catch (SocketException ex) {
- throw new AxisFault("Unable to determine the host's IP address", ex);
- }
- }
- StringBuilder epr = new StringBuilder("udp://");
- epr.append(ip);
- epr.append(':');
- epr.append(getPort());
- // If messages are predispatched to a service, then WS-Addressing will be used and we
- // need to include the service path in the EPR.
- if (getService() == null) {
- epr.append('/');
- epr.append(getConfigurationContext().getServiceContextPath());
- epr.append('/');
- epr.append(service.getName());
- }
- epr.append("?contentType=");
- epr.append(getContentType());
- return new EndpointReference[] { new EndpointReference(epr.toString()) };
- }
-}
diff --git a/modules/udp/src/main/java/org/apache/axis2/transport/udp/IODispatcher.java b/modules/udp/src/main/java/org/apache/axis2/transport/udp/IODispatcher.java
deleted file mode 100644
index e23bfb1..0000000
--- a/modules/udp/src/main/java/org/apache/axis2/transport/udp/IODispatcher.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.DatagramChannel;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.util.Iterator;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CountDownLatch;
-
-import org.apache.axis2.transport.base.datagram.DatagramDispatcher;
-import org.apache.axis2.transport.base.datagram.DatagramDispatcherCallback;
-import org.apache.axis2.transport.base.datagram.ProcessPacketTask;
-import org.apache.axis2.transport.base.threads.WorkerPool;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * I/O dispatcher for incoming UDP packets.
- * This class is responsible for receiving UDP packets and dispatch
- * the processing of these packets to worker threads.
- * It uses a {@link Selector} to receive packets from multiple endpoints
- * and a {@link WorkerPool} to dispatch the processing tasks.
- * <p>
- * The dispatcher uses the following thread model:
- * Incoming packets for all the registered endpoints are received
- * in the thread that executes the {@link #run()} method. For every
- * packet received, a {@link ProcessPacketTask} instance is created
- * and dispatched to a worker thread from the configured pool.
- * <p>
- * The methods {@link #addEndpoint(Endpoint)}, {@link #removeEndpoint(Endpoint)}
- * and {@link #stop()} are thread safe and may be called from any thread.
- * However, to avoid concurrency issues, the operation on the underlying
- * {@link Selector} will always be executed by the thread executing the
- * {@link #run()} method. The three methods mentioned above will block until
- * the operation has completed.
- */
-public class IODispatcher implements DatagramDispatcher<Endpoint>, Runnable {
- private static abstract class SelectorOperation {
- private final CountDownLatch done = new CountDownLatch(1);
- private IOException exception;
-
- public void waitForCompletion() throws IOException, InterruptedException {
- done.await();
- if (exception != null) {
- throw exception;
- }
- }
-
- public void execute(Selector selector) {
- try {
- doExecute(selector);
- } catch (IOException ex) {
- exception = ex;
- } catch (Throwable ex) {
- exception = new IOException("Unexpected exception");
- exception.initCause(ex);
- }
- done.countDown();
- }
-
- public abstract void doExecute(Selector selector) throws IOException;
- }
-
- private static final Log log = LogFactory.getLog(IODispatcher.class);
-
- private final DatagramDispatcherCallback callback;
- private final Selector selector;
- private final Queue<SelectorOperation> selectorOperationQueue =
- new ConcurrentLinkedQueue<SelectorOperation>();
-
- /**
- * Constructor.
- *
- * @param callback
- * @throws IOException if the {@link Selector} instance could not be created
- */
- public IODispatcher(DatagramDispatcherCallback callback) throws IOException {
- this.callback = callback;
- selector = Selector.open();
- }
-
- /**
- * Add a new endpoint. This method creates a new socket listening on
- * the UDP port specified in the endpoint description and makes sure
- * that incoming packets are routed to the specified service.
- *
- * @param endpoint the endpoint description
- * @throws IOException if the socket could not be created or
- * registered with the selector
- */
- public void addEndpoint(final Endpoint endpoint) throws IOException {
- final DatagramChannel channel = DatagramChannel.open();
- channel.socket().bind(new InetSocketAddress(endpoint.getPort()));
- channel.configureBlocking(false);
- execute(new SelectorOperation() {
- @Override
- public void doExecute(Selector selector) throws IOException {
- channel.register(selector, SelectionKey.OP_READ, endpoint);
- }
- });
- log.info("UDP endpoint started on port : " + endpoint.getPort());
- }
-
- /**
- * Remove an endpoint. This causes the corresponding UDP socket to be
- * closed.
- *
- * @param endpoint the endpoint description
- * @throws IOException if an error occurred when closing the socket
- */
- public void removeEndpoint(final Endpoint endpoint) throws IOException {
- execute(new SelectorOperation() {
- @Override
- public void doExecute(Selector selector) throws IOException {
- Iterator<SelectionKey> it = selector.keys().iterator();
- while (it.hasNext()) {
- SelectionKey key = it.next();
- Endpoint endpointForKey = (Endpoint)key.attachment();
- if (endpoint == endpointForKey) {
- key.cancel();
- key.channel().close();
- break;
- }
- }
- }
- });
- }
-
- /**
- * Stop the dispatcher.
- * This method closes all sockets and causes the execution of the
- * {@link #run()} method to stop.
- *
- * @throws IOException
- */
- public void stop() throws IOException {
- execute(new SelectorOperation() {
- @Override
- public void doExecute(Selector selector) throws IOException {
- IOException exception = null;
- for (SelectionKey key : selector.keys()) {
- try {
- key.channel().close();
- } catch (IOException ex) {
- if (exception == null) {
- exception = ex;
- }
- }
- }
- try {
- selector.close();
- } catch (IOException ex) {
- if (exception == null) {
- exception = ex;
- }
- }
- if (exception != null) {
- throw exception;
- }
- }
- });
- }
-
- /**
- * Run the I/O dispatcher.
- * This method contains the event loop that polls the selector, reads the incoming
- * packets and dispatches the work.
- * It only returns when {@link #stop()} is called.
- */
- public void run() {
- while (true) {
- try {
- selector.select();
- } catch (IOException ex) {
- log.error("Exception in select; I/O dispatcher will be shut down", ex);
- return;
- }
- // Execute pending selector operations
- while (true) {
- SelectorOperation request = selectorOperationQueue.poll();
- if (request == null) {
- break;
- }
- request.execute(selector);
- if (!selector.isOpen()) {
- return;
- }
- }
- for (Iterator<SelectionKey> it = selector.selectedKeys().iterator(); it.hasNext(); ) {
- SelectionKey key = it.next();
- it.remove();
- if (key.isValid() && key.isReadable()) {
- receive((Endpoint)key.attachment(), (DatagramChannel)key.channel());
- }
- }
- }
- }
-
- private void execute(SelectorOperation operation) throws IOException {
- selectorOperationQueue.add(operation);
- selector.wakeup();
- // Waiting for the execution of the selector operation will
- // never take a long time. It therefore makes no sense to
- // propagate InterruptedExceptions. If one is thrown, we
- // remember that and set the interruption status accordingly
- // afterwards.
- // See http://www.ibm.com/developerworks/java/library/j-jtp05236.html
- boolean interrupted = false;
- try {
- while (true) {
- try {
- operation.waitForCompletion();
- return;
- } catch (InterruptedException ex) {
- interrupted = true;
- }
- }
- } finally {
- if (interrupted) {
- Thread.currentThread().interrupt();
- }
- }
- }
-
- private void receive(Endpoint endpoint, DatagramChannel channel) {
- try {
- byte[] data = new byte[endpoint.getMaxPacketSize()];
- ByteBuffer buffer = ByteBuffer.wrap(data);
- InetSocketAddress address = (InetSocketAddress)channel.receive(buffer);
- int length = buffer.position();
- if (log.isDebugEnabled()) {
- log.debug("Received packet from " + address + " with length " + length);
- }
- callback.receive(endpoint, data, length, new UDPOutTransportInfo(address));
- } catch (IOException ex) {
- endpoint.getMetrics().incrementFaultsReceiving();
- log.error("Error receiving UDP packet", ex);
- }
- }
-}
diff --git a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPConstants.java b/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPConstants.java
deleted file mode 100644
index b9256ce..0000000
--- a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPConstants.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-/**
- * Utility class defining constants used by the UDP transport.
- */
-public class UDPConstants {
- private UDPConstants() {}
-
- public static final int DEFAULT_MAX_PACKET_SIZE = 1024;
-
- public static final String PORT_KEY = "transport.udp.port";
- public static final String CONTENT_TYPE_KEY = "transport.udp.contentType";
- public static final String MAX_PACKET_SIZE_KEY = "transport.udp.maxPacketSize";
-}
diff --git a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java b/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java
deleted file mode 100644
index 2cabf67..0000000
--- a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import java.io.IOException;
-
-import org.apache.axis2.transport.base.ManagementSupport;
-import org.apache.axis2.transport.base.datagram.AbstractDatagramTransportListener;
-import org.apache.axis2.transport.base.datagram.DatagramDispatcherCallback;
-
-/**
- * Transport listener for the UDP protocol.
- * Services accepting messages using this transport must be configured with the
- * following parameters:
- * <dl>
- * <dt>transport.udp.port</dt>
- * <dd>The UDP port to listen to (required).</dd>
- * <dt>transport.udp.contentType</dt>
- * <dd>The content type of the messages received (required). This setting
- * is used to select the appropriate message builder.</dd>
- * <dt>transport.udp.maxPacketSize</dt>
- * <dd>The maximum packet size (optional; default 1024). Packets longer
- * than the specified length will be truncated.</dd>
- * </dl>
- *
- * @see org.apache.axis2.transport.udp
- */
-public class UDPListener extends AbstractDatagramTransportListener<Endpoint>
- implements ManagementSupport {
-
- @Override
- protected IODispatcher createDispatcher(DatagramDispatcherCallback callback)
- throws IOException {
- IODispatcher dispatcher = new IODispatcher(callback);
- new Thread(dispatcher, getTransportName() + "-dispatcher").start();
- // Start a new thread for the I/O dispatcher
- return dispatcher;
- }
-
- @Override
- protected Endpoint doCreateEndpoint() {
- return new Endpoint();
- }
-}
diff --git a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPOutTransportInfo.java b/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPOutTransportInfo.java
deleted file mode 100644
index 60779f2..0000000
--- a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPOutTransportInfo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.transport.base.datagram.DatagramOutTransportInfo;
-
-/**
- * Holder of information to send an outgoing message to a UDP destination.
- */
-public class UDPOutTransportInfo extends DatagramOutTransportInfo {
- private InetSocketAddress address;
-
- public UDPOutTransportInfo(String eprString) throws AxisFault {
- URI epr;
- try {
- epr = new URI(eprString);
- } catch (URISyntaxException ex) {
- throw new AxisFault("Invalid endpoint reference", ex);
- }
-
- // TODO: quick&dirty; need to do this in a proper way
- String params = epr.getQuery();
- if (!params.startsWith("contentType=")) {
- throw new AxisFault("Invalid endpoint reference: no content type");
- }
- address = new InetSocketAddress(epr.getHost(), epr.getPort());
- setContentType(params.substring(12));
- }
-
- public UDPOutTransportInfo(InetSocketAddress address) {
- this.address = address;
- }
-
- public InetSocketAddress getAddress() {
- return address;
- }
-
- public void setAddress(InetSocketAddress address) {
- this.address = address;
- }
-}
diff --git a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java b/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java
deleted file mode 100644
index 16e84ea..0000000
--- a/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.description.WSDL2Constants;
-import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.transport.base.AbstractTransportSender;
-import org.apache.axis2.transport.base.BaseUtils;
-import org.apache.axis2.util.MessageProcessorSelector;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.stream.XMLStreamException;
-
-/**
- * Transport sender for the UDP protocol.
- *
- * @see org.apache.axis2.transport.udp
- */
-public class UDPSender extends AbstractTransportSender {
- public UDPSender() {
- log = LogFactory.getLog(UDPSender.class);
- }
-
- @Override
- public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut)
- throws AxisFault {
- super.init(cfgCtx, transportOut);
- }
-
- @Override
- public void sendMessage(MessageContext msgContext, String targetEPR,
- OutTransportInfo outTransportInfo) throws AxisFault {
- UDPOutTransportInfo udpOutInfo;
- if ((targetEPR == null) && (outTransportInfo != null)) {
- // this can happen only at the server side and send the message using back chanel
- udpOutInfo = (UDPOutTransportInfo) outTransportInfo;
- } else {
- udpOutInfo = new UDPOutTransportInfo(targetEPR);
- }
- MessageFormatter messageFormatter = MessageProcessorSelector.getMessageFormatter(msgContext);
- OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
- format.setContentType(udpOutInfo.getContentType());
- byte[] payload = messageFormatter.getBytes(msgContext, format);
- try {
- DatagramSocket socket = new DatagramSocket();
- if (log.isDebugEnabled()) {
- log.debug("Sending " + payload.length + " bytes to " + udpOutInfo.getAddress());
- }
- try {
- socket.send(new DatagramPacket(payload, payload.length, udpOutInfo.getAddress()));
- if (!msgContext.getOptions().isUseSeparateListener() &&
- !msgContext.isServerSide()){
- waitForReply(msgContext, socket, udpOutInfo.getContentType());
- }
- }
- finally {
- socket.close();
- }
- }
- catch (IOException ex) {
- throw new AxisFault("Unable to send packet", ex);
- }
- }
-
- private void waitForReply(MessageContext messageContext, DatagramSocket datagramSocket,
- String contentType) throws IOException {
-
- // piggy back message constant is used to pass a piggy back
- // message context in asnych model
- if (!(messageContext.getAxisOperation() instanceof OutInAxisOperation) &&
- messageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null) {
- return;
- }
-
- byte[] inputBuffer = new byte[4096]; //TODO set the maximum size parameter
- DatagramPacket packet = new DatagramPacket(inputBuffer, inputBuffer.length);
- datagramSocket.receive(packet);
-
- // create the soap envelope
- try {
- MessageContext respMessageContext = messageContext.getOperationContext().
- getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
- InputStream inputStream = new ByteArrayInputStream(inputBuffer, 0, packet.getLength());
- SOAPEnvelope envelope = TransportUtils.createSOAPMessage(respMessageContext,
- inputStream, contentType);
- respMessageContext.setEnvelope(envelope);
- } catch (XMLStreamException e) {
- throw new AxisFault("Can not build the soap message ", e);
- }
- }
-}
diff --git a/modules/udp/src/main/java/org/apache/axis2/transport/udp/package-info.java b/modules/udp/src/main/java/org/apache/axis2/transport/udp/package-info.java
deleted file mode 100644
index 65c97cb..0000000
--- a/modules/udp/src/main/java/org/apache/axis2/transport/udp/package-info.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Transport implementation for the UDP protocol.
- * <p>
- * This package contains a transport implementation allowing Axis to
- * send and receive UDP packets. It is an implementation of "raw" UDP in the
- * sense that the message is directly extracted from the UDP payload without
- * any intermediate application protocol. This has several important implications:
- * <ul>
- * <li>The only way to route the incoming message to the appropriate Axis service
- * is to bind the service a specific UDP port. The port number must be
- * explicitly defined in the service configuration. This is different
- * from protocols such as HTTP where the message can be routed
- * based on the URL in the request.</li>
- * <li>The transport has no way to detect the content type of an incoming
- * message. Indeed, there is no equivalent to HTTP's
- * <tt>Content-Type</tt> header. Again the expected content type must be
- * configured explicitly for the service.</li>
- * <li>Since UDP doesn't provide any mean to correlate responses to requests,
- * the transport can only be used for asynchronous communication.</li>
- * </ul>
- * See the documentation of {@link org.apache.synapse.transport.udp.UDPListener}
- * for more information about how to configure a service to accept UDP packets.
- * Endpoint references for the UDP transport are assumed to follow the following
- * syntax:
- * <pre>
- * udp://<em>host</em>:<em>port</em>?contentType=...</pre>
- * <p>
- * The UDP transport can be enabled in the Axis configuration as follows:
- * <pre>
- * <transportReceiver name="udp" class="org.apache.synapse.transport.udp.UDPListener"/>
- * <transportSender name="udp" class="org.apache.synapse.transport.udp.UDPSender"/></pre>
- * It should be noted that given its characteristics, UDP is not a
- * suitable transport protocol for SOAP, except maybe in very particular
- * circumstances. Indeed, UDP is an unreliable protocol:
- * <ul>
- * <li>There is no delivery guarantee, i.e. packets may be lost.</li>
- * <li>Messages may arrive out of order.</li>
- * <li>Messages may be duplicated, i.e. delivered twice.</li>
- * </ul>
- * However the unit tests show an example of how to use this transport with SOAP
- * and WS-Addressing to achieve two-way asynchronous communication.
- * Note that the transport has not been designed to implement the
- * <a href="http://specs.xmlsoap.org/ws/2004/09/soap-over-udp/soap-over-udp.pdf">SOAP
- * over UDP specification</a> and will probably not be interoperable.
- * <p>
- * The main purpose of this transport implementation is to integrate Axis (and in
- * particular Synapse) with existing UDP based protocols. See
- * {@link org.apache.synapse.format.syslog} for an example of this kind
- * of protocol.
- *
- * <h4>Known issues and limitations</h4>
- *
- * <ul>
- * <li>Packets longer than the configured maximum packet size
- * are silently truncated. Packet truncation should be detected
- * and trigger an error.</li>
- * <li>The listener doesn't implement all management operations
- * specified by
- * {@link org.apache.synapse.transport.base.ManagementSupport}.</li>
- * <li>The listener assumes that services are bound to unique UDP ports
- * and predispatches incoming requests based on port numbers.
- * When SOAP with WS-Addressing is used, the packets could be
- * received on a single port and dispatched based on the <tt>To</tt>
- * header. This is not supported.</li>
- * <li>It might be useful to allow configuration of the content type at the
- * transport level rather than the service level. In this case, the
- * <tt>contentType</tt> parameter would not be included in the endpoint
- * reference. This is necessary for interoperability with the SOAP over UDP
- * standard.</li>
- * <li>Technically, it would be quite easy to support binding several UDP ports
- * to the same service. However, the way endpoints are configured
- * at the service level doesn't allow this for the moment. Indeed,
- * using simple text properties only allows to specify the configuration
- * of a single endpoint.</li>
- * <li>The transport sender uses a randomly chosen UDP source port. Some
- * UDP based services may check the source port and discard the packet.
- * Also, in two-way communication scenarios, stateful firewalls will
- * not be able to correlate the exchanged packets and may drop
- * some of them.</li>
- * </ul>
- */
-package org.apache.axis2.transport.udp;
\ No newline at end of file
diff --git a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPChannel.java b/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPChannel.java
deleted file mode 100644
index de0e20c..0000000
--- a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPChannel.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.transport.testkit.axis2.AxisServiceConfigurator;
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
-
-// TODO: need to find a way to get the content type (which differs from one test case to another) at this level
-public class UDPChannel implements AsyncChannel, RequestResponseChannel, AxisServiceConfigurator {
- private final int port = 3333; // TODO: should use port allocator here
-
- public EndpointReference getEndpointReference() throws Exception {
- return new EndpointReference("udp://127.0.0.1:" + port + "?contentType=text/xml");
- }
-
- public void setupService(AxisService service, boolean isClientSide) throws Exception {
- if (!isClientSide) {
- service.addParameter(UDPConstants.PORT_KEY, String.valueOf(port));
- service.addParameter(UDPConstants.CONTENT_TYPE_KEY, "text/xml");
- }
- }
-}
diff --git a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPTest.java b/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPTest.java
deleted file mode 100644
index 9e3e913..0000000
--- a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.AbstractTransportTest;
-import org.apache.axis2.transport.CustomAxisConfigurator;
-import org.apache.axis2.transport.UtilsTransportServer;
-
-/**
- * Test case for {@link UDPListener} and {@link UDPSender}.
- */
-public class UDPTest extends AbstractTransportTest {
- @Override
- protected UtilsTransportServer createServer() throws Exception {
- return new UtilsUDPServer();
- }
-
- public void testSoapOverUdpWithEchoService() throws Exception {
- Options options = new Options();
- options.setTo(new EndpointReference("udp://127.0.0.1:3333?contentType=text/xml+soap"));
- options.setAction(Constants.AXIS2_NAMESPACE_URI + "/echoOMElement");
- options.setUseSeparateListener(true);
- options.setTimeOutInMilliSeconds(Long.MAX_VALUE);
-
- ServiceClient serviceClient = new ServiceClient(getClientCfgCtx(), null);
- serviceClient.setOptions(options);
- // We need to set up the anonymous service Axis uses to get the response
- AxisService clientService = serviceClient.getServiceContext().getAxisService();
- clientService.addParameter(UDPConstants.PORT_KEY, 4444);
- clientService.addParameter(UDPConstants.CONTENT_TYPE_KEY, "text/xml+soap");
- OMElement response = serviceClient.sendReceive(createPayload());
-
- assertEchoResponse(response);
- }
-
- public ConfigurationContext getClientCfgCtx() throws Exception {
- ConfigurationContext cfgCtx =
- ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
- AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
- axisCfg.engageModule("addressing");
-
- TransportInDescription trpInDesc = new TransportInDescription("udp");
- trpInDesc.setReceiver(new UDPListener());
- axisCfg.addTransportIn(trpInDesc);
-
- TransportOutDescription trpOutDesc = new TransportOutDescription("udp");
- trpOutDesc.setSender(new UDPSender());
- axisCfg.addTransportOut(trpOutDesc);
-
- return cfgCtx;
- }
-}
diff --git a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPTransportTest.java b/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPTransportTest.java
deleted file mode 100644
index 669f7ed..0000000
--- a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UDPTransportTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.udp;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.axis2.transport.testkit.ManagedTestSuite;
-import org.apache.axis2.transport.testkit.TransportTestSuiteBuilder;
-import org.apache.axis2.transport.testkit.axis2.SimpleTransportDescriptionFactory;
-import org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient;
-import org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint;
-import org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint;
-
-public class UDPTransportTest extends TestCase {
- public static TestSuite suite() throws Exception {
- ManagedTestSuite suite = new ManagedTestSuite(UDPTransportTest.class);
-
- // For the moment, we can only do SOAP 1.1 (see TODO item on UDPChannel)
- suite.addExclude("(|(messageType=SOAP12)(messageType=POX)(test=AsyncTextPlain)(test=AsyncBinary))");
-
- // Who would want to do SwA over UDP?
- suite.addExclude("(test=AsyncSwA)");
-
- // Obviously, UDP will not support large SOAP messages
- suite.addExclude("(test=AsyncSOAPLarge)");
-
- TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
- builder.addAsyncChannel(new UDPChannel());
- builder.addRequestResponseChannel(new UDPChannel());
- builder.addEnvironment(new SimpleTransportDescriptionFactory("udp", UDPListener.class, UDPSender.class));
- builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
- builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
- builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient());
- builder.addEchoEndpoint(new AxisEchoEndpoint());
- builder.build();
-
- return suite;
- }
-}
diff --git a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UtilsUDPServer.java b/modules/udp/src/test/java/org/apache/axis2/transport/udp/UtilsUDPServer.java
deleted file mode 100644
index 0306994..0000000
--- a/modules/udp/src/test/java/org/apache/axis2/transport/udp/UtilsUDPServer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.udp;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.transport.UtilsTransportServer;
-
-public class UtilsUDPServer extends UtilsTransportServer {
- public UtilsUDPServer() throws Exception {
- TransportInDescription trpInDesc = new TransportInDescription("udp");
- trpInDesc.setReceiver(new UDPListener());
- TransportOutDescription trpOutDesc = new TransportOutDescription("udp");
- trpOutDesc.setSender(new UDPSender());
- addTransport(trpInDesc, trpOutDesc);
- enableAddressing();
-
- List<Parameter> params = new LinkedList<Parameter>();
- params.add(new Parameter(UDPConstants.PORT_KEY, 3333));
- params.add(new Parameter(UDPConstants.CONTENT_TYPE_KEY, "text/xml+soap"));
- deployEchoService("EchoService", params);
- }
-}
diff --git a/modules/xmpp/pom.xml b/modules/xmpp/pom.xml
deleted file mode 100644
index 18d17dd..0000000
--- a/modules/xmpp/pom.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transports</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <artifactId>axis2-transport-xmpp</artifactId>
- <name>Apache Axis2 - Transport - XMPP</name>
- <description>This inclues all the available transports in Axis2 </description>
- <packaging>bundle</packaging>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/xmpp</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/xmpp</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp</url>
- </scm>
-
- <build>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
- <Bundle-Description>${project.description}</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.apache.axis2.transport.xmpp.*;-split-package:=merge-last,
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>conf</directory>
- <excludes>
- <exclude>**/*.properties</exclude>
- </excludes>
- <filtering>false</filtering>
- </resource>
- <resource>
- <directory>src</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
-
- <!-- Smack Jabber client libraries to be included -->
- <dependency>
- <groupId>jivesoftware</groupId>
- <artifactId>smack</artifactId>
- <version>3.0.4</version>
- </dependency>
- <dependency>
- <groupId>jivesoftware</groupId>
- <artifactId>smackx</artifactId>
- <version>3.0.4</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
deleted file mode 100644
index ed81fb9..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.SessionContext;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterIncludeImpl;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.xmpp.util.XMPPConnectionFactory;
-import org.apache.axis2.transport.xmpp.util.XMPPConstants;
-import org.apache.axis2.transport.xmpp.util.XMPPPacketListener;
-import org.apache.axis2.transport.xmpp.util.XMPPServerCredentials;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jivesoftware.smack.Roster;
-import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.Roster.SubscriptionMode;
-
-
-public class XMPPListener implements TransportListener {
-
- /**
- Uncomment this enable XMPP logging, this is useful for testing.
- static {
- XMPPConnection.DEBUG_ENABLED = true;
- }
- **/
- private static Log log = LogFactory.getLog(XMPPListener.class);
- private ConfigurationContext configurationContext = null;
- private XMPPServerCredentials serverCredentials;
-
- /**
- * A Map containing the connection factories managed by this,
- * keyed by userName-at-jabberServerURL
- */
- private Map connectionFactories = new HashMap();
- private ExecutorService workerPool;
- private static final int WORKERS_MAX_THREADS = 5;
- private static final long WORKER_KEEP_ALIVE = 60L;
- private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
- private XMPPConnection xmppConnection = null;
-
-
-
- public XMPPListener() {
- }
-
- /**
- * Initializing the XMPPListener. Retrieve connection details provided in
- * xmpp transport receiver, connect to those servers & start listening in
- * for messages.
- */
- public void init(ConfigurationContext configurationCtx, TransportInDescription transportIn)
- throws AxisFault {
- log.info("Initializing XMPPListener...");
- //allow anyone to send message to listening account
- Roster.setDefaultSubscriptionMode(SubscriptionMode.accept_all);
- configurationContext = configurationCtx;
- initializeConnectionFactories(transportIn);
- if (connectionFactories.isEmpty()) {
- log.warn("No XMPP connection factories defined." +
- "Will not listen for any XMPP messages");
- return;
- }
- }
-
- /**
- * Extract connection details & connect to those xmpp servers.
- * @see init(ConfigurationContext configurationCtx, TransportInDescription transportIn)
- * @param configurationContext
- * @param transportIn
- */
- private void initializeConnectionFactories(TransportInDescription transportIn) throws AxisFault{
- Iterator serversToListenOn = transportIn.getParameters().iterator();
- while (serversToListenOn.hasNext()) {
- Parameter connection = (Parameter) serversToListenOn.next();
- log.info("Trying to establish connection for : "+connection.getName());
- ParameterIncludeImpl pi = new ParameterIncludeImpl();
- try {
- pi.deserializeParameters((OMElement) connection.getValue());
- } catch (AxisFault axisFault) {
- log.error("Error reading parameters");
- }
-
- Iterator params = pi.getParameters().iterator();
- serverCredentials = new XMPPServerCredentials();
-
- while (params.hasNext()) {
- Parameter param = (Parameter) params.next();
- if(XMPPConstants.XMPP_SERVER_URL.equals(param.getName())){
- serverCredentials.setServerUrl((String)param.getValue());
- }else if(XMPPConstants.XMPP_SERVER_USERNAME.equals(param.getName())){
- serverCredentials.setAccountName((String)param.getValue());
- }else if(XMPPConstants.XMPP_SERVER_PASSWORD.equals(param.getName())){
- serverCredentials.setPassword((String)param.getValue());
- }else if(XMPPConstants.XMPP_SERVER_TYPE.equals(param.getName())){
- serverCredentials.setServerType((String)param.getValue());
- }else if(XMPPConstants.XMPP_DOMAIN_NAME.equals(param.getName())){
- serverCredentials.setDomainName((String)param.getValue());
- }
- }
- XMPPConnectionFactory xmppConnectionFactory = new XMPPConnectionFactory();
- xmppConnectionFactory.connect(serverCredentials);
-
- connectionFactories.put(serverCredentials.getAccountName() + "@"
- + serverCredentials.getServerUrl(), xmppConnectionFactory);
- }
- }
-
- /**
- * Stop XMPP listener & disconnect from all XMPP Servers
- */
- public void stop() {
- if (workerPool != null && !workerPool.isShutdown()) {
- workerPool.shutdown();
- }
- //TODO : Iterate through all connections in connectionFactories & call disconnect()
- }
-
- /**
- * Returns Default EPR for a given Service name & IP
- * @param serviceName
- * @param ip
- */
- public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault {
- return getEPRsForService(serviceName, ip)[0];
- }
-
- /**
- * Returns all EPRs for a given Service name & IP
- * @param serviceName
- * @param ip
- */
- public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault {
- String domainName = serverCredentials.getDomainName() == null? serverCredentials.getDomainName()
- : serverCredentials.getServerUrl();
- return new EndpointReference[]{new EndpointReference(XMPPConstants.XMPP_PREFIX +
- serverCredentials.getAccountName() +"@"+ domainName +"/services/" + serviceName)};
- }
-
-
- public SessionContext getSessionContext(MessageContext messageContext) {
- return null;
- }
-
- public void destroy() {
- if(xmppConnection != null && xmppConnection.isConnected()){
- xmppConnection.disconnect();
- }
- }
-
- /**
- * Start a pool of Workers. For each connection in connectionFactories,
- * assign a packer listener. This packet listener will trigger when a
- * message arrives.
- */
- public void start() throws AxisFault {
- // create thread pool of workers
- ExecutorService workerPool = new ThreadPoolExecutor(
- 1,
- WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
- new LinkedBlockingQueue(),
- new org.apache.axis2.util.threadpool.DefaultThreadFactory(
- new ThreadGroup("XMPP Worker thread group"),
- "XMPPWorker"));
-
- Iterator iter = connectionFactories.values().iterator();
- while (iter.hasNext()) {
- XMPPConnectionFactory connectionFactory = (XMPPConnectionFactory) iter.next();
- XMPPPacketListener xmppPacketListener =
- new XMPPPacketListener(connectionFactory,this.configurationContext,workerPool);
- connectionFactory.listen(xmppPacketListener);
- }
- }
-}
\ No newline at end of file
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
deleted file mode 100644
index eb97ca8..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAP12Version;
-import org.apache.axiom.soap.SOAPVersion;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisMessage;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.description.WSDL2Constants;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.transport.TransportSender;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.transport.xmpp.util.XMPPClientResponseManager;
-import org.apache.axis2.transport.xmpp.util.XMPPConnectionFactory;
-import org.apache.axis2.transport.xmpp.util.XMPPConstants;
-import org.apache.axis2.transport.xmpp.util.XMPPOutTransportInfo;
-import org.apache.axis2.transport.xmpp.util.XMPPServerCredentials;
-import org.apache.axis2.transport.xmpp.util.XMPPUtils;
-import org.apache.axis2.util.Utils;
-import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ws.commons.schema.XmlSchemaAll;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaGroupBase;
-import org.apache.ws.commons.schema.XmlSchemaParticle;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
-import org.apache.ws.commons.schema.XmlSchemaType;
-import org.jivesoftware.smack.Chat;
-import org.jivesoftware.smack.ChatManager;
-import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.filter.PacketFilter;
-import org.jivesoftware.smack.filter.PacketTypeFilter;
-import org.jivesoftware.smack.packet.Message;
-
-public class XMPPSender extends AbstractHandler implements TransportSender {
- static Log log = null;
-
- XMPPServerCredentials serverCredentials;
- private XMPPClientResponseManager xmppClientSidePacketListener;
- private XMPPConnectionFactory defaultConnectionFactory;
-
- public XMPPSender() {
- log = LogFactory.getLog(XMPPSender.class);
- xmppClientSidePacketListener = new XMPPClientResponseManager();
- }
-
- public void cleanup(MessageContext msgContext) throws AxisFault {
- }
-
- /**
- * Initialize the transport sender by reading pre-defined connection factories for
- * outgoing messages. These will create sessions (one per each destination dealt with)
- * to be used when messages are being sent.
- * @param confContext the configuration context
- * @param transportOut the transport sender definition from axis2.xml
- * @throws AxisFault on error
- */
- public void init(ConfigurationContext confContext,
- TransportOutDescription transportOut) throws AxisFault {
- //if connection details are available from axis configuration
- //use those & connect to jabber server(s)
- serverCredentials = new XMPPServerCredentials();
- getConnectionDetailsFromAxisConfiguration(transportOut);
-
- defaultConnectionFactory = new XMPPConnectionFactory();
- }
-
-
- public void stop() {}
-
- public InvocationResponse invoke(MessageContext msgContext)
- throws AxisFault {
- String targetAddress = (String) msgContext.getProperty(
- Constants.Configuration.TRANSPORT_URL);
- if (targetAddress != null) {
- sendMessage(msgContext, targetAddress, null);
- } else if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
- targetAddress = msgContext.getTo().getAddress();
-
- if (!msgContext.getTo().hasNoneAddress()) {
- sendMessage(msgContext, targetAddress, null);
- } else {
- //Don't send the message.
- return InvocationResponse.CONTINUE;
- }
- } else if (msgContext.isServerSide()) {
- // get the out transport info for server side when target EPR is unknown
- sendMessage(msgContext, null,
- (OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO));
- }
- return InvocationResponse.CONTINUE;
- }
-
- /**
- * Send the given message over XMPP transport
- *
- * @param msgCtx the axis2 message context
- * @throws AxisFault on error
- */
- public void sendMessage(MessageContext msgCtx, String targetAddress,
-
- OutTransportInfo outTransportInfo) throws AxisFault {
- XMPPConnection xmppConnection = null;
- XMPPOutTransportInfo xmppOutTransportInfo = null;
- XMPPConnectionFactory connectionFactory;
-
- //if on client side,create connection to xmpp server
- if(msgCtx.isServerSide()){
- xmppOutTransportInfo = (XMPPOutTransportInfo)msgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO);
- connectionFactory = xmppOutTransportInfo.getConnectionFactory();
- }else{
- getConnectionDetailsFromClientOptions(msgCtx);
- connectionFactory = defaultConnectionFactory;
- }
-
- synchronized (this) {
- xmppConnection = connectionFactory.getXmppConnection();
- if(xmppConnection == null){
- connectionFactory.connect(serverCredentials);
- xmppConnection = connectionFactory.getXmppConnection();
- }
- }
-
- Message message = new Message();
- Options options = msgCtx.getOptions();
- String serviceName = XMPPUtils.getServiceName(targetAddress);
-
- SOAPVersion version = msgCtx.getEnvelope().getVersion();
- if(version instanceof SOAP12Version){
- message.setProperty(XMPPConstants.CONTENT_TYPE, HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML+ "; action="+ msgCtx.getSoapAction());
- }else{
- message.setProperty(XMPPConstants.CONTENT_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
- }
-
-
- if (targetAddress != null) {
- xmppOutTransportInfo = new XMPPOutTransportInfo(targetAddress);
- xmppOutTransportInfo.setConnectionFactory(defaultConnectionFactory);
- } else if (msgCtx.getTo() != null &&
- !msgCtx.getTo().hasAnonymousAddress()) {
- //TODO
- } else if (msgCtx.isServerSide()) {
- xmppOutTransportInfo = (XMPPOutTransportInfo)
- msgCtx.getProperty(Constants.OUT_TRANSPORT_INFO);
- }
- try{
- if(msgCtx.isServerSide()){
- message.setProperty(XMPPConstants.IS_SERVER_SIDE, new Boolean(false));
- message.setProperty(XMPPConstants.IN_REPLY_TO, xmppOutTransportInfo.getInReplyTo());
- message.setProperty(XMPPConstants.SEQUENCE_ID, xmppOutTransportInfo.getSequenceID());
- }else{
- //message is going to be processed on server side
- message.setProperty(XMPPConstants.IS_SERVER_SIDE,new Boolean(true));
- //we are sending a soap envelope as a message
- message.setProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE, new Boolean(true));
- message.setProperty(XMPPConstants.SERVICE_NAME, serviceName);
- String action = options.getAction();
- if (action == null) {
- AxisOperation axisOperation = msgCtx.getAxisOperation();
- if (axisOperation != null) {
- action = axisOperation.getSoapAction();
- }
- }
- if (action != null) {
- message.setProperty(XMPPConstants.ACTION, action);
- }
- }
- if(xmppConnection == null){
- handleException("Connection to XMPP Server is not established.");
- }
-
-
-
- //initialize the chat manager using connection
- ChatManager chatManager = xmppConnection.getChatManager();
- Chat chat = chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);
-
- boolean waitForResponse =
- msgCtx.getOperationContext() != null &&
- WSDL2Constants.MEP_URI_OUT_IN.equals(
- msgCtx.getOperationContext().getAxisOperation().getMessageExchangePattern());
-
- OMElement msgElement;
- String messageToBeSent = "";
-
- if(XMPPConstants.XMPP_CONTENT_TYPE_STRING.equals(xmppOutTransportInfo.getContentType())){
- //if request is received from a chat client, whole soap envelope
- //should not be sent.
- OMElement soapBodyEle = msgCtx.getEnvelope().getBody();
- OMElement responseEle = soapBodyEle.getFirstElement();
- if(responseEle != null){
- msgElement = responseEle.getFirstElement();
- }else{
- msgElement = responseEle;
- }
- }else{
- //if request received from a ws client whole soap envelope
- //must be sent.
- msgElement = msgCtx.getEnvelope();
- }
- messageToBeSent = msgElement.toString();
- message.setBody(messageToBeSent);
-
- String key = null;
- if(waitForResponse && !msgCtx.isServerSide()){
- PacketFilter filter = new PacketTypeFilter(message.getClass());
- xmppConnection.addPacketListener(xmppClientSidePacketListener,filter);
- key = UUID.randomUUID().toString();
- xmppClientSidePacketListener.listenForResponse(key, msgCtx);
- message.setProperty(XMPPConstants.SEQUENCE_ID, key);
- }
-
- chat.sendMessage(message);
- log.debug("Sent message :"+message.toXML());
-
- //If this is on client side, wait for the response from server.
- //Is this the best way to do this?
- if(waitForResponse && !msgCtx.isServerSide()){
- xmppClientSidePacketListener.waitFor(key);
- //xmppConnection.disconnect();
- log.debug("Received response sucessfully");
- }
-
-
- } catch (XMPPException e) {
- log.error("Error occurred while sending the message : "+message.toXML(),e);
- handleException("Error occurred while sending the message : "+message.toXML(),e);
- } catch (InterruptedException e) {
- log.error("Error occurred while sending the message : "+message.toXML(),e);
- handleException("Error occurred while sending the message : "+message.toXML(),e);
- }finally{
-// if(xmppConnection != null && !msgCtx.isServerSide()){
-// xmppConnection.disconnect();
-// }
- }
- }
-
- /**
- * Process message requests that came in through chat clients
- * @param msgCtx
- * @throws AxisFault
- */
- public static void processChatMessage(MessageContext msgCtx) throws AxisFault {
- Object obj = msgCtx.getProperty(XMPPConstants.MESSAGE_FROM_CHAT);
- if(obj != null){
- String message = (String)obj;
- String response = "";
-
- if(message.trim().startsWith("help")){
- response = prepareHelpTextForChat();
- }else if(message.trim().startsWith("listServices")){
- response = prepareServicesList(msgCtx);
- }else if (message.trim().startsWith("getOperations")){
- response = prepareOperationList(msgCtx,message);
- }else{
- //TODO add support for more help commands
- }
- sendChatMessage(msgCtx,response);
- }
- }
-
- /**
- * Prepares a list of service names deployed in current runtime
- * @param msgCtx
- * @return
- */
- private static String prepareOperationList(MessageContext msgCtx,String chatMessage) {
- StringBuffer sb = new StringBuffer();
- //extract service name
- String serviceName = chatMessage.replace("getOperations", "");
- serviceName = serviceName.replaceAll(" ", "");
- if(log.isDebugEnabled()){
- log.debug("Finding operations for service :"+ serviceName);
- }
-
- try {
- AxisService service = msgCtx.getConfigurationContext().getAxisConfiguration().getService(serviceName);
- Iterator itrOperations = service.getOperations();
- int index = 1;
- while(itrOperations.hasNext()){
- AxisOperation operation = (AxisOperation)itrOperations.next();
- String parameterList = getParameterListForOperation(operation);
- sb.append(index +"."+operation.getName().getLocalPart()+"("+parameterList+")"+"\n");
- index++;
- }
- } catch (AxisFault e) {
- log.error("Error occurred while retreiving AxisService : "+serviceName,e);
- sb.append("Error occurred while retrieving operations for service : "+serviceName);
- }
- return sb.toString();
- }
-
- /**
- * Retrieves list of parameter names & their type for a given operation
- * @param operation
- */
- private static String getParameterListForOperation(AxisOperation operation) {
- //Logic copied from BuilderUtil.buildsoapMessage(...)
- StringBuffer paramList = new StringBuffer();
- AxisMessage axisMessage =
- operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- XmlSchemaElement xmlSchemaElement = axisMessage.getSchemaElement();
- if(xmlSchemaElement != null){
- XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
- if (schemaType instanceof XmlSchemaComplexType) {
- XmlSchemaComplexType complexType = ((XmlSchemaComplexType)schemaType);
- XmlSchemaParticle particle = complexType.getParticle();
- if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) {
- XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase)particle;
- Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();
-
- while (iterator.hasNext()) {
- XmlSchemaElement innerElement = (XmlSchemaElement)iterator.next();
- QName qName = innerElement.getQName();
- if (qName == null && innerElement.getSchemaTypeName()
- .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
- break;
- }
- long minOccurs = innerElement.getMinOccurs();
- boolean nillable = innerElement.isNillable();
- String name =
- qName != null ? qName.getLocalPart() : innerElement.getName();
- String type = innerElement.getSchemaTypeName().toString();
- paramList.append(","+type +" " +name);
- }
- }
- }
- }
- //remove first ","
- String list = paramList.toString();
- return list.replaceFirst(",", "");
- }
-
-
- /**
- * Prepares a list of service names deployed in current runtime
- * @param msgCtx
- * @return
- */
- private static String prepareServicesList(MessageContext msgCtx) {
- Map services = msgCtx.getConfigurationContext().getAxisConfiguration().getServices();
- StringBuffer sb = new StringBuffer();
- if(services != null && services.size() > 0){
- Iterator itrServiceNames = services.keySet().iterator();
- int index = 1;
- while (itrServiceNames.hasNext()) {
- String serviceName = (String) itrServiceNames.next();
- sb.append(index+"."+serviceName+"\n");
- index++;
- }
- }
- return sb.toString();
- }
-
-
- /**
- * Generate help text for chat client
- * @return {@link String}
- */
- private static String prepareHelpTextForChat(){
- StringBuffer helpText = new StringBuffer();
- helpText.append("Following commands are supported :"+"\n");
- helpText.append("-----------------------------------"+"\n");
- helpText.append("1. listServices"+"\n");
- helpText.append("2. getOperations <service-name>"+"\n");
- helpText.append("3. call <service-name>:<operation>(<param1>,<param2>,...)"+"\n");
- return helpText.toString();
- }
-
- /**
- * Replies to IM clients via a chat message. The reply contains the invocation response as a string.
- * @param msgCtx
- * @param responseMsg
- * @throws AxisFault
- */
- private static void sendChatMessage(MessageContext msgCtx,String responseMsg) throws AxisFault {
- XMPPConnection xmppConnection = null;
- XMPPOutTransportInfo xmppOutTransportInfo = null;
- Message message = new Message();
-
- xmppOutTransportInfo = (XMPPOutTransportInfo)msgCtx.getProperty(Constants.OUT_TRANSPORT_INFO);
- if(xmppOutTransportInfo != null){
- message.setProperty(XMPPConstants.IN_REPLY_TO, xmppOutTransportInfo.getInReplyTo());
- xmppConnection = xmppOutTransportInfo.getConnectionFactory().getXmppConnection();
- if(xmppConnection == null){
- handleException("Connection to XMPP Server is not established.");
- }
- }else{
- handleException("Could not find message sender details.");
- }
-
- //initialize the chat manager using connection
- ChatManager chatManager = xmppConnection.getChatManager();
- Chat chat = chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);
- try{
- message.setProperty(XMPPConstants.SEQUENCE_ID,
- xmppOutTransportInfo.getSequenceID());
- message.setBody(responseMsg);
- chat.sendMessage(message);
- log.debug("Sent message :"+message.toXML());
- } catch (XMPPException e) {
- XMPPSender.handleException("Error occurred while sending the message : "+message.toXML(),e);
- }
- }
-
- /**
- * Extract connection details from axis2.xml's transportsender section
- * @param serverCredentials
- * @param transportOut
- */
- private void getConnectionDetailsFromAxisConfiguration(TransportOutDescription transportOut){
- if(transportOut != null){
- Parameter serverUrl = transportOut.getParameter(XMPPConstants.XMPP_SERVER_URL);
- if (serverUrl != null) {
- serverCredentials.setServerUrl(Utils.getParameterValue(serverUrl));
- }
-
- Parameter userName = transportOut.getParameter(XMPPConstants.XMPP_SERVER_USERNAME);
- if (userName != null) {
- serverCredentials.setAccountName(Utils.getParameterValue(userName));
- }
-
- Parameter password = transportOut.getParameter(XMPPConstants.XMPP_SERVER_PASSWORD);
- if (password != null) {
- serverCredentials.setPassword(Utils.getParameterValue(password));
- }
-
- Parameter serverType = transportOut.getParameter(XMPPConstants.XMPP_SERVER_TYPE);
- if (serverType != null) {
- serverCredentials.setServerType(Utils.getParameterValue(serverType));
- }
-
- Parameter domainName = transportOut.getParameter(XMPPConstants.XMPP_DOMAIN_NAME);
- if (serverUrl != null) {
- serverCredentials.setDomainName(Utils.getParameterValue(domainName));
- }
- }
- }
-
- /**
- * Extract connection details from client options
- * @param serverCredentials
- * @param msgContext
- */
- private void getConnectionDetailsFromClientOptions(MessageContext msgContext){
- Options clientOptions = msgContext.getOptions();
-
- if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME) != null){
- serverCredentials.setAccountName((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME));
- }
- if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_PASSWORD) != null){
- serverCredentials.setPassword((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_PASSWORD));
- }
- if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_URL) != null){
- serverCredentials.setServerUrl((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_URL));
- }
- if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_TYPE) != null){
- serverCredentials.setServerType((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_TYPE));
- }
- }
-
- private static void handleException(String msg, Exception e) throws AxisFault {
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
- private static void handleException(String msg) throws AxisFault {
- log.error(msg);
- throw new AxisFault(msg);
- }
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/sample/XMPPSampleClient.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/sample/XMPPSampleClient.java
deleted file mode 100644
index 4791bee..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/sample/XMPPSampleClient.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.apache.axis2.transport.xmpp.sample;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.transport.xmpp.util.XMPPConstants;
-import org.apache.axis2.util.XMLPrettyPrinter;
-
-public class XMPPSampleClient {
- public static void main(String[] args) {
- invokeTimeService();
- }
-
- private static void invokeTimeService() {
- String endPointUrl = "xmpp://synapse.demo.0@gmail.com/" + "TimeService";
-
- EndpointReference targetEPR = new EndpointReference(endPointUrl);
- try {
- ConfigurationContext ctx =
- ConfigurationContextFactory.createConfigurationContextFromURIs(
- XMPPSampleClient.class.getResource("axis2.xml"), null);
-
- OMElement payload = getPayload();
- Options options = new Options();
- options.setProperty(XMPPConstants.XMPP_SERVER_TYPE, XMPPConstants.XMPP_SERVER_TYPE_GOOGLETALK);
- options.setProperty(XMPPConstants.XMPP_SERVER_URL, XMPPConstants.GOOGLETALK_URL);
- options.setProperty(XMPPConstants.XMPP_SERVER_USERNAME, "synapse.demo.0");
- options.setProperty(XMPPConstants.XMPP_SERVER_PASSWORD, "mailpassword");
-
- options.setTo(targetEPR);
- options.setAction("urn:getServerTime");
- ServiceClient sender = new ServiceClient(ctx,null);
-
- sender.setOptions(options);
- OMElement result = sender.sendReceive(payload);
- XMLPrettyPrinter.prettify(result, System.out);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static OMElement getPayload() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace(
- "http://example.xmpp.transports.axis2.org/example1", "example1");
- return fac.createOMElement("getServerTime", omNs);
- }
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/sample/axis2.xml b/modules/xmpp/src/org/apache/axis2/transport/xmpp/sample/axis2.xml
deleted file mode 100644
index 9ce14d1..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/sample/axis2.xml
+++ /dev/null
@@ -1,551 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<axisconfig name="AxisJava2.0">
- <!-- ================================================= -->
- <!-- Parameters -->
- <!-- ================================================= -->
- <parameter name="hotdeployment">true</parameter>
- <parameter name="hotupdate">false</parameter>
- <parameter name="enableMTOM">false</parameter>
- <parameter name="enableSwA">false</parameter>
-
- <!--Uncomment if you want to enable file caching for attachments -->
- <!--parameter name="cacheAttachments">true</parameter>
- <parameter name="attachmentDIR"></parameter>
- <parameter name="sizeThreshold">4000</parameter-->
-
- <!--Uncomment if you want to plugin your own attachments lifecycle implementation -->
- <!--<attachmentsLifecycleManager class="org.apache.axiom.attachments.lifecycle.impl.LifecycleManagerImpl"/>-->
-
-
- <!--Uncomment if you want to enable the reduction of the in-memory cache of WSDL definitions -->
- <!--In some server environments, the available memory heap is limited and can fill up under load -->
- <!--Since in-memory copies of WSDL definitions can be large, some steps can be taken-->
- <!--to reduce the memory needed for the cached WSDL definitions. -->
- <!--parameter name="reduceWSDLMemoryCache">true</parameter-->
-
- <!--This will give out the timout of the configuration contexts, in milliseconds-->
- <parameter name="ConfigContextTimeoutInterval">30000</parameter>
-
- <!--During a fault, stack trace can be sent with the fault message. The following flag will control -->
- <!--that behavior.-->
- <parameter name="sendStacktraceDetailsWithFaults">false</parameter>
-
- <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
- <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
- <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
- <!--is set, then Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
- <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
-
- <parameter name="userName">admin</parameter>
- <parameter name="password">axis2</parameter>
-
- <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
- <!--ServicesDirectory only works on the following cases-->
- <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
- <!---When creating URL Based configurator with URL file:// -->
- <!--- War based configurator with expanded case , -->
-
- <!--All the other scenarios it will be ignored.-->
- <!--<parameter name="ServicesDirectory">service</parameter>-->
- <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
- <!--<parameter name="ModulesDirectory">modules</parameter>-->
-
-
- <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
- <!--root which can configured using the following contextRoot parameter-->
- <!--<parameter name="contextRoot">axis2</parameter>-->
-
- <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguiush those endpoints-->
- <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
- <!--context path to proper Axis2 servlets-->
- <!--<parameter name="servicePath">services</parameter>-->
- <!--<parameter name="restPath">rest</parameter>-->
-
- <!-- Following parameter will completely disable REST handling in Axis2-->
- <parameter name="disableREST" locked="false">false</parameter>
-
- <!-- Following parameter will suppress generation of SOAP 1.2 bindings in auto-generated WSDL files -->
- <parameter name="disableSOAP12" locked="true">false</parameter>
-
- <!-- ================================================= -->
- <!-- Deployers -->
- <!-- ================================================= -->
-
- <!--Service deployer , this will alow users to deploy AAR or exploded AAR as axis2 services-->
- <deployer extension=".aar" directory="services" class="org.apache.axis2.deployment.ServiceDeployer">
- <serviceBuilderExtension name ="jwsbuilderExt" class="org.apache.axis2.jaxws.framework.JAXWSServiceBuilderExtension"/>
- <serviceBuilderExtension name ="wsdlbuilderExt" class="org.apache.axis2.deployment.WSDLServiceBuilderExtension"/>
- </deployer>
-
- <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
- <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
- <deployer extension=".jar" directory="servicejars"
- class="org.apache.axis2.jaxws.framework.JAXWSDeployer"/>
- <deployer extension=".jar" directory="transports"
- class="org.apache.axis2.deployment.TransportDeployer"/>
-
- <!--CORBA deployer , this will alow users to invoke remote CORBA services through Axis2-->
- <!--<deployer extension=".xml" directory="corba" class="org.apache.axis2.corba.deployer.CorbaDeployer"/>-->
-
- <!--<deployer extension=".jsa" directory="rmiservices" class="org.apache.axis2.rmi.deploy.RMIServiceDeployer"/>-->
-
-
- <!-- Following parameter will set the host name for the epr-->
- <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
-
- <!-- If you have a front end host which exposes this webservice using a different public URL -->
- <!-- use this parameter to override autodetected url -->
- <!--<parameter name="httpFrontendHostUrl">https://someotherhost/context</parameter>-->
-
- <!--By default, JAXWS services are created by reading annotations. WSDL and schema are generated-->
- <!--using a separate WSDL generator only when ?wsdl is called. Therefore, even if you engage-->
- <!--policies etc.. to AxisService, it doesn't appear in the WSDL. By setting the following property-->
- <!--to true, you can create the AxisService using the generated WSDL and remove the need for a-->
- <!--WSDL generator. When ?wsdl is called, WSDL is generated in the normal way.-->
- <parameter name="useGeneratedWSDLinJAXWS">false</parameter>
-
- <!-- The way of adding listener to the system-->
- <!-- <listener class="org.apache.axis2.ObserverIMPL">-->
- <!-- <parameter name="RSS_URL">http://127.0.0.1/rss</parameter>-->
- <!-- </listener>-->
-
- <threadContextMigrators>
- <threadContextMigrator listId="JAXWS-ThreadContextMigrator-List"
- class="org.apache.axis2.jaxws.addressing.migrator.EndpointContextMapMigrator"/>
- </threadContextMigrators>
-
- <!-- ================================================= -->
- <!-- Message Receivers -->
- <!-- ================================================= -->
- <!--This is the default MessageReceiver for the system , if you want to have MessageReceivers for -->
- <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
- <!--any operation -->
- <!--Note : You can override this for a particular service by adding the same element with your requirement-->
- <messageReceivers>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- </messageReceivers>
-
- <!-- ================================================= -->
- <!-- Message Formatter -->
- <!-- ================================================= -->
- <!--Following content type to message formatter mapping can be used to implement support for different message -->
- <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageFormatters>
- <messageFormatter contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
- <messageFormatter contentType="multipart/form-data"
- class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
- <messageFormatter contentType="application/xml"
- class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
- <messageFormatter contentType="text/xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- <messageFormatter contentType="application/soap+xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- </messageFormatters>
-
- <!-- ================================================= -->
- <!-- Message Builders -->
- <!-- ================================================= -->
- <!--Following content type to builder mapping can be used to implement support for different message -->
- <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageBuilders>
- <messageBuilder contentType="application/xml"
- class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
- <messageBuilder contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
- <messageBuilder contentType="multipart/form-data"
- class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
- </messageBuilders>
-
- <!-- ================================================= -->
- <!-- Transport Ins -->
- <!-- ================================================= -->
- <!-- <transportReceiver name="http"
- class="org.apache.axis2.transport.http.SimpleHTTPServer"> -->
- <!--<parameter name="port">8080</parameter> -->
- <!-- Here is the complete list of supported parameters (see example settings further below):
- port: the port to listen on (default 6060)
- hostname: if non-null, url prefix used in reply-to endpoint references (default null)
- originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1")
- requestTimeout: value in millis of time that requests can wait for data (default 20000)
- requestTcpNoDelay: true to maximize performance and minimize latency (default true)
- false to minimize bandwidth consumption by combining segments
- requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25)
- requestMaxThreadPoolSize: number of threads available for request processing if queue fills up (default 150)
- note that default queue never fills up: see HttpFactory
- threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180)
- note that no such threads can exist with default unbounded request queue
- threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS)
- -->
- <!-- <parameter name="hostname">http://www.myApp.com/ws</parameter> -->
- <!-- <parameter name="originServer">My-Server/1.1</parameter> -->
- <!-- <parameter name="requestTimeout">10000</parameter> -->
- <!-- <parameter name="requestTcpNoDelay">false</parameter> -->
- <!-- <parameter name="requestCoreThreadPoolSize">50</parameter> -->
- <!-- <parameter name="requestMaxThreadPoolSize">100</parameter> -->
- <!-- <parameter name="threadKeepAliveTime">240000</parameter> -->
- <!-- <parameter name="threadKeepAliveTimeUnit">MILLISECONDS</parameter> -->
- <!-- </transportReceiver> -->
- <!-- <transportReceiver name="sms"
- class="org.apache.axis2.transport.sms.SMSMessageReciever"> -->
-
- <!-- <parameter name="smsImplClass">org.apache.axis2.transport.sms.gsm.GSMImplManager</parameter> -->
- <!-- <parameter name="com_port">/dev/ttyUSB0</parameter> -->
- <!-- <parameter name="gateway_id">modem.ttyUSB0</parameter> -->
- <!-- <parameter name="baud_rate">115200</parameter> -->
- <!-- <parameter name="manufacturer">HUAWEI</parameter> -->
- <!-- <parameter name="model">E220</parameter> -->
- <!-- </transportReceiver> -->
-
-
-<transportReceiver name="xmpp" class="org.apache.axis2.transport.xmpp.XMPPListener">
- <!-- Account details for google talk -->
- <parameter name="GoogleServer">
- <parameter name="transport.xmpp.ServerUrl">talk.google.com</parameter>
- <parameter name="transport.xmpp.ServerAccountUserName">axis2.xmpp.account1</parameter>
- <parameter name="transport.xmpp.ServerAccountPassword">apacheaxis2</parameter>
- <parameter name="transport.xmpp.ServerType">transport.xmpp.ServerType.GoogleTalk</parameter>
- </parameter>
-</transportReceiver>
-
- <!--Uncomment if you want to have TCP transport support-->
- <!--transportReceiver name="tcp"
- class="org.apache.axis2.transport.tcp.TCPServer">
- <parameter name="port">6060</parameter-->>
- <!--If you want to give your own host address for EPR generation-->
- <!--uncomment the following paramter , and set it as you required.-->
- <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
- <!-- /transportReceiver -->
-
- <!-- ================================================= -->
- <!-- Transport Outs -->
- <!-- ================================================= -->
-
- <!--Uncomment if you want to have TCP transport support-->
- <!--
- <transportSender name="tcp"
- class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
- -->
-
- <!-- <transportSender name="sms" class="org.apache.axis2.transport.sms.SMSSender"> -->
- <!-- <parameter name="smsImplClass">org.apache.axis2.transport.sms.gsm.GSMImplManager</parameter> -->
- <!-- <parameter name="com_port">/dev/ttyUSB0</parameter> -->
- <!-- <parameter name="gateway_id">modem.ttyUSB0</parameter> -->
- <!-- <parameter name="baud_rate">115200</parameter> -->
- <!-- <parameter name="manufacturer">HUAWEI</parameter> -->
- <!-- <parameter name="model">E220</parameter> -->
- <!-- </transportSender> -->
-
-<transportSender name="xmpp" class="org.apache.axis2.transport.xmpp.XMPPSender">
-</transportSender>
-
- <!-- Please enable this if you need the java transport -->
- <!-- <transportSender name="java"
- class="org.apache.axis2.transport.java.JavaTransportSender"/> -->
-
- <!-- ================================================= -->
- <!-- Global Modules -->
- <!-- ================================================= -->
- <!-- Comment this to disable Addressing -->
- <!--<module ref="addressing"/>-->
-
- <!--Configuring module , providing parameters for modules whether they refer or not-->
- <!--<moduleConfig name="addressing">-->
- <!--<parameter name="addressingPara">N/A</parameter>-->
- <!--</moduleConfig>-->
-
- <!-- ================================================= -->
- <!-- Clustering -->
- <!-- ================================================= -->
- <!--
- To enable clustering for this node, set the value of "enable" attribute of the "clustering"
- element to "true". The initialization of a node in the cluster is handled by the class
- corresponding to the "class" attribute of the "clustering" element. It is also responsible for
- getting this node to join the cluster.
- -->
- <clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="false">
-
- <!--
- This parameter indicates whether the cluster has to be automatically initalized
- when the AxisConfiguration is built. If set to "true" the initialization will not be
- done at that stage, and some other party will have to explictly initialize the cluster.
- -->
- <parameter name="AvoidInitiation">true</parameter>
-
- <!--
- The membership scheme used in this setup. The only values supported at the moment are
- "multicast" and "wka"
-
- 1. multicast - membership is automatically discovered using multicasting
- 2. wka - Well-Known Address based multicasting. Membership is discovered with the help
- of one or more nodes running at a Well-Known Address. New members joining a
- cluster will first connect to a well-known node, register with the well-known node
- and get the membership list from it. When new members join, one of the well-known
- nodes will notify the others in the group. When a member leaves the cluster or
- is deemed to have left the cluster, it will be detected by the Group Membership
- Service (GMS) using a TCP ping mechanism.
- -->
- <parameter name="membershipScheme">multicast</parameter>
-
- <!--
- The clustering domain/group. Nodes in the same group will belong to the same multicast
- domain. There will not be interference between nodes in different groups.
- -->
- <parameter name="domain">wso2.carbon.domain</parameter>
-
- <!--
- When a Web service request is received, and processed, before the response is sent to the
- client, should we update the states of all members in the cluster? If the value of
- this parameter is set to "true", the response to the client will be sent only after
- all the members have been updated. Obviously, this can be time consuming. In some cases,
- such this overhead may not be acceptable, in which case the value of this parameter
- should be set to "false"
- -->
- <parameter name="synchronizeAll">true</parameter>
-
- <!--
- The maximum number of times we need to retry to send a message to a particular node
- before giving up and considering that node to be faulty
- -->
- <parameter name="maxRetries">10</parameter>
-
- <!-- The multicast address to be used -->
- <parameter name="mcastAddress">228.0.0.4</parameter>
-
- <!-- The multicast port to be used -->
- <parameter name="mcastPort">45564</parameter>
-
- <!-- The frequency of sending membership multicast messages (in ms) -->
- <parameter name="mcastFrequency">500</parameter>
-
- <!-- The time interval within which if a member does not respond, the member will be
- deemed to have left the group (in ms)
- -->
- <parameter name="memberDropTime">3000</parameter>
-
- <!--
- The IP address of the network interface to which the multicasting has to be bound to.
- Multicasting would be done using this interface.
- -->
- <parameter name="mcastBindAddress">127.0.0.1</parameter>
-
- <!-- The host name or IP address of this member -->
- <parameter name="localMemberHost">127.0.0.1</parameter>
-
- <!--
- The TCP port used by this member. This is the port through which other nodes will
- contact this member
- -->
- <parameter name="localMemberPort">4000</parameter>
-
- <!--
- Preserve message ordering. This will be done according to sender order.
- -->
- <parameter name="preserveMessageOrder">true</parameter>
-
- <!--
- Maintain atmost-once message processing semantics
- -->
- <parameter name="atmostOnceMessageSemantics">true</parameter>
-
- <!--
- Properties specific to this member
- -->
- <parameter name="properties">
- <property name="backendServerURL" value="https://${hostName}:${httpsPort}/services/"/>
- <property name="mgtConsoleURL" value="https://${hostName}:${httpsPort}/"/>
- </parameter>
-
- <!--
- The list of static or well-known members. These entries will only be valid if the
- "membershipScheme" above is set to "wka"
- -->
- <members>
- <member>
- <hostName>127.0.0.1</hostName>
- <port>4000</port>
- </member>
- <member>
- <hostName>127.0.0.1</hostName>
- <port>4001</port>
- </member>
- </members>
-
- <!--
- Enable the groupManagement entry if you need to run this node as a cluster manager.
- Multiple application domains with different GroupManagementAgent implementations
- can be defined in this section.
- -->
- <groupManagement enable="false">
- <applicationDomain name="apache.axis2.application.domain"
- description="Axis2 group"
- agent="org.apache.axis2.clustering.management.DefaultGroupManagementAgent"/>
- </groupManagement>
-
- <!--
- This interface is responsible for handling management of a specific node in the cluster
- The "enable" attribute indicates whether Node management has been enabled
- -->
- <nodeManager class="org.apache.axis2.clustering.management.DefaultNodeManager"
- enable="true"/>
-
- <!--
- This interface is responsible for handling state replication. The property changes in
- the Axis2 context hierarchy in this node, are propagated to all other nodes in the cluster.
-
- The "excludes" patterns can be used to specify the prefixes (e.g. local_*) or
- suffixes (e.g. *_local) of the properties to be excluded from replication. The pattern
- "*" indicates that all properties in a particular context should not be replicated.
-
- The "enable" attribute indicates whether context replication has been enabled
- -->
- <stateManager class="org.apache.axis2.clustering.state.DefaultStateManager"
- enable="true">
- <replication>
- <defaults>
- <exclude name="local_*"/>
- <exclude name="LOCAL_*"/>
- </defaults>
- <context class="org.apache.axis2.context.ConfigurationContext">
- <exclude name="local_*"/>
- </context>
- <context class="org.apache.axis2.context.ServiceGroupContext">
- <exclude name="local_*"/>
- </context>
- <context class="org.apache.axis2.context.ServiceContext">
- <exclude name="local_*"/>
- </context>
- </replication>
- </stateManager>
- </clustering>
-
- <!-- ================================================= -->
- <!-- Phases -->
- <!-- ================================================= -->
- <phaseOrder type="InFlow">
- <!-- System predefined phases -->
- <phase name="Transport">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- </phase>
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- <handler name="GenericProviderDispatcher"
- class="org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher"/>
- <handler name="MustUnderstandValidationDispatcher"
- class="org.apache.axis2.jaxws.dispatchers.MustUnderstandValidationDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- System predefined phases -->
- <!-- After Postdispatch phase module author or service author can add any phase he want -->
- <phase name="OperationInPhase">
- <handler name="MustUnderstandChecker"
- class="org.apache.axis2.jaxws.dispatchers.MustUnderstandChecker">
- <order phase="OperationInPhase"/>
- </handler>
- </phase>
- <phase name="soapmonitorPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFlow">
- <!-- user can add his own phases to this area -->
- <phase name="soapmonitorPhase"/>
- <phase name="OperationOutPhase"/>
- <!--system predefined phase-->
- <!--these phase will run irrespective of the service-->
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
- <phaseOrder type="InFaultFlow">
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- <handler name="GenericProviderDispatcher"
- class="org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher"/>
- <handler name="MustUnderstandValidationDispatcher"
- class="org.apache.axis2.jaxws.dispatchers.MustUnderstandValidationDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- user can add his own phases to this area -->
- <phase name="OperationInFaultPhase"/>
- <phase name="soapmonitorPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFaultFlow">
- <!-- user can add his own phases to this area -->
- <phase name="soapmonitorPhase"/>
- <phase name="OperationOutFaultPhase"/>
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
-</axisconfig>
\ No newline at end of file
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientConnectionFactory.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientConnectionFactory.java
deleted file mode 100755
index 6278398..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientConnectionFactory.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jivesoftware.smack.ConnectionConfiguration;
-import org.jivesoftware.smack.ConnectionListener;
-import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.filter.FromContainsFilter;
-import org.jivesoftware.smack.filter.PacketFilter;
-import org.jivesoftware.smack.filter.ToContainsFilter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class XMPPClientConnectionFactory {
- private static Log log = LogFactory.getLog(XMPPClientConnectionFactory.class);
- private XMPPConnection xmppConnection = null;
- private PacketFilter packetFilter = null;
- private Map<String,XMPPConnectionDetails> xmppConnections = new HashMap<String,XMPPConnectionDetails>();
-
- public XMPPClientConnectionFactory(){}
-
- /**
- * Connects to a XMPP server based on the details available in serverCredentials object
- * @param serverCredentials
- * @throws XMPPException
- */
- public XMPPConnection connect(final XMPPServerCredentials serverCredentials) throws AxisFault {
- //XMPPConnection.DEBUG_ENABLED = true;
- if(XMPPConstants.XMPP_SERVER_TYPE_JABBER.equals(serverCredentials.getServerType())){
- xmppConnection = new XMPPConnection(serverCredentials.getServerUrl());
- try {
- xmppConnection.connect();
- } catch (XMPPException e) {
- log.error("Failed to connect to server :"+serverCredentials.getServerUrl(), e);
- throw new AxisFault("Failed to connect to server :"+serverCredentials.getServerUrl());
- }
- //Pause for a small time before trying to login.
- //This prevents random ssl exception from Smack API
- try {
- Thread.sleep(100);
- } catch (InterruptedException e5) {
- log.debug("Sleep interrupted ",e5);
- }
-
- if(xmppConnection.isConnected()){
- String resource = serverCredentials.getResource()+ new Object().hashCode();
- if(! xmppConnection.isAuthenticated()){
- try {
- //xmppConnection.login(serverCredentials.getAccountName()+"@"+
- // serverCredentials.getServerUrl(),
- xmppConnection.login(serverCredentials.getAccountName(),
- serverCredentials.getPassword(),
- resource,
- true);
- } catch (XMPPException e) {
- try {
- log.error("Login failed for "
- +serverCredentials.getAccountName()
- +"@"+serverCredentials.getServerUrl()
- +".Retrying in 2 secs",e);
- Thread.sleep(2000);
- //xmppConnection.login(serverCredentials.getAccountName()+"@"+
- // serverCredentials.getServerUrl(),
- xmppConnection.login(serverCredentials.getAccountName(),
- serverCredentials.getPassword(),
- resource,
- true);
-
- } catch (InterruptedException e1) {
- log.error("Sleep interrupted.",e1);
- } catch (XMPPException e2) {
- log.error("Login failed for : "+serverCredentials.getAccountName()
- +"@"+serverCredentials.getServerUrl(),e2);
- throw new AxisFault("Login failed for : "+serverCredentials.getAccountName()
- +"@"+serverCredentials.getServerUrl());
- }
- }
- //Listen for Message type packets from specified server url
- //packetFilter = new AndFilter(new PacketTypeFilter(Message.class),
- // new FromContainsFilter(serverCredentials.getServerUrl()));
- packetFilter = new FromContainsFilter(serverCredentials.getServerUrl());
- }
- }
- }else if(XMPPConstants.XMPP_SERVER_TYPE_GOOGLETALK.equals(serverCredentials.getServerType())){
- ConnectionConfiguration connectionConfiguration =
- new ConnectionConfiguration(XMPPConstants.GOOGLETALK_URL
- ,XMPPConstants.GOOGLETALK_PORT
- ,XMPPConstants.GOOGLETALK_SERVICE_NAME);
- xmppConnection = new XMPPConnection(connectionConfiguration);
- try {
- xmppConnection.connect();
- xmppConnection.login(serverCredentials.getAccountName()
- , serverCredentials.getPassword()
- ,serverCredentials.getResource(),
- true);
- //packetFilter = new AndFilter(new PacketTypeFilter(Message.class),
- // new FromContainsFilter(XMPPConstants.GOOGLETALK_FROM));
- //packetFilter = new FromContainsFilter(XMPPConstants.GOOGLETALK_FROM);
- packetFilter = new ToContainsFilter("@gmail.com");
-
- } catch (XMPPException e1) {
- log.error("Error occured while connecting to Googletalk server.",e1);
- throw new AxisFault("Error occured while connecting to Googletalk server.");
- }
- }
-
- ConnectionListener connectionListener = null;
- connectionListener = new ConnectionListener(){
- public void connectionClosed() {
- log.debug("Connection closed normally");
- }
- public void connectionClosedOnError(
- Exception e1) {
- log.error("Connection to "+serverCredentials.getServerUrl()
- + " closed with error.",e1);
- }
- public void reconnectingIn(int seconds) {
- log.error("Connection to "+serverCredentials.getServerUrl()
- +" failed. Reconnecting in "+seconds+"s");
- }
- public void reconnectionFailed(Exception e) {
- log.error("Reconnection to "+serverCredentials.getServerUrl()+" failed.",e);
- }
- public void reconnectionSuccessful() {
- log.debug("Reconnection to "+serverCredentials.getServerUrl()+" successful.");
- }
- };
- if(xmppConnection != null && xmppConnection.isConnected()){
- xmppConnection.addConnectionListener(connectionListener);
- log.info("Connected to " +serverCredentials.getAccountName()+ "@"
- + serverCredentials.getServerUrl()+ "/"+ serverCredentials.getResource());
- }else{
- log.warn(" Not Connected to " +serverCredentials.getAccountName()+ "@"
- + serverCredentials.getServerUrl()+ "/"+ serverCredentials.getResource());
- }
- return xmppConnection;
- }
-
- public XMPPConnection getXmppConnection(){
- return xmppConnection;
- }
-
-// public XMPPConnection getConnection(XMPPServerCredentials credentials) throws AxisFault{
-// StringBuffer buf = new StringBuffer();
-// String key = buf.append(credentials.getServerUrl()).append(credentials.getAccountName()).toString();
-//
-// XMPPConnectionDetails connDetails = xmppConnections.get(key);
-// if(connDetails == null){
-// connDetails = new XMPPConnectionDetails();
-// connDetails.connection = connect(credentials);
-// connDetails.userCount = 1;
-// xmppConnections.put(key, connDetails);
-// }else{
-// connDetails.userCount = 1;
-// }
-// return connDetails.connection;
-// }
-//
-// public void disconnect(XMPPServerCredentials credentials){
-// StringBuffer buf = new StringBuffer();
-// String key = buf.append(credentials.getServerUrl()).append(credentials.getAccountName()).toString();
-//
-// XMPPConnectionDetails connDetails = xmppConnections.get(key);
-// if(connDetails != null){
-// connDetails.userCount--;
-// }
-// if(connDetails.userCount == 0){
-// xmppConnections.remove(key);
-// connDetails.connection.disconnect();
-// }
-// }
-
-
-// public void listen(XMPPPacketListener packetListener){
-// xmppConnection.addPacketListener(packetListener,packetFilter);
-// }
-
- public void stop() {}
-
- public class XMPPConnectionDetails{
- XMPPConnection connection;
- int userCount;
- }
-}
\ No newline at end of file
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientResponseManager.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientResponseManager.java
deleted file mode 100755
index 96d386a..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientResponseManager.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Semaphore;
-
-import org.apache.axis2.context.MessageContext;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jivesoftware.smack.PacketListener;
-import org.jivesoftware.smack.packet.Message;
-import org.jivesoftware.smack.packet.Packet;
-
-public class XMPPClientResponseManager implements PacketListener {
- private static Log log = LogFactory.getLog(XMPPClientResponseManager.class);
-
- private ConcurrentHashMap<String, WaitingDetails> prespectiveResponseMap = new ConcurrentHashMap<String, WaitingDetails>();
-
-
- public XMPPClientResponseManager(){
- }
-
-
- public void listenForResponse(String key, MessageContext messageContext){
- prespectiveResponseMap.put(key, new WaitingDetails(messageContext));
- }
-
-
- /**
- * This method will be triggered, when a message is arrived at client side
- */
- public void processPacket(Packet packet) {
- Message message = (Message)packet;
- String xml = StringEscapeUtils.unescapeXml(message.getBody());
- log.debug("Client received message : "+message.toXML());
- InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
-
- String sequenceNumber = (String)message.getProperty(XMPPConstants.SEQUENCE_ID);
- if(sequenceNumber != null){
- WaitingDetails waitingDetails = prespectiveResponseMap.remove(sequenceNumber);
- if(waitingDetails != null){
- waitingDetails.messageContext.setProperty(MessageContext.TRANSPORT_IN, inputStream);
- waitingDetails.wait.release();
- }else{
- log.error("No one waiting for message "+ xml);
- }
- }else{
- log.error(XMPPConstants.SEQUENCE_ID + " not found in the message");
- }
- }
-
- /**
- * Indicates response message is received at client side.
- * @see processPacket(Packet packet)
- * @return
- * @throws InterruptedException
- */
- public void waitFor(String key) throws InterruptedException{
- WaitingDetails waitingDetails = prespectiveResponseMap.get(key);
- if(waitingDetails == null){
- //this mean response has arrvied before wait
- return;
- }
- waitingDetails.wait.acquire();
- }
-
- public class WaitingDetails{
- Semaphore wait = new Semaphore(0);
- MessageContext messageContext;
- public WaitingDetails(MessageContext messageContext) {
- super();
- this.messageContext = messageContext;
- }
-
- }
-
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java
deleted file mode 100644
index c6daf3f..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.apache.axis2.context.MessageContext;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jivesoftware.smack.PacketListener;
-import org.jivesoftware.smack.packet.Message;
-import org.jivesoftware.smack.packet.Packet;
-
-public class XMPPClientSidePacketListener implements PacketListener {
- private static Log log = LogFactory.getLog(XMPPClientSidePacketListener.class);
- private MessageContext messageContext = null;
- private boolean responseReceived;
-
- public XMPPClientSidePacketListener(MessageContext messageContext){
- this.messageContext = messageContext;
- }
-
-
-
- /**
- * This method will be triggered, when a message is arrived at client side
- */
- public void processPacket(Packet packet) {
- Message message = (Message)packet;
- String xml = StringEscapeUtils.unescapeXml(message.getBody());
- log.info("Client received message : "+xml);
- this.responseReceived = true;
- InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
- messageContext.setProperty(MessageContext.TRANSPORT_IN, inputStream);
- }
-
- /**
- * Indicates response message is received at client side.
- * @see processPacket(Packet packet)
- * @return
- */
- public boolean isResponseReceived() {
- return responseReceived;
- }
-
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java
deleted file mode 100644
index 6df842a..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jivesoftware.smack.ConnectionConfiguration;
-import org.jivesoftware.smack.ConnectionListener;
-import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.filter.FromContainsFilter;
-import org.jivesoftware.smack.filter.PacketFilter;
-import org.jivesoftware.smack.filter.ToContainsFilter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class XMPPConnectionFactory {
- private static Log log = LogFactory.getLog(XMPPConnectionFactory.class);
- private XMPPConnection xmppConnection = null;
- private PacketFilter packetFilter = null;
- private Map<String,XMPPConnectionDetails> xmppConnections = new HashMap<String,XMPPConnectionDetails>();
-
- public XMPPConnectionFactory(){}
-
- /**
- * Connects to a XMPP server based on the details available in serverCredentials object
- * @param serverCredentials
- * @throws XMPPException
- */
- public XMPPConnection connect(final XMPPServerCredentials serverCredentials) throws AxisFault {
- //XMPPConnection.DEBUG_ENABLED = true;
- if(XMPPConstants.XMPP_SERVER_TYPE_JABBER.equals(serverCredentials.getServerType())){
- xmppConnection = new XMPPConnection(serverCredentials.getServerUrl());
- try {
- xmppConnection.connect();
- } catch (XMPPException e) {
- log.error("Failed to connect to server :"+serverCredentials.getServerUrl(), e);
- throw new AxisFault("Failed to connect to server :"+serverCredentials.getServerUrl());
- }
- //Pause for a small time before trying to login.
- //This prevents random ssl exception from Smack API
- try {
- Thread.sleep(100);
- } catch (InterruptedException e5) {
- log.debug("Sleep interrupted ",e5);
- }
-
- if(xmppConnection.isConnected()){
- String resource = serverCredentials.getResource()+ new Object().hashCode();
- if(! xmppConnection.isAuthenticated()){
- try {
- xmppConnection.login(serverCredentials.getAccountName(),
- serverCredentials.getPassword(),
- resource,
- true);
- } catch (XMPPException e) {
- try {
- log.error("Login failed for "
- +serverCredentials.getAccountName()
- +"@"+serverCredentials.getServerUrl()
- +".Retrying in 2 secs",e);
- Thread.sleep(2000);
- xmppConnection.login(serverCredentials.getAccountName(),
- serverCredentials.getPassword(),
- resource,
- true);
-
- } catch (InterruptedException e1) {
- log.error("Sleep interrupted.",e1);
- } catch (XMPPException e2) {
- log.error("Login failed for : "+serverCredentials.getAccountName()
- +"@"+serverCredentials.getServerUrl(),e2);
- throw new AxisFault("Login failed for : "+serverCredentials.getAccountName()
- +"@"+serverCredentials.getServerUrl());
- }
- }
- //Listen for Message type packets from specified server url
- packetFilter = new FromContainsFilter(serverCredentials.getServerUrl());
- }
- }
- }else if(XMPPConstants.XMPP_SERVER_TYPE_GOOGLETALK.equals(serverCredentials.getServerType())){
- ConnectionConfiguration connectionConfiguration =
- new ConnectionConfiguration(XMPPConstants.GOOGLETALK_URL
- ,XMPPConstants.GOOGLETALK_PORT
- ,XMPPConstants.GOOGLETALK_SERVICE_NAME);
- xmppConnection = new XMPPConnection(connectionConfiguration);
- try {
- xmppConnection.connect();
- xmppConnection.login(serverCredentials.getAccountName()
- , serverCredentials.getPassword()
- ,serverCredentials.getResource(),
- true);
- packetFilter = new ToContainsFilter("@gmail.com");
-
- } catch (XMPPException e1) {
- log.error("Error occured while connecting to Googletalk server.",e1);
- throw new AxisFault("Error occured while connecting to Googletalk server.");
- }
- }
-
- ConnectionListener connectionListener = null;
- connectionListener = new ConnectionListener(){
- public void connectionClosed() {
- log.debug("Connection closed normally");
- }
- public void connectionClosedOnError(
- Exception e1) {
- log.error("Connection to "+serverCredentials.getServerUrl()
- + " closed with error.",e1);
- }
- public void reconnectingIn(int seconds) {
- log.error("Connection to "+serverCredentials.getServerUrl()
- +" failed. Reconnecting in "+seconds+"s");
- }
- public void reconnectionFailed(Exception e) {
- log.error("Reconnection to "+serverCredentials.getServerUrl()+" failed.",e);
- }
- public void reconnectionSuccessful() {
- log.debug("Reconnection to "+serverCredentials.getServerUrl()+" successful.");
- }
- };
- if(xmppConnection != null && xmppConnection.isConnected()){
- xmppConnection.addConnectionListener(connectionListener);
- log.info("Connected to " +serverCredentials.getAccountName()+ "@"
- + serverCredentials.getServerUrl()+ "/"+ serverCredentials.getResource());
- }else{
- log.warn(" Not Connected to " +serverCredentials.getAccountName()+ "@"
- + serverCredentials.getServerUrl()+ "/"+ serverCredentials.getResource());
- }
- return xmppConnection;
- }
-
- public XMPPConnection getXmppConnection(){
- return xmppConnection;
- }
-
-
- public void listen(XMPPPacketListener packetListener){
- xmppConnection.addPacketListener(packetListener,packetFilter);
- }
-
- public void stop() {}
-
- public class XMPPConnectionDetails{
- XMPPConnection connection;
- int userCount;
- }
-}
\ No newline at end of file
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java
deleted file mode 100644
index 27d956b..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-
-public class XMPPConstants {
- public static final String XMPP = "xmpp";
- //The prefix indicating an Axis XMPP URL
- public static final String XMPP_PREFIX = "xmpp://";
-
- //properties related to XMPP server connection
- public static final String XMPP_SERVER_USERNAME = "transport.xmpp.ServerAccountUserName";
- public static final String XMPP_SERVER_PASSWORD = "transport.xmpp.ServerAccountPassword";
- public static final String XMPP_SERVER_URL = "transport.xmpp.ServerUrl";
- public static final String XMPP_DOMAIN_NAME = "transport.xmpp.domain";
-
- //Google talk attributes
- public static final String GOOGLETALK_URL = "talk.google.com";
- public static final int GOOGLETALK_PORT = 5222;
- public static final String GOOGLETALK_SERVICE_NAME = "gmail.com";
- public static final String GOOGLETALK_FROM = "gmail.com";
-
-
- //XMPP Server Types
- public static final String XMPP_SERVER_TYPE = "transport.xmpp.ServerType";
- public static final String XMPP_SERVER_TYPE_JABBER = "transport.xmpp.ServerType.Jabber";
- public static final String XMPP_SERVER_TYPE_GOOGLETALK = "transport.xmpp.ServerType.GoogleTalk";
-
- public static final String IS_SERVER_SIDE = "isServerSide";
- public static final String IN_REPLY_TO = "inReplyTo";
- public static final String SERVICE_NAME = "ServiceName";
- public static final String ACTION = "Action";
- public static final String CONTENT_TYPE = "ContentType";
- //This is set to true, if a request message is sent through XMPPSender
- //Used to distinguish messages coming from chat clients.
- public static final String CONTAINS_SOAP_ENVELOPE = "transport.xmpp.containsSOAPEnvelope";
- public static final String MESSAGE_FROM_CHAT = "transport.xmpp.message.from.chat";
- public static final String SEQUENCE_ID = "transport.xmpp.sequenceID";
-
- public static final String XMPP_CONTENT_TYPE_STRING = "xmpp/text";
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java
deleted file mode 100644
index 6c82fb4..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.transport.OutTransportInfo;
-
-/**
- *
- * Holds XMPP transport out details
- *
- */
-public class XMPPOutTransportInfo implements OutTransportInfo{
- private String contentType = null;
- private String destinationAccount = null;
- private String inReplyTo;
- private EndpointReference from;
- private XMPPConnectionFactory connectionFactory = null;
- private String sequenceID;
-
- public XMPPOutTransportInfo(){
-
- }
-
- public XMPPOutTransportInfo(String transportUrl) throws AxisFault {
- this.destinationAccount = XMPPUtils.getAccountName(transportUrl);
- }
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public XMPPConnectionFactory getConnectionFactory() {
- return connectionFactory;
- }
-
- public void setConnectionFactory(XMPPConnectionFactory connectionFactory) {
- this.connectionFactory = connectionFactory;
- }
-
- public String getDestinationAccount() {
- return destinationAccount;
- }
-
- public EndpointReference getFrom() {
- return from;
- }
-
- public void setFrom(EndpointReference from) {
- this.from = from;
- }
-
- public String getInReplyTo() {
- return inReplyTo;
- }
-
- public void setInReplyTo(String inReplyTo) {
- this.inReplyTo = inReplyTo;
- }
-
- public void setDestinationAccount(String destinationAccount) {
- this.destinationAccount = destinationAccount;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public String getSequenceID() {
- return sequenceID;
- }
-
- public void setSequenceID(String sequenceID) {
- this.sequenceID = sequenceID;
- }
-
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java
deleted file mode 100644
index 4a1176e..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.concurrent.Executor;
-
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMException;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.builder.BuilderUtil;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.transport.xmpp.XMPPSender;
-import org.apache.axis2.util.MessageContextBuilder;
-import org.apache.axis2.util.MultipleEntryHashMap;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jivesoftware.smack.PacketListener;
-import org.jivesoftware.smack.packet.Message;
-import org.jivesoftware.smack.packet.Packet;
-
-public class XMPPPacketListener implements PacketListener {
- private static final Log log = LogFactory.getLog(XMPPPacketListener.class);
- private XMPPConnectionFactory xmppConnectionFactory = null;
- private ConfigurationContext configurationContext = null;
- private Executor workerPool = null;
-
- public final static String CONTENT_TYPE = "mail.contenttype";
-
- public XMPPPacketListener(XMPPConnectionFactory xmppConnectionFactory, ConfigurationContext configurationContext, Executor workerPool) {
- this.xmppConnectionFactory = xmppConnectionFactory;
- this.configurationContext = configurationContext;
- this.workerPool = workerPool;
- }
-
- /**
- * This method gets triggered when server side gets a message
- */
- public void processPacket(Packet packet) {
- log.debug("Received : "+packet.toXML());
- if(packet instanceof Message){
- workerPool.execute(new Worker(packet));
- }
- }
-
- /**
- * Creates message context using values received in XMPP packet
- * @param packet
- * @return MessageContext
- * @throws AxisFault
- */
- private MessageContext createMessageContext(Packet packet) throws AxisFault {
- Message message = (Message) packet;
-
- Boolean isServerSide = (Boolean) message
- .getProperty(XMPPConstants.IS_SERVER_SIDE);
- String serviceName = (String) message
- .getProperty(XMPPConstants.SERVICE_NAME);
- String action = (String) message.getProperty(XMPPConstants.ACTION);
- MessageContext msgContext = null;
-
- TransportInDescription transportIn = configurationContext
- .getAxisConfiguration().getTransportIn("xmpp");
- TransportOutDescription transportOut = configurationContext
- .getAxisConfiguration().getTransportOut("xmpp");
- if ((transportIn != null) && (transportOut != null)) {
- msgContext = configurationContext.createMessageContext();
- msgContext.setTransportIn(transportIn);
- msgContext.setTransportOut(transportOut);
- if (isServerSide != null) {
- msgContext.setServerSide(isServerSide.booleanValue());
- }
- msgContext.setProperty(
- CONTENT_TYPE,
- "text/xml");
- msgContext.setProperty(
- Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
- msgContext.setIncomingTransportName("xmpp");
-
- Map services = configurationContext.getAxisConfiguration()
- .getServices();
-
- AxisService axisService = (AxisService) services.get(serviceName);
- msgContext.setAxisService(axisService);
- msgContext.setSoapAction(action);
-
- // pass the configurationFactory to transport sender
- msgContext.setProperty("XMPPConfigurationFactory",
- this.xmppConnectionFactory);
-
- if (packet.getFrom() != null) {
- msgContext.setFrom(new EndpointReference(packet.getFrom()));
- }
- if (packet.getTo() != null) {
- msgContext.setTo(new EndpointReference(packet.getTo()));
- }
-
- XMPPOutTransportInfo xmppOutTransportInfo = new XMPPOutTransportInfo();
- xmppOutTransportInfo
- .setConnectionFactory(this.xmppConnectionFactory);
-
- String packetFrom = packet.getFrom();
- if (packetFrom != null) {
- EndpointReference fromEPR = new EndpointReference(packetFrom);
- xmppOutTransportInfo.setFrom(fromEPR);
- xmppOutTransportInfo.setDestinationAccount(packetFrom);
- }
-
- // Save Message-Id to set as In-Reply-To on reply
- String xmppMessageId = packet.getPacketID();
- if (xmppMessageId != null) {
- xmppOutTransportInfo.setInReplyTo(xmppMessageId);
- }
- xmppOutTransportInfo.setSequenceID((String)message.getProperty(XMPPConstants.SEQUENCE_ID));
- msgContext.setProperty(
- org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
- xmppOutTransportInfo);
- buildSOAPEnvelope(packet, msgContext);
- } else {
- throw new AxisFault("Either transport in or transport out is null");
- }
- return msgContext;
- }
-
- /**
- * builds SOAP envelop using message contained in packet
- * @param packet
- * @param msgContext
- * @throws AxisFault
- */
- private void buildSOAPEnvelope(Packet packet, MessageContext msgContext) throws AxisFault{
- Message message = (Message)packet;
- String logMsg = "Trying to create " +
- "message content using XMPP message received :"+packet.toXML();
-
- String messageBody = StringEscapeUtils.unescapeXml(message.getBody());
- if(msgContext.isServerSide()){
- log.debug("Received Envelope : "+messageBody);
- }
-
- InputStream inputStream = new ByteArrayInputStream(messageBody.getBytes());
- SOAPEnvelope envelope = null;
- try {
- Object obj = message.getProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE);
- if(obj != null && ((Boolean)obj).booleanValue()){
- String contentType = (String)message.getProperty(XMPPConstants.CONTENT_TYPE);
- if(contentType == null){
- throw new AxisFault("Can not Find Content type Property in the XMPP Message");
- }
- envelope = TransportUtils.createSOAPMessage(msgContext, inputStream, contentType);
- msgContext.setProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE, new Boolean(true));
- }else{
- //A text message has been received from a chat client
- //This message could either be a service call or a help command
- if(!(messageContainsCommandsFromChat(messageBody,msgContext))){
- envelope = createSOAPEnvelopeForRawMessage(msgContext, messageBody);
- }
- }
- if(envelope != null){
- msgContext.setEnvelope(envelope);
- }
- }catch (OMException e) {
- log.error(logMsg, e);
- throw new AxisFault(logMsg);
- }catch (XMLStreamException e) {
- log.error(logMsg, e);
- throw new AxisFault(logMsg);
- }catch (FactoryConfigurationError e) {
- log.error(logMsg, e);
- throw new AxisFault(logMsg);
- }catch (AxisFault e){
- log.error(logMsg, e);
- throw new AxisFault(logMsg);
- }
- }
-
- /**
- * In the direct chat client scenario, client can send commands & retrieve details
- * on available services, operations,etc. This method checks if a client has sent
- * such command. Only limited set of commands are available as of now.
- * @param message
- * @param msgContext
- * @return
- */
- private boolean messageContainsCommandsFromChat(String message,MessageContext msgContext){
- boolean containsKnownCommand = false;
- if(message.trim().startsWith("help")){
- containsKnownCommand = true;
- }else if(message.trim().startsWith("listServices")){
- containsKnownCommand = true;
- }else if (message.trim().startsWith("getOperations")){
- containsKnownCommand = true;
- }
-
- if(containsKnownCommand){
- msgContext.setProperty(XMPPConstants.MESSAGE_FROM_CHAT,message.trim());
- }
- return containsKnownCommand;
- }
-
- /**
- * Creates a SOAP envelope using details found in chat message.
- * @param msgCtx
- * @param chatMessage
- * @return
- */
- private SOAPEnvelope createSOAPEnvelopeForRawMessage(MessageContext msgCtx,String chatMessage)
- throws AxisFault{
- //TODO : need to add error handling logic
- String callRemoved = chatMessage.replaceFirst("call", "");
- //extract Service name
- String serviceName = callRemoved.trim().substring(0, callRemoved.indexOf(":")-1);
- String operationName = callRemoved.trim().substring(callRemoved.indexOf(":"), callRemoved.indexOf("(")-1);
-
- //Extract parameters from IM message
- String parameterList = callRemoved.trim().substring(callRemoved.indexOf("("),callRemoved.trim().length()-1);
- StringTokenizer st = new StringTokenizer(parameterList,",");
- MultipleEntryHashMap parameterMap = new MultipleEntryHashMap();
- while(st.hasMoreTokens()){
- String token = st.nextToken();
- String name = token.substring(0, token.indexOf("="));
- String value = token.substring(token.indexOf("=")+1);
- parameterMap.put(name, value);
- }
-
- SOAPEnvelope envelope = null;
- try {
- msgCtx.setProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE, new Boolean(true));
- if(serviceName != null && serviceName.trim().length() > 0){
- AxisService axisService = msgCtx.getConfigurationContext().getAxisConfiguration().getService(serviceName);
- msgCtx.setAxisService(axisService);
-
- AxisOperation axisOperation = axisService.getOperationBySOAPAction("urn:"+operationName);
- if(axisOperation != null){
- msgCtx.setAxisOperation(axisOperation);
- }
- }
-
- if(operationName != null && operationName.trim().length() > 0){
- msgCtx.setSoapAction("urn:"+operationName);
- }
-
- XMPPOutTransportInfo xmppOutTransportInfo = (XMPPOutTransportInfo)msgCtx.getProperty(
- org.apache.axis2.Constants.OUT_TRANSPORT_INFO);
- //This should be only set for messages received via chat.
- //TODO : need to read from a constant
- xmppOutTransportInfo.setContentType("xmpp/text");
-
- msgCtx.setServerSide(true);
-
- //TODO : need to support SOAP12 as well
- SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
- envelope = BuilderUtil.buildsoapMessage(msgCtx, parameterMap,
- soapFactory);
- //TODO : improve error handling & messages
- } catch (AxisFault e) {
- throw new AxisFault(e.getMessage());
- } catch (OMException e) {
- throw new AxisFault(e.getMessage());
- } catch (FactoryConfigurationError e) {
- throw new AxisFault(e.getMessage());
- }
- return envelope;
- }
-
- /**
- * The actual Runnable Worker implementation which will process the
- * received XMPP messages in the worker thread pool
- */
- class Worker implements Runnable {
- private Packet packet = null;
- Worker(Packet packet) {
- this.packet = packet;
- }
-
- public void run() {
- MessageContext msgCtx = null;
- try {
- msgCtx = createMessageContext(packet);
- Object obj = msgCtx.getProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE);
- if(obj != null && ((Boolean)obj).booleanValue()){
- if(msgCtx.isProcessingFault() && msgCtx.isServerSide()){
- AxisEngine.sendFault(msgCtx);
- }else{
- AxisEngine.receive(msgCtx);
- }
- }else{
- //Send a text reply message to command received from chat client
- XMPPSender.processChatMessage(msgCtx);
- }
- } catch (AxisFault e) {
- log.error("Error occurred while sending message"+e);
- if (msgCtx != null && msgCtx.isServerSide()) {
- MessageContext faultContext;
- try {
- faultContext = MessageContextBuilder.createFaultMessageContext(msgCtx, e);
- AxisEngine.sendFault(faultContext);
- } catch (AxisFault e1) {
- log.error("Error occurred while creating SOAPFault message"+e1);
- }
- }
- }
- }
- }
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java
deleted file mode 100644
index 25943f6..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-/**
- * Holds connection details to a XMPP Server
- *
- */
-public class XMPPServerCredentials {
- private String accountName;
- private String serverUrl;
- private String password;
- private String serverType;
- private String resource;
- private String domainName;
-
- public String getAccountName() {
- return accountName;
- }
- public void setAccountName(String accountName) {
- this.accountName = accountName;
- }
- public String getServerUrl() {
- return serverUrl;
- }
- public void setServerUrl(String serverUrl) {
- this.serverUrl = serverUrl;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getServerType() {
- return serverType;
- }
- public void setServerType(String serverType) {
- this.serverType = serverType;
- }
- public String getResource() {
- return resource;
- }
- public void setResource(String resource) {
- this.resource = resource;
- }
-
- public XMPPServerCredentials() {
- super();
- this.accountName = "";
- this.serverUrl = "";
- this.password = "";
- this.serverType = "";
- this.resource = "soapserver"; //Default value
- }
-
- public XMPPServerCredentials(String accountName, String serverUrl,
- String password, String serverType, String resource) {
- super();
- this.accountName = accountName;
- this.serverUrl = serverUrl;
- this.password = password;
- this.serverType = serverType;
- this.resource = resource;
- }
- public String getDomainName() {
- return domainName;
- }
- public void setDomainName(String domainName) {
- this.domainName = domainName;
- }
-
-
-}
diff --git a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPUtils.java b/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPUtils.java
deleted file mode 100644
index ea1ab75..0000000
--- a/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPUtils.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.xmpp.util;
-
-import org.apache.axis2.AxisFault;
-
-
-public class XMPPUtils {
-
- /**
- * Extract XMPP server accountName section from transport URL passed in.
- * @param transportUrl
- * @return String
- * @throws AxisFault
- */
- public static String getAccountName(String transportUrl) throws AxisFault{
- String accountName = "";
- if(transportUrl == null){
- return null;
- }
-
- if (!transportUrl.startsWith(XMPPConstants.XMPP)) {
- throw new AxisFault ("Invalid XMPP URL : " + transportUrl +
- " Must begin with the prefix xmpp");
- }
- //eg: transportUrl is similar to xmpp://axisserver@sumedha/Version
- int start = transportUrl.indexOf("://") + 3;
- int end = transportUrl.lastIndexOf("/"); //first index
- if(start != -1 && end != -1){
- accountName = transportUrl.substring(start, end);
- }else{
- accountName = transportUrl;
- }
- return accountName;
- }
-
- /**
- * Extract Service name from transport URL passed in
- * @param transportUrl
- * @return
- * @throws AxisFault
- */
- public static String getServiceName(String transportUrl) throws AxisFault{
- String serviceName = "";
- if(transportUrl == null){
- return null;
- }
- if (!transportUrl.startsWith(XMPPConstants.XMPP)) {
- throw new AxisFault ("Invalid XMPP URL : " + transportUrl +
- " Must begin with the prefix xmpp");
- }
- //eg: transportUrl is similar to xmpp://axisserver@sumedha/Version
- int start = transportUrl.lastIndexOf("/") + 1;
- int end = transportUrl.length();
- if(start != -1 && end != -1){
- serviceName = transportUrl.substring(start, end);
- }
- return serviceName;
- }
-
-}
-
diff --git a/pom.xml b/pom.xml
index 349f094..26070d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -147,15 +147,8 @@
</scm>
<modules>
- <module>modules/base</module>
<module>modules/http</module>
- <module>modules/tcp</module>
- <module>modules/udp</module>
- <module>modules/xmpp</module>
- <module>modules/mail</module>
- <module>modules/jms</module>
<module>modules/sms</module>
- <module>modules/testkit</module>
<module>modules/all</module>
</modules>