Revision: 15229
Author: [email protected]
Date: Mon Nov 15 12:09:36 2010
Log: [No log message]
http://code.google.com/p/mobicents/source/detail?r=15229

Added:
/branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/annotations/SipInstanceManager.java
Modified:
/branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipListenersHolder.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipStandardManager.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/security/authentication/DigestAuthenticator.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipContext.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardEngine.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardHost.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardService.java /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/loading/SipServletImpl.java

=======================================
--- /dev/null
+++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/annotations/SipInstanceManager.java Mon Nov 15 12:09:36 2010
@@ -0,0 +1,15 @@
+package org.mobicents.servlet.sip.annotations;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+
+import javax.naming.NamingException;
+
+import org.apache.tomcat.InstanceManager;
+
+public interface SipInstanceManager extends InstanceManager {
+
+ public void processAnnotations(Object instance, Map<String, String> injections) + throws IllegalAccessException, InvocationTargetException, NamingException;
+
+}
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipListenersHolder.java Sun Nov 7 11:24:04 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipListenersHolder.java Mon Nov 15 12:09:36 2010
@@ -1,8 +1,29 @@
+/*
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.mobicents.servlet.sip.core.session;

+import java.util.ArrayList;
+import java.util.EventListener;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;

 import javax.servlet.ServletContextListener;
+import javax.servlet.ServletException;
 import javax.servlet.sip.SipApplicationSessionActivationListener;
 import javax.servlet.sip.SipApplicationSessionAttributeListener;
 import javax.servlet.sip.SipApplicationSessionBindingListener;
@@ -14,175 +35,382 @@
 import javax.servlet.sip.SipSessionBindingListener;
 import javax.servlet.sip.SipSessionListener;
 import javax.servlet.sip.TimerListener;
-
+import javax.servlet.sip.annotation.SipServlet;
+
+import org.apache.log4j.Logger;
 import org.mobicents.javax.servlet.sip.ProxyBranchListener;
 import org.mobicents.servlet.sip.listener.SipConnectorListener;
-
-public interface SipListenersHolder {
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#loadListeners(java.lang.String[], java.lang.ClassLoader)
+import org.mobicents.servlet.sip.startup.SipContext;
+import org.mobicents.servlet.sip.startup.loading.SipServletImpl;
+
+
+public abstract class SipListenersHolder {
+ private static final Logger logger = Logger.getLogger(SipListenersHolder.class);
+
+ private List<SipApplicationSessionAttributeListener> sipApplicationSessionAttributeListeners; + private List<SipApplicationSessionBindingListener> sipApplicationSessionBindingListeners; + private List<SipApplicationSessionListener> sipApplicationSessionListeners; + private List<SipApplicationSessionActivationListener> sipApplicationSessionActivationListeners;
+       private List<SipSessionActivationListener> 
sipSessionActivationListeners;
+       private List<SipSessionAttributeListener> sipSessionAttributeListeners;
+       private List<SipSessionBindingListener> sipSessionBindingListeners;
+       private List<SipSessionListener> sipSessionListeners;
+       private List<SipServletListener> sipServletsListeners;
+       private List<SipErrorListener> sipErrorListeners;
+       private List<SipConnectorListener> sipConnectorListeners;
+       private List<ProxyBranchListener> proxyBranchListeners;
+       private List<ServletContextListener> servletContextListeners;
+       protected Map<EventListener, SipServletImpl> listenerServlets;
+       // There may be at most one TimerListener defined.
+       private TimerListener timerListener;
+       //the sip context the holder is attached to
+       protected SipContext sipContext;
+
+       /**
+        * Default Constructor
         */
-       boolean loadListeners(String[] listeners, ClassLoader classLoader);
+       public SipListenersHolder(SipContext sipContext) {
+               this.sipContext = sipContext;
+ this.sipApplicationSessionAttributeListeners = new ArrayList<SipApplicationSessionAttributeListener>(); + this.sipApplicationSessionBindingListeners = new ArrayList<SipApplicationSessionBindingListener>(); + this.sipApplicationSessionListeners = new ArrayList<SipApplicationSessionListener>(); + this.sipApplicationSessionActivationListeners = new ArrayList<SipApplicationSessionActivationListener>(); + this.sipSessionActivationListeners = new ArrayList<SipSessionActivationListener>(); + this.sipSessionAttributeListeners = new ArrayList<SipSessionAttributeListener>(); + this.sipSessionBindingListeners = new ArrayList<SipSessionBindingListener>();
+               this.sipSessionListeners = new ArrayList<SipSessionListener>();
+               this.sipServletsListeners = new ArrayList<SipServletListener>();
+               this.sipErrorListeners = new ArrayList<SipErrorListener>();
+               this.servletContextListeners = new 
ArrayList<ServletContextListener>();
+               this.sipConnectorListeners = new 
ArrayList<SipConnectorListener>();
+               this.proxyBranchListeners = new 
ArrayList<ProxyBranchListener>();
+               listenerServlets = new HashMap<EventListener, SipServletImpl>();
+       }
+
+       /**
+        * 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 abstract 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;
+//     }
+
+       protected void addListenerToBunch(EventListener listener) {
+               boolean added = false;
+               if (listener instanceof SipApplicationSessionAttributeListener) 
{
+                       
this.addListener((SipApplicationSessionAttributeListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipApplicationSessionBindingListener) {
+                       this.addListener((SipApplicationSessionBindingListener) 
listener);
+                       added = true;
+               }
+
+               if (listener instanceof 
SipApplicationSessionActivationListener) {
+                       
this.addListener((SipApplicationSessionActivationListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipApplicationSessionListener) {
+                       this.addListener((SipApplicationSessionListener) 
listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipSessionActivationListener) {
+                       this.addListener((SipSessionActivationListener) 
listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipSessionAttributeListener) {
+                       this.addListener((SipSessionAttributeListener) 
listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipSessionBindingListener) {
+                       this.addListener((SipSessionBindingListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipSessionListener) {
+                       this.addListener((SipSessionListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipServletListener) {
+                       this.addListener((SipServletListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipErrorListener) {
+                       this.addListener((SipErrorListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof ServletContextListener) {
+                       this.addListener((ServletContextListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof TimerListener) {
+                       this.setTimerListener((TimerListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof SipConnectorListener) {
+                       this.addListener((SipConnectorListener) listener);
+                       added = true;
+               }
+
+               if (listener instanceof ProxyBranchListener) {
+                       this.addListener((ProxyBranchListener) listener);
+                       added = true;
+               }
+
+               if(!added) {
+                       throw new IllegalArgumentException("Wrong type of 
LISTENER!!!["
+                               + listener + "]");
+               }
+       }

        // this.sipApplicationSessionAttributeListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipApplicationSessionAttributeListener)
-        */
-       void addListener(SipApplicationSessionAttributeListener listener);
+       public void addListener(SipApplicationSessionAttributeListener 
listener) {
+               this.sipApplicationSessionAttributeListeners.add(listener);
+       }

        // this.sipApplicationSessionBindingListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipApplicationSessionBindingListener)
-        */
-       void addListener(SipApplicationSessionBindingListener listener);
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipApplicationSessionActivationListener)
-        */
-       void addListener(SipApplicationSessionActivationListener listener);
-
+       public void addListener(SipApplicationSessionBindingListener listener) {
+               this.sipApplicationSessionBindingListeners.add(listener);
+       }
+
+ public void addListener(SipApplicationSessionActivationListener listener) {
+               this.sipApplicationSessionActivationListeners.add(listener);
+       }
+
        // this.sipApplicationSessionListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipApplicationSessionListener)
-        */
-       void addListener(SipApplicationSessionListener listener);
+       public void addListener(SipApplicationSessionListener listener) {
+               this.sipApplicationSessionListeners.add(listener);
+       }

        // this.sipSessionActivationListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipSessionActivationListener)
-        */
-       void addListener(SipSessionActivationListener listener);
+       public void addListener(SipSessionActivationListener listener) {
+               this.sipSessionActivationListeners.add(listener);
+       }

        // this.sipSessionAttributeListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipSessionAttributeListener)
-        */
-       void addListener(SipSessionAttributeListener listener);
+       public void addListener(SipSessionAttributeListener listener) {
+               this.sipSessionAttributeListeners.add(listener);
+       }

        // this.sipSessionBindingListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipSessionBindingListener)
-        */
-       void addListener(SipSessionBindingListener listener);
+       public void addListener(SipSessionBindingListener listener) {
+               this.sipSessionBindingListeners.add(listener);
+       }

        // this.sipSessionListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipSessionListener)
-        */
-       void addListener(SipSessionListener listener);
+       public void addListener(SipSessionListener listener) {
+               this.sipSessionListeners.add(listener);
+       }

        // this.sipSessionListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipServletListener)
-        */
-       void addListener(SipServletListener listener);
+       public void addListener(SipServletListener listener) {
+               this.sipServletsListeners.add(listener);
+       }

        // this.sipErrorListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.sip.SipErrorListener)
-        */
-       void addListener(SipErrorListener listener);
+       public void addListener(SipErrorListener listener) {
+               this.sipErrorListeners.add(listener);
+       }

        // this.servletContextListeners.clear();
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(javax.servlet.ServletContextListener)
-        */
-       void addListener(ServletContextListener listener);
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(org.mobicents.servlet.sip.listener.SipConnectorListener)
-        */
-       void addListener(SipConnectorListener listener);
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#addListener(org.mobicents.javax.servlet.sip.ProxyBranchListener)
-        */
-       void addListener(ProxyBranchListener listener);
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#setTimerListener(javax.servlet.sip.TimerListener)
-        */
-       void setTimerListener(TimerListener listener);
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipApplicationSessionAttributeListeners()
-        */
- List<SipApplicationSessionAttributeListener> getSipApplicationSessionAttributeListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipApplicationSessionBindingListeners()
-        */
- List<SipApplicationSessionBindingListener> getSipApplicationSessionBindingListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipApplicationSessionActivationListeners()
-        */
- List<SipApplicationSessionActivationListener> getSipApplicationSessionActivationListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipApplicationSessionListeners()
-        */
-       List<SipApplicationSessionListener> getSipApplicationSessionListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipSessionActivationListeners()
-        */
-       List<SipSessionActivationListener> getSipSessionActivationListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipSessionAttributeListeners()
-        */
-       List<SipSessionAttributeListener> getSipSessionAttributeListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipSessionBindingListeners()
-        */
-       List<SipSessionBindingListener> getSipSessionBindingListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipSessionListeners()
-        */
-       List<SipSessionListener> getSipSessionListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipServletsListeners()
-        */
-       List<SipServletListener> getSipServletsListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipErrorListeners()
+       public void addListener(ServletContextListener listener) {
+               this.servletContextListeners.add(listener);
+       }
+
+       public void addListener(SipConnectorListener listener) {
+               this.sipConnectorListeners.add(listener);
+       }
+
+       public void addListener(ProxyBranchListener listener) {
+               this.proxyBranchListeners.add(listener);
+       }
+
+       public void setTimerListener(TimerListener listener) {
+               if(this.timerListener != null) {
+                       throw new IllegalArgumentException(
+ "the time listener has already been set ("+timerListener.getClass().getName() +
+                                       "), There may be at most one TimerListener 
defined !");
+               }
+               this.timerListener = listener;
+       }
+
+ public List<SipApplicationSessionAttributeListener> getSipApplicationSessionAttributeListeners() {
+               return sipApplicationSessionAttributeListeners;
+       }
+
+ public List<SipApplicationSessionBindingListener> getSipApplicationSessionBindingListeners() {
+               return sipApplicationSessionBindingListeners;
+       }
+
+ public List<SipApplicationSessionActivationListener> getSipApplicationSessionActivationListeners() {
+               return sipApplicationSessionActivationListeners;
+       }
+
+ public List<SipApplicationSessionListener> getSipApplicationSessionListeners() {
+               return sipApplicationSessionListeners;
+       }
+
+ public List<SipSessionActivationListener> getSipSessionActivationListeners() {
+               return sipSessionActivationListeners;
+       }
+
+ public List<SipSessionAttributeListener> getSipSessionAttributeListeners() {
+               return sipSessionAttributeListeners;
+       }
+
+       public List<SipSessionBindingListener> getSipSessionBindingListeners() {
+               return sipSessionBindingListeners;
+       }
+
+       public List<SipSessionListener> getSipSessionListeners() {
+               return sipSessionListeners;
+       }
+
+       public List<SipServletListener> getSipServletsListeners() {
+               return sipServletsListeners;
+       }
+
+       public List<SipErrorListener> getSipErrorListeners() {
+               return sipErrorListeners;
+       }
+
+       public List<ServletContextListener> getServletContextListeners() {
+               return servletContextListeners;
+       }
+
+       public List<SipConnectorListener> getSipConnectorListeners() {
+               return sipConnectorListeners;
+       }
+
+       public List<ProxyBranchListener> getProxyBranchListeners() {
+               return proxyBranchListeners;
+       }
+
+       public TimerListener getTimerListener() {
+               return timerListener;
+       }
+
+       public void deallocateServletsActingAsListeners () {
+               //need to deallocate listeners that are servlets...
+ for(SipApplicationSessionAttributeListener sipApplicationSessionAttributeListener : sipApplicationSessionAttributeListeners) {
+                       
checkDeallocateServlet(sipApplicationSessionAttributeListener);
+               }
+ for(SipApplicationSessionBindingListener sipApplicationSessionBindingListener : sipApplicationSessionBindingListeners) {
+                       
checkDeallocateServlet(sipApplicationSessionBindingListener);
+               }
+ for(SipApplicationSessionActivationListener sipApplicationSessionActivationListener : sipApplicationSessionActivationListeners) {
+                       
checkDeallocateServlet(sipApplicationSessionActivationListener);
+               }
+ for(SipApplicationSessionListener sipApplicationSessionListener : sipApplicationSessionListeners) {
+                       checkDeallocateServlet(sipApplicationSessionListener);
+               }
+ for(SipSessionActivationListener sipSessionActivationListener : sipSessionActivationListeners) {
+                       checkDeallocateServlet(sipSessionActivationListener);
+               }
+ for(SipSessionAttributeListener sipSessionAttributeListener : sipSessionAttributeListeners) {
+                       checkDeallocateServlet(sipSessionAttributeListener);
+               }
+ for(SipSessionBindingListener sipSessionBindingListener : sipSessionBindingListeners) {
+                       checkDeallocateServlet(sipSessionBindingListener);
+               }
+               for(SipSessionListener sipSessionListener : 
sipSessionListeners) {
+                       checkDeallocateServlet(sipSessionListener);
+               }
+               for(SipServletListener sipServletListener : 
sipServletsListeners) {
+                       checkDeallocateServlet(sipServletListener);
+               }
+               for(SipErrorListener sipErrorListener : sipErrorListeners) {
+                       checkDeallocateServlet(sipErrorListener);
+               }
+ for(ServletContextListener servletContextListener : servletContextListeners) {
+                       checkDeallocateServlet(servletContextListener);
+               }
+               for(SipConnectorListener sipConnectorListener : 
sipConnectorListeners) {
+                       checkDeallocateServlet(sipConnectorListener);
+               }
+               for(ProxyBranchListener proxyListener : proxyBranchListeners) {
+                       checkDeallocateServlet(proxyListener);
+               }
+               checkDeallocateServlet(timerListener);
+       }
+
+       /**
+        * Empty vectors to allow garbage collection
         */
-       List<SipErrorListener> getSipErrorListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getServletContextListeners()
+       public void clean() {
+
+               this.sipApplicationSessionAttributeListeners.clear();
+               this.sipApplicationSessionBindingListeners.clear();
+               this.sipApplicationSessionActivationListeners.clear();
+               this.sipApplicationSessionListeners.clear();
+               this.sipSessionActivationListeners.clear();
+               this.sipSessionAttributeListeners.clear();
+               this.sipSessionBindingListeners.clear();
+               this.sipSessionListeners.clear();
+               this.sipServletsListeners.clear();
+               this.sipErrorListeners.clear();
+               this.servletContextListeners.clear();
+               this.sipConnectorListeners.clear();
+               this.proxyBranchListeners.clear();
+               this.listenerServlets.clear();
+               this.timerListener = null;
+       }
+
+       /**
+        * @param sipApplicationSessionAttributeListener
         */
-       List<ServletContextListener> getServletContextListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getSipConnectorListeners()
-        */
-       List<SipConnectorListener> getSipConnectorListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getProxyBranchListeners()
-        */
-       List<ProxyBranchListener> getProxyBranchListeners();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#getTimerListener()
-        */
-       TimerListener getTimerListener();
-
-       /* (non-Javadoc)
- * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#deallocateServletsActingAsListeners()
-        */
-       void deallocateServletsActingAsListeners();
-
-       /* (non-Javadoc)
-        * @see org.mobicents.servlet.sip.core.session.SipListenerHolder#clean()
-        */
-       void clean();
+       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());
+                       }
+               }
+       }

 }
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipStandardManager.java Mon Nov 1 14:56:52 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipStandardManager.java Mon Nov 15 12:09:36 2010
@@ -25,6 +25,7 @@

 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.session.StandardManager;
@@ -67,9 +68,14 @@
        }

        @Override
-       public void initInternal() {
+       public void initInternal() throws LifecycleException {
                if( this.getState().equals(LifecycleState.INITIALIZED) ) return;
-
+
+               super.initInternal();
+
+               ObjectName oname = super.getObjectName();
+               String domain;
+
         if(oname==null && this.getContainer() instanceof SipContext) {
             SipContext ctx=(SipContext)this.getContainer();
             domain=ctx.getEngineName();
@@ -121,8 +127,6 @@
                                }
                        }
                }, 1000, 4000);*/
-
-               super.init();
        }

        @Override
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java Mon Nov 1 14:56:52 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java Mon Nov 15 12:09:36 2010
@@ -1981,7 +1981,7 @@
        }

        public ServletContext getServletContext() {
-               // TODO Auto-generated method stub
+               // TODO: throw new  UnsupportedOperationExceptio
                return null;
        }

=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/security/authentication/DigestAuthenticator.java Mon Nov 1 14:56:52 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/security/authentication/DigestAuthenticator.java Mon Nov 15 12:09:36 2010
@@ -523,7 +523,8 @@
        public void register(Request request, HttpServletResponse response,
                        Principal principal, String authType, String username,
                        String password) {
-               // TODO Auto-generated method stub
+
+               throw new UnsupportedOperationException();

        }

=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipContext.java Sun Nov 7 11:24:04 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipContext.java Mon Nov 15 12:09:36 2010
@@ -25,8 +25,10 @@

 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
+import org.apache.catalina.core.DefaultInstanceManager;
 import org.apache.tomcat.InstanceManager;
 import org.mobicents.servlet.sip.annotation.ConcurrencyControlMode;
+import org.mobicents.servlet.sip.annotations.SipInstanceManager;
 import org.mobicents.servlet.sip.core.SipApplicationDispatcher;
 import org.mobicents.servlet.sip.core.SipContextEvent;
import org.mobicents.servlet.sip.core.session.MobicentsSipApplicationSession;
@@ -140,8 +142,10 @@

 //     AnnotationProcessor getAnnotationProcessor();

-       InstanceManager getInstanceManager();
-
+//     InstanceManager getInstanceManager();
+
+       SipInstanceManager getInstanceManager();
+
        String getEngineName();

        String getBasePath();
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardEngine.java Mon Nov 1 14:56:52 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardEngine.java Mon Nov 15 12:09:36 2010
@@ -19,6 +19,7 @@
 import org.apache.catalina.Container;
 import org.apache.catalina.Host;
 import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleState;
 import org.apache.catalina.core.StandardEngine;
 import org.mobicents.servlet.sip.core.SipApplicationDispatcher;

@@ -89,7 +90,6 @@
* since when addChild is called the sip application dispatcher is still null or getService might still return null
         */
        public void startInternal() throws LifecycleException {
-               super.start();
                if(getService() instanceof SipService) {
                        final SipService sipService = (SipService) getService();
SipApplicationDispatcher sipApplicationDispatcher = sipService.getSipApplicationDispatcher();
@@ -105,5 +105,7 @@
                                }
                        }
                }
+               setState(LifecycleState.STARTING);
+               super.startInternal();
        }
 }
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardHost.java Mon Nov 1 14:56:52 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardHost.java Mon Nov 15 12:09:36 2010
@@ -39,7 +39,7 @@
                initialized=true;

                try {
-                       super.init();
+                       super.initInternal();
                } catch (LifecycleException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardService.java Mon Nov 1 14:56:52 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardService.java Mon Nov 15 12:09:36 2010
@@ -182,12 +182,12 @@
ObjectName objectName = createSipConnectorObjectName(connector, getName(), "SipConnector");
                    Registry.getRegistry(null, null)
                        .registerComponent(connector, objectName, null);
-                   connector.setController(objectName);
+//TODO             connector.setController(objectName);
                } catch (Exception e) {
                    logger.error( "Error registering connector ", e);
                }
                if(logger.isDebugEnabled())
-                   logger.debug("Creating name for connector " + oname);
+                   logger.debug("Creating name for connector " + 
this.getObjectName());
        }

        @Override
@@ -202,7 +202,7 @@
        }

        @Override
-       public void initialize() throws LifecycleException {
+       public void initInternal() throws LifecycleException {
//load the sip application disptacher from the class name specified in the server.xml file
                //and initializes it
                StaticServiceHolder.sipStandardService = this;
@@ -234,7 +234,7 @@
                        }
System.setProperty("javax.servlet.sip.dar", darConfigurationFileLocation);
                }
-               super.initialize();
+               super.initInternal();
                sipApplicationDispatcher.setDomain(this.getName());
                if(baseTimerInterval < 1) {
throw new LifecycleException("It's forbidden to set the Base Timer Interval to a non positive value");
@@ -272,8 +272,7 @@
        }

        @Override
-       public void start() throws LifecycleException {
-               super.start();
+       public void startInternal() throws LifecycleException {
                synchronized (connectors) {
                        for (Connector connector : connectors) {
                                final ProtocolHandler protocolHandler = 
connector.getProtocolHandler();
@@ -314,6 +313,8 @@
                if(logger.isInfoEnabled()) {
                        logger.info("SIP Standard Service Started.");
                }
+               setState(LifecycleState.STARTING);
+               super.startInternal();
        }

        public String getJvmRoute() {
@@ -514,8 +515,8 @@
        }

        @Override
-       public void stop() throws LifecycleException {
-               super.stop();
+       public void stopInternal() throws LifecycleException {
+
                // Tomcat specific unloading case
                // Issue 1411 
http://code.google.com/p/mobicents/issues/detail?id=1411
// Sip Connectors should be removed after removing all Sip Servlets to allow them to send BYE to terminate cleanly
@@ -535,6 +536,7 @@
                if(logger.isInfoEnabled()) {
                        logger.info("SIP Standard Service Stopped.");
                }
+               setState(LifecycleState.STOPPING);
        }

        /**
@@ -858,7 +860,7 @@
                        sipProtocolHandler.setSipConnector(sipConnector);
                        sipProtocolHandler.setSipStack(sipStack);
                        connector.setService(this);
-                       connector.setContainer(container);
+//TODO                 connector.setContainer(container);
                        connector.init();
                        addConnector(connector);
                        ExtendedListeningPoint extendedListeningPoint = 
(ExtendedListeningPoint)
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/loading/SipServletImpl.java Fri Nov 6 09:14:49 2009 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/loading/SipServletImpl.java Mon Nov 15 12:09:36 2010
@@ -117,6 +117,8 @@
//copied over from super class changing the JMX name being registered j2eeType is now SipServlet instead of Servlet
        protected void registerJMX(StandardContext ctx) {

+               ObjectName oname;
+
         String parentName = ctx.getName();
         parentName = ("".equals(parentName)) ? "/" : parentName;

@@ -132,7 +134,7 @@
                           ctx.getJ2EEServer();
         try {
             oname=new ObjectName(onameStr);
-            controller=oname;
+// controller=oname; // GVAG: no more controller in the org.apache.catalina.core.ContainerBase
             Registry.getRegistry(null, null)
                 .registerComponent(this, oname, null );

@@ -145,7 +147,7 @@
                 broadcaster.sendNotification(notification);
             }
         } catch( Exception ex ) {
-            log.info("Error registering servlet with jmx " + this);
+ super.getLogger().info("Error registering servlet with jmx " + this);
         }
     }

Reply via email to