throw new ServletException(status.getException());
}
}
public void init(FilterConfig nullConfig) throws ServletException {
BundleContextRunnable runnable = new BundleContextRunnable(
getBundleContext()) {
@Override
protected IStatus execute() {
// Make sure active the web application dynamically.
IWebApplication webApp = getBundleContext().getWebApplication();
if (!FwkRuntime.getInstance().makeSureWabActive(webApp)) {
return new Status(Status.ERROR, FwkActivator.getInstance()
.getBundleSymbleName(),
"Web appliction not actived and wait timeout to do servlet filter:"
+ filterBase.name);
}
FilterConfig filterConfig = new FilterConfig() {
public String getFilterName() {
return filterBase.name;
}
public String getInitParameter(String name) {
if (filterBase.parameters != null)
return filterBase.parameters.get(name);
return null;
}
public Enumeration getInitParameterNames() {
if (filterBase.parameters != null)
return filterBase.parameters.keys();
return null;
}
public ServletContext getServletContext() {
return ctx;
}
};
// Lazy load filter class.
if (filterBase.filter == null) {
try {
Class clazz = getWabCtxClassLoader().loadClass(
filterBase.clazzName);
filterBase.filter = (Filter) clazz.newInstance();
} catch (Exception e) {
// e.printStackTrace();
return new Status(Status.ERROR, FwkActivator
.getInstance().getBundleSymbleName(),
"Filter Instance Create failed["
+ filterBase.clazzName + "]", e);
}
}
try {
filterBase.filter.init(filterConfig);
} catch (ServletException e) {
// e.printStackTrace();
return new Status(Status.ERROR, FwkActivator.getInstance()
.getBundleSymbleName(), "Filter Init failed["
+ filterBase.clazzName + "]", e);
}
setInitialized(true);
return Status.OK_STATUS;
}
};
runnable.run();
IStatus status = runnable.getResult();
if (!status.isOK()) {
Throwable e = status.getException();
if (e instanceof ServletException)
throw (ServletException) e;
else if (e != null)