Hello,
Since a long time I use jersey for webservice. In my case i need to send
a request to my WS for reload all the resource.
here is the solution i was using (based on conversation on this list
called [Jersey] restart a resource ) :
I have overriden the servlet container :
public class CstlServletContainer extends ServletContainer {
public static boolean configured = false;
@Override
protected void configure(final ServletConfig sc, ResourceConfig rc, WebApplication wa) {
super.configure(sc, rc, wa);
if (!configured) {
final ContainerNotifierImpl cnImpl = new ContainerNotifierImpl();
rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_NOTIFIER, cnImpl);
rc.getSingletons().add(new ContextInjectableProvider<ContainerNotifierImpl>(ContainerNotifierImpl.class, cnImpl));
configured = true;
}
}
private static class ContextInjectableProvider<T> extends SingletonTypeInjectableProvider<Context, T> {
ContextInjectableProvider(Type type, T instance) {
super(type, instance);
}
}
}
I have a container notifier :
public class ContainerNotifierImpl implements ContainerNotifier {
private List<ContainerListener> cls;
public ContainerNotifierImpl() {
cls = new ArrayList<ContainerListener>();
}
public void addListener(ContainerListener arg0) {
cls.add(arg0);
}
public void reload() {
for ( ContainerListener cl : cls) {
cl.onReload();
}
}
}
And i one of my resource i call the containerNotifier to restart all the
singleton resource:
@Path("configuration")
@Singleton
public final class ConfigurationService extends AbstractWebService {
@Context
private ContainerNotifierImpl cn;
// this is simplified here
private Response treatIncommingResponse() {
cn.reload();
}
}
Now that i have upgraded to jersey 1.4, the call to cn.reload do
absolutly nothing.
Is this a bug or is there a new way to do so ?
thanks
Guilhem Legal (Geomatys)