I'm working on a prototype implementation of a bundle that publishes JAX-WS
endpoints for specially marked services. (I realize there are off the shelf
implementations of various tools that ought to do the same thing, but right
now I'm just getting my feet wet.)
I've actually been able to get the endpoint published just fine, using
something like this:
private Object startEndpoint(ServiceReference reference) {
Object service = getBundleContext().getService(reference);
if (service != null) {
ClassLoader originalClassLoader =
Thread.currentThread().getContextClassLoader();
try {
Object instance = createEndpointImpl(service);
Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
endpoint = Endpoint.create(instance);
endpoint.setMetadata(getMetadata(reference));
// TODO: remove hard-coded port number
endpoint.publish("http://0.0.0.0:7001/hello/");
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
return service;
}
The problem I'm running to, however, is with setting the endpoint metadata;
this is a list of the WSDLs and schema types used to generate the endpoint.
(Without specifying this JAX-WS attempt to create one at runtime; it manages
to get close, but close isn't enough.)
What I've been trying to do is get these files from the API bundle using
Bundle.findEntries(), something like this:
Enumeration<?> entryEnumeration =
serviceBundle.findEntries("/META-INF/wsdls", null, true);
// enumeration can be null if path isn't found
if (entryEnumeration != null) {
while (entryEnumeration.hasMoreElements()) {
URL entry = (URL)entryEnumeration.nextElement();
try {
md.add(new
StreamSource(entry.openConnection().getInputStream()));
} catch (IOException e) {
// TODO: do something
}
}
}
This actually works exactly what I want: I get a list of StreamSources to
the URLs' input streams. However, when the endpoint is published I'm
getting a MalformedURLException because the URL is using a bundle: protocol,
which isn't known.
Based on my searching I expect that Felix will start by default with the URL
Handlers Service started, no? So why can't these URLs be resolved? I'm
guessing I'm missing something silly...
Thanks,
Rich