• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Bootstrap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.star.comp.helper.Bootstrap的典型用法代码示例。如果您正苦于以下问题:Java Bootstrap类的具体用法?Java Bootstrap怎么用?Java Bootstrap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Bootstrap类属于com.sun.star.comp.helper包,在下文中一共展示了Bootstrap类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: connect

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
/**
 * Establishes the connection to the office.
 * 
 * @return constructed component context
 * 
 * @author Andreas Bröker
 */
private XComponentContext connect() {
	try {
		if (officeProgressMonitor != null)
			officeProgressMonitor
					.beginSubTask(Messages
							.getString("LocalOfficeConnectionGhost_monitor_constructing_initial_context_message")); //$NON-NLS-1$

		XComponentContext xContext = Bootstrap.bootstrap();
		return xContext;
	} catch (java.lang.Exception exception) {
		System.out.println("java.lang.Exception: "); //$NON-NLS-1$
		System.out.println(exception);
		exception.printStackTrace();
		System.out.println("--- end."); //$NON-NLS-1$
		throw new com.sun.star.uno.RuntimeException(exception.toString());
	}
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:25,代码来源:LocalOfficeConnectionGhost.java


示例2: openConnection

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
/**
 * Opens connection to OpenOffice.org.
 * 
 * @return information whether the connection is available
 * 
 * @throws Exception if any error occurs
 */
public boolean openConnection() throws Exception {
  String unoUrl = "uno:socket,host=" + host + ",port=" + port +";urp;StarOffice.ServiceManager";
  XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
  Object connector = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.connection.Connector", xLocalContext);
  XConnector xConnector = (XConnector) UnoRuntime.queryInterface(XConnector.class, connector);
  
  String url[] = parseUnoUrl(unoUrl);
  if (null == url) {
    throw new com.sun.star.uno.Exception("Couldn't parse UNO URL "+ unoUrl);
  }
  
  XConnection connection = xConnector.connect(url[0]);
  Object bridgeFactory = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.BridgeFactory", xLocalContext);
  XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class, bridgeFactory);
  xBridge = xBridgeFactory.createBridge("", url[1], connection ,null);
  bridgeFactory = xBridge.getInstance(url[2]);
  xMultiComponentFactory = (XMultiComponentFactory)UnoRuntime.queryInterface(XMultiComponentFactory.class, bridgeFactory);
  XPropertySet xProperySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xMultiComponentFactory);
  Object remoteContext = xProperySet.getPropertyValue("DefaultContext");
  xRemoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, remoteContext);
  xMultiServiceFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xMultiComponentFactory);
  isConnectionEstablished = true;
  return true;      
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:32,代码来源:RemoteOfficeConnection.java


示例3: initContext

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
private static XComponentLoader initContext() {
    try {
        XComponentContext xContext = Bootstrap.bootstrap();
        XMultiComponentFactory xMCF = xContext.getServiceManager();
        Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
        return UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
    } catch (Exception e) {
        throw new LibreOfficeException(e);
    }
}
 
开发者ID:kamax-io,项目名称:libreoffice4j,代码行数:11,代码来源:LibreOfficeManager.java


示例4: connect

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
public void connect() throws ConnectException {
    logger.fine(String.format("connecting with connectString '%s'", unoUrl));
    try {
        XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
        XMultiComponentFactory localServiceManager = localContext.getServiceManager();
        XConnector connector = OfficeUtils.cast(XConnector.class, localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
        XConnection connection = connector.connect(unoUrl.getConnectString());
        XBridgeFactory bridgeFactory = OfficeUtils.cast(XBridgeFactory.class, localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
        String bridgeName = "jodconverter_" + bridgeIndex.getAndIncrement();
        XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
        bridgeComponent = OfficeUtils.cast(XComponent.class, bridge);
        bridgeComponent.addEventListener(bridgeListener);
        serviceManager = OfficeUtils.cast(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
        XPropertySet properties = OfficeUtils.cast(XPropertySet.class, serviceManager);
        componentContext = OfficeUtils.cast(XComponentContext.class, properties.getPropertyValue("DefaultContext"));
        connected = true;
        logger.info(String.format("connected: '%s'", unoUrl));
        OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(this);
        for (OfficeConnectionEventListener listener : connectionEventListeners) {
            listener.connected(connectionEvent);
        }
    } catch (NoConnectException connectException) {
        throw new ConnectException(String.format("connection failed: '%s'; %s", unoUrl, connectException.getMessage()));
    } catch (Exception exception) {
        throw new OfficeException("connection failed: "+ unoUrl, exception);
    }
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:28,代码来源:OfficeConnection.java


示例5: connect

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
/**
 * To set up connection.
 * @throws ConnectException if failure occurs
 */
public void connect() throws ConnectException {
	LOGGER.fine(String.format("connecting with connectString '%s'", unoUrl));
	try {

		XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
		XMultiComponentFactory localServiceManager = localContext.getServiceManager();

		Object urlResolver = localServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext);
		XUnoUrlResolver unoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class, urlResolver);
		Object initialObject = unoUrlResolver.resolve(unoUrl.getConnectString());
		XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, initialObject);

		componentContext = OfficeUtils.cast(XComponentContext.class, properties.getPropertyValue("DefaultContext"));
		serviceManager = componentContext.getServiceManager();
		connected = true;
		LOGGER.info(String.format("connected: '%s'", unoUrl));
		OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(this);
		for (OfficeConnectionEventListener listener : connectionEventListeners) {
			listener.connected(connectionEvent);
		}
	} catch (NoConnectException connectException) {
		throw new ConnectException(String.format("connection failed: '%s'; %s", unoUrl, connectException.getMessage()));
	} catch (Exception exception) {
		throw new OfficeException("connection failed: " + unoUrl, exception);
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:31,代码来源:OfficeConnection.java


示例6: connect

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
/**
 * To set up connection.
 * @throws ConnectException if connection fails
 */
public void connect() throws ConnectException {
	logger.fine(String.format("connecting with connectString '%s'", unoUrl));
	try {
		XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
		XMultiComponentFactory localServiceManager = localContext.getServiceManager();
		XConnector connector = OfficeUtils.cast(XConnector.class, localServiceManager.createInstanceWithContext(
				"com.sun.star.connection.Connector", localContext));
		XConnection connection = connector.connect(unoUrl.getConnectString());
		XBridgeFactory bridgeFactory = OfficeUtils.cast(XBridgeFactory.class, localServiceManager.createInstanceWithContext(
				"com.sun.star.bridge.BridgeFactory", localContext));
		String bridgeName = "jodconverter_" + bridgeIndex.getAndIncrement();
		XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
		bridgeComponent = OfficeUtils.cast(XComponent.class, bridge);
		bridgeComponent.addEventListener(bridgeListener);
		serviceManager = OfficeUtils.cast(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
		XPropertySet properties = OfficeUtils.cast(XPropertySet.class, serviceManager);
		componentContext = OfficeUtils.cast(XComponentContext.class, properties.getPropertyValue("DefaultContext"));
		connected = true;
		logger.info(String.format("connected: '%s'", unoUrl));
		OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(this);
		for (OfficeConnectionEventListener listener : connectionEventListeners) {
			listener.connected(connectionEvent);
		}
	} catch (NoConnectException connectException) {
		throw new ConnectException(String.format("connection failed: '%s'; %s", unoUrl, connectException.getMessage()));
	} catch (Exception exception) {
		throw new OfficeException("connection failed: " + unoUrl, exception);
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:34,代码来源:InternalOfficeConnection.java


示例7: connect

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
/**
 * (non-Javadoc)
 * @see net.heartsome.cat.converter.ooconnect.OPconnect#connect()
 * @throws ConnectException
 */
public void connect() throws ConnectException {
	try {
		XComponentContext localContext;

		localContext = Bootstrap.createInitialComponentContext(null);

		XMultiComponentFactory localServiceManager = localContext.getServiceManager();
		XConnector connector = (XConnector) UnoRuntime.queryInterface(XConnector.class, localServiceManager
				.createInstanceWithContext("com.sun.star.connection.Connector", localContext)); //$NON-NLS-1$
		XConnection connection = connector.connect(strConnection);
		XBridgeFactory bridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class,
				localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext)); //$NON-NLS-1$
		bridge = bridgeFactory.createBridge("ms2ooBridge", "urp", connection, null); //$NON-NLS-1$ //$NON-NLS-2$
		bgComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, bridge);
		// bgComponent.addEventListener(this);
		serviceMg = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class, bridge
				.getInstance("StarOffice.ServiceManager")); //$NON-NLS-1$
		XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, serviceMg);
		componentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, properties
				.getPropertyValue("DefaultContext")); //$NON-NLS-1$
		connected = true;
		if (connected) {
			System.out.println("has already connected"); //$NON-NLS-1$
		} else {
			System.out.println("connect to Openoffice fail,please check OpenOffice service that have to open"); //$NON-NLS-1$
		}

	} catch (NoConnectException connectException) {
		throw new ConnectException(MessageFormat.format(Messages.getString("ooconnect.OPConnection.msg"), strConnection + ": " + connectException.getMessage())); //$NON-NLS-1$ //$NON-NLS-2$
	} catch (Exception exception) {
		throw new OPException(MessageFormat.format(Messages.getString("ooconnect.OPConnection.msg"), strConnection), exception); //$NON-NLS-1$
	} catch (java.lang.Exception e) {
		if (Converter.DEBUG_MODE) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:43,代码来源:OPConnection.java


示例8: simpleBootstrap

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
private XDesktop simpleBootstrap(String pathToExecutable)
        throws IllegalAccessException, InvocationTargetException, BootstrapException,
        CreationException, IOException {

    ClassLoader loader = ClassLoader.getSystemClassLoader();
    if (loader instanceof URLClassLoader) {
        URLClassLoader cl = (URLClassLoader) loader;
        Class<URLClassLoader> sysclass = URLClassLoader.class;
        try {
            Method method = sysclass.getDeclaredMethod("addURL", URL.class);
            method.setAccessible(true);
            method.invoke(cl, new File(pathToExecutable).toURI().toURL());
        } catch (SecurityException | NoSuchMethodException | MalformedURLException t) {
            LOGGER.error("Error, could not add URL to system classloader", t);
            cl.close();
            throw new IOException("Error, could not add URL to system classloader", t);
        }
    } else {
        LOGGER.error("Error occured, URLClassLoader expected but " + loader.getClass()
                + " received. Could not continue.");
    }

    //Get the office component context:
    XComponentContext xContext = Bootstrap.bootstrap();
    //Get the office service manager:
    XMultiComponentFactory xServiceManager = xContext.getServiceManager();
    //Create the desktop, which is the root frame of the
    //hierarchy of frames that contain viewable components:
    Object desktop;
    try {
        desktop = xServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
    } catch (Exception e) {
        throw new CreationException(e.getMessage());
    }
    XDesktop resultDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop);

    UnoRuntime.queryInterface(XComponentLoader.class, desktop);

    return resultDesktop;
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:41,代码来源:OOBibBase.java


示例9: getLocalContext

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
/**
 * Create default local component context.
 * 
 * @return      The default local component context
 */
protected XComponentContext getLocalContext() throws BootstrapException, Exception {

    XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
    if (xLocalContext == null) {
        throw new BootstrapException("no local component context!");
    }
    return xLocalContext;
}
 
开发者ID:cuba-platform,项目名称:yarg,代码行数:14,代码来源:BootstrapConnector.java


示例10: convert

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
private static ByteArrayOutputStream convert(
		ByteArrayOutputStream odxStream, String targetFormat,
		Map<String, Object> filterParameters) throws BootstrapException,
		Exception, IOException {
	// TODO: Can this be done once during app init?
	XComponentContext xContext = Bootstrap.bootstrap();

	OOoStreamConverter converter = new OOoStreamConverter(xContext);

	ByteArrayOutputStream generatedPDFOutputStream = new ByteArrayOutputStream();
	OOoOutputStream convertedOutputStream = null;
	OOoInputStream generatedODFInputStream = null;
	try {
		convertedOutputStream = null;
		generatedODFInputStream = new OOoInputStream(
				odxStream.toByteArray());
		convertedOutputStream = new OOoOutputStream();
		converter.convert(generatedODFInputStream, convertedOutputStream,
				targetFormat, filterParameters);

		generatedPDFOutputStream.write(convertedOutputStream.toByteArray());
	} finally {
		IOUtils.closeQuietly(generatedODFInputStream);
		IOUtils.closeQuietly(convertedOutputStream);
	}

	return generatedPDFOutputStream;
}
 
开发者ID:Altrusoft,项目名称:docserv,代码行数:29,代码来源:Application.java


示例11: main

import com.sun.star.comp.helper.Bootstrap; //导入依赖的package包/类
/**
 * Stellt eine Verbindung mit OpenOffice.org her (und startet dabei einen
 * soffice-Prozess, falls noch keiner läuft) und beendet dann OpenOffice.org
 * mittels XDesktop.terminate(). Das Programm beendet die JVM mit Statuscode 0,
 * wenn das Beenden von Openoffice.org erfolgreich war und mit einem Statuscode !=
 * 0, wenn OpenOffice.org nicht beendet wurde bzw. irgendetwas schief gelaufen ist
 * (z.B. beim Verbindungsaufbau). Zudem wird auf der Standardausgabe eine
 * entsprechende Meldung ausgegeben.
 * 
 * @param args
 *          wird nicht ausgewertet
 * @author Daniel Benkmann (D-III-ITD-D101)
 */
public static void main(String[] args)
{
  boolean terminated = false;
  try
  {
    XMultiComponentFactory xMCF = Bootstrap.bootstrap().getServiceManager();
    XComponentContext defaultContext =
      (XComponentContext) UnoRuntime.queryInterface(
        XComponentContext.class,
        ((XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xMCF)).getPropertyValue("DefaultContext"));
    XDesktop desktop =
      (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
        xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
          defaultContext));

    // Quickstarter soll das Terminieren des Prozesses nicht verhindern
    XPropertySet xPropSet =
      (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, desktop);
    xPropSet.setPropertyValue("SuspendQuickstartVeto", Boolean.TRUE);
    //ACHTUNG: Der obige Code hat keine Auswirkung auf den Quickstarter der
    //WollMuxBar! Wenn die WollMuxBar mit "--quickstarter" gestartet wird,
    //kann OpenOffice nicht beendet werden.
    

    // Versuch OOo zu beenden
    terminated = desktop.terminate();
  }
  catch (Exception e)
  {
    System.out.println("Exception occured while trying to terminate OpenOffice.org!");
    e.printStackTrace();
    System.exit(2);
  }

  if (terminated)
  {
    System.out.println("OpenOffice.org was terminated successfully!");
    System.exit(0);
  }
  else
  {
    System.out.println("OpenOffice.org was NOT terminated!");
    System.exit(1);
  }
}
 
开发者ID:WollMux,项目名称:WollMux,代码行数:59,代码来源:TerminateOOo.java



注:本文中的com.sun.star.comp.helper.Bootstrap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RadiusClient类代码示例发布时间:2022-05-22
下一篇:
Java ShortEditor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap