Hi Daan,

for I am very new to singletons, please allow me some more questions.
May be some are silly, but I have a lack of knowledge...

> 1. You first need to create an UNO interface for your extension (say
> XConnectionManager)

I have already created a UNO interface for my extension:
- XJudasComponent.idl and
- JudasComponent.idl

Now I add a new idl file named XSpringLoader.idl:
-----%<-----
#ifndef __de_twc_oocom_comp_xspringloader_idl__
#define __de_twc_oocom_comp_xspringloader_idl__

#include <com/sun/star/uno/XInterface.idl>
module de { module twc { module oocom { module comp {   

        interface XSpringLoader : com::sun::star::uno::XInterface {
                published singleton twcSpringLoader : XSpringLoader;
        };

 }; }; }; };
#endif
-----%<-----
But my idlc compiler won't compile:
-----%<-----
...XSpringLoader.idl(8) : error in lookup of symbol: 'published'
...XSpringLoader.idl(8) : Illegal syntax or missing identifier after
operation type: syntax error, unexpected IDL_SINGLETON, expecting
IDL_IDENTIFIER or IDL_GET or IDL_SET or IDL_PUBLISHED
-----%<-----

> 2. The UNO singleton is then defined as follows: 
>       published singleton theConnectionManager : XConnectionManager;

What is incorrect in the above idl file?

> 3. Implement the singleton by creating an implementation of the
> XConnectionManager interface, say ConnectionManagerImpl.

OK. This will look like this:
-----%<-----
package de.twc.oocom.comp;

public class SpringLoaderImpl implements XSpringLoader {
        //myCode
}
-----%<-----

> 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;
>       }

Should I add this code in the new class SpringLoaderImpl or in the class
JudasComponent, which im my "main" class for the extension?

> 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)

I have to read about this...

Thanks a lot for your help! It boosts my task!

Greetings, Tobias

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

Reply via email to