use of org.ops4j.pax.web.service.spi.ServletEvent in project karaf by apache.
the class ServletServiceImpl method getServlets.
@Override
public List<ServletInfo> getServlets() {
List<ServletInfo> servletInfos = new ArrayList<>();
Collection<ServletEvent> events = servletEventHandler.getServletEvents();
for (ServletEvent event : events) {
Servlet servlet = event.getServlet();
String servletClassName = " ";
if (servlet != null) {
servletClassName = servlet.getClass().getName();
servletClassName = servletClassName.substring(servletClassName.lastIndexOf(".") + 1, servletClassName.length());
}
String servletName = event.getServletName() != null ? event.getServletName() : " ";
if (servletName.contains(".")) {
servletName = servletName.substring(servletName.lastIndexOf(".") + 1, servletName.length());
}
String alias = event.getAlias() != null ? event.getAlias() : " ";
String[] urls = event.getUrlParameter() != null ? event.getUrlParameter() : new String[] { "" };
ServletInfo info = new ServletInfo();
info.setBundleId(event.getBundle().getBundleId());
info.setName(servletName);
info.setClassName(servletClassName);
info.setState(event.getType());
info.setAlias(alias);
info.setUrls(urls);
servletInfos.add(info);
}
return servletInfos;
}
use of org.ops4j.pax.web.service.spi.ServletEvent in project karaf by apache.
the class HttpPlugin method getServletDetails.
protected List<ServletDetails> getServletDetails() {
Collection<ServletEvent> events = servletEventHandler.getServletEvents();
List<ServletDetails> result = new ArrayList<>(events.size());
for (ServletEvent event : events) {
Servlet servlet = event.getServlet();
String servletClassName = " ";
if (servlet != null) {
servletClassName = servlet.getClass().getName();
servletClassName = servletClassName.substring(servletClassName.lastIndexOf(".") + 1, servletClassName.length());
}
String servletName = event.getServletName() != null ? event.getServletName() : " ";
if (servletName.contains(".")) {
servletName = servletName.substring(servletName.lastIndexOf(".") + 1, servletName.length());
}
String alias = event.getAlias() != null ? event.getAlias() : " ";
String[] urls = event.getUrlParameter() != null ? event.getUrlParameter() : new String[] { "" };
ServletDetails details = new ServletDetails();
details.setId(event.getBundle().getBundleId());
details.setAlias(alias);
details.setServlet(servletClassName);
details.setServletName(servletName);
details.setState(getStateString(event.getType()));
details.setUrls(urls);
result.add(details);
}
return result;
}
Aggregations