public void startBundle(long bundleId) throws Exception { frameworkMBean.startBundle(bundleId); }
@Override public long installBundleFromURL(String location, String url) throws IOException { long result = getFrameworkMBean().installBundleFromURL(location, url); if (log.isTraceEnabled()) log.trace("installBundleFromURL [location=" + location + ",url=" + url + "] => " + result); return result; }
@Override public void stopBundle(long bundleId) throws IOException { if (log.isTraceEnabled()) log.trace("stopBundle: " + bundleId); getFrameworkMBean().stopBundle(bundleId); }
public long startBundle(FrameworkMBean osgiFrameworkProxy, String bundleName) throws Exception { echo("\n>>> Perform startBundle on Framework MBean <<<"); long bundleNumber = osgiFrameworkProxy.installBundle(bundleName); osgiFrameworkProxy.startBundle(bundleNumber); return bundleNumber; }
@Override public void uninstallBundle(long bundleId) throws Exception { try { frameworkMBean.uninstallBundle(bundleId); logger.info("Bundle '" + bundleId + " was uninstalled"); } catch (Exception ex) { throw new LifecycleException("Cannot uninstall " + bundleId, ex); } }
@Override public void refreshBundles(long[] bundleIds) throws IOException { if (log.isTraceEnabled()) log.trace("refreshBundles " + (bundleIds != null ? Arrays.asList(bundleIds) : null)); getFrameworkMBean().refreshBundles(bundleIds); }
protected void awaitBeginningStartLevel(final Integer beginningStartLevel, long timeout, TimeUnit unit) throws IOException, TimeoutException, InterruptedException { int startLevel = 0; long timeoutMillis = System.currentTimeMillis() + unit.toMillis(timeout); while (System.currentTimeMillis() < timeoutMillis) { startLevel = frameworkMBean.getFrameworkStartLevel(); if (startLevel >= beginningStartLevel) { return; } else { Thread.sleep(500); } } throw new TimeoutException("Beginning start level [" + beginningStartLevel + "] not reached: " + startLevel); }
@Override public long installBundle(String location) throws IOException { long result = getFrameworkMBean().installBundle(location); if (log.isTraceEnabled()) log.trace("installBundle [location=" + location + "] => " + result); return result; }
@Override public void uninstallBundle(long bundleId) throws IOException { if (log.isTraceEnabled()) log.trace("uninstallBundle: " + bundleId); getFrameworkMBean().uninstallBundle(bundleId); }
@Override public void refreshPackages(OSGiBundle[] bundles) throws IOException { long[] bundleIds = null; if (bundles != null) { bundleIds = new long[bundles.length]; for (int i = 0; i < bundles.length; i++) bundleIds[i] = bundles[i].getBundleId(); } try { // This is an asynchronous opertation. Give it some time // [JBOSGI-381] Make it possible to listen to remote framework events getFrameworkMBean().refreshBundles(bundleIds); Thread.sleep(2000); } catch (InterruptedException ex) { // ignore } }
@Override public int getFrameworkStartLevel() throws IOException { int result = getFrameworkMBean().getFrameworkStartLevel(); if (log.isTraceEnabled()) log.trace("getFrameworkStartLevel => " + result); return result; }
@Override public void startBundle(long bundleId) throws IOException { if (log.isTraceEnabled()) log.trace("startBundle: " + bundleId); getFrameworkMBean().startBundle(bundleId); }
private void undeploy(String symbolicName) throws DeploymentException { BundleHandle handle = deployedBundles.remove(symbolicName); if (handle != null) { String bundleState = null; try { long bundleId = handle.getBundleId(); CompositeData bundleType = bundleStateMBean.getBundle(bundleId); if (bundleType != null) { bundleState = (String) bundleType.get(BundleStateMBean.STATE); } } catch (IOException e) { // ignore non-existent bundle return; } if (bundleState != null && !bundleState.equals(BundleStateMBean.UNINSTALLED)) { try { long bundleId = handle.getBundleId(); frameworkMBean.uninstallBundle(bundleId); } catch (IOException ex) { logger.error("Cannot undeploy: " + symbolicName, ex); } } } }
@Override OSGiBundle installBundleInternal(BundleInfo info) throws BundleException { try { String location = info.getLocation(); String streamURL = info.getRoot().getStreamURL().toExternalForm(); long bundleId = getFrameworkMBean().installBundleFromURL(location, streamURL); return new RemoteBundle(this, bundleId); } catch (RuntimeException rte) { throw rte; } catch (Exception ex) { throw new BundleException("Cannot install: " + info, ex); } }
public void stopBundle(FrameworkMBean osgiFrameworkProxy, long bundleNumber) throws Exception { echo("\n>>> Perform stopBundle on Framework MBean <<<"); osgiFrameworkProxy.stopBundle(bundleNumber); }
@Override protected void startInternal() throws BundleException { assertNotUninstalled(); try { getRuntime().getFrameworkMBean().startBundle(bundleId); } catch (IOException ex) { Throwable cause = ex.getCause(); if (cause instanceof BundleException) throw (BundleException)cause; throw new BundleException("Cannot start bundle: " + this, ex); } }
@Override protected void uninstallInternal() throws BundleException { assertNotUninstalled(); try { getRuntime().getFrameworkMBean().uninstallBundle(bundleId); OSGiRuntimeImpl runtimeImpl = (OSGiRuntimeImpl)getRuntime(); runtimeImpl.unregisterBundle(this); uninstalled = true; } catch (RuntimeException rte) { throw rte; } catch (Exception ex) { log.error("Cannot uninstall: " + getLocation(), ex); } }
private BundleHandle installBundle(String location, URL streamURL) throws BundleException, IOException { URL serverUrl = streamURL; // Adapt URL to remote system by serving over HTTP SimpleHTTPServer server = null; if (!isLocalHost(config)) { server = new SimpleHTTPServer(); serverUrl = server.serve(streamURL); server.start(); } try { long bundleId = frameworkMBean.installBundleFromURL(location, serverUrl.toExternalForm()); String symbolicName = bundleStateMBean.getSymbolicName(bundleId); String version = bundleStateMBean.getVersion(bundleId); return new BundleHandle(bundleId, symbolicName, version); } finally { if (server != null) { server.shutdown(); } } }
@Override protected void stopInternal() throws BundleException { assertNotUninstalled(); try { getRuntime().getFrameworkMBean().stopBundle(bundleId); } catch (IOException ex) { Throwable cause = ex.getCause(); if (cause instanceof BundleException) throw (BundleException)cause; throw new BundleException("Cannot stop bundle: " + this, ex); } }
try { FrameworkMBean frameworkMBean = getFrameworkMBean(mbsc); frameworkMBean.startBundle(bundleId); consoleReader.printString(DeployUtils.reformat("Started bundle: " + bundleId, 4, 72)); } catch (Exception e) {