Author: jliu
Date: Thu Nov 22 23:08:49 2007
New Revision: 597577
URL: http://svn.apache.org/viewvc?rev=597577&view=rev
Log:
Support JAX-WS 2.1 Endpoint.getEndpointReference() etc.
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/BindingImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/http/HTTPBindingImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Thu Nov 22 23:08:49 2007
@@ -24,23 +24,29 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
+import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.ws.Binding;
import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.WebServicePermission;
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.soap.MTOM;
import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
import org.w3c.dom.Element;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.binding.BindingConfiguration;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
import org.apache.cxf.configuration.Configurable;
import org.apache.cxf.configuration.Configurer;
@@ -67,6 +73,7 @@
private static final WebServicePermission PUBLISH_PERMISSION =
new WebServicePermission("publishEndpoint");
+ private static final Logger LOG =
LogUtils.getL7dLogger(EndpointImpl.class);
private Bus bus;
private Object implementor;
@@ -251,6 +258,7 @@
ServerImpl serv = getServer(addr);
if (addr != null) {
serv.getEndpoint().getEndpointInfo().setAddress(addr);
+ this.address = addr;
}
serv.start();
}
@@ -336,6 +344,11 @@
//hold onto the wsdl location so cache won't clear till we go
away
setWsdlLocation(serverFactory.getWsdlURL());
}
+
+ if (serviceName == null) {
+
setServiceName(serverFactory.getServiceFactory().getServiceQName());
+ }
+
}
return (ServerImpl) server;
}
@@ -474,13 +487,38 @@
this.schemaLocations = schemaLocations;
}
- //TODO JAX-WS 2.1
public EndpointReference getEndpointReference(Element...
referenceParameters) {
- throw new UnsupportedOperationException();
+ if (!isPublished()) {
+ throw new WebServiceException(new
Message("ENDPOINT_NOT_PUBLISHED", LOG).toString());
+ }
+
+ String bindingId = getBinding().getBindingID();
+ if (!"http://schemas.xmlsoap.org/soap/".equals(bindingId)) {
+ throw new UnsupportedOperationException(new
Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING",
+
LOG).toString());
+ }
+
+ W3CEndpointReferenceBuilder builder = new
W3CEndpointReferenceBuilder();
+ builder.address(address);
+ builder.serviceName(serviceName);
+ builder.endpointName(endpointName);
+ if (referenceParameters != null) {
+ for (Element referenceParameter : referenceParameters) {
+ builder.referenceParameter(referenceParameter);
+ }
+ }
+ builder.wsdlDocumentLocation(wsdlLocation);
+
+ return builder.build();
}
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz,
Element...
referenceParameters) {
- throw new UnsupportedOperationException();
+ if (W3CEndpointReference.class.isAssignableFrom(clazz)) {
+ return clazz.cast(getEndpointReference(referenceParameters));
+ } else {
+ throw new WebServiceException(new
Message("ENDPOINTREFERENCE_TYPE_NOT_SUPPORTED", LOG, clazz
+ .getName()).toString());
+ }
}
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties
Thu Nov 22 23:08:49 2007
@@ -49,3 +49,7 @@
SEI_METHOD_NOT_FOUND = Service class {1} does not implement the {0} method.
SEI_NO_WEBSERVICE_ANNOTATION = Service endpoint interface class {0} does not
have a javax.jws.WebService annotation.
COULD_NOT_LOAD_CLASS = Unable to load the class {0}.
+
+ENDPOINT_NOT_PUBLISHED = Endpoing has not been published yet.
+ENDPOINTREFERENCE_TYPE_NOT_SUPPORTED = Class type {0} is not a subclass of
EndpointReference or the Endpoint implementation does not support
EndpointReferences of this type.
+GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING = getEndpointReference is not
supported if the binding is not SOAP 1.1/HTTP or SOAP 1.2/HTTP.
\ No newline at end of file
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/BindingImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/BindingImpl.java?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/BindingImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/BindingImpl.java
Thu Nov 22 23:08:49 2007
@@ -25,7 +25,7 @@
import javax.xml.ws.Binding;
import javax.xml.ws.handler.Handler;
-public class BindingImpl implements Binding {
+public abstract class BindingImpl implements Binding {
private List<Handler> handlerChain = new ArrayList<Handler>();
public List<Handler> getHandlerChain() {
@@ -36,8 +36,5 @@
handlerChain = hc;
}
- public String getBindingID() {
- // TODO
- throw new UnsupportedOperationException();
- }
+ public abstract String getBindingID();
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/http/HTTPBindingImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/http/HTTPBindingImpl.java?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/http/HTTPBindingImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/http/HTTPBindingImpl.java
Thu Nov 22 23:08:49 2007
@@ -29,4 +29,8 @@
public HTTPBindingImpl(BindingInfo sb) {
}
+ public String getBindingID() {
+ //REVISIT: JIRA CXF-613
+ return "http://cxf.apache.org/bindings/xformat";
+ }
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
Thu Nov 22 23:08:49 2007
@@ -119,6 +119,11 @@
}
}
return null;
+ }
+
+ public String getBindingID() {
+ //REVISIT: JIRA CXF-613
+ return "http://schemas.xmlsoap.org/soap/";
}
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
Thu Nov 22 23:08:49 2007
@@ -93,8 +93,7 @@
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(cos);
try {
- //TODO: when serviceName/portName is null
-
+ //TODO: when serviceName/portName is null
writer.setPrefix("wsa", W3C_NS);
String portNamePrefix = null;
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Thu Nov 22 23:08:49 2007
@@ -34,7 +34,6 @@
import org.apache.cxf.endpoint.EndpointImpl;
import org.apache.cxf.feature.AbstractFeature;
import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.jaxws.binding.BindingImpl;
import org.apache.cxf.jaxws.binding.http.HTTPBindingImpl;
import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor;
@@ -214,8 +213,6 @@
}
} else if (getBinding() instanceof XMLBinding) {
jaxwsBinding = new HTTPBindingImpl(getEndpointInfo().getBinding());
- } else {
- jaxwsBinding = new BindingImpl();
- }
+ }
}
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java?rev=597577&r1=597576&r2=597577&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
Thu Nov 22 23:08:49 2007
@@ -151,7 +151,6 @@
}
@Test
- @Ignore("Not implemented yet")
public void testEndpointGetEndpointReferenceSOAPBinding() throws Exception
{
GreeterImpl greeter = new GreeterImpl();
EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
(String)null);
@@ -162,10 +161,9 @@
Document doc = XMLUtils.parse(is);
Element referenceParameters =
XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
"wsa:ReferenceParameters",
-
"wsa:ReferenceParameters");
+ "");
EndpointReference endpointReference =
endpoint.getEndpointReference(referenceParameters);
assertNotNull(endpointReference);
-
assertTrue(endpointReference instanceof W3CEndpointReference);
//A returned W3CEndpointReferenceMUST also contain the specified
referenceParameters.
@@ -177,7 +175,8 @@
@Test
@Ignore("Not implemented yet")
public void testEndpointGetEndpointReferenceXMLBinding() throws Exception {
- GreeterImpl greeter = new GreeterImpl();
+ org.apache.hello_world_xml_http.bare.Greeter greeter =
+ new org.apache.hello_world_xml_http.bare.GreeterImpl();
EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
(String)null);
endpoint.publish("http://localhost:8080/test");
@@ -187,7 +186,7 @@
Document doc = XMLUtils.parse(is);
Element referenceParameters =
XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
"wsa:ReferenceParameters",
-
"wsa:ReferenceParameters");
+
"");
endpoint.getEndpointReference(referenceParameters);
fail("Did not get expected UnsupportedOperationException");
@@ -199,7 +198,6 @@
}
@Test
- @Ignore("Not implemented yet")
public void testEndpointGetEndpointReferenceW3C() throws Exception {
GreeterImpl greeter = new GreeterImpl();
EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
(String)null);
@@ -210,7 +208,7 @@
Document doc = XMLUtils.parse(is);
Element referenceParameters =
XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
"wsa:ReferenceParameters",
-
"wsa:ReferenceParameters");
+ "");
EndpointReference endpointReference =
endpoint.getEndpointReference(W3CEndpointReference.class,
referenceParameters);
assertNotNull(endpointReference);
@@ -225,7 +223,6 @@
@Test
- @Ignore("Not implemented yet")
public void testEndpointGetEndpointReferenceInvalid() throws Exception {
GreeterImpl greeter = new GreeterImpl();
EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
(String)null);