Hi,

i think i finally did it :-)
the trick is to implement your own SingletonFactory ...

public class SingletonFactory implements XSingleComponentFactory {

        private transient LogServiceImpl instance = null;

        public Object createInstanceWithArgumentsAndContext(final Object[] args,
                        final XComponentContext xComponentContext) throws 
Exception {
                return createInstanceWithContext(xComponentContext);
        }

        public Object createInstanceWithContext(
                        final XComponentContext xComponentContext) throws 
Exception {
                if (this.instance == null)
                        this.instance = new LogServiceImpl(xComponentContext);
                return this.instance;
        }

and changing ServiceProvider class:

public class ServiceProvider {

        public static XSingleComponentFactory __getComponentFactory(final 
String sImplName) {
                XSingleComponentFactory xSingleComponentFactory = null;
                if (sImplName.equals(LogServiceImpl.class.getName()))
                        xSingleComponentFactory = new SingletonFactory();
                return xSingleComponentFactory;
        }

        public static boolean __writeRegistryServiceInfo(final XRegistryKey 
xRegistryKey) {
                try {
                        final XRegistryKey newKey = xRegistryKey
                                        
.createKey(LogServiceImpl.class.getName()
                                                        + "/UNO/SINGLETONS/" + 
LogServiceImpl._serviceName);
                        newKey.setStringValue(LogServiceImpl._serviceName);
                } catch (final InvalidRegistryException e) {
                        return false;
                }
                return 
Factory.writeRegistryServiceInfo(LogServiceImpl.class.getName(),
                                new String[] { LogServiceImpl._serviceName }, 
xRegistryKey);
        }
}

now  EqualUnoObjects(oA,oB) returns true ...

        oA = CreateUnoService("logging.LogService")
        oB = CreateUnoService("logging.LogService")

and generated LogService.class has a static method get(xComponentContext)

Oliver

GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to