本文整理了Java中org.eclipse.osgi.service.resolver.State.addBundle()
方法的一些代码示例,展示了State.addBundle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。State.addBundle()
方法的具体详情如下:
包路径:org.eclipse.osgi.service.resolver.State
类名称:State
方法名:addBundle
[英]Adds the given bundle to this state.
If the bundle already exists in another state then an IllegalStateException
will be thrown. Note that even if you remove a BundleDescription
from one State
object using State#removeBundle(BundleDescription) it may still be considered as removing pending if other bundles in that state depend on the bundle you removed. To complete a pending removal a call must be done to State#resolve(BundleDescription[]) with the removed bundle.
[中]将给定捆绑添加到此状态。
如果捆绑包已存在于另一个状态,则会抛出IllegalStateException
。请注意,即使使用状态#removeBundle(BundleDescription)从一个State
对象中删除BundleDescription
,如果处于该状态的其他捆绑依赖于您删除的捆绑,则仍可能被视为删除挂起。要完成挂起的删除,必须调用状态#resolve(BundleDescription[])来处理删除的捆绑包。
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
public void addBundleDescription(BundleDescription toAdd) {
if (toAdd != null)
fState.addBundle(toAdd);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core
public void addBundleDescription(BundleDescription toAdd) {
if (toAdd != null)
fState.addBundle(toAdd);
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
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;
}
代码示例来源:origin: org.eclipse.equinox.frameworkadmin/equinox
private void addBundleToState(BundleDescription bundleDescription) {
state.addBundle(bundleDescription);
URI location = FileUtils.getRealLocation(manipulator, bundleDescription.getLocation());
locationStateIndex.put(location, bundleDescription);
nameVersionStateIndex.put(getKey(bundleDescription), bundleDescription);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.frameworkadmin.equinox
private void addBundleToState(BundleDescription bundleDescription) {
state.addBundle(bundleDescription);
URI location = FileUtils.getRealLocation(manipulator, bundleDescription.getLocation());
locationStateIndex.put(location, bundleDescription);
nameVersionStateIndex.put(getKey(bundleDescription), bundleDescription);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core
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;
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.api.tools
/**
* 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;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core
@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();
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
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();
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.api.tools
@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();
}
代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components
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;
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
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$
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
if (model != null && fState.addBundle(newbundle)) {
fId = Math.max(fId, newbundle.getBundleId());
fWorkspaceModels.add(model);
代码示例来源:origin: org.eclipse.tycho/tycho-core
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);
}
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi
systemState.addBundle(newDescription);
} catch (BundleException be) {
代码示例来源:origin: org.eclipse/org.eclipse.osgi
systemState.addBundle(newDescription);
} catch (BundleException be) {
代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi.compatibility.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;
}
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.osgi.compatibility.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;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core
@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;
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
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;
}
内容来源于网络,如有侵权,请联系作者删除!