David Dankwerth wrote:
Hello

I am playing with the FirstConnection example that comes with the SDK
for version 1.1.4 .
I have noticed that it has inside it :

finally {
    System.exit(0) ;
}

Is there any way to avoid this and have the main exit without forcing it ?
I intend to embed similar code in a servlet, and therefor can not
execute the System.exit

The problem is that when your application uses a remote UNO bridge, that bridge has an internal thread that keeps running (and thus keeps your application up) as long as the bridge has not yet been disposed. Now, such a bridge can be disposed in three ways:


1 Manually by calling the UNO method dispose (see the UNO service com.sun.star.bridge.Bridge, which includes the UNO interface com.sun.star.lang.XComponent). The problem is that when you use UnoUrlResolver or the simple bootstrap mechanism, the bridge instance is not directly available to you, as those mechanisms encapsulate its use.

2 The bridge is disposed when the underlying connection (TCP/IP, ...) is closed (for example, when the application at the remote end of the bridge is terminated).

3 The bridge is automatically disposed once no more UNO objects are "mapped" over it (i.e., no more UNO objects from the local end are used by the remote end, or vice versa). The problem with Java is that if you locally use a UNO object from the remote end, it will remain "used" (and thus the bridge be kept up) until the (local Java object that is a proxy for that remote UNO) object is garbage collected by the local JVM, and there is no robust way to enforce garbage collection of specific objects. (See qadevOOo/runner/util/WaitUnreachable.java for some hacky solution, and grep the bridges/test tree for uses of it.)

-Stephan

Thanks
David Dankwerth

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to