Revision: 15366
Author: [email protected]
Date: Wed Nov 17 15:24:52 2010
Log: [No log message]
http://code.google.com/p/mobicents/source/detail?r=15366

Modified:
/branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/core/session/TomcatSipListenersHolder.java /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java

=======================================
--- /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/core/session/TomcatSipListenersHolder.java Tue Nov 16 06:25:02 2010 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/core/session/TomcatSipListenersHolder.java Wed Nov 17 15:24:52 2010
@@ -32,12 +32,12 @@
                                Class listenerClass = Class.forName(className, 
false, classLoader);
                                EventListener listener = (EventListener) 
listenerClass.newInstance();

- SipInstanceManager sipInstanceManager = ((SipContext)sipContext).getInstanceManager();
-                               if (!(sipInstanceManager==null)){
- sipInstanceManager.processAnnotations(listener, sipInstanceManager.getInjectionMap(listenerClass.getName()));
-                               } else{
- logger.info("Skipping processAnnotations for listener "+listenerClass.getName()+" since injectionMap is null");
-                               }
+// SipInstanceManager sipInstanceManager = ((SipContext)sipContext).getInstanceManager();
+//                             if (!(sipInstanceManager==null)){
+// sipInstanceManager.processAnnotations(listener, sipInstanceManager.getInjectionMap(listenerClass.getName()));
+//                             } else{
+// logger.info("Skipping processAnnotations for listener "+listenerClass.getName()+" since injectionMap is null");
+//                             }


SipServletImpl sipServletImpl = (SipServletImpl)sipContext.findChildrenByClassName(className);
=======================================
--- /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java Tue Nov 16 06:25:02 2010 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java Wed Nov 17 15:24:52 2010
@@ -79,7 +79,7 @@
                super.lifecycleEvent(event);
                if (event.getType().equalsIgnoreCase(Lifecycle.START_EVENT)) {
                        if (container instanceof SipContext) {
- ((DefaultSipInstanceManager)((SipContext)container).getInstanceManager()).setContext(envCtx); +// ((DefaultSipInstanceManager)((SipContext)container).getInstanceManager()).setContext(envCtx);
                        }
                }
        }
=======================================
--- /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java Tue Nov 16 06:25:02 2010 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java Wed Nov 17 15:24:52 2010
@@ -60,7 +60,10 @@
 import org.apache.catalina.deploy.InjectionTarget;
 import org.apache.catalina.deploy.LoginConfig;
 import org.apache.catalina.deploy.NamingResources;
+import org.apache.catalina.loader.WebappLoader;
 import org.apache.log4j.Logger;
+import org.apache.naming.resources.FileDirContext;
+import org.apache.naming.resources.WARDirContext;
 import org.apache.tomcat.InstanceManager;
//import org.jboss.web.tomcat.service.session.ClusteredSipApplicationSession;
 //import org.jboss.web.tomcat.service.session.ClusteredSipSession;
@@ -169,7 +172,7 @@
     protected transient SipServletTimerService timerService = null;
     // timer service used to schedule proxy timer tasks
     protected transient ProxyTimerService proxyTimerService = null;
-       private SipInstanceManager instanceManager;
+//     private SipInstanceManager instanceManager;

        /**
         *
@@ -189,7 +192,7 @@
        }

        @Override
- public void initInternal() throws LifecycleException { // Gvag changed from init to initInternal
+       public void initInternal() throws LifecycleException {
                if(logger.isInfoEnabled()) {
                        logger.info("Initializing the sip context");
                }
@@ -204,7 +207,7 @@
                // init event on the new registered SipContextConfig, so that 
the
                // standardcontextconfig
                // is correctly initialized too
-               setState(LifecycleState.INITIALIZING);
+//             setState(LifecycleState.INITIALIZING);
                super.initInternal();

                prepareServletContext();
@@ -272,7 +275,7 @@
        @Override
        public synchronized void startInternal() throws LifecycleException {

-               setState(LifecycleState.STARTING);
+//             setState(LifecycleState.STARTING);
                if(logger.isInfoEnabled()) {
                        logger.info("Starting the sip context");
                        logger.info("LifecycleState: "+this.getState());
@@ -287,12 +290,23 @@
                 logger.debug("Configuring default Resources");
             try {
if ((getDocBase() != null) && (getDocBase().endsWith(".sar")) && (!(new File(getBasePath())).isDirectory()))
-                    setResources(new SARDirContext());
+                    setResources(new SARDirContext());
             } catch (IllegalArgumentException e) {
logger.error("Error initializing resources: " + e.getMessage());
 //                ok = false;
             }
         }
+        if (!resourcesStart()) {
+            logger.error( "Error in resourceStart()");
+        }
+
+        if (getLoader() == null) {
+ WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
+            webappLoader.setDelegate(getDelegate());
+            setLoader(webappLoader);
+        }
+
+
         // Configure default manager if none was specified
         if (manager == null) {
             if ((getCluster() != null) && getDistributable()) {
@@ -312,6 +326,8 @@
             && (useNamingProperty.equals("false"))) {
             setUseNaming(false);
         }
+
+

//activating our custom naming context to be able to set the sip factory in JNDI
         if (isUseNaming()) {
@@ -323,20 +339,36 @@
                 addLifecycleListener(namingContextListener);
                 addContainerListener(namingContextListener);
                }
+
+            // Start our subordinate components, if any
+            if ((loader != null) && (loader instanceof Lifecycle))
+                ((Lifecycle) loader).start();
+
+            if ((cluster != null) && (cluster instanceof Lifecycle))
+                ((Lifecycle) cluster).start();
+            if ((realm != null) && (realm instanceof Lifecycle))
+                ((Lifecycle) realm).start();
+            if ((resources != null) && (resources instanceof Lifecycle))
+                ((Lifecycle) resources).start();
+
+
+               fireLifecycleEvent(Lifecycle.CONFIGURE_START_EVENT, null);
+
// Replace the default annotation processor. This is needed to handle resource injection // for SipFactory, Session utils and other objects residing in the servlet context space. // Of course if the variable is not found in in the servet context it defaults to the
                        // normal lookup method - in the default naming context.
                        //tomcat naming
+
                Map<String, Map<String, String>> injectionMap = 
buildInjectionMap(
getIgnoreAnnotations() ? new NamingResources(): getNamingResources()); - if (getNamingContextListener().getEnvContext()==null){fireLifecycleEvent(START_EVENT, getNamingContextName());} - if (getNamingContextListener().getEnvContext()==null){logger.info("getNamingContextListener().getEnvContext() is null");}
-                       if (injectionMap==null){logger.info("injectionMap is 
null");}
-                       if (super.context==null){logger.info("super.context is 
null");}
- if (this.getClass().getClassLoader()==null){logger.info("this.getClass().getClassLoader() is null");}
-                       if (this==null){logger.info("this sipContext is null");}
-               this.setInstanceManager(
+// if (getNamingContextListener().getEnvContext()==null){fireLifecycleEvent(START_EVENT, getNamingContextName());} +// if (getNamingContextListener().getEnvContext()==null){logger.info("getNamingContextListener().getEnvContext() is null");}
+//                     if (injectionMap==null){logger.info("injectionMap is 
null");}
+//                     if (super.context==null){logger.info("super.context is 
null");}
+// if (this.getClass().getClassLoader()==null){logger.info("this.getClass().getClassLoader() is null");}
+//                     if (this==null){logger.info("this sipContext is null");}
+               setInstanceManager(
                                new DefaultSipInstanceManager(
                                                        
getNamingContextListener().getEnvContext(),
                                                        injectionMap, this, 
this.getClass().getClassLoader(),this));
@@ -367,7 +399,7 @@
// for SipFactory, Session utils and other objects residing in the servlet context space. // Of course if the variable is not found in in the servet context it defaults to the
                        // normal lookup method - in the default naming context.
- if(getInstanceManager() == null || !(getInstanceManager() instanceof SipInstanceManager)) { + if(getInstanceManager() == null || !(getInstanceManager() instanceof DefaultSipInstanceManager)) {
                                if(isUseNaming()) {
                                        //tomcat naming
                                        Map<String, Map<String, String>> 
injectionMap = buildInjectionMap(
@@ -1492,13 +1524,13 @@
             }
         }
     }
-
-    public void setInstanceManager(SipInstanceManager instanceManager) {
-       this.instanceManager = instanceManager;
-    }
-
-    @Override
-    public SipInstanceManager getInstanceManager() {
-       return instanceManager;
-    }
-}
+
+//    public void setInstanceManager(SipInstanceManager instanceManager) {
+//     this.instanceManager = instanceManager;
+//    }
+//
+//    @Override
+//    public SipInstanceManager getInstanceManager() {
+//     return instanceManager;
+//    }
+}

Reply via email to