< prev index next >
jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/transport/http/server/EndpointImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -67,17 +67,15 @@
import org.w3c.dom.Element;
/**
* Implements {@link Endpoint}.
- * <p/>
- * <p/>
+ *
* This class accumulates the information necessary to create
* {@link WSEndpoint}, and then when {@link #publish} method
* is called it will be created.
- * <p/>
- * <p/>
+ *
* This object also allows accumulated information to be retrieved.
*
* @author Jitendra Kotamraju
*/
public class EndpointImpl extends Endpoint {
@@ -203,18 +201,21 @@
implementor = null; // this violates the semantics, but hey, this is a backdoor.
implClass = null;
invoker = null;
}
+ @Override
public Binding getBinding() {
return binding;
}
+ @Override
public Object getImplementor() {
return implementor;
}
+ @Override
public void publish(String address) {
canPublish();
URL url;
try {
url = new URL(address);
@@ -230,62 +231,72 @@
}
createEndpoint(url.getPath());
((HttpEndpoint) actualEndpoint).publish(address);
}
+ @Override
public void publish(Object serverContext) {
canPublish();
if (!com.sun.net.httpserver.HttpContext.class.isAssignableFrom(serverContext.getClass())) {
throw new IllegalArgumentException(serverContext.getClass() + " is not a supported context.");
}
createEndpoint(((com.sun.net.httpserver.HttpContext)serverContext).getPath());
((HttpEndpoint) actualEndpoint).publish(serverContext);
}
+ @Override
public void publish(HttpContext serverContext) {
canPublish();
createEndpoint(serverContext.getPath());
((HttpEndpoint) actualEndpoint).publish(serverContext);
}
+ @Override
public void stop() {
if (isPublished()) {
((HttpEndpoint) actualEndpoint).stop();
actualEndpoint = null;
stopped = true;
}
}
+ @Override
public boolean isPublished() {
return actualEndpoint != null;
}
+ @Override
public List<Source> getMetadata() {
return metadata;
}
+ @Override
public void setMetadata(java.util.List<Source> metadata) {
if (isPublished()) {
throw new IllegalStateException("Cannot set Metadata. Endpoint is already published");
}
this.metadata = metadata;
}
+ @Override
public Executor getExecutor() {
return executor;
}
+ @Override
public void setExecutor(Executor executor) {
this.executor = executor;
}
+ @Override
public Map<String, Object> getProperties() {
- return new HashMap<String, Object>(properties);
+ return new HashMap<>(properties);
}
+ @Override
public void setProperties(Map<String, Object> map) {
- this.properties = new HashMap<String, Object>(map);
+ this.properties = new HashMap<>(map);
}
/*
* Checks the permission of "publishEndpoint" before accessing HTTP classes.
* Also it checks if there is an available HTTP server implementation.
@@ -333,27 +344,21 @@
/**
* Convert metadata sources using identity transform. So that we can
* reuse the Source object multiple times.
*/
private List<SDDocumentSource> buildDocList() {
- List<SDDocumentSource> r = new ArrayList<SDDocumentSource>();
+ List<SDDocumentSource> r = new ArrayList<>();
if (metadata != null) {
for (Source source : metadata) {
try {
XMLStreamBufferResult xsbr = XmlUtil.identityTransform(source, new XMLStreamBufferResult());
String systemId = source.getSystemId();
r.add(SDDocumentSource.create(new URL(systemId), xsbr.getXMLStreamBuffer()));
- } catch (TransformerException te) {
+ } catch (TransformerException | IOException | SAXException | ParserConfigurationException te) {
throw new ServerRtException("server.rt.err", te);
- } catch (IOException te) {
- throw new ServerRtException("server.rt.err", te);
- } catch (SAXException e) {
- throw new ServerRtException("server.rt.err", e);
- } catch (ParserConfigurationException e) {
- throw new ServerRtException("server.rt.err", e);
}
}
}
return r;
@@ -365,15 +370,10 @@
private @Nullable SDDocumentSource getPrimaryWsdl(MetadataReader metadataReader) {
// Takes care of @WebService, @WebServiceProvider's wsdlLocation
EndpointFactory.verifyImplementorClass(implClass, metadataReader);
String wsdlLocation = EndpointFactory.getWsdlLocation(implClass, metadataReader);
if (wsdlLocation != null) {
- ClassLoader cl = implClass.getClassLoader();
- URL url = cl.getResource(wsdlLocation);
- if (url != null) {
- return SDDocumentSource.create(url);
- }
return SDDocumentSource.create(implClass, wsdlLocation);
}
return null;
}
@@ -386,14 +386,16 @@
throw new IllegalStateException(
"Cannot publish this endpoint. Endpoint has been already stopped.");
}
}
+ @Override
public EndpointReference getEndpointReference(Element...referenceParameters) {
return getEndpointReference(W3CEndpointReference.class, referenceParameters);
}
+ @Override
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element...referenceParameters) {
if (!isPublished()) {
throw new WebServiceException("Endpoint is not published yet");
}
return ((HttpEndpoint)actualEndpoint).getEndpointReference(clazz,referenceParameters);
@@ -456,17 +458,16 @@
@Override
public void start(@NotNull WSWebServiceContext wsc, @NotNull WSEndpoint endpoint) {
try {
spiInvoker.inject(wsc);
- } catch (IllegalAccessException e) {
- throw new WebServiceException(e);
- } catch (InvocationTargetException e) {
+ } catch (IllegalAccessException | InvocationTargetException e) {
throw new WebServiceException(e);
}
}
+ @Override
public Object invoke(@NotNull Packet p, @NotNull Method m, @NotNull Object... args) throws InvocationTargetException, IllegalAccessException {
return spiInvoker.invoke(m, args);
}
}
}
< prev index next >