Juergen Schmidt wrote:
Hi Tabish,
Tabish F. Mufti wrote:
I have Sentence.idl:
module com { module sun { module star { module ex { module comp {
first of all, i would change the module com.sun.star to something like
org.openoffice. or maybe your company. The com.sun.star module hierarchy
is historically and should be used for external extension.
>>> should not <<<
Juergen
service Sentence
{
interface com::sun::star::ex::comp::XSentence;
};
singleton theSentence
{
service com::sun::star::ex::comp::Sentence;
};
}; }; }; }; };
fine, think about your construct, do you need it only as singleton? If
yes, you won't need the service construct. It is sufficient to define a
interface based singleton (new style UNO)
module mycompany {
interface XSentence ...
singleton theSentence : XSentence;
};
Implment your UNO object as usual. Later you can access the object
directly by using the construct
mycompany.XSentence singleton = mycompany.theSentence.get(context);
instead of the old
mycompany.XSentence singleton = (mycompany.XSentence)AnyConverter.toObject(
mycompany.XSentence.class,
context.getValueByName("/singletons/mycompany.theSentence"));
and XSentence.idl:
module com { module sun { module star { module ex { module comp {
interface XSentence: com::sun::star::uno::XInterface
{
void reverse();
void getInput();
};
}; }; }; }; };
I have a class Sentence.java which provides the service Sentence:
static final String SERVICENAME = "com.sun.star.ex.comp.Sentence";
I want to know how do I create a Singleton service given the above
context ?
The code which I'm using to create the service Sentence is the following:
XMultiComponentFactory factory = xContext.getServiceManager();
Object transObj = factory.createInstanceWithContext("
com.sun.star.ex.comp.Sentence", xContext);
XSentence sentence =
(XSentence)UnoRuntime.queryInterface(XSentence.class,
transObj);
But this does not returns me Sentence as Singleton class infact
everytime a
new instance of the class Sentence is returned.
see above
Juergen
---------------------------------------------------------------------
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]