/** * Start the Framework */ public void start() { try { framework.start(); openTrackers(); } catch(BundleException ex) { LOGGER.error(ex.getLocalizedMessage(),ex); } } private void openTrackers() {
/** * User close the window */ public void onMainWindowClosing() { if(closeWindowSaveState()) { // Hide window for fastest close mainPanel.setVisible(false); // Stop application try { if (bundleContext != null) { bundleContext.getBundle(0).stop(); } } catch (BundleException ex) { LOGGER.error(ex.getLocalizedMessage(), ex); } } }
/** * Create a valid bundleContext, but do not start bundles */ public void init() { Map<String, String> frameworkConfig = new HashMap<String,String>(); // Define service interface exported by Framework orbisgis-core frameworkConfig.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,getExtraPackage()); // Persistence's data frameworkConfig.put(Constants.FRAMEWORK_STORAGE, pluginCacheFolder.getAbsolutePath()); framework = createEmbeddedFramework(frameworkConfig); try { framework.init(); } catch(BundleException ex) { LOGGER.error(ex.getLocalizedMessage(),ex); } } /**
static void parseSystemCapabilities(String systemCapabilities, MultiStatus parsingStatus, List<IProvidedCapability> parsingResult) { if (systemCapabilities == null || (systemCapabilities.trim().length() == 0)) { return; } try { ManifestElement[] eeEntries = ManifestElement.parseHeader(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilities); parseSystemCapabilities(eeEntries, parsingStatus, parsingResult); } catch (BundleException e) { parsingStatus.add(newErrorStatus(e.getLocalizedMessage(), e)); } }
/** * User click on install Plug-in from disk button. */ public void onAddBundleJar() { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); FileNameExtensionFilter filter = new FileNameExtensionFilter( I18N.tr("OSGi Jar"), "jar"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(this); if(returnVal == JFileChooser.APPROVE_OPTION) { File[] selection = chooser.getSelectedFiles(); for(File selected : selection) { try { LOGGER.info(I18N.tr("Install bundle {0}", selected.toURI().toString())); bundleContext.installBundle(selected.toURI().toString()); } catch (BundleException ex) { LOGGER.error(ex.getLocalizedMessage(),ex); } } } } /**
static void parseSystemCapabilities(String systemCapabilities, MultiStatus parsingStatus, List<IProvidedCapability> parsingResult) { if (systemCapabilities == null || (systemCapabilities.trim().length() == 0)) { return; } try { ManifestElement[] eeEntries = ManifestElement.parseHeader(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilities); parseSystemCapabilities(eeEntries, parsingStatus, parsingResult); } catch (BundleException e) { parsingStatus.add(newErrorStatus(e.getLocalizedMessage(), e)); } }
static void parseSystemCapabilities(String systemCapabilities, MultiStatus parsingStatus, List<IProvidedCapability> parsingResult) { if (systemCapabilities == null || (systemCapabilities.trim().length() == 0)) { return; } try { ManifestElement[] eeEntries = ManifestElement.parseHeader(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilities); parseSystemCapabilities(eeEntries, parsingStatus, parsingResult); } catch (BundleException e) { parsingStatus.add(newErrorStatus(e.getLocalizedMessage(), e)); } }
static void parseSystemCapabilities(String systemCapabilities, MultiStatus parsingStatus, List<IProvidedCapability> parsingResult) { if (systemCapabilities == null || (systemCapabilities.trim().length() == 0)) { return; } try { ManifestElement[] eeEntries = ManifestElement.parseHeader(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilities); parseSystemCapabilities(eeEntries, parsingStatus, parsingResult); } catch (BundleException e) { parsingStatus.add(newErrorStatus(e.getLocalizedMessage(), e)); } }
framework.init(); } catch(BundleException ex) { LOGGER.log(Logger.LOG_ERROR, ex.getLocalizedMessage(), ex);
/** * Start the Framework */ public void start() { try { framework.start(); openTrackers(); } catch(BundleException ex) { LOGGER.log(Logger.LOG_ERROR, ex.getLocalizedMessage(), ex); } } private void openTrackers() {
@Override public void uninstallBundle(Entity bundleEntity) { try { BundleObject componentObject = bundleEntity.getAttributeInstance(BundleObject.class); if (componentObject != null) { Bundle bundle = (Bundle) componentObject.getValue().getData(); contextProxy.release(componentObject.getId()); bundle.uninstall(); } } catch (BundleException ex) { Logger.getLogger(this.getClass()).error(ex.getLocalizedMessage(), ex); } }
@Override public Entity installBundle(URL bundleURL) throws IOException { if (componentContext != null) { try { BundleContext bundleContext = componentContext.getBundleContext(); Bundle bundle = bundleContext.installBundle(bundleURL.toString(), bundleURL.openStream()); URI symName = URI.create("/" + bundle.getSymbolicName().replace(".", "/")); es.ucm.fdi.grasia.faerie.core.model.BundleEntity installedBundleEntity = new es.ucm.fdi.grasia.faerie.core.model.BundleEntity( authorityURI(localURI()), namespaceURI(symName), nameURI(symName)); BundleObject installedBundleObjectInstance = new BundleObject(installedBundleEntity); installedBundleObjectInstance.update(new BasicContextValue<Object>(bundle, 1.0, getBundleEntity())); if (!contextProxy.contains(installedBundleObjectInstance.getId())) { contextProxy.request(installedBundleObjectInstance); bundle.start(); } return installedBundleEntity; } catch (BundleException ex) { Logger.getLogger(this.getClass()).error(ex.getLocalizedMessage(), ex); } } return null; }
systemBundle.update(is); } catch (final BundleException e) { String message = MessageFormat.format("Updating system bundle failed due to {0} - unable to retry: {1}", e.getLocalizedMessage(), this); getLogger().warn(message, e); this.setFinishedState(ResourceState.IGNORED, null, message);