Question about shutdown of Metro controller

Stephen McConnell mcconnell at dpml.net
Sat Jan 21 16:56:52 EST 2006


 


>     public void destroy() {
>         if (_component != null) {
>             try {
>                 _component.deactivate();
> 
>                 _component = null;
>             } catch (final RemoteException re) {
>                 re.printStackTrace();
>             }
>         }
> 
>         super.destroy();
>     }
> 

> 
> Here, the test-component does nothing useful since its 
> implementation is only a final class that has a public empty 
> constructor (no context, no part, no getter/setter and no 
> function). I can start and query my servlet properly into 
> Tomcat form an Eclipse and/or JBuilder environment. However, 
> I cannot stop Tomcat properly. From the JBuilder debug mode, 
> I see that two threads still run dpml code after stopping Tomcat:
> 
> net.dpml.transit.DefaultModel$EventDispatchThread
> net.dpml.metro.runtime.UnicastEventSource$EventDispatchThread
> 
> How I can properly shutdown the Metro controller?

You don't need to shutdown the controller but you do need to dispose of the
component handler to remove the UnicastEventSource$EventDispatchThread.  You
can do this by casting your component to net.dpml.part.Disposable and
invoking the 'dispose' operation on it.

E.g.:

    if( _component instanceof Disposable )
    {
        Disposable disposable = (Disposable) _component;
        disposable.dispose();
    }

The Transit event dispatch thread is another matter.  In effect we need to
dispose of the Transit Model (because the testcase is the ultimate
controller).  I'll put together an example of this later today and post the
details through.

Cheers, Steve. 





More information about the dev-dpml mailing list