hi,
since i use jersey, i always search a way to reload only one singleton
resource instead of reload all.
finally, i have download the jersey sources and add some piece of code
in the module server.
here is the classes and methods that i have added, could someone tell me
if its a good aproach to do that :
1) I add an extension of containerListener :
public interface ContainerListenerExt extends ContainerListener {
void reloadResource(Class c);
}
2) I add the follonwing in package
com.sun.jersey.spi.container.servlet.WebComponent.java
public class WebComponent implements ContainerListener,
ContainerListenerExt {
.......
.......
@Override
public void reloadResource(Class c) {
application.reloadResource(c);
}
.....
}
3) I add and implements a method in
com.sun.jersey.spi.container.WebApplication and
com.sun.jersey.server.impl.application.WebApplicationImpl
public interface WebApplication extends Traceable {
......
......
/**
* Destroy and recreate the resource of class c.
*
* @param c The class of the resource to reload.
*/
void reloadResource(Class c);
}
public final class WebApplicationImpl implements WebApplication {
......
......
@Override
public void reloadResource(Class c) {
for (ResourceComponentProvider rcp : providerMap.values()) {
if ( rcp.getInstance().getClass().equals(c)) {
LOGGER.info("removing and destroying the class:" +
c.getName());
rcp.destroy();
rcp.init(getAbstractResource(c));
}
}
}
......
......
}
thanks for your return,
Guilhem legal