Hello all:
One of the most repeated questions in the OOo Developer's Forums is
this: How do I make a clean disconnect?
I scoured the archives and found that the question has been repeatedly
asked since as far back as 2003. Almost any single tutorial out there
stresses on opening a document, making changes to it and leaving it open
in front of the user's nose. I don't need an API to do that!
Being a newbie, I spent a lot of sweat, blood and tears :-) finding the
answer. Please correct me if I am wrong but in order to make a clean
disconnect the following prerequisites are needed:
(1) The OOo process has to be started (why?) in one of the 2 "dual
listening" modes (i.e., either socket or named pipe). More on this in my
next message.
(2) The statement Bootstrap.bootstrap() cannot be used, you should use
Bootstrap.createInitialComponentContext(null) instead.
(3) You need to create a bridge and keep its value around, to be used at
disconnect time. That's why I changed the bridge variable to be global.
I am sure aspiring developers will appreciate the explanation implicit
in the enclosed code. I added a third button which will disconnect the
bridge. You can now see the disconnect process in action. I hypothesize
that if programmers add a deliberate bridge dispose (instead of a rude
and nasty System.exit()) they will not experience all those memory leaks
and OOo process restarts that I keep on reading about.
Here's the magic code that new users have been clamoring for since 2003:
XComponent xcomponent = UnoRuntime.queryInterface(XComponent.class,
bridge);
xcomponent.dispose();
Alternatives to the above and comments are most requested and welcome.
Regards,
-Ramon F Herrera
Note: I am writing all this in the WindowsXP context. Haven't tried OOo
in U*ix yet.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]