Revision: 15423
Author: [email protected]
Date: Fri Nov 19 13:18:13 2010
Log: Fixes Issue 2110
Fixes Issue 2111
Fixes Issue 2128
Fixes Issue 2084

http://code.google.com/p/mobicents/source/detail?r=15423

Modified:
/branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/annotations/SipInstanceManager.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/tomcat-7/src/main/java/org/mobicents/servlet/sip/annotations/DefaultSipInstanceManager.java /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/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/annotations/SipInstanceManager.java Tue Nov 16 06:26:13 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/annotations/SipInstanceManager.java Fri Nov 19 13:18:13 2010
@@ -3,6 +3,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.Map;

+import javax.naming.Context;
 import javax.naming.NamingException;

 import org.apache.tomcat.InstanceManager;
@@ -14,4 +15,6 @@

        public Map<String, String> getInjectionMap(String name);

-}
+       public void setContext(Context context);
+       public Context getContext();
+}
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipContext.java Wed Nov 17 15:24:27 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipContext.java Fri Nov 19 13:18:13 2010
@@ -142,9 +142,9 @@

 //     AnnotationProcessor getAnnotationProcessor();

-       InstanceManager getInstanceManager();
-
-//     SipInstanceManager getInstanceManager();
+//     InstanceManager getInstanceManager();
+
+       SipInstanceManager getSipInstanceManager();

        String getEngineName();

=======================================
--- /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/annotations/DefaultSipInstanceManager.java Tue Nov 16 06:25:02 2010 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/annotations/DefaultSipInstanceManager.java Fri Nov 19 13:18:13 2010
@@ -18,7 +18,6 @@

 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
 import java.util.Map;

 import javax.annotation.Resource;
@@ -30,7 +29,6 @@
 import javax.xml.ws.WebServiceRef;

 import org.apache.catalina.core.DefaultInstanceManager;
-import org.apache.tomcat.InstanceManager;
 import org.mobicents.servlet.sip.startup.SipContext;
 /**
* An annotation processor which tries to inject resources found in the servlet context
@@ -134,10 +132,10 @@
     }

public DefaultSipInstanceManager(Context context, Map<String, Map<String, String>> injectionMap, - org.apache.catalina.Context catalinaContext, ClassLoader containerClassLoader, SipContext sipContext) {
+                       SipContext catalinaContext, ClassLoader 
containerClassLoader) {
                super(context, injectionMap, catalinaContext, 
containerClassLoader);
                this.context = context;
-               this.sipContext = sipContext;
+               this.sipContext = catalinaContext;
                this.injectionMap = injectionMap;
        }

=======================================
--- /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 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/core/session/TomcatSipListenersHolder.java Fri Nov 19 13:18:13 2010
@@ -32,13 +32,8 @@
                                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).getSipInstanceManager(); + sipInstanceManager.processAnnotations(listener, sipInstanceManager.getInjectionMap(listenerClass.getName()));

SipServletImpl sipServletImpl = (SipServletImpl)sipContext.findChildrenByClassName(className);
                                if(sipServletImpl != null) {
=======================================
--- /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 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java Fri Nov 19 13:18:13 2010
@@ -16,36 +16,18 @@
  */
 package org.mobicents.servlet.sip.startup;

-import java.util.Iterator;
-
 import javax.naming.Context;
-import javax.naming.NameAlreadyBoundException;
 import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
 import javax.servlet.sip.SipFactory;
 import javax.servlet.sip.SipSessionsUtil;
 import javax.servlet.sip.TimerService;

-import org.apache.catalina.Container;
 import org.apache.catalina.ContainerEvent;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.Server;
-import org.apache.catalina.core.DefaultInstanceManager;
 import org.apache.catalina.core.NamingContextListener;
-import org.apache.catalina.deploy.ContextEjb;
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceEnvRef;
-import org.apache.catalina.deploy.ContextResourceLink;
-import org.apache.catalina.deploy.ContextService;
-import org.apache.catalina.deploy.ContextTransaction;
-import org.apache.catalina.deploy.NamingResources;
 import org.apache.log4j.Logger;
 import org.apache.naming.ContextAccessController;
-import org.apache.naming.TransactionRef;
-import org.mobicents.servlet.sip.annotations.DefaultSipInstanceManager;

 /**
  * Helper class used to initialize and populate the JNDI context associated
@@ -72,14 +54,12 @@
public static final String SIP_SESSIONS_UTIL_JNDI_NAME = "SipSessionsUtil";
        public static final String TIMER_SERVICE_JNDI_NAME = "TimerService";

-
-       //This is where the NamingContextListener initialize
        @Override
        public void lifecycleEvent(LifecycleEvent event) {
                super.lifecycleEvent(event);
                if (event.getType().equalsIgnoreCase(Lifecycle.START_EVENT)) {
                        if (container instanceof SipContext) {
-// ((DefaultSipInstanceManager)((SipContext)container).getInstanceManager()).setContext(envCtx);
+                               
((SipContext)container).getSipInstanceManager().setContext(envCtx);
                        }
                }
        }
=======================================
--- /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java Fri Nov 19 11:19:01 2010 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java Fri Nov 19 13:18:13 2010
@@ -17,7 +17,6 @@
 package org.mobicents.servlet.sip.startup;

 import java.io.File;
-import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -25,7 +24,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Stack;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Semaphore;
@@ -49,30 +47,22 @@
 import org.apache.catalina.Globals;
 import org.apache.catalina.Host;
 import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Service;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.core.ApplicationContext;
 import org.apache.catalina.core.NamingContextListener;
 import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.deploy.Injectable;
 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.catalina.util.ExtensionValidator;
 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;
-//import org.jboss.web.tomcat.service.session.ConvergedSessionReplicationContext;
-//import org.jboss.web.tomcat.service.session.SnapshotSipManager;
 import org.mobicents.servlet.sip.SipConnector;
 import org.mobicents.servlet.sip.annotation.ConcurrencyControlMode;
 import org.mobicents.servlet.sip.annotations.DefaultSipInstanceManager;
@@ -176,7 +166,6 @@
     protected transient SipServletTimerService timerService = null;
     // timer service used to schedule proxy timer tasks
     protected transient ProxyTimerService proxyTimerService = null;
-//     private SipInstanceManager instanceManager;

        /**
         *
@@ -211,12 +200,8 @@
                // init event on the new registered SipContextConfig, so that 
the
                // standardcontextconfig
                // is correctly initialized too
-//             setState(LifecycleState.INITIALIZING);
                super.initInternal();

-//        // Post work directory
-//        postWorkDirectory();
-
                prepareServletContext();

                if(logger.isInfoEnabled()) {
@@ -281,58 +266,35 @@

        @Override
        public synchronized void startInternal() throws LifecycleException {
-
-//             setState(LifecycleState.STARTING);
                if(logger.isInfoEnabled()) {
                        logger.info("Starting the sip context");
-                       logger.info("LifecycleState: "+this.getState());
-               }
-               if( this.getState().equals(LifecycleState.INITIALIZED)) {
+               }
+               if( this.getState().equals(LifecycleState.INITIALIZED)) {
                        prepareServletContext();
                }
-
-               super.setConfigured(false);
-
-               // Add missing components as necessary
+                // Add missing components as necessary
+               boolean ok = true;
         if (getResources() == null) {   // (1) Required by Loader
             if (logger.isDebugEnabled())
                 logger.debug("Configuring default Resources");
             try {
+ if ((getDocBase() != null) && (getDocBase().endsWith(".war")) && (!(new File(getBasePath())).isDirectory()))
+                    setResources(new WARDirContext());
if ((getDocBase() != null) && (getDocBase().endsWith(".sar")) && (!(new File(getBasePath())).isDirectory()))
                     setResources(new SARDirContext());
- else if ((getDocBase() != null) && (getDocBase().endsWith(".war")) && (!(new File(getBasePath())).isDirectory()))
-                    setResources(new WARDirContext());
                 else
                     setResources(new FileDirContext());
             } catch (IllegalArgumentException e) {
logger.error("Error initializing resources: " + e.getMessage());
-//                ok = false;
+                ok = false;
             }
         }
-        //Initialize resources
-        if (!resourcesStart()) {
-            logger.error( "Error in resourceStart()");
-        }
-
-        if (getLoader() == null) {
- WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
-            webappLoader.setDelegate(getDelegate());
-            setLoader(webappLoader);
-        }
-
-        // Post work directory
-        postWorkDirectory();
-
-        boolean dependencyCheck = true;
-        try {
-            dependencyCheck = ExtensionValidator.validateApplication
-                (getResources(), this);
-        } catch (IOException ioe) {
-            logger.error("Error in dependencyCheck", ioe);
-            dependencyCheck = false;
-        }
-
-
+        if (ok) {
+            if (!resourcesStart()) {
+                logger.error( "Error in resourceStart()");
+                ok = false;
+            }
+        }
         // Configure default manager if none was specified
         if (manager == null) {
             if ((getCluster() != null) && getDistributable()) {
@@ -352,66 +314,58 @@
             && (useNamingProperty.equals("false"))) {
             setUseNaming(false);
         }
+
+        // the loader is needed for creating the DefaultSipInstanceManager
+        if (getLoader() == null) {
+ WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
+            webappLoader.setDelegate(getDelegate());
+            setLoader(webappLoader);
+            webappLoader.start();
+            // Report this property change to interested listeners
+            support.firePropertyChange("loader", null, webappLoader);
+        }

//activating our custom naming context to be able to set the sip factory in JNDI
         if (isUseNaming()) {
                if (getNamingContextListener() == null) {
-                       logger.info("Creating new SipNamingContextListener");
NamingContextListener namingContextListener = new SipNamingContextListener();
                 namingContextListener.setName(getNamingContextName());
                 setNamingContextListener(namingContextListener);
                 addLifecycleListener(namingContextListener);
-                addContainerListener(namingContextListener);
-               }
-
-            // Start our subordinate components, if any
-
-            if ((loader != null) && (loader instanceof Lifecycle))
-                ((Lifecycle) loader).start();
-
-            if ((resources != null) && (resources instanceof Lifecycle))
-                ((Lifecycle) resources).start();
-
-//             fireLifecycleEvent(Lifecycle.CONFIGURE_START_EVENT, null);
-
+                addContainerListener(namingContextListener);
+            }
// 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());
-               setInstanceManager(
-                               new DefaultSipInstanceManager(
+               this.setInstanceManager(
+                                       new DefaultSipInstanceManager(
                                                        
getNamingContextListener().getEnvContext(),
-                                                       injectionMap, this, 
this.getClass().getClassLoader(),this));
-//        } else {
-//             // jboss or other kind of naming
-//                     try {
-//                             Map<String, Map<String, String>> injectionMap = 
buildInjectionMap(
-// getIgnoreAnnotations() ? new NamingResources(): getNamingResources());
-//                             InitialContext iniCtx = new InitialContext();
-//                             Context envCtx = (Context) 
iniCtx.lookup("java:comp/env");
-//                             this.setInstanceManager(
-//                                             new DefaultSipInstanceManager(
-//                                                             envCtx,
-//                                                             injectionMap, 
this, this.getClass().getClassLoader(),this));
-//                     } catch (NamingException e) {
-//                             logger.error("Impossible to get the naming context 
", e);
-//                     }
+                                                       injectionMap, this, 
this.getClass().getClassLoader()));
+        } else {
+               // jboss or other kind of naming
+                       try {
+                               Map<String, Map<String, String>> injectionMap = 
buildInjectionMap(
+ getIgnoreAnnotations() ? new NamingResources(): getNamingResources());
+                               InitialContext iniCtx = new InitialContext();
+                               Context envCtx = (Context) 
iniCtx.lookup("java:comp/env");
+                               this.setInstanceManager(
+                                               new DefaultSipInstanceManager(
+                                                               envCtx,
+                                                               injectionMap, 
this, this.getClass().getClassLoader()));
+                       } catch (NamingException e) {
+                               logger.error("Impossible to get the naming context 
", e);
+                       }
         }
                //JSR 289 Section 2.1.1 Step 1.Deploy the application.
//This will make start the sip context config, which will in turn parse the sip descriptor deployment
                //and call load on startup which is equivalent to
//JSR 289 Section 2.1.1 Step 2.Invoke servlet.init(), the initialization method on the Servlet. Invoke the init() on all the load-on-startup Servlets in the application
-
-
-//
-//        fireLifecycleEvent(Lifecycle.CONFIGURE_START_EVENT, null);
-
-        super.startInternal();
-
+               super.startInternal();
+
                if(getAvailable()) {
// 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.
@@ -422,15 +376,10 @@
                                        //tomcat naming
                                        Map<String, Map<String, String>> 
injectionMap = buildInjectionMap(
getIgnoreAnnotations() ? new NamingResources(): getNamingResources()); - 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(
                                                        new 
DefaultSipInstanceManager(
                                                                        
getNamingContextListener().getEnvContext(),
-                                                                       
injectionMap, this, this.getClass().getClassLoader(),this));
+                                                                       
injectionMap, this, this.getClass().getClassLoader()));
                                } else {
                                        // jboss or other kind of naming
                                        try {
@@ -441,18 +390,20 @@
                                                this.setInstanceManager(
                                                                new 
DefaultSipInstanceManager(
                                                                                
envCtx,
-                                                                               
injectionMap, this, this.getClass().getClassLoader(),this));
+                                                                               
injectionMap, this, this.getClass().getClassLoader()));
                                        } catch (NamingException e) {
                                                logger.error("Impossible to get the 
naming context ", e);
                                        }
                                }
-                       }
+                       }
+ getServletContext().setAttribute(InstanceManager.class.getName(), getInstanceManager()); //set the session manager on the specific sipstandardmanager to handle converged http sessions
                        if(getManager() instanceof SipManager) {
                                ((SipManager)getManager()).setSipFactoryImpl(
                                                
((SipFactoryImpl)sipApplicationDispatcher.getSipFactory()));
                                ((SipManager)manager).setContainer(this);
-                       }
+                       }
+
                        // JSR 289 16.2 Servlet Selection
                        // When using this mechanism (the main-servlet) for 
servlet selection,
                        // if there is only one servlet in the application then 
this
@@ -479,7 +430,7 @@
                        if(logger.isInfoEnabled()) {
                                logger.info("sip context didn't started due to 
errors");
                        }
-               }
+               }
        }

        @Override
@@ -683,14 +634,14 @@
        }

        protected void loadSipJNDIContext() {
-               if(getInstanceManager() instanceof DefaultSipInstanceManager) {
+               if(getInstanceManager() instanceof SipInstanceManager) {
                        if(getNamingContextListener() != null) {
- ((DefaultSipInstanceManager)getInstanceManager()).setContext(getNamingContextListener().getEnvContext()); + getSipInstanceManager().setContext(getNamingContextListener().getEnvContext());
                        } else {
                                try {
                                        InitialContext iniCtx = new 
InitialContext();
                                        Context envCtx = (Context) 
iniCtx.lookup("java:comp/env");
-                                       
((DefaultSipInstanceManager)getInstanceManager()).setContext(envCtx);
+                                       
getSipInstanceManager().setContext(envCtx);
                                } catch (NamingException e) {
                                        logger.error("Impossible to get the naming 
context ", e);
                                        throw new IllegalStateException(e);
@@ -1350,84 +1301,6 @@
                                break;
                }
        }
-
-// public void enterSipAppHa(SipServletRequestImpl request, SipServletResponseImpl response, boolean startCacheActivity, boolean bindSessions) {
-//             if(getDistributable() && hasDistributableManager) {
-//                     if(bindSessions) {
-// ConvergedSessionReplicationContext.enterSipappAndBindSessions(request, response, getSipManager(), startCacheActivity);
-//                     } else {
-// ConvergedSessionReplicationContext.enterSipapp(request, response, startCacheActivity);
-//                     }
-//             }
-//     }
-// public void enterSipAppHa(MobicentsSipApplicationSession sipApplicationSession, boolean startCacheActivity, boolean bindSessions) {
-//             if(getDistributable() && hasDistributableManager) {
-//                     if(bindSessions) {
-// ConvergedSessionReplicationContext.enterSipappAndBindSessions(sipApplicationSession,
-//                             getSipManager(), startCacheActivity);
-//                     } else {
-// ConvergedSessionReplicationContext.enterSipapp(null, null, startCacheActivity);
-//                     }
-//             }
-//     }
-
-//     public void enterSipAppHa(boolean startCacheActivity) {
-//             if(getDistributable() && hasDistributableManager) {
-////                   if(bindSessions) {
-//// ConvergedSessionReplicationContext.enterSipappAndBindSessions(sipApplicationSession,
-////                           getSipManager(), startCacheActivity);
-////                   } else {
-// ConvergedSessionReplicationContext.enterSipapp(null, null, startCacheActivity);
-////                   }
-//             }
-//     }
-
-
-// public void exitSipAppHa(SipServletRequestImpl request, SipServletResponseImpl response) {
-//             if (getDistributable() && hasDistributableManager) {
-//                     if(logger.isDebugEnabled()) {
-//                             if(request != null) {
-// logger.debug("We are now after the servlet invocation for request " + request + ", We replicate no matter what " );
-//                             } else if (response != null) {
-// logger.debug("We are now after the servlet invocation for request " + response + ", We replicate no matter what " );
-//                             } else {
-// logger.debug("We are now after the servlet invocation, We replicate no matter what " );
-//                             }
-//                     }
-//                     try {
-// ConvergedSessionReplicationContext ctx = ConvergedSessionReplicationContext
-//                                             .exitSipapp();
-// final SnapshotSipManager snapshotSipManager =(SnapshotSipManager) ctx.getSoleSnapshotManager();
-//                             if(logger.isDebugEnabled()) {
-//                                     logger.debug("Snapshot Manager " + 
ctx.getSoleSnapshotManager());
-//                             }
-//                             if (snapshotSipManager != null) {
-//                                     Set<ClusteredSipSession> sipSessions = 
ctx.getSipSessions();
-//                                     for (ClusteredSipSession 
clusteredSipSession : sipSessions) {
-//                                             
snapshotSipManager.snapshot(clusteredSipSession);
-//                                     }
-// Set<ClusteredSipApplicationSession> sipApplicationSessions = ctx.getSipApplicationSessions(); -// for (ClusteredSipApplicationSession clusteredSipApplicationSession : sipApplicationSessions) {
-//                                             
snapshotSipManager.snapshot(clusteredSipApplicationSession);
-//                                     }
-//                             }
-//                             if(logger.isDebugEnabled()) {
-// logger.debug("After the snapshots for mgr=" + ctx.getSoleSnapshotManager());
-//                             }
-//                     } finally {
-//                             
ConvergedSessionReplicationContext.finishSipCacheActivity();
-//                             if(logger.isDebugEnabled()) {
-//                                     if(request != null) {
-// logger.debug("We are now after the replication finishCacheActivity for request " + request + ", We replicate no matter what " );
-//                                     } else if (response != null) {
-// logger.debug("We are now after the replication finishCacheActivity for request " + response + ", We replicate no matter what " );
-//                                     } else {
-// logger.debug("We are now after the replication finishCacheActivity, We replicate no matter what " );
-//                                     }
-//                             }
-//                     }
-//             }
-//     }

        public ConcurrencyControlMode getConcurrencyControlMode() {
                return concurrencyControlMode;
@@ -1478,20 +1351,17 @@

        @Override
        public void enterSipAppHa(boolean startCacheActivity) {
-               // TODO Auto-generated method stub
-//             throw new UnsupportedOperationException();
+               // we don't support ha features, so nothing to do here
        }

        @Override
        public void exitSipAppHa(SipServletRequestImpl request,
                        SipServletResponseImpl response) {
-               // TODO Auto-generated method stub
-//             throw new UnsupportedOperationException();
+               // we don't support ha features, so nothing to do here
        }

        /**
-        * from Tomcat 7 StandardContext
-        * Used to create the injectionMap
+        * Copied from Tomcat 7 StandardContext
         *
         * @param namingResources
         * @return injectionMap
@@ -1543,81 +1413,9 @@
             }
         }
     }
-
-    /**
-     * Set the appropriate context attribute for our work directory.
-     */
-    private void postWorkDirectory() {
-
-        // Acquire (or calculate) the work directory path
-        String workDir = getWorkDir();
-        if (workDir == null || workDir.length() == 0) {
-
-            // Retrieve our parent (normally a host) name
-            String hostName = null;
-            String engineName = null;
-            String hostWorkDir = null;
-            Container parentHost = getParent();
-            if (parentHost != null) {
-                hostName = parentHost.getName();
-                if (parentHost instanceof StandardHost) {
-                    hostWorkDir = ((StandardHost)parentHost).getWorkDir();
-                }
-                Container parentEngine = parentHost.getParent();
-                if (parentEngine != null) {
-                   engineName = parentEngine.getName();
-                }
-            }
-            if ((hostName == null) || (hostName.length() < 1))
-                hostName = "_";
-            if ((engineName == null) || (engineName.length() < 1))
-                engineName = "_";
-
-            String temp = getPath();
-            if (temp.startsWith("/"))
-                temp = temp.substring(1);
-            temp = temp.replace('/', '_');
-            temp = temp.replace('\\', '_');
-            if (temp.length() < 1)
-                temp = "_";
-            if (hostWorkDir != null ) {
-                workDir = hostWorkDir + File.separator + temp;
-            } else {
-                workDir = "work" + File.separator + engineName +
-                    File.separator + hostName + File.separator + temp;
-            }
-            setWorkDir(workDir);
-        }
-
-        // Create this directory if necessary
-        File dir = new File(workDir);
-        if (!dir.isAbsolute()) {
-            File catalinaHome = engineBase();
-            String catalinaHomePath = null;
-            try {
-                catalinaHomePath = catalinaHome.getCanonicalPath();
-                dir = new File(catalinaHomePath, workDir);
-            } catch (IOException e) {
-            }
-        }
-        dir.mkdirs();
-
-        // Set the appropriate servlet context attribute
-        getServletContext().setAttribute(ServletContext.TEMPDIR, dir);
-//        if (getServletContext() instanceof ConvergedApplicationContext){
-// ((ConvergedApplicationContext) getServletContext()).setAttributeReadOnly
-//                (ServletContext.TEMPDIR);
-//        }
-    }
-
-
-
-//    public void setInstanceManager(SipInstanceManager instanceManager) {
-//     this.instanceManager = instanceManager;
-//    }
-//
-//    @Override
-//    public SipInstanceManager getInstanceManager() {
-//     return instanceManager;
-//    }
-}
+
+    @Override
+    public SipInstanceManager getSipInstanceManager() {
+       return (SipInstanceManager) super.getInstanceManager();
+    }
+}

Reply via email to