From a4e0151a43f96247638cb3c6f2d8c0ee53d28b4f Mon Sep 17 00:00:00 2001
From: Andreas Veithen
Date: Sun, 18 Nov 2012 16:32:51 +0000
Subject: [PATCH 1/6] Created a development branch to work on AXIS-2882.
From cf18b499c4e400f6e2bc6803a7f14b99533336fb Mon Sep 17 00:00:00 2001
From: Andreas Veithen
Date: Sun, 18 Nov 2012 17:28:33 +0000
Subject: [PATCH 2/6] Some initial changes.
---
.../java/org/apache/axis/client/Call.java | 51 ++++++++++++-------
.../java/org/apache/axis/client/Service.java | 10 ++--
2 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/Call.java b/axis-rt-core/src/main/java/org/apache/axis/client/Call.java
index 9a0ce97fa3..aaadedc4e2 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/client/Call.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/client/Call.java
@@ -82,6 +82,8 @@
import java.io.StringWriter;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -332,17 +334,17 @@ public Call(Service service) {
/**
* Build a call from a URL string.
*
- * This is handy so that you don't have to manually call Call.initialize()
- * in order to register custom transports. In other words, whereas doing
- * a new URL("local:...") would fail, new Call("local:...") works because
- * we do the initialization of our own and any configured custom protocols.
- *
* @param url the target endpoint URL
* @exception MalformedURLException
*/
public Call(String url) throws MalformedURLException {
this(new Service());
- setTargetEndpointAddress(new URL(url));
+ try {
+ setTargetEndpointAddress(new URI(url));
+ } catch (URISyntaxException ex) {
+ // The method used to use new URL(...). Need this to ensure source code compatibility:
+ throw new MalformedURLException(ex.getMessage());
+ }
}
/**
@@ -803,31 +805,47 @@ public String getEncodingStyle() {
* as URI
*/
public void setTargetEndpointAddress(String address) {
- URL urlAddress;
+ // Special case: Since Axis 1.4 used java.net.URL, it accepted ":" (e.g. "local:")
+ // as a valid URL. However this is not a valid URI. If we encounter this case, we add a
+ // slash to make it a valid URI: ":/".
+ if (address.indexOf(':') == address.length() - 1) {
+ address += '/';
+ }
try {
- urlAddress = new URL(address);
+ setTargetEndpointAddress(new URI(address));
}
- catch (MalformedURLException mue) {
+ catch (URISyntaxException mue) {
throw new JAXRPCException(mue);
}
- setTargetEndpointAddress(urlAddress);
}
/**
* Sets the URL of the target Web Service.
+ *
+ * Note: Not part of JAX-RPC specification.
*
+ * @param address URL of the target Web Service
+ */
+ public void setTargetEndpointAddress(URL address) {
+ // Note: the URL#toURI method is not available in Java 1.4
+ setTargetEndpointAddress(address == null ? null : address.toString());
+ }
+
+ /**
+ * Sets the URL of the target Web Service.
+ *
* Note: Not part of JAX-RPC specification.
*
* @param address URL of the target Web Service
*/
- public void setTargetEndpointAddress(java.net.URL address) {
+ public void setTargetEndpointAddress(URI address) {
try {
if ( address == null ) {
setTransport(null);
return ;
}
- String protocol = address.getProtocol();
+ String protocol = address.getScheme();
// Handle the case where the protocol is the same but we
// just want to change the URL - if so just set the URL,
@@ -840,8 +858,8 @@ public void setTargetEndpointAddress(java.net.URL address) {
if ( this.transport != null ) {
String oldAddr = this.transport.getUrl();
if ( oldAddr != null && !oldAddr.equals("") ) {
- URL tmpURL = new URL( oldAddr );
- String oldProto = tmpURL.getProtocol();
+ URI tmpURL = new URI( oldAddr );
+ String oldProto = tmpURL.getScheme();
if ( protocol.equals(oldProto) ) {
this.transport.setUrl( address.toString() );
return ;
@@ -1623,7 +1641,7 @@ public void setOperation(QName portName, QName opName) {
}
// we reinitialize target endpoint only if we have wsdl
- this.setTargetEndpointAddress( (URL) null );
+ this.setTargetEndpointAddress( (URI) null );
Port port = wsdlService.getPort( portName.getLocalPart() );
if ( port == null ) {
@@ -1639,8 +1657,7 @@ public void setOperation(QName portName, QName opName) {
if ( obj instanceof SOAPAddress ) {
try {
SOAPAddress addr = (SOAPAddress) obj ;
- URL url = new URL(addr.getLocationURI());
- this.setTargetEndpointAddress(url);
+ this.setTargetEndpointAddress(new URI(addr.getLocationURI()));
}
catch(Exception exp) {
throw new JAXRPCException(
diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/Service.java b/axis-rt-core/src/main/java/org/apache/axis/client/Service.java
index ffdf92f848..5f93c74f9e 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/client/Service.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/client/Service.java
@@ -47,6 +47,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URL;
import java.rmi.Remote;
import java.util.HashMap;
@@ -439,7 +440,7 @@ private Remote getPort(String endpoint, QName portName,
if (portName == null) {
call = (org.apache.axis.client.Call) createCall();
if (endpoint != null) {
- call.setTargetEndpointAddress(new URL(endpoint));
+ call.setTargetEndpointAddress(new URI(endpoint));
}
} else {
call = (org.apache.axis.client.Call) createCall(portName);
@@ -494,8 +495,7 @@ public javax.xml.rpc.Call createCall(QName portName)
if (obj instanceof SOAPAddress) {
try {
SOAPAddress addr = (SOAPAddress) obj;
- URL url = new URL(addr.getLocationURI());
- call.setTargetEndpointAddress(url);
+ call.setTargetEndpointAddress(new URI(addr.getLocationURI()));
} catch (Exception exp) {
throw new ServiceException(
Messages.getMessage("cantSetURI00", "" + exp));
@@ -871,14 +871,14 @@ public void setHandlerChain(QName portName, List chain) {
/**
* Register a Transport for a particular URL.
*/
- void registerTransportForURL(URL url, Transport transport) {
+ void registerTransportForURL(URI url, Transport transport) {
transportImpls.put(url.toString(), transport);
}
/**
* Get any registered Transport object for a given URL.
*/
- Transport getTransportForURL(URL url) {
+ Transport getTransportForURL(URI url) {
return (Transport) transportImpls.get(url.toString());
}
From 985dac4296711ebc81ff789c90dbaa97db5986d6 Mon Sep 17 00:00:00 2001
From: Andreas Veithen
Date: Fri, 7 Dec 2012 20:24:34 +0000
Subject: [PATCH 3/6] More work on AXIS-2882.
---
.../org/apache/axis/client/AdminClient.java | 13 ++++++-
.../java/org/apache/axis/client/Call.java | 15 +++-----
.../java/org/apache/axis/client/Service.java | 4 +--
.../java/org/apache/axis/utils/IOUtils.java | 24 +++++++++++++
.../java/org/apache/axis/utils/Options.java | 17 +++++----
.../samples/transport/tcp/AdminClient.java | 1 -
.../java/samples/transport/tcp/GetQuote.java | 4 +--
.../java/samples/transport/tcp/Handler.java | 35 -------------------
.../samples/transport/tcp/TCPTransport.java | 12 ++++---
.../functional/TestTCPTransportSample.java | 3 +-
10 files changed, 62 insertions(+), 66 deletions(-)
delete mode 100644 samples/transport-sample/src/main/java/samples/transport/tcp/Handler.java
diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java b/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java
index 319d1459b3..d06b8904af 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java
@@ -21,6 +21,7 @@
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.deployment.wsdd.WSDDConstants;
import org.apache.axis.message.SOAPBodyElement;
+import org.apache.axis.utils.IOUtils;
import org.apache.axis.utils.Messages;
import org.apache.axis.utils.Options;
import org.apache.axis.utils.StringUtils;
@@ -30,6 +31,7 @@
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
+import java.net.URI;
import java.net.URL;
import java.util.Vector;
@@ -346,7 +348,7 @@ public void processOpts(Options opts) throws Exception {
throw new Exception(Messages.getMessage("nullCall00"));
}
- URL address = new URL(opts.getURL());
+ URI address = IOUtils.toURI(opts.getURL());
setTargetEndpointAddress(address);
setLogin(opts.getUser(), opts.getPassword());
@@ -374,6 +376,15 @@ public void setTargetEndpointAddress(URL address) {
call.setTargetEndpointAddress( address );
}
+ /**
+ * set the URL to deploy to
+ * requires that call!=null
+ * @param address
+ */
+ public void setTargetEndpointAddress(URI address) {
+ call.setTargetEndpointAddress( address );
+ }
+
/**
* set the transport to deploy with.
* requires that call!=null
diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/Call.java b/axis-rt-core/src/main/java/org/apache/axis/client/Call.java
index aaadedc4e2..80702ffd9a 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/client/Call.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/client/Call.java
@@ -51,6 +51,7 @@
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.transport.http.HTTPTransport;
import org.apache.axis.utils.ClassUtils;
+import org.apache.axis.utils.IOUtils;
import org.apache.axis.utils.JavaUtils;
import org.apache.axis.utils.Messages;
import org.apache.axis.utils.LockableHashtable;
@@ -340,7 +341,7 @@ public Call(Service service) {
public Call(String url) throws MalformedURLException {
this(new Service());
try {
- setTargetEndpointAddress(new URI(url));
+ setTargetEndpointAddress(IOUtils.toURI(url));
} catch (URISyntaxException ex) {
// The method used to use new URL(...). Need this to ensure source code compatibility:
throw new MalformedURLException(ex.getMessage());
@@ -805,14 +806,8 @@ public String getEncodingStyle() {
* as URI
*/
public void setTargetEndpointAddress(String address) {
- // Special case: Since Axis 1.4 used java.net.URL, it accepted ":" (e.g. "local:")
- // as a valid URL. However this is not a valid URI. If we encounter this case, we add a
- // slash to make it a valid URI: ":/".
- if (address.indexOf(':') == address.length() - 1) {
- address += '/';
- }
try {
- setTargetEndpointAddress(new URI(address));
+ setTargetEndpointAddress(IOUtils.toURI(address));
}
catch (URISyntaxException mue) {
throw new JAXRPCException(mue);
@@ -858,7 +853,7 @@ public void setTargetEndpointAddress(URI address) {
if ( this.transport != null ) {
String oldAddr = this.transport.getUrl();
if ( oldAddr != null && !oldAddr.equals("") ) {
- URI tmpURL = new URI( oldAddr );
+ URI tmpURL = IOUtils.toURI( oldAddr );
String oldProto = tmpURL.getScheme();
if ( protocol.equals(oldProto) ) {
this.transport.setUrl( address.toString() );
@@ -1657,7 +1652,7 @@ public void setOperation(QName portName, QName opName) {
if ( obj instanceof SOAPAddress ) {
try {
SOAPAddress addr = (SOAPAddress) obj ;
- this.setTargetEndpointAddress(new URI(addr.getLocationURI()));
+ this.setTargetEndpointAddress(addr.getLocationURI());
}
catch(Exception exp) {
throw new JAXRPCException(
diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/Service.java b/axis-rt-core/src/main/java/org/apache/axis/client/Service.java
index 5f93c74f9e..0aececafaa 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/client/Service.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/client/Service.java
@@ -440,7 +440,7 @@ private Remote getPort(String endpoint, QName portName,
if (portName == null) {
call = (org.apache.axis.client.Call) createCall();
if (endpoint != null) {
- call.setTargetEndpointAddress(new URI(endpoint));
+ call.setTargetEndpointAddress(endpoint);
}
} else {
call = (org.apache.axis.client.Call) createCall(portName);
@@ -495,7 +495,7 @@ public javax.xml.rpc.Call createCall(QName portName)
if (obj instanceof SOAPAddress) {
try {
SOAPAddress addr = (SOAPAddress) obj;
- call.setTargetEndpointAddress(new URI(addr.getLocationURI()));
+ call.setTargetEndpointAddress(addr.getLocationURI());
} catch (Exception exp) {
throw new ServiceException(
Messages.getMessage("cantSetURI00", "" + exp));
diff --git a/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java b/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java
index 411b1f9aaf..deac1c10b2 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java
@@ -18,6 +18,9 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
/**
* Utility class containing IO helper methods
@@ -62,4 +65,25 @@ public static int readFully(InputStream in, byte[] b, int off, int len)
}
}
}
+
+ /**
+ * Constructs a {@link URI} by parsing the given string. This method basically does the same as
+ * {@link URI#URI(String)}, with one exception: it accepts URIs of the form
+ * <scheme>: (e.g. local:). They are accepted by {@link URL}, but they are
+ * not valid URIs. If the passed string is of that form, the method adds a slash to make it a
+ * valid URI, i.e. it transforms <scheme>: into <scheme>:/. This ensures
+ * compatibility with Axis 1.4 (which used {@link URL} internally).
+ *
+ * @param str
+ * the string to be parsed into a URI
+ * @return the URI
+ * @throws URISyntaxException
+ * if the given string is not a valid URI
+ */
+ public static URI toURI(String str) throws URISyntaxException {
+ if (str.indexOf(':') == str.length() - 1) {
+ str += '/';
+ }
+ return new URI(str);
+ }
}
\ No newline at end of file
diff --git a/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java b/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java
index 7d0f3887e1..6789ff183f 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java
@@ -27,6 +27,8 @@
import org.apache.commons.logging.Log;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Vector;
@@ -228,17 +230,18 @@ public String getURL() throws MalformedURLException {
String servlet = null ; // -s also -f (file)
String protocol = null ;
- URL url = null ;
+ URI url = null ;
- // Just in case...
- org.apache.axis.client.Call.initialize();
-
if ( (tmp = isValueSet( 'l' )) != null ) {
- url = new URL( tmp );
+ try {
+ url = IOUtils.toURI( tmp );
+ } catch (URISyntaxException ex) {
+ throw new MalformedURLException(ex.getMessage());
+ }
host = url.getHost();
port = "" + url.getPort();
- servlet = url.getFile();
- protocol = url.getProtocol();
+ servlet = url.getPath();
+ protocol = url.getScheme();
}
if ( (tmp = isValueSet( 'f' )) != null ) {
diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java b/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java
index 348c2aa0db..bfc3a451b7 100644
--- a/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java
+++ b/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java
@@ -33,7 +33,6 @@
public class AdminClient extends org.apache.axis.client.AdminClient {
public static void main(String args[]) {
- Call.addTransportPackage("samples.transport");
Call.setTransportForProtocol("tcp", TCPTransport.class);
// Deploy the transport on top of the default client configuration.
diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java b/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java
index 209dc7b473..a5fa397d8f 100644
--- a/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java
+++ b/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java
@@ -28,7 +28,6 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
-import java.net.URL;
/**
*
@@ -39,7 +38,6 @@ public class GetQuote {
// helper function; does all the real work
public float getQuote (String args[]) throws Exception {
- Call.addTransportPackage("samples.transport");
Call.setTransportForProtocol("tcp", TCPTransport.class);
Options opts = new Options( args );
@@ -65,7 +63,7 @@ public float getQuote (String args[]) throws Exception {
call.setTransport(new TCPTransport());
- call.setTargetEndpointAddress( new URL(opts.getURL()) );
+ call.setTargetEndpointAddress(opts.getURL());
call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") );
call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_FLOAT );
diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/Handler.java b/samples/transport-sample/src/main/java/samples/transport/tcp/Handler.java
deleted file mode 100644
index ad4e6c6654..0000000000
--- a/samples/transport-sample/src/main/java/samples/transport/tcp/Handler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2001-2004 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 samples.transport.tcp;
-
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-
-/**
- * A stub URLStreamHandler, so the system will recognize our
- * custom URLs as valid.
- *
- * @author Glen Daniels (gdaniels@apache.org)
- */
-public class Handler extends URLStreamHandler
-{
- protected URLConnection openConnection(URL u)
- {
- return null;
- }
-}
diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java b/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java
index b641ff3724..384c278285 100644
--- a/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java
+++ b/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java
@@ -17,13 +17,15 @@
package samples.transport.tcp;
import org.apache.axis.AxisEngine;
+import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Transport;
import org.apache.axis.components.logger.LogFactory;
import org.apache.commons.logging.Log;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
/**
*
@@ -63,17 +65,17 @@ public TCPTransport (String host, String port) {
*/
public void setupMessageContextImpl(MessageContext mc,
Call call,
- AxisEngine engine)
+ AxisEngine engine) throws AxisFault
{
try {
String urlString = mc.getStrProp(MessageContext.TRANS_URL);
if (urlString != null) {
- URL url = new URL(urlString);
+ URI url = new URI(urlString);
host = url.getHost();
port = new Integer(url.getPort()).toString();
}
- } catch (java.net.MalformedURLException e) {
- // Do nothing here?
+ } catch (URISyntaxException ex) {
+ throw AxisFault.makeFault(ex);
}
if (host != null) mc.setProperty(HOST, host);
diff --git a/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java b/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java
index da7c322e04..0c1acbc361 100644
--- a/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java
+++ b/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java
@@ -33,7 +33,6 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
-import java.net.URL;
/** Test the stock sample code.
*/
@@ -74,7 +73,7 @@ public void doTestStock() throws Exception {
Call call = (Call) service.createCall();
- call.setTargetEndpointAddress( new URL(uri) );
+ call.setTargetEndpointAddress(uri);
call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") );
call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_FLOAT );
From 348b6bb4cf35dc4808fae3d2dc02dbaa876d8b53 Mon Sep 17 00:00:00 2001
From: Andreas Veithen
Date: Mon, 10 Dec 2012 12:39:58 +0000
Subject: [PATCH 4/6] Removed two files that should have been deleted by the
last merge from trunk.
---
.../java/org/apache/axis/model/wsdd/Flow.java | 44 ------
.../apache/axis/model/wsdd/impl/FlowImpl.java | 145 ------------------
2 files changed, 189 deletions(-)
delete mode 100644 axis-model/src/main/java/org/apache/axis/model/wsdd/Flow.java
delete mode 100644 axis-model/src/main/java/org/apache/axis/model/wsdd/impl/FlowImpl.java
diff --git a/axis-model/src/main/java/org/apache/axis/model/wsdd/Flow.java b/axis-model/src/main/java/org/apache/axis/model/wsdd/Flow.java
deleted file mode 100644
index a0f5486c85..0000000000
--- a/axis-model/src/main/java/org/apache/axis/model/wsdd/Flow.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *
- *
- *
- * $Id$
- */
-package org.apache.axis.model.wsdd;
-
-import java.util.List;
-
-
-/**
- *
- * A representation of the model object 'Flow'.
- *
- *
- *
- * The following features are supported:
- *
- * - {@link org.apache.axis.model.wsdd.Flow#getHandlers Handlers}
- *
- *
- *
- * @model
- * @generated
- */
-public interface Flow {
-
- /**
- * Returns the value of the 'Handlers' containment reference list.
- * The list contents are of type {@link org.apache.axis.model.wsdd.Handler}.
- *
- *
- * If the meaning of the 'Handlers' reference list isn't clear,
- * there really should be more of a description here...
- *
- *
- * @return the value of the 'Handlers' containment reference list.
- * @model type="org.apache.axis.model.wsdd.Handler" containment="true"
- * extendedMetaData="name='handler' kind='element' namespace='##targetNamespace'"
- * @generated
- */
- List getHandlers();
-} // Flow
diff --git a/axis-model/src/main/java/org/apache/axis/model/wsdd/impl/FlowImpl.java b/axis-model/src/main/java/org/apache/axis/model/wsdd/impl/FlowImpl.java
deleted file mode 100644
index d94d9135c0..0000000000
--- a/axis-model/src/main/java/org/apache/axis/model/wsdd/impl/FlowImpl.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- *
- *
- *
- * $Id$
- */
-package org.apache.axis.model.wsdd.impl;
-
-import java.util.Collection;
-import java.util.List;
-import org.apache.axis.model.wsdd.Flow;
-
-import org.apache.axis.model.wsdd.Handler;
-import org.eclipse.emf.common.notify.NotificationChain;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.impl.EObjectImpl;
-import org.eclipse.emf.ecore.util.BasicInternalEList;
-import org.eclipse.emf.ecore.util.InternalEList;
-
-/**
- *
- * An implementation of the model object 'Flow'.
- *
- *
- * The following features are implemented:
- *
- * - {@link org.apache.axis.model.wsdd.impl.FlowImpl#getHandlers Handlers}
- *
- *
- *
- * @generated
- */
-public class FlowImpl extends EObjectImpl implements Flow {
- /**
- * The cached value of the '{@link #getHandlers() Handlers}' containment reference list.
- *
- *
- * @see #getHandlers()
- * @generated
- * @ordered
- */
- protected EList handlers;
-
- /**
- *
- *
- * @generated
- */
- protected FlowImpl() {
- super();
- }
-
- /**
- *
- *
- * @generated
- */
- protected EClass eStaticClass() {
- return WSDDPackageImpl.Literals.FLOW;
- }
-
- /**
- *
- *
- * @generated
- */
- public List getHandlers() {
- if (handlers == null) {
- handlers = new BasicInternalEList(Handler.class);
- }
- return handlers;
- }
-
- /**
- *
- *
- * @generated
- */
- public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
- switch (featureID) {
- case WSDDPackageImpl.FLOW__HANDLERS:
- return ((InternalEList)getHandlers()).basicRemove(otherEnd, msgs);
- }
- return super.eInverseRemove(otherEnd, featureID, msgs);
- }
-
- /**
- *
- *
- * @generated
- */
- public Object eGet(int featureID, boolean resolve, boolean coreType) {
- switch (featureID) {
- case WSDDPackageImpl.FLOW__HANDLERS:
- return getHandlers();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- *
- *
- * @generated
- */
- public void eSet(int featureID, Object newValue) {
- switch (featureID) {
- case WSDDPackageImpl.FLOW__HANDLERS:
- getHandlers().clear();
- getHandlers().addAll((Collection)newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- *
- *
- * @generated
- */
- public void eUnset(int featureID) {
- switch (featureID) {
- case WSDDPackageImpl.FLOW__HANDLERS:
- getHandlers().clear();
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- *
- *
- * @generated
- */
- public boolean eIsSet(int featureID) {
- switch (featureID) {
- case WSDDPackageImpl.FLOW__HANDLERS:
- return handlers != null && !handlers.isEmpty();
- }
- return super.eIsSet(featureID);
- }
-
-} //FlowImpl
From aa4f91675de1abf2d6f5c658ab0cc9cf083c2dc6 Mon Sep 17 00:00:00 2001
From: Andreas Veithen
Date: Mon, 10 Dec 2012 14:00:31 +0000
Subject: [PATCH 5/6] More work on AXIS-2882.
---
.../wsdl/toJava/JavaServiceImplWriter.java | 32 ++++++++++++++++
.../axis/wsdl/toJava/JavaStubWriter.java | 11 ++++++
.../axis/utils/DummyURLStreamHandler.java | 31 +++++++++++++++
.../java/org/apache/axis/utils/IOUtils.java | 18 +++++++++
.../org/apache/axis/utils/IOUtilsTest.java | 38 +++++++++++++++++++
.../java/samples/jms/stub/JMSURLStubTest.java | 6 +--
6 files changed, 131 insertions(+), 5 deletions(-)
create mode 100644 axis-rt-core/src/main/java/org/apache/axis/utils/DummyURLStreamHandler.java
create mode 100644 axis-rt-core/src/test/java/org/apache/axis/utils/IOUtilsTest.java
diff --git a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java
index 1bfaa7b6bc..43266b77a1 100644
--- a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java
+++ b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java
@@ -256,6 +256,8 @@ protected void writeFileBody(PrintWriter pw) throws IOException {
writeGetPortName(pw, bindingType, portName);
writeGetPortNameURL(pw, bindingType, portName, stubClass,
wsddServiceName);
+ writeGetPortNameString(pw, bindingType, portName, stubClass,
+ wsddServiceName);
writeSetPortEndpointAddress(pw, portName);
}
@@ -409,6 +411,36 @@ protected void writeGetPortNameURL(PrintWriter pw, String bindingType,
pw.println();
} // writeGetPortNameURL
+ /**
+ * Write the get(String) method.
+ *
+ * @param pw
+ * @param bindingType
+ * @param portName
+ * @param stubClass
+ * @param wsddServiceName
+ */
+ protected void writeGetPortNameString(PrintWriter pw, String bindingType,
+ String portName, String stubClass,
+ String wsddServiceName) {
+
+ pw.println(" public " + bindingType + " get" + portName
+ + "(java.lang.String portAddress) throws "
+ + javax.xml.rpc.ServiceException.class.getName() + " {");
+ pw.println(" try {");
+ pw.println(" " + stubClass + " _stub = new " + stubClass
+ + "(portAddress, this);");
+ pw.println(" _stub.setPortName(get" + wsddServiceName
+ + "());");
+ pw.println(" return _stub;");
+ pw.println(" }");
+ pw.println(" catch (org.apache.axis.AxisFault e) {");
+ pw.println(" return null;");
+ pw.println(" }");
+ pw.println(" }");
+ pw.println();
+ } // writeGetPortNameURL
+
/**
* Write the setEndpointAddress(String) method.
*
diff --git a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java
index a93cd98648..83666a1d46 100644
--- a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java
+++ b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java
@@ -187,6 +187,17 @@ protected void writeFileBody(PrintWriter pw) throws IOException {
pw.println(" super.cachedEndpoint = endpointURL;");
pw.println(" }");
pw.println();
+ pw.println(
+ " public " + className
+ + "(java.lang.String endpoint, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {");
+ pw.println(" this(service);");
+ pw.println(" try {");
+ pw.println(" super.cachedEndpoint = org.apache.axis.utils.IOUtils.toURL(endpoint);");
+ pw.println(" } catch (java.net.MalformedURLException ex) {");
+ pw.println(" throw org.apache.axis.AxisFault.makeFault(ex);");
+ pw.println(" }");
+ pw.println(" }");
+ pw.println();
pw.println(
" public " + className
+ "(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {");
diff --git a/axis-rt-core/src/main/java/org/apache/axis/utils/DummyURLStreamHandler.java b/axis-rt-core/src/main/java/org/apache/axis/utils/DummyURLStreamHandler.java
new file mode 100644
index 0000000000..328629e536
--- /dev/null
+++ b/axis-rt-core/src/main/java/org/apache/axis/utils/DummyURLStreamHandler.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis.utils;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+final class DummyURLStreamHandler extends URLStreamHandler {
+ static final DummyURLStreamHandler INSTANCE = new DummyURLStreamHandler();
+
+ protected URLConnection openConnection(URL u) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java b/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java
index deac1c10b2..cb9d77af30 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java
@@ -18,9 +18,11 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLStreamHandler;
/**
* Utility class containing IO helper methods
@@ -86,4 +88,20 @@ public static URI toURI(String str) throws URISyntaxException {
}
return new URI(str);
}
+
+ /**
+ * Constructs a {@link URL} by parsing the given string. This method does the same as
+ * {@link URL#URL(String)}, except that it configures the URL with a dummy
+ * {@link URLStreamHandler}. This means that the method works for URIs with any protocol, not
+ * just protocols for which a {@link URLStreamHandler} is registered.
+ *
+ * @param str
+ * the string to be parsed into a URL
+ * @return the URL
+ * @throws MalformedURLException
+ * if the given string is not a valid URL
+ */
+ public static URL toURL(String str) throws MalformedURLException {
+ return new URL(null, str, DummyURLStreamHandler.INSTANCE);
+ }
}
\ No newline at end of file
diff --git a/axis-rt-core/src/test/java/org/apache/axis/utils/IOUtilsTest.java b/axis-rt-core/src/test/java/org/apache/axis/utils/IOUtilsTest.java
new file mode 100644
index 0000000000..db6cee0cfd
--- /dev/null
+++ b/axis-rt-core/src/test/java/org/apache/axis/utils/IOUtilsTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis.utils;
+
+import java.net.URI;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+public class IOUtilsTest extends TestCase {
+ public void testToURIParticularCase() throws Exception {
+ URI uri = IOUtils.toURI("local:");
+ assertEquals("local", uri.getScheme());
+ assertEquals("/", uri.getPath());
+ }
+
+ public void testToURL() throws Exception {
+ String s = "fancyp://user:password@localhost:8888/dest?prop=value";
+ URL url = IOUtils.toURL(s);
+ assertEquals(s, url.toString());
+ }
+}
diff --git a/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java b/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java
index be4402dad0..806c6ccfac 100644
--- a/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java
+++ b/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java
@@ -25,8 +25,6 @@
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
@@ -57,12 +55,10 @@ public static Float getQuote(String endptAddr, String ticker) throws AxisFault {
}
try {
- getQuote = locator.getGetQuote(new URL(endptAddr));
+ getQuote = locator.getGetQuote(endptAddr);
}
catch (ServiceException e) {
throw new AxisFault("JAX-RPC ServiceException caught: ", e);
- } catch (MalformedURLException e) {
- throw new AxisFault("MalformedURLException caught: ", e);
}
assertTrue("getQuote is null", getQuote != null);
From 8f7b440d1b64ec4108eded50a2cde7742544d129 Mon Sep 17 00:00:00 2001
From: Andreas Veithen
Date: Mon, 10 Dec 2012 15:50:26 +0000
Subject: [PATCH 6/6] More work on AXIS-2882.
---
.../java/org/apache/axis/transport/local/LocalSender.java | 7 ++++---
.../src/main/java/samples/jms/dii/JMSURLTest.java | 7 +------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java b/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java
index 1e9cec04ce..26962fbccd 100644
--- a/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java
+++ b/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java
@@ -26,10 +26,11 @@
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPFault;
import org.apache.axis.server.AxisServer;
+import org.apache.axis.utils.IOUtils;
import org.apache.axis.utils.Messages;
import org.apache.commons.logging.Log;
-import java.net.URL;
+import java.net.URI;
/**
* This is meant to be used on a SOAP Client to call a SOAP server.
@@ -114,8 +115,8 @@ public void invoke(MessageContext clientContext) throws AxisFault {
String transURL = clientContext.getStrProp(MessageContext.TRANS_URL);
if (transURL != null) {
try {
- URL url = new URL(transURL);
- String file = url.getFile();
+ URI url = IOUtils.toURI(transURL);
+ String file = url.getPath();
if (file.length()>0 && file.charAt(0)=='/') {
file = file.substring(1);
}
diff --git a/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java b/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java
index 409ba464e4..b79f63ce99 100644
--- a/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java
+++ b/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java
@@ -108,8 +108,7 @@ public static Float getQuote(String ticker, String username, String password)
try
{
- java.net.URL jmsurl = new java.net.URL(sampleJmsUrl);
- call.setTargetEndpointAddress(jmsurl);
+ call.setTargetEndpointAddress(sampleJmsUrl);
// set additional params on the call if desired
call.setUsername(username);
@@ -118,10 +117,6 @@ public static Float getQuote(String ticker, String username, String password)
res = (Float) call.invoke(new Object[] {ticker});
}
- catch (java.net.MalformedURLException e)
- {
- throw new AxisFault("Invalid JMS URL", e);
- }
catch (java.rmi.RemoteException e)
{
throw new AxisFault("Failed in getQuote()", e);