XImplementationLoader loader = (XImplementationLoader)UnoRuntime.queryInterface(XImplementationLoader.class,
compContext._xMultiServiceFactory.createInstance("com.sun.star.loader.Java"));
Object serviceManager = compContext._xMultiServiceFactory.createInstance("com.sun.star.lang.ServiceManager");
XSet serviceManager_xSet = (XSet)UnoRuntime.queryInterface(XSet.class, serviceManager);
XRegistryKey xRegistryKey = new RegistryKey("ROOT");
loader.writeRegistryInfo(xRegistryKey, null, componentName);
String keys[] = xRegistryKey.getKeyNames();
for(int j = 0; j < keys.length; ++ j) {
String implName = keys[j].substring(1);
implName = implName.substring(0, implName.length() - "/UNO/SERVICES".length());
Object factory = loader.activate(implName, null, componentName, xRegistryKey);
XSingleServiceFactory xSingleServiceFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class,
factory);
if (xSingleServiceFactory == null)
throw new com.sun.star.loader.CannotActivateFactoryException("Can not get factory for " + implName);
serviceManager_xSet.insert(xSingleServiceFactory);
}
return serviceManager;
}