Refine search
StartLevel sl = (StartLevel) context.getService( context.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName())); Bundle[] bundles = context.getBundles(); for (int i = 0; i < bundles.length; i++) installedBundleMap.put(bundles[i].getLocation(), bundles[i]); b.update(); + ex + ((ex.getCause() != null) ? " - " + ex.getCause() : "")); if (b.getBundleId() != 0) + ex + ((ex.getCause() != null) ? " - " + ex.getCause() : "")); + ex + ((ex.getCause() != null) ? " - " + ex.getCause() : ""));
protected void stopBundle(Bundle bundle) { if (bundle.getState() == Bundle.ACTIVE) { LOG.debug("Stopping bundle %s version %s", bundle.getSymbolicName(), bundle.getVersion()); try { bundle.stop(); } catch (BundleException e) { System.out.println("Failed to start " + bundle.getSymbolicName() + " " + bundle.getVersion() + ". " + e); e.printStackTrace(); } } } }
public void windowClosing(WindowEvent e) { try { Activator.context.getBundle().stop(); } catch (BundleException ex) { ex.printStackTrace(); } } });
@Override public void start(final BundleContext context) throws Exception { final String snampUrl = System.getProperty(SNAMP_URL_PROPERTY, context.getProperty(SNAMP_URL_PROPERTY)); if(snampUrl == null || snampUrl.isEmpty()) throw new BundleException(String.format("Unable to instantiate HttpReporter for OSGi environment. JVM property or OSGi property %s is not defined", SNAMP_URL_PROPERTY)); final HttpReporter reporter = new HttpReporter(snampUrl, null); final Dictionary<String, String> regProperties = new Hashtable<>(); regProperties.put(Reporter.TYPE_PROPERTY, HttpReporter.TYPE); regProperties.put(SNAMP_URL_PROPERTY, snampUrl); reporterRegistration = context.registerService(Reporter.class, reporter, regProperties); }
@SuppressWarnings("deprecation") public void checkForConsoleBundle() throws BundleException { if ("none".equals(consolePort)) //$NON-NLS-1$ return; // otherwise we need to check for the equinox console bundle and start it ServiceReference<org.osgi.service.packageadmin.PackageAdmin> paRef = context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class); org.osgi.service.packageadmin.PackageAdmin pa = paRef == null ? null : context.getService(paRef); Bundle[] consoles = pa.getBundles(consoleBundle, null); if (consoles == null || consoles.length == 0) { if (consolePort != null) throw new BundleException("Could not find bundle: " + consoleBundle, BundleException.UNSUPPORTED_OPERATION); //$NON-NLS-1$ return; } try { consoles[0].start(Bundle.START_TRANSIENT); } catch (BundleException e) { throw new BundleException("Could not start bundle: " + consoleBundle, BundleException.UNSUPPORTED_OPERATION, e); //$NON-NLS-1$ } }
@Override public synchronized long install(String location, InputStream stream) { try { Bundle b = framework.getBundleContext().installBundle(location, stream); installed.push(b.getBundleId()); LOG.debug("Installed bundle " + b.getSymbolicName() + " as Bundle ID " + b.getBundleId()); setBundleStartLevel(b.getBundleId(), Constants.START_LEVEL_TEST_BUNDLE); b.start(); return b.getBundleId(); } catch (BundleException e) { e.printStackTrace(); } return -1; }
private void start(Bundle bundle) throws BundleException { if (bundle.getState() == Bundle.ACTIVE) { throw new BundleException("OSGi bundle " + bundle.getSymbolicName() + " already started."); } if (!OsgiHeader.asList(bundle, OsgiHeader.APPLICATION).isEmpty()) { throw new BundleException("OSGi header '" + OsgiHeader.APPLICATION + "' not allowed for " + "non-application bundle " + bundle.getSymbolicName() + "."); } osgiFramework.startBundles(Arrays.asList(bundle), false); }
public int getBundleState( long bundleId ) throws RemoteException, BundleException { Bundle bundle = framework.getBundleContext().getBundle( bundleId ); if( bundle == null ) { throw new BundleException( String.format( "bundle [%d] does not exist", bundleId ) ); } return bundle.getState(); }
private static ClassLoader getBundleClassLoader(String symbolicName) throws BundleException { Bundle bundle = Activator.getBundle(symbolicName); if (bundle == null) { throw new RuntimeException("Bundle " + symbolicName + " is not found"); } try { bundle.start(); } catch (BundleException ex) { if (ex.getType() == BundleException.RESOLVE_ERROR) { System.err.println("Resolution errors for " + bundle.toString()); Set<ResolverError> errors = Activator.getResolutionErrors(bundle); if (errors.size() > 0) { for (ResolverError error : errors) { System.err.println("\t" + error.toString()); } } } else { System.err.println("Could not start test bundle: " + bundle.getSymbolicName()); ex.printStackTrace(); } throw ex; } return new BundleClassLoader(bundle); }
public void startService(Long [] id) { try { bc.getBundle(id[0].longValue()).start(); } catch (BundleException e) { e.printStackTrace(); } }
/** * Internal worker to stop a bundle. * * @param options */ protected void stopWorker(int options) throws BundleException { throw new BundleException(NLS.bind(Msg.BUNDLE_FRAGMENT_STOP, this), BundleException.INVALID_OPERATION); }
public void uninstall(Long [] id) { try { bc.getBundle(id[0].longValue()).uninstall(); } catch (BundleException e) { e.printStackTrace(); } }
@Override public void install(MarketplaceExtension ext) throws MarketplaceHandlerException { String url = ext.getDownloadUrl(); try { Bundle bundle = bundleContext.installBundle(url); try { bundle.start(); } catch (BundleException e) { logger.warn("Installed bundle, but failed to start it: {}", e.getMessage()); } installedBindings.put(ext.getId(), bundle.getBundleId()); persistInstalledBindingsMap(installedBindings); } catch (BundleException e) { throw new MarketplaceHandlerException("Binding cannot be installed: " + e.getMessage()); } }
public void update(Long [] id) { try { bc.getBundle(id[0].longValue()).update(); } catch (BundleException e) { e.printStackTrace(); } }
private static void checkExtensionBundle(String headerKey, ManifestElement[] elements) throws BundleException { if (elements.length == 0 || elements[0].getDirective(Constants.EXTENSION_DIRECTIVE) == null) return; String hostName = elements[0].getValue(); // XXX: The extension bundle check is done against system.bundle and org.eclipse.osgi if (!hostName.equals(Constants.SYSTEM_BUNDLE_SYMBOLICNAME) && !hostName.equals(EquinoxContainer.NAME)) { String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[0].toString()); throw new BundleException(message + " : " + NLS.bind(StateMsg.HEADER_EXTENSION_ERROR, hostName), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } }
public void start(BundleContext bc) throws BundleException { try { final BundleImpl b = (BundleImpl)bc.getBundle(); runner = new Thread(b.fwCtx.threadGroup, "start thread for executable jar file, bundle id=" + b.getBundleId()); runner.start(); } catch (final Exception e) { throw new BundleException("Failed to start main class", BundleException.UNSPECIFIED, e); } }
private void startBundle(Bundle bundle) { if (BundleUtils.canStart(bundle)) { try { bundle.start(Bundle.START_TRANSIENT); } catch (BundleException e) { log.error("Bundle " + bundle.getBundleId() + " failed to start: " + e.getMessage()); } } }
private void uninstallBundle(Bundle bundle) { try { bundle.uninstall(); } catch (BundleException e) { log.error("Bundle " + bundle.getBundleId() + " failed to uninstall: " + e.getMessage()); } }
private static ManifestElement[] parseManifestHeader(String header, Map<String, String> manifest, String bundleLocation) { try { return ManifestElement.parseHeader(header, manifest.get(header)); } catch (BundleException e) { String message = NLS.bind(Messages.exception_errorReadingManifest, bundleLocation, e.getMessage()); LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, e)); return null; } }
private void uninstallBundles(Collection<Bundle> bundles) { bundles.stream(). filter(bundle -> (bundle.getBundleId() != 0)). forEach(bundle -> { try { bundle.uninstall(); } catch (BundleException ex) { System.err.println("Auto-deploy uninstall: " + ex + ((ex.getCause() != null) ? " - " + ex.getCause() : "")); } }); }