Magnus ?or Torfason <[EMAIL PROTECTED]> writes:
> > Magnus writes:
> > [snip]
> > > I will not propose the modifications to the Turbine servlet, but
> > > I believe that the only reason I am the only one suffering from this
> > > bug is that I am the only one calling initialization more than once.
> > > I believe that these problems are best solved in the core code for
> > > services, instead of requiring each service to worry about such
> > > matters.
> >
> > Why are you initializing more than once?
> >
> > Daniel
> >
>
> My problem is that the web part of the application is not an
> required part of my system, but an optional part. I am however
> relying heavily on turbine for Connection pooling, the service
> framework and other stuff. Therefore I consider Tomcat just
> yet another Turbine Service.
>
> I am using the following code, to initialize Turbine. The code
> causes all services to be initialized, including the web service.
> The error occurs if someone hits the webserver whili this routine
> is still working.
>
> Note that even if there are no major hurdles to enabling the
> web service by default, it is not acceptable for me to rely
> only on a hit to the web server for initialization, since
> that hit will never occur if the user does not need that service.
>
> ------------------------------------------------
>
> TurbineConfig config = new TurbineConfig(
> "../webapps/myapp","/WEB-INF/conf/TurbineResources.properties" );
> Turbine turbine = new Turbine();
> turbine.init(config);
I believe that the TurbineServices ServiceBroker implementation should
only allow initialization once. I propose this patch to it:
Index: TurbineServices.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/services/TurbineServices.java,v
retrieving revision 1.8
diff -u -u -r1.8 TurbineServices.java
--- TurbineServices.java 2000/12/14 22:24:59 1.8
+++ TurbineServices.java 2000/12/14 22:36:54
@@ -92,16 +92,24 @@
*/
public static final String CLASSNAME_SUFFIX = ".classname";
- /** The single instance of this class. */
+ /**
+ * The single instance of this class.
+ */
private static TurbineServices instance = null;
/**
+ * Whether service initialization has occurred.
+ */
+ private boolean hasInitializedServices;
+
+ /**
* This constructor is protected to force clients to use
* getInstance() to access this class.
*/
protected TurbineServices()
{
super();
+ hasInitializedServices = false;
}
/**
@@ -122,6 +130,20 @@
}
}
return instance;
+ }
+
+ /**
+ * Initializes brokered services. Initialization occurs only once.
+ *
+ * @param config Additional configuration information.
+ */
+ public synchronized void initServices (ServletConfig config)
+ {
+ if (!hasInitializedServices)
+ {
+ super.initServices(config);
+ hasInitializedServices = true;
+ }
}
/**
It's possible that initServices() should take a Object instead of a
ServletConfig parameter.
Daniel
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]