public void addAppListenerDescriptor(AppListenerDescriptorImpl ref) { addAppListenerDescriptor((AppListenerDescriptor) ref); }
private void addWeldListenerToAllWars(DeploymentContext context) { // if there's at least 1 ejb jar then add the listener to all wars ApplicationHolder applicationHolder = context.getModuleMetaData(ApplicationHolder.class); if ( applicationHolder != null ) { if ( applicationHolder.app.getBundleDescriptors(EjbBundleDescriptor.class).size() > 0 ) { Set<WebBundleDescriptor> webBundleDescriptors = applicationHolder.app.getBundleDescriptors(WebBundleDescriptor.class); for ( WebBundleDescriptor oneWebBundleDescriptor : webBundleDescriptors ) { // Add the Weld Listener if it does not already exist.. // we have to do this regardless because the war may not be cdi-enabled but an ejb is. oneWebBundleDescriptor.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER)); oneWebBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_TERMINATION_LISTENER)); } } } }
wDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_CONTEXT_LISTENER)); wDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_TERMINATION_LISTENER));
private void addWSServletContextListener(WebBundleDescriptor webBunDesc) { for(AppListenerDescriptor appListner: webBunDesc.getAppListenerDescriptors()) { if(appListner.getListener().equals(WSServletContextListener.class.getName())) { //already registered return; } } webBunDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WSServletContextListener.class.getName())); }
private HandlerProcessingResult processAnnotation( AnnotationInfo ainfo, WebBundleDescriptor webBundleDesc) throws AnnotationProcessorException { Class listenerClass = (Class)ainfo.getAnnotatedElement(); if (!(ServletContextListener.class.isAssignableFrom(listenerClass) || ServletContextAttributeListener.class.isAssignableFrom(listenerClass) || ServletRequestListener.class.isAssignableFrom(listenerClass) || ServletRequestAttributeListener.class.isAssignableFrom(listenerClass) || HttpSessionListener.class.isAssignableFrom(listenerClass) || HttpSessionAttributeListener.class.isAssignableFrom(listenerClass))) { log(Level.SEVERE, ainfo, localStrings.getLocalString( "enterprise.deployment.annotation.handlers.needtoimpllistenerinterface", "The Class {0} having annotation javax.servlet.annotation.WebListener need to implement one of the following interfaces: javax.servlet.ServletContextLisener, javax.servlet.ServletContextAttributeListener, javax.servlet.ServletRequestListener, javax.servletServletRequestAttributeListener, javax.servlet.http.HttpSessionListener, javax.servlet.http.HttpSessionAttributeListener.", listenerClass.getName())); return getDefaultFailedResult(); } WebListener listenerAn = (WebListener)ainfo.getAnnotation(); AppListenerDescriptor appListener = new AppListenerDescriptorImpl(listenerClass.getName()); appListener.setDescription(listenerAn.value()); webBundleDesc.addAppListenerDescriptor(appListener); return getDefaultProcessedResult(); } }