if (UtilValidate.isEmpty(port)) port = UtilProperties.getPropertyValue("openoffice-uno", "oo.port", "8100");
XMultiComponentFactory xmulticomponentfactory = null;
XComponentContext xcomponentcontext = null;
Object objectUrlResolver = null;
XUnoUrlResolver xurlresolver = null;
Object objectInitial = null;
// Converting the document to the favoured type
try {
/* Bootstraps a component context with the jurt base components
registered. Component context to be granted to a component for running.
Arbitrary values can be retrieved from the context. */
xcomponentcontext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
/* Gets the service manager instance to be used (or null). This method has
been added for convenience, because the service manager is a often used
object. */
xmulticomponentfactory = xcomponentcontext.getServiceManager();
/* Creates an instance of the component UnoUrlResolver which
supports the services specified by the factory. */
objectUrlResolver = xmulticomponentfactory.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xcomponentcontext);
// Create a new url resolver
xurlresolver = (XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class, objectUrlResolver);
// Resolves an object that is specified as follow:
// uno:<connection description>;<protocol description>;<initial object name>
String url = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ServiceManager";
objectInitial = xurlresolver.resolve(url);
// Create a service manager from the initial object
xmulticomponentfactory = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class, objectInitial);
} catch (Exception e) {
// TODO: None of this works. Need a programmable start solution.