public void addBundleDescription(BundleDescription toAdd) { if (toAdd != null) fState.addBundle(toAdd); }
public void addBundleDescription(BundleDescription toAdd) { if (toAdd != null) fState.addBundle(toAdd); }
public BundleDescription addBundle(Dictionary manifest, File bundleLocation, long bundleId) { try { BundleDescription descriptor = stateObjectFactory.createBundleDescription( fState, manifest, bundleLocation.getAbsolutePath(), bundleId == -1 ? getNextId() : bundleId); // new bundle if (bundleId == -1) { fState.addBundle(descriptor); } else if (!fState.updateBundle(descriptor)) { fState.addBundle(descriptor); } return descriptor; } catch (BundleException e) { } catch (NumberFormatException e) { } catch (IllegalArgumentException e) { } return null; }
private void addBundleToState(BundleDescription bundleDescription) { state.addBundle(bundleDescription); URI location = FileUtils.getRealLocation(manipulator, bundleDescription.getLocation()); locationStateIndex.put(location, bundleDescription); nameVersionStateIndex.put(getKey(bundleDescription), bundleDescription); }
private void addBundleToState(BundleDescription bundleDescription) { state.addBundle(bundleDescription); URI location = FileUtils.getRealLocation(manipulator, bundleDescription.getLocation()); locationStateIndex.put(location, bundleDescription); nameVersionStateIndex.put(getKey(bundleDescription), bundleDescription); }
public BundleDescription addBundle(Map<String, String> manifest, File bundleLocation, long bundleId) throws CoreException { try { // OSGi requires a dictionary over any map Hashtable<String, String> dictionaryManifest = new Hashtable<>(manifest); BundleDescription descriptor = stateObjectFactory.createBundleDescription(fState, dictionaryManifest, bundleLocation.getAbsolutePath(), bundleId == -1 ? getNextId() : bundleId); // new bundle if (bundleId == -1) { fState.addBundle(descriptor); } else if (!fState.updateBundle(descriptor)) { fState.addBundle(descriptor); } return descriptor; } catch (BundleException e) { // A stack trace isn't helpful here, but need to list the plug-in location causing the issue MultiStatus status = new MultiStatus(PDECore.PLUGIN_ID, 0, NLS.bind(UtilMessages.ErrorReadingManifest, bundleLocation.toString()), null); status.add(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, e.getMessage())); throw new CoreException(status); } catch (NumberFormatException e) { } catch (IllegalArgumentException e) { } return null; }
/** * Returns the {@link BundleDescription} for the given manifest + state or * throws an exception, never returns <code>null</code> * * @param manifest * @param location * @param id * @return the {@link BundleDescription} or throws an exception * @throws BundleException */ protected BundleDescription getBundleDescription(Map<String, String> manifest, String location, long id) throws BundleException { State state = getState(); BundleDescription bundle = lookupBundle(state, manifest); if (bundle != null) { return bundle; } StateObjectFactory factory = StateObjectFactory.defaultFactory; Hashtable<String, String> dictionaryManifest = new Hashtable<>(manifest); bundle = factory.createBundleDescription(state, dictionaryManifest, fLocation, id); state.addBundle(bundle); return bundle; }
@Override public void run(IProgressMonitor monitor) throws CoreException { if (FACTORY == null) FACTORY = Platform.getPlatformAdmin().getFactory(); monitor.beginTask("", fModels.length + 1); //$NON-NLS-1$ fState = FACTORY.createState(true); for (int i = 0; i < fModels.length; i++) { BundleDescription bundle = fModels[i].getBundleDescription(); if (bundle != null) fState.addBundle(FACTORY.createBundleDescription(bundle)); monitor.worked(1); } fState.setPlatformProperties(fProperties); fState.resolve(false); monitor.done(); }
public void run(IProgressMonitor monitor) throws CoreException { if (FACTORY == null) FACTORY = Platform.getPlatformAdmin().getFactory(); monitor.beginTask("", fModels.length + 1); //$NON-NLS-1$ fState = FACTORY.createState(true); for (int i = 0; i < fModels.length; i++) { BundleDescription bundle = fModels[i].getBundleDescription(); if (bundle != null) fState.addBundle(FACTORY.createBundleDescription(bundle)); monitor.worked(1); } fState.setPlatformProperties(fProperties); fState.resolve(false); monitor.done(); }
@Override public void addApiComponents(IApiComponent[] components) throws CoreException { HashSet<String> ees = new HashSet<>(); for (IApiComponent apiComponent : components) { BundleComponent component = (BundleComponent) apiComponent; if (component.isSourceComponent()) { continue; } BundleDescription description = component.getBundleDescription(); getState().addBundle(description); addComponent(component); ees.addAll(Arrays.asList(component.getExecutionEnvironments())); } resolveSystemLibrary(ees); getState().resolve(); }
private BundleDescription addBundle( Dictionary enhancedManifest, File bundleLocation, boolean override ) throws BundleException { BundleDescription descriptor; descriptor = factory.createBundleDescription( state, enhancedManifest, bundleLocation.getAbsolutePath(), getNextBundleId() ); setUserProperty( descriptor, PROP_MANIFEST, enhancedManifest ); if ( override ) { BundleDescription[] conflicts = state.getBundles( descriptor.getSymbolicName() ); if ( conflicts != null ) { for ( BundleDescription conflict : conflicts ) { state.removeBundle( conflict ); getLogger().warn( conflict.toString() + " has been replaced by another bundle with the same symbolic name " + descriptor.toString() ); } } } state.addBundle( descriptor ); return descriptor; }
public void shutdown() { IPluginModelBase[] models = PluginRegistry.getWorkspaceModels(); long timestamp = 0; if (!"true".equals(System.getProperty("pde.nocache")) && shouldSaveState(models)) { //$NON-NLS-1$ //$NON-NLS-2$ timestamp = computeTimestamp(models); File dir = new File(DIR, Long.toString(timestamp) + ".workspace"); //$NON-NLS-1$ State state = stateObjectFactory.createState(false); for (int i = 0; i < models.length; i++) { state.addBundle(models[i].getBundleDescription()); } saveState(state, dir); PDEAuxiliaryState.writePluginInfo(models, dir); PDEExtensionRegistry.writeExtensions(models, dir); } clearStaleStates(".target", fTargetTimestamp); //$NON-NLS-1$ clearStaleStates(".workspace", timestamp); //$NON-NLS-1$ clearStaleStates(".cache", 0); //$NON-NLS-1$ }
if (model != null && fState.addBundle(newbundle)) { fId = Math.max(fId, newbundle.getBundleId()); fWorkspaceModels.add(model);
public void addBundle(State state, long id, File bundleLocation, Dictionary<String, String> mf, boolean override) throws BundleException { BundleDescription descriptor = factory.createBundleDescription(state, mf, getNormalizedPath(bundleLocation), id); if (override) { BundleDescription[] conflicts = state.getBundles(descriptor.getSymbolicName()); if (conflicts != null) { for (BundleDescription conflict : conflicts) { state.removeBundle(conflict); logger.warn( conflict.toString() + " has been replaced by another bundle with the same symbolic name " + descriptor.toString()); } } } state.addBundle(descriptor); }
systemState.addBundle(newDescription); } catch (BundleException be) {
systemState.addBundle(newDescription); } catch (BundleException be) {
private State createSystemState() { State state = factory.createState(true); StateConverter converter = new StateConverter(state); ModuleDatabase database = equinoxContainer.getStorage().getModuleDatabase(); database.readLock(); try { ModuleContainer container = equinoxContainer.getStorage().getModuleContainer(); List<Module> modules = equinoxContainer.getStorage().getModuleContainer().getModules(); for (Module module : modules) { ModuleRevision current = module.getCurrentRevision(); BundleDescription description = converter.createDescription(current); state.addBundle(description); } state.setPlatformProperties(asDictionary(equinoxContainer.getConfiguration().getInitialConfig())); synchronizer = new PlatformBundleListener(state, converter, database, container); state.setResolverHookFactory(synchronizer); bc.addBundleListener(synchronizer); bc.addFrameworkListener(synchronizer); state.resolve(); state.setTimeStamp(database.getRevisionsTimestamp()); } finally { database.readUnlock(); } return state; }
private State createSystemState() { State state = factory.createState(true); StateConverter converter = new StateConverter(state); ModuleDatabase database = equinoxContainer.getStorage().getModuleDatabase(); database.readLock(); try { ModuleContainer container = equinoxContainer.getStorage().getModuleContainer(); List<Module> modules = equinoxContainer.getStorage().getModuleContainer().getModules(); for (Module module : modules) { ModuleRevision current = module.getCurrentRevision(); BundleDescription description = converter.createDescription(current); state.addBundle(description); } state.setPlatformProperties(asDictionary(equinoxContainer.getConfiguration().getInitialConfig())); synchronizer = new PlatformBundleListener(state, converter, database, container); state.setResolverHookFactory(synchronizer); bc.addBundleListener(synchronizer); bc.addFrameworkListener(synchronizer); state.resolve(); state.setTimeStamp(database.getRevisionsTimestamp()); } finally { database.readUnlock(); } return state; }
@Override protected boolean shouldAddPlugin(BundleDescription bundle, Dictionary<String, String> environment) { // if there is an environment conflict boolean conflict = !super.shouldAddPlugin(bundle, environment); if (conflict) { // make a copy of the state if we haven't already if (fStateCopy == null) copyState(TargetPlatformHelper.getState()); // replace the current BundleDescription with a copy who does not have the platform filter. This will allow the plug-in to be resolved BundleDescription desc = fStateCopy.removeBundle(bundle.getBundleId()); BundleDescription newDesc = fStateCopy.getFactory().createBundleDescription(desc.getBundleId(), desc.getSymbolicName(), desc.getVersion(), desc.getLocation(), desc.getRequiredBundles(), desc.getHost(), desc.getImportPackages(), desc.getExportPackages(), desc.isSingleton(), desc.attachFragments(), desc.dynamicFragments(), null, desc.getExecutionEnvironments(), desc.getGenericRequires(), desc.getGenericCapabilities()); fStateCopy.addBundle(newDesc); } // always include plug-ins, even ones with environment conflicts return true; }
protected boolean shouldAddPlugin(BundleDescription bundle, Dictionary environment) { // if there is an environment conflict boolean conflict = !super.shouldAddPlugin(bundle, environment); if (conflict) { // make a copy of the state if we haven't already if (fStateCopy == null) copyState(TargetPlatformHelper.getState()); // replace the current BundleDescription with a copy who does not have the platform filter. This will allow the plug-in to be resolved BundleDescription desc = fStateCopy.removeBundle(bundle.getBundleId()); BundleDescription newDesc = fStateCopy.getFactory().createBundleDescription(desc.getBundleId(), desc.getSymbolicName(), desc.getVersion(), desc.getLocation(), desc.getRequiredBundles(), desc.getHost(), desc.getImportPackages(), desc.getExportPackages(), desc.isSingleton(), desc.attachFragments(), desc.dynamicFragments(), null, desc.getExecutionEnvironments(), desc.getGenericRequires(), desc.getGenericCapabilities()); fStateCopy.addBundle(newDesc); } // always include plug-ins, even ones with environment conflicts return true; }