本文整理了Java中org.eclipse.osgi.service.resolver.State
类的一些代码示例,展示了State
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。State
类的具体详情如下:
包路径:org.eclipse.osgi.service.resolver.State
类名称:State
[英]The state of a system as reported by a resolver. This includes all bundles presented to the resolver relative to this state (i.e., both resolved and unresolved).
This interface is not intended to be implemented by clients. The StateObjectFactory should be used to construct instances.
[中]解析程序报告的系统状态。这包括相对于该状态(即已解析和未解析)呈现给解析器的所有束。
此接口不打算由客户端实现。StateObjectFactory应用于构造实例。
代码示例来源:origin: org.eclipse/org.eclipse.osgi
public BundleDescription getBundle(long id) {
return target.getBundle(id);
}
代码示例来源:origin: org.eclipse/org.eclipse.osgi
private BundleDescription getBundleDescriptionFromToken(State state, String token) {
try {
long id = Long.parseLong(token);
return state.getBundle(id);
} catch (NumberFormatException nfe) {
BundleDescription[] allBundles = state.getBundles(token);
if (allBundles.length > 0)
return allBundles[0];
}
return null;
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
public Map getResolverErrors() {
Map map = new HashMap();
BundleDescription[] bundles = fState.getBundles();
for (int i = 0; i < bundles.length; i++) {
if (!bundles[i].isResolved()) {
map.put(bundles[i], fState.getResolverErrors(bundles[i]));
}
}
return map;
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
public boolean hasErrors() {
return fState.getHighestBundleId() > -1
&& fState.getBundles().length > fState.getResolvedBundles().length;
}
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi
private void checkSystemState(State state) {
BundleDescription[] bundles = state.getBundles();
if (bundles == null)
return;
boolean removedBundle = false;
for (int i = 0; i < bundles.length; i++) {
if (adaptor.getBundle(bundles[i].getBundleId()) == null) {
state.removeBundle(bundles[i]);
removedBundle = true;
}
}
if (removedBundle)
state.resolve(false); // do a full resolve
BundleDescription systemBundle = state.getBundle(0);
if (systemBundle == null || !systemBundle.isResolved()) {
ResolverError[] errors = systemBundle == null ? new ResolverError[0] : state.getResolverErrors(systemBundle);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < errors.length; i++) {
sb.append(errors[i].toString());
if (i < errors.length - 1)
sb.append(", "); //$NON-NLS-1$
}
// this would be a bug in the framework
throw new IllegalStateException(NLS.bind(AdaptorMsg.SYSTEMBUNDLE_NOTRESOLVED, sb.toString()));
}
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
protected void copyState(State state) {
fStateCopy = state.getFactory().createState(state);
fStateCopy.setResolver(Platform.getPlatformAdmin().getResolver());
fStateCopy.setPlatformProperties(state.getPlatformProperties());
}
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.osgi.compatibility.state
public State createState(State original) {
StateImpl newState = internalCreateState();
newState.setTimeStamp(original.getTimeStamp());
BundleDescription[] bundles = original.getBundles();
for (int i = 0; i < bundles.length; i++) {
BundleDescription newBundle = createBundleDescription(bundles[i]);
newState.basicAddBundle(newBundle);
DisabledInfo[] infos = original.getDisabledInfos(bundles[i]);
for (int j = 0; j < infos.length; j++)
newState.addDisabledInfo(new DisabledInfo(infos[j].getPolicyName(), infos[j].getMessage(), newBundle));
}
newState.setResolved(false);
newState.setPlatformProperties(original.getPlatformProperties());
return newState;
}
代码示例来源: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.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.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: org.eclipse/org.eclipse.pde.core
public static HashMap getBundleClasspaths(PDEState state) {
HashMap properties = new HashMap();
BundleDescription[] bundles = state.getState().getBundles();
for (int i = 0; i < bundles.length; i++) {
properties.put(new Long(bundles[i].getBundleId()), getValue(bundles[i], state));
}
return properties;
}
代码示例来源:origin: org.eclipse/org.eclipse.osgi
public ResolverError[] getResolverErrors(BundleDescription bundle) {
return target.getResolverErrors(bundle);
}
代码示例来源: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.core/runtime
public long getStateTimeStamp() {
PlatformAdmin admin = getPlatformAdmin();
return admin == null ? -1 : admin.getState(false).getTimeStamp();
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
protected MinimalState(MinimalState state) {
this.fState = stateObjectFactory.createState(state.fState);
this.fState.setPlatformProperties(state.fState.getPlatformProperties());
this.fState.setResolver(Platform.getPlatformAdmin().getResolver());
this.fId = state.fId;
this.fEEListChanged = state.fEEListChanged;
this.fExecutionEnvironments = state.fExecutionEnvironments;
this.fNoProfile = state.fNoProfile;
}
代码示例来源:origin: org.eclipse/org.eclipse.osgi
private Collection<BundleDescription> getDescriptionClosure(Collection<Bundle> bundles) {
State state = framework.adaptor.getState();
Collection<BundleDescription> descriptions = new ArrayList<BundleDescription>();
for (Bundle bundle : bundles) {
BundleDescription description = state.getBundle(bundle.getBundleId());
if (description != null)
descriptions.add(description);
}
return state.getDependencyClosure(descriptions);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.frameworkadmin.equinox
@Override
public void resolve(boolean increment) {
state.resolve(increment);
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.runtime
private static boolean getIsEnabled(org.osgi.framework.Bundle bundle) {
PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
State state = plaformAdmin.getState(false);
BundleDescription description = state.getBundle(bundle.getBundleId());
return (state.getDisabledInfos(description)).length == 0;
}
代码示例来源:origin: org.eclipse.tycho/tycho-core
protected void resolveState(State state) {
state.resolve(false);
// warn about missing/ambiguous/inconsistent system.bundle
BundleDescription[] bundles = state.getBundles("system.bundle");
if (bundles == null || bundles.length == 0) {
logger.warn("No system.bundle");
} else if (bundles.length > 1) {
logger.warn("Multiple system.bundles " + Arrays.toString(bundles));
} else if (bundles[0].getBundleId() != SYSTEM_BUNDLE_ID) {
logger.warn("system.bundle bundleId == " + bundles[0].getBundleId());
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core
public boolean hasErrors() {
if (fState.getHighestBundleId() > -1) {
BundleDescription[] bundles = fState.getBundles();
for (int i = 0; i < bundles.length; i++) {
BundleDescription desc = bundles[i];
if (!desc.isResolved()) {
return true;
} else if (desc.isSingleton()) {
BundleDescription[] dups = fState.getBundles(desc.getSymbolicName());
if (dups.length > 1) {
// more than one singleton
return true;
}
}
}
}
return false;
}
内容来源于网络,如有侵权,请联系作者删除!