You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Daniel Rall <dl...@finemaltcoding.com> on 2001/10/02 02:06:46 UTC

[PATCH] TurbineServices

Shouldn't the {init,shutdown}Service(String) methods be sync'd to
avoid problems in a multi-threaded environment?

Index: BaseServiceBroker.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseServiceBroker.java,v
retrieving revision 1.9
diff -u -u -r1.9 BaseServiceBroker.java
--- BaseServiceBroker.java	2001/10/01 23:55:38	1.9
+++ BaseServiceBroker.java	2001/10/02 00:02:54
@@ -441,7 +441,7 @@
      * @exception InitializationException Initilaization of this
      * service was not successful.
      */
-    public void initService(String name)
+    public synchronized void initService(String name)
         throws InitializationException
     {
         String className = (String) mapping.get(name);
@@ -483,7 +483,6 @@
      * after one service fails, the other will not have the chance
      * to initialize.
      *
-     * @param data An Object to use for initialization activities.
      * @param report <code>true</code> if you want exceptions thrown.
      */
     public void initServices(boolean report)
@@ -562,7 +561,7 @@
      *
      * @param name The name of the <code>Service</code> to be uninitialized.
      */
-    public void shutdownService(String name)
+    public synchronized void shutdownService(String name)
     {
         String className = (String) mapping.get(name);
 

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: [PATCH] TurbineServices

Posted by Jason van Zyl <jv...@apache.org>.
On 10/12/01 5:21 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:

> Jason van Zyl <jv...@apache.org> writes:
> 
>> On 10/1/01 8:06 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
>> 
>>> Shouldn't the {init,shutdown}Service(String) methods be sync'd to
>>> avoid problems in a multi-threaded environment?
>> 
>> Should we consider it the job of the application using fulcrum to make sure
>> that these methods only get called once. We should definitely document it.
>> 
>> I haven't given it much thought, I'm just going through all the patches :-)
> 
> I need to be able to startup and shutdown inidividual services at
> will, and would rather have the mechanism for doing so be thread-safe.
> I checked in this patch a while back, but as always am open to
> comments and revision.

Ah, I didn't know you were shutting down individual services. I have no
problem with the patch.
 
>>> Index: BaseServiceBroker.java
>>> ===================================================================
>>> RCS file: 
>>> /home/cvs/jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseServi
>>> ce
>>> Broker.java,v
>>> retrieving revision 1.9
>>> diff -u -u -r1.9 BaseServiceBroker.java
>>> --- BaseServiceBroker.java    2001/10/01 23:55:38    1.9
>>> +++ BaseServiceBroker.java    2001/10/02 00:02:54
>>> @@ -441,7 +441,7 @@
>>>     * @exception InitializationException Initilaization of this
>>>     * service was not successful.
>>>     */
>>> -    public void initService(String name)
>>> +    public synchronized void initService(String name)
>>>        throws InitializationException
>>>    {
>>>        String className = (String) mapping.get(name);
>>> @@ -483,7 +483,6 @@
>>>     * after one service fails, the other will not have the chance
>>>     * to initialize.
>>>     *
>>> -     * @param data An Object to use for initialization activities.
>>>     * @param report <code>true</code> if you want exceptions thrown.
>>>     */
>>>    public void initServices(boolean report)
>>> @@ -562,7 +561,7 @@
>>>     *
>>>     * @param name The name of the <code>Service</code> to be uninitialized.
>>>     */
>>> -    public void shutdownService(String name)
>>> +    public synchronized void shutdownService(String name)
>>>    {
>>>        String className = (String) mapping.get(name);
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: [PATCH] TurbineServices

Posted by Jon Stevens <jo...@latchkey.com>.
on 10/13/01 3:41 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:

> Jon Stevens <jo...@latchkey.com> writes:
> 
>> on 10/12/01 2:21 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
>> 
>>> I need to be able to startup and shutdown inidividual services at
>>> will, and would rather have the mechanism for doing so be thread-safe.
>>> I checked in this patch a while back, but as always am open to
>>> comments and revision.
>> 
>> Shutdown of services is generally broken.
> 
> Thanks for the info.  I'm going to have to get it working for Nile,
> and likely even for SourceCast 1.3.

It shouldn't be that hard...just needs to be thought over...you are just the
man to fix it. :-)

-jon


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: [PATCH] TurbineServices

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Jon Stevens <jo...@latchkey.com> writes:

> on 10/12/01 2:21 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
>
>> I need to be able to startup and shutdown inidividual services at
>> will, and would rather have the mechanism for doing so be thread-safe.
>> I checked in this patch a while back, but as always am open to
>> comments and revision.
>
> Shutdown of services is generally broken.

Thanks for the info.  I'm going to have to get it working for Nile,
and likely even for SourceCast 1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: [PATCH] TurbineServices

Posted by Jon Stevens <jo...@latchkey.com>.
on 10/12/01 2:21 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:

> I need to be able to startup and shutdown inidividual services at
> will, and would rather have the mechanism for doing so be thread-safe.
> I checked in this patch a while back, but as always am open to
> comments and revision.

Shutdown of services is generally broken.

-jon


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: [PATCH] TurbineServices

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Jason van Zyl <jv...@apache.org> writes:

> On 10/1/01 8:06 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
>
>> Shouldn't the {init,shutdown}Service(String) methods be sync'd to
>> avoid problems in a multi-threaded environment?
>
> Should we consider it the job of the application using fulcrum to make sure
> that these methods only get called once. We should definitely document it.
>
> I haven't given it much thought, I'm just going through all the patches :-)

I need to be able to startup and shutdown inidividual services at
will, and would rather have the mechanism for doing so be thread-safe.
I checked in this patch a while back, but as always am open to
comments and revision.

>> Index: BaseServiceBroker.java
>> ===================================================================
>> RCS file: 
>> /home/cvs/jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseService
>> Broker.java,v
>> retrieving revision 1.9
>> diff -u -u -r1.9 BaseServiceBroker.java
>> --- BaseServiceBroker.java    2001/10/01 23:55:38    1.9
>> +++ BaseServiceBroker.java    2001/10/02 00:02:54
>> @@ -441,7 +441,7 @@
>>     * @exception InitializationException Initilaization of this
>>     * service was not successful.
>>     */
>> -    public void initService(String name)
>> +    public synchronized void initService(String name)
>>        throws InitializationException
>>    {
>>        String className = (String) mapping.get(name);
>> @@ -483,7 +483,6 @@
>>     * after one service fails, the other will not have the chance
>>     * to initialize.
>>     *
>> -     * @param data An Object to use for initialization activities.
>>     * @param report <code>true</code> if you want exceptions thrown.
>>     */
>>    public void initServices(boolean report)
>> @@ -562,7 +561,7 @@
>>     *
>>     * @param name The name of the <code>Service</code> to be uninitialized.
>>     */
>> -    public void shutdownService(String name)
>> +    public synchronized void shutdownService(String name)
>>    {
>>        String className = (String) mapping.get(name);

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: [PATCH] TurbineServices

Posted by Jason van Zyl <jv...@apache.org>.
On 10/1/01 8:06 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:

> Shouldn't the {init,shutdown}Service(String) methods be sync'd to
> avoid problems in a multi-threaded environment?

Should we consider it the job of the application using fulcrum to make sure
that these methods only get called once. We should definitely document it.

I haven't given it much thought, I'm just going through all the patches :-)
 
> Index: BaseServiceBroker.java
> ===================================================================
> RCS file: 
> /home/cvs/jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseService
> Broker.java,v
> retrieving revision 1.9
> diff -u -u -r1.9 BaseServiceBroker.java
> --- BaseServiceBroker.java    2001/10/01 23:55:38    1.9
> +++ BaseServiceBroker.java    2001/10/02 00:02:54
> @@ -441,7 +441,7 @@
>     * @exception InitializationException Initilaization of this
>     * service was not successful.
>     */
> -    public void initService(String name)
> +    public synchronized void initService(String name)
>        throws InitializationException
>    {
>        String className = (String) mapping.get(name);
> @@ -483,7 +483,6 @@
>     * after one service fails, the other will not have the chance
>     * to initialize.
>     *
> -     * @param data An Object to use for initialization activities.
>     * @param report <code>true</code> if you want exceptions thrown.
>     */
>    public void initServices(boolean report)
> @@ -562,7 +561,7 @@
>     *
>     * @param name The name of the <code>Service</code> to be uninitialized.
>     */
> -    public void shutdownService(String name)
> +    public synchronized void shutdownService(String name)
>    {
>        String className = (String) mapping.get(name);
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org