karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Achim Nierbeck <bcanh...@googlemail.com>
Subject Re: svn commit: r1055945 - /karaf/branches/karaf-2.1.x/main/src/main/java/org/apache/karaf/main/Main.java
Date Thu, 06 Jan 2011 18:28:39 GMT
Well, right now it looks almost like my first solution which didn't
quite work, at least as Bengt suggested.
If you like I can add my camel route on the issue which I used for testing.

> The stop method is supposed to not block I think, but I'll do some
> more testing tomorrow.
>
> On Thursday, January 6, 2011, Achim Nierbeck <bcanhome@googlemail.com> wrote:
>> Hi,
>>
>> are you sure we don't need the extra thread for the shutdown?
>> While testing with the camel example I used it did take a bit longer to
>> stop.
>> And it looks like the stop method doesn't return until the framework is
>> stopped.
>> Now if the shutdown takes to long the wrapper normaly just "kills" the
>> vm, doesn't it?
>>
>> Achim
>>
>>
>>> Author: gnodet
>>> Date: Thu Jan  6 17:24:29 2011
>>> New Revision: 1055945
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1055945&view=rev
>>> Log:
>>> [KARAF-327] - This should handle the stopping through the wrapper better.
>>>
>>> Modified:
>>>     karaf/branches/karaf-2.1.x/main/src/main/java/org/apache/karaf/main/Main.java
>>>
>>> Modified: karaf/branches/karaf-2.1.x/main/src/main/java/org/apache/karaf/main/Main.java
>>> URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.1.x/main/src/main/java/org/apache/karaf/main/Main.java?rev=1055945&r1=1055944&r2=1055945&view=diff
>>> ==============================================================================
>>> --- karaf/branches/karaf-2.1.x/main/src/main/java/org/apache/karaf/main/Main.java
(original)
>>> +++ karaf/branches/karaf-2.1.x/main/src/main/java/org/apache/karaf/main/Main.java
Thu Jan  6 17:24:29 2011
>>> @@ -39,6 +39,7 @@ import java.util.regex.Pattern;
>>>
>>>  import org.osgi.framework.Bundle;
>>>  import org.osgi.framework.BundleContext;
>>> +import org.osgi.framework.BundleException;
>>>  import org.osgi.framework.Constants;
>>>  import org.osgi.framework.FrameworkEvent;
>>>  import org.osgi.framework.ServiceReference;
>>> @@ -262,11 +263,25 @@ public class Main {
>>>                       FrameworkEvent event;
>>>                       if (callback != null) {
>>>                               callback.waitingForShutdown();
>>> -                             framework.stop();
>>> -                             do {
>>> +                             event = framework.waitForStop(timeout);
>>> +                             //do the stoping in an extra thread
>>> +                             Runnable stopper = new Runnable() {
>>> +
>>> +                                                     public void run() {
>>> +                                                             try {
>>> +
>>> +                                                                     framework.stop();
>>> +                                                             } catch (BundleException
e) {
>>> +                                                                     System.err.println("Exception
while stoping framework: " + e);
>>> +                                                             }
>>> +                                                     }
>>> +                                             };
>>> +                             Thread t = new Thread(stopper);
>>> +


Mime
View raw message