List of usage examples for javax.servlet ServletRegistration getClassName
public String getClassName();
From source file:org.wso2.carbon.discovery.cxf.listeners.TomcatCxfDiscoveryListener.java
public void lifecycleEvent(LifecycleEvent lifecycleEvent) { try {// ww w . ja v a2 s .co m String type = lifecycleEvent.getType(); if (Lifecycle.AFTER_START_EVENT.equals(type) || Lifecycle.BEFORE_STOP_EVENT.equals(type)) { StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); String jaxServletMapping = null; boolean isJaxWebapp = false; Map<String, ? extends ServletRegistration> servletRegs = context.getServletContext() .getServletRegistrations(); for (ServletRegistration servletReg : servletRegs.values()) { if (cxfServletClass.equals(servletReg.getClassName())) { Object[] mappings = servletReg.getMappings().toArray(); jaxServletMapping = mappings.length > 0 ? getServletContextPath((String) mappings[0]) : null; isJaxWebapp = true; break; } } if (isJaxWebapp) { CXFServiceInfo serviceBean = getServiceInfo(context, jaxServletMapping); if (serviceBean == null) { return; } if (Lifecycle.AFTER_START_EVENT.equals(type)) { cxfMessageSender.sendHello(serviceBean, null); } else if (Lifecycle.BEFORE_STOP_EVENT.equals(type)) { cxfMessageSender.sendBye(serviceBean, null); } } } } catch (DiscoveryException e) { log.warn("Error while publishing the services to the discovery service ", e); } catch (Throwable e) { //Catching throwable since this listener's state shouldn't affect the webapp deployment. log.warn("Error while publishing the services to the discovery service ", e); } }