use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.
the class DeploymentDescriptorParser method parse.
/**
* Parses the {@code sun-jaxws.xml} file and configures
* a set of {@link HttpAdapter}s.
*/
@NotNull
public List<A> parse(String systemId, InputStream is) {
XMLStreamReader reader = null;
try {
reader = new TidyXMLStreamReader(XMLStreamReaderFactory.create(systemId, is, true), is);
XMLStreamReaderUtil.nextElementContent(reader);
return parseAdapters(reader);
} finally {
if (reader != null) {
try {
reader.close();
} catch (XMLStreamException e) {
throw new ServerRtException("runtime.parser.xmlReader", e);
}
}
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.
the class ServerMgr method createContext.
/*
* Creates a HttpContext at the given address. If there is already a server
* it uses that server to create a context. Otherwise, it creates a new
* HTTP server. This sever is added to servers Map.
*/
/*package*/
HttpContext createContext(String address) {
try {
HttpServer server;
ServerState state;
URL url = new URL(address);
int port = url.getPort();
if (port == -1) {
port = url.getDefaultPort();
}
InetSocketAddress inetAddress = new InetSocketAddress(url.getHost(), port);
synchronized (servers) {
state = servers.get(inetAddress);
if (state == null) {
ServerState free = null;
for (ServerState ss : servers.values()) {
if (port == ss.getServer().getAddress().getPort()) {
free = ss;
break;
}
}
if (inetAddress.getAddress().isAnyLocalAddress() && free != null) {
state = free;
} else {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Creating new HTTP Server at " + inetAddress);
}
// Creates server with default socket backlog
server = HttpServer.create(inetAddress, 0);
server.setExecutor(Executors.newCachedThreadPool());
String path = url.toURI().getPath();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Creating HTTP Context at = " + path);
}
HttpContext context = server.createContext(path);
server.start();
// we have to get actual inetAddress from server, which can differ from the original in some cases.
// e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation,
// or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address
inetAddress = server.getAddress();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("HTTP server started = " + inetAddress);
}
state = new ServerState(server, path);
servers.put(inetAddress, state);
return context;
}
}
}
server = state.getServer();
if (state.getPaths().contains(url.getPath())) {
String err = "Context with URL path " + url.getPath() + " already exists on the server " + server.getAddress();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine(err);
}
throw new IllegalArgumentException(err);
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Creating HTTP Context at = " + url.getPath());
}
HttpContext context = server.createContext(url.getPath());
state.oneMoreContext(url.getPath());
return context;
} catch (Exception e) {
throw new ServerRtException("server.rt.err", e);
}
}
Aggregations