XComponent xcomponent = xcomponentloader.loadComponentFromURL(
"private:factory/scalc", "_blank", 0,
new PropertyValue[0] );
// Querying for the interface XSet on the XMultiServiceFactory
XSet xsetMultiComponentFactory = ( XSet ) UnoRuntime.queryInterface(
XSet.class, xmulticomponentfactory );
// Getting the single service factory of the instance inspector
XSingleServiceFactory xsingleservicefactoryInstanceInspector =
InstanceInspector.__getServiceFactory(
"InstanceInspector$_InstanceInspector", ( XMultiServiceFactory )
UnoRuntime.queryInterface( XMultiServiceFactory.class,
xmulticomponentfactory ), null );
// Inserting the single service factory into the multi service factory
// Only for this example, so this example is independent of deplying the
// InstanceInspector component in your office.
xsetMultiComponentFactory.insert( xsingleservicefactoryInstanceInspector );
// Creating an instance of the instance inspector with arguments
Object objectInstanceInspector =
xmulticomponentfactory.createInstanceWithArgumentsAndContext(
"org.OpenOffice.InstanceInspector",
new Object[]{ xmulticomponentfactory }, xcomponentcontext );
// Create a new instance inspector
XInstanceInspector xinstanceinspector = ( XInstanceInspector )
UnoRuntime.queryInterface( XInstanceInspector.class,
objectInstanceInspector );
// Inspect the calc
xinstanceinspector.inspect( xcomponent );
// Remove instance inspector from the container
xsetMultiComponentFactory.remove( xsingleservicefactoryInstanceInspector );
System.out.println("\nPlease inspect the new spreadsheet document component." +
" Press RETURN to exit");
DataInputStream inputStream = new DataInputStream(System.in);
inputStream.read();