/** * Load Listeners the given in parameter with the given classloader * * @param listenerList the list of listeners to load * @param classLoader the classloader to load the listeners with * @return true if all the listeners have been successfully loaded, false otherwise */ public boolean loadListeners(String[] listeners, ClassLoader classLoader) { // Instantiate all the listeners for (String className : listeners) { try { Class listenerClass = Class.forName(className, false, classLoader); EventListener listener = (EventListener) listenerClass.newInstance(); ((SipContext) sipContext).getAnnotationProcessor().processAnnotations(listener); SipServletImpl sipServletImpl = (SipServletImpl) sipContext.findChildrenByClassName(className); if (sipServletImpl != null) { listener = (EventListener) sipServletImpl.allocate(); listenerServlets.put(listener, sipServletImpl); } else { SipServlet servlet = (SipServlet) listenerClass.getAnnotation(SipServlet.class); if (servlet != null) { sipServletImpl = (SipServletImpl) sipContext.findChildrenByName(servlet.name()); if (sipServletImpl != null) { listener = (EventListener) sipServletImpl.allocate(); listenerServlets.put(listener, sipServletImpl); } } } addListenerToBunch(listener); } catch (Exception e) { logger.fatal("Cannot instantiate listener class " + className, e); return false; } } return true; }
/** @param sipApplicationSessionAttributeListener */ private void checkDeallocateServlet(EventListener eventListener) { if (eventListener instanceof javax.servlet.sip.SipServlet) { try { SipServletImpl wrapper = listenerServlets.get(eventListener); if (wrapper != null) { wrapper.deallocate((javax.servlet.sip.SipServlet) eventListener); } } catch (ServletException e) { logger.error("couldn't deallocate listener " + eventListener.getClass().getName()); } } }