Jon, I know that you are (understandably) wary of patching or otherwise
meddling with Turbine.java, but I have a problem that I can not see how to
solve with other means.

I'm using Rafal's TurbineConfig class to init turbine without a Servlet
runner.  It is working great, but my problem is that my system may be fired
up with a WebService running, or without it.

This causes Services to be initialized twice (first with Rafal's code, and
then on the first hit to the Turbine Servlet), causing most of the services
to scream in pain, since they do not expect double initialization.

What I did was put a firstInit variable in Turbine servlet, comparable to
firstDoGet.

The overhead is nil, since the code is run only once, and I hope the minimal
code bloat is acceptable (or that a better solution exists).

Magnus




Index: src/java/org/apache/turbine/Turbine.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/Turbine.java,v
retrieving revision 1.20
diff -u -r1.20 Turbine.java
--- src/java/org/apache/turbine/Turbine.java    2000/12/05 17:30:23     1.20
+++ src/java/org/apache/turbine/Turbine.java    2000/12/06 18:58:06
@@ -113,6 +113,12 @@
     public static final String INIT_PROPS_KEY = "properties";

     /**
+     * Should initialization activities be performed during init()
+     * execution?
+     */
+    private static boolean firstInit = true;
+
+    /**
      * Should initialization activities be performed during doGet()
      * execution?
      */
@@ -130,6 +136,15 @@
     {
         super.init(config);

+        // If this is the first invocation, perform some
+        // initialization.
+        if(firstInit)
+        {
+            synchronized(Turbine.class)
+            {
+                if(firstInit)
+                {
+
         String props = getInitParameter(INIT_PROPS_KEY);

         /*
@@ -175,10 +190,17 @@
         }

         log ("Turbine initialized");
+
+        firstInit = false;
+                }
+            }
+        }
+
+
     }

     /**
      * The <code>Servlet</code> destroy method.  Invokes
      * <code>ServiceBroker</code> tear down method.
      */
     public void destroy()



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to