Hi Tobias,
That's indeed possible.
A singleton can be created by following these steps:
1. You first need to create an UNO interface for your extension (say
XConnectionManager)
2. The UNO singleton is then defined as follows:
published singleton theConnectionManager : XConnectionManager;
3. Implement the singleton by creating an implementation of the
XConnectionManager interface, say ConnectionManagerImpl.
4. Store the singleton by adding the following code to
__writeRegistryServiceInfo in you component registration class:
try {
XRegistryKey newKey =
xRegistryKey.createKey(ConnectionManagerImpl.class.getName() +
"/UNO/SINGLETONS/" + theConnectionManager.class.getName());
newKey.setStringValue("de.krais.tobias.sample.theConnectionManager");
} catch (InvalidRegistryException e) {
return false;
}
5. __getComponentFactory can be updated as you would do for an ordinary
service (no special handling for singletons required)
6. Now the singleton can be retrieved by calling
theConnectionManager.get(componentContext)
Hth,
Daan
-----Original Message-----
From: Tobias Krais [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 26, 2008 9:46
To: [email protected]
Subject: Re: [api-dev] Loading Extension on startup of OpenOffice and
use it later
Hi together,
> You'll need to register a job that is to be invoked on the
'OnStartApp'
> event, in this job you can create the connection, and than store it in
a
> singleton service for later use.
I start OOo via API. Is it also possible to store the connection from
that code in a singelton and then use it later? In that case I won't
need a job.
Where can I find information about storing and reading a singleton?
Greetings, Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]