}
private GuiceFilter load(Plugin plugin) {
if (plugin.getHttpInjector() != null) {
final String name = plugin.getName();
final GuiceFilter filter;
try {
filter = plugin.getHttpInjector().getInstance(GuiceFilter.class);
} catch (RuntimeException e) {
log.warn(String.format("Plugin %s cannot load GuiceFilter", name), e);
return null;
}
try {
WrappedContext ctx = new WrappedContext(plugin, base + name);
filter.init(new WrappedFilterConfig(ctx));
} catch (ServletException e) {
log.warn(String.format("Plugin %s failed to initialize HTTP", name), e);
return null;
}
plugin.add(new RegistrationHandle() {
@Override
public void remove() {
filter.destroy();
}
});
return filter;
}
return null;