本文整理汇总了Java中org.osgi.framework.Version.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Version.equals方法的具体用法?Java Version.equals怎么用?Java Version.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.Version
的用法示例。
在下文中一共展示了Version.equals方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rebuildProjectIfPluginVersionChanged
import org.osgi.framework.Version; //导入方法依赖的package包/类
private static void rebuildProjectIfPluginVersionChanged(IProject project) {
// We're only worried about GWT projects
if (GWTNature.isGWTProject(project.getProject())) {
// Find the last plugin version that know the project was built with
Version lastForcedRebuildAt = GdtPreferences.getVersionForLastForcedRebuild(project);
Version currentPluginVersion = GdtPlugin.getVersion();
if (!lastForcedRebuildAt.equals(currentPluginVersion)) {
GdtPreferences.setVersionForLastForcedRebuild(project, currentPluginVersion);
BuilderUtilities.scheduleRebuild(project);
CorePluginLog.logInfo("Scheduled rebuild of project " + project.getName()
+ " because of plugin update (current version: " + currentPluginVersion.toString() + ")");
}
}
}
示例2: loadBundleFromLocal
import org.osgi.framework.Version; //导入方法依赖的package包/类
public static Bundle loadBundleFromLocal(BundleContext bc,String name, Version version, boolean loadIfNecessary, Bundle defaultValue) {
name=name.trim();
Bundle[] bundles = bc.getBundles();
for(Bundle b:bundles){
if(name.equalsIgnoreCase(b.getSymbolicName())) {
if(version==null || version.equals(b.getVersion())) {
return b;
}
}
}
if(!loadIfNecessary) return defaultValue;
// is it in jar directory but not loaded
CFMLEngine engine = ConfigWebUtil.getEngine(ThreadLocalPageContext.getConfig());
CFMLEngineFactory factory = engine.getCFMLEngineFactory();
BundleFile bf = _getBundleFile(factory, name, version, null);
if(bf!=null) {
try {
return _loadBundle(bc, bf.getFile());
}
catch (Exception e) {}
}
return defaultValue;
}
示例3: getBundleLoaded
import org.osgi.framework.Version; //导入方法依赖的package包/类
public static Bundle getBundleLoaded(BundleContext bc,String name, Version version, Bundle defaultValue) {
name=name.trim();
Bundle[] bundles = bc.getBundles();
for(Bundle b:bundles){
if(name.equalsIgnoreCase(b.getSymbolicName())) {
if(version==null || version.equals(b.getVersion())) {
return b;
}
}
}
return defaultValue;
}
示例4: _cleanBundles
import org.osgi.framework.Version; //导入方法依赖的package包/类
private static void _cleanBundles(BundleDefinition[] candiatesToRemove, String name, Version version) {
BundleDefinition bd;
for(int i=0;i<candiatesToRemove.length;i++){
bd=candiatesToRemove[i];
if(bd!=null && name.equalsIgnoreCase(bd.getName())) {
if(version==null) {
if(bd.getVersion()==null) candiatesToRemove[i]=null; // remove that from array
}
else if(bd.getVersion()!=null && version.equals(bd.getVersion())) {
candiatesToRemove[i]=null; // remove that from array
}
}
}
}
示例5: matchExtenderVersionRange
import org.osgi.framework.Version; //导入方法依赖的package包/类
public static boolean matchExtenderVersionRange(Bundle bundle, String header, Version versionToMatch) {
Assert.notNull(bundle);
// get version range
String range = (String) bundle.getHeaders().get(header);
boolean trace = log.isTraceEnabled();
// empty value = empty version = *
if (!StringUtils.hasText(range))
return true;
if (trace)
log.trace("discovered " + header + " header w/ value=" + range);
// do we have a range or not ?
range = StringUtils.trimWhitespace(range);
// a range means one comma
int commaNr = StringUtils.countOccurrencesOf(range, COMMA);
// no comma, no intervals
if (commaNr == 0) {
Version version = Version.parseVersion(range);
return versionToMatch.equals(version);
}
if (commaNr == 1) {
// sanity check
if (!((range.startsWith(LEFT_CLOSED_INTERVAL) || range.startsWith(LEFT_OPEN_INTERVAL)) && (range.endsWith(RIGHT_CLOSED_INTERVAL) || range.endsWith(RIGHT_OPEN_INTERVAL)))) {
throw new IllegalArgumentException("range [" + range + "] is invalid");
}
boolean equalMin = range.startsWith(LEFT_CLOSED_INTERVAL);
boolean equalMax = range.endsWith(RIGHT_CLOSED_INTERVAL);
// remove interval brackets
range = range.substring(1, range.length() - 1);
// split the remaining string in two pieces
String[] pieces = StringUtils.split(range, COMMA);
if (trace)
log.trace("discovered low/high versions : " + ObjectUtils.nullSafeToString(pieces));
Version minVer = Version.parseVersion(pieces[0]);
Version maxVer = Version.parseVersion(pieces[1]);
if (trace)
log.trace("comparing version " + versionToMatch + " w/ min=" + minVer + " and max=" + maxVer);
boolean result = true;
int compareMin = versionToMatch.compareTo(minVer);
if (equalMin)
result = (result && (compareMin >= 0));
else
result = (result && (compareMin > 0));
int compareMax = versionToMatch.compareTo(maxVer);
if (equalMax)
result = (result && (compareMax <= 0));
else
result = (result && (compareMax < 0));
return result;
}
// more then one comma means incorrect range
throw new IllegalArgumentException("range [" + range + "] is invalid");
}
示例6: debugClassLoading
import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
* Tries (through a best-guess attempt) to figure out why a given class
* could not be found. This method will search the given bundle and its
* classpath to determine the reason for which the class cannot be loaded.
*
* <p/> This method tries to be effective especially when the dealing with
* {@link NoClassDefFoundError} caused by failure of loading transitive
* classes (such as getting a NCDFE when loading <code>foo.A</code>
* because <code>bar.B</code> cannot be found).
*
* @param bundle the bundle to search for (and which should do the loading)
* @param className the name of the class that failed to be loaded in dot
* format (i.e. java.lang.Thread)
* @param rootClassName the name of the class that triggered the loading
* (i.e. java.lang.Runnable)
*/
public static void debugClassLoading(Bundle bundle, String className, String rootClassName) {
boolean trace = log.isTraceEnabled();
if (!trace)
return;
Dictionary dict = bundle.getHeaders();
String bname = dict.get(Constants.BUNDLE_NAME) + "(" + dict.get(Constants.BUNDLE_SYMBOLICNAME) + ")";
if (trace)
log.trace("Could not find class [" + className + "] required by [" + bname + "] scanning available bundles");
BundleContext context = OsgiBundleUtils.getBundleContext(bundle);
int pkgIndex = className.lastIndexOf('.');
// Reject global packages
if (pkgIndex < 0) {
if (trace)
log.trace("Class is not in a package, its unlikely that this will work");
return;
}
String packageName = className.substring(0, pkgIndex);
Version iversion = hasImport(bundle, packageName);
if (iversion != null && context != null) {
if (trace)
log.trace("Class is correctly imported as version [" + iversion + "], checking providing bundles");
Bundle[] bundles = context.getBundles();
for (int i = 0; i < bundles.length; i++) {
if (bundles[i].getBundleId() != bundle.getBundleId()) {
Version exported = checkBundleForClass(bundles[i], className, iversion);
// Everything looks ok, but is the root bundle importing the
// dependent class also?
if (exported != null && exported.equals(iversion) && rootClassName != null) {
for (int j = 0; j < bundles.length; j++) {
Version rootexport = hasExport(bundles[j], rootClassName.substring(0,
rootClassName.lastIndexOf('.')));
if (rootexport != null) {
// TODO -- this is very rough, check the bundle
// classpath also.
Version rootimport = hasImport(bundles[j], packageName);
if (rootimport == null || !rootimport.equals(iversion)) {
if (trace)
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundles[j])
+ "] exports [" + rootClassName + "] as version [" + rootexport
+ "] but does not import dependent package [" + packageName
+ "] at version [" + iversion + "]");
}
}
}
}
}
}
}
if (hasExport(bundle, packageName) != null) {
if (trace)
log.trace("Class is exported, checking this bundle");
checkBundleForClass(bundle, className, iversion);
}
}
示例7: checkBundleForClass
import org.osgi.framework.Version; //导入方法依赖的package包/类
private static Version checkBundleForClass(Bundle bundle, String name, Version iversion) {
String packageName = name.substring(0, name.lastIndexOf('.'));
Version hasExport = hasExport(bundle, packageName);
// log.info("Examining Bundle [" + bundle.getBundleId() + ": " + bname +
// "]");
// Check for version matching
if (hasExport != null && !hasExport.equals(iversion)) {
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] exports [" + packageName
+ "] as version [" + hasExport + "] but version [" + iversion + "] was required");
return hasExport;
}
// Do more detailed checks
String cname = name.substring(packageName.length() + 1) + ".class";
Enumeration e = bundle.findEntries("/" + packageName.replace('.', '/'), cname, false);
if (e == null) {
if (hasExport != null) {
URL url = checkBundleJarsForClass(bundle, name);
if (url != null) {
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains [" + cname
+ "] in embedded jar [" + url.toString() + "] but exports the package");
}
else {
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] does not contain ["
+ cname + "] but exports the package");
}
}
String root = "/";
String fileName = packageName;
if (packageName.lastIndexOf(".") >= 0) {
root = root + packageName.substring(0, packageName.lastIndexOf(".")).replace('.', '/');
fileName = packageName.substring(packageName.lastIndexOf(".") + 1).replace('.', '/');
}
Enumeration pe = bundle.findEntries(root, fileName, false);
if (pe != null) {
if (hasExport != null) {
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains package ["
+ packageName + "] and exports it");
}
else {
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains package ["
+ packageName + "] but does not export it");
}
}
}
// Found the resource, check that it is exported.
else {
if (hasExport != null) {
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains resource [" + cname
+ "] and it is correctly exported as version [" + hasExport + "]");
Class<?> c = null;
try {
c = bundle.loadClass(name);
}
catch (ClassNotFoundException e1) {
// Ignored
}
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] loadClass [" + cname
+ "] returns [" + c + "]");
}
else {
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains resource [" + cname
+ "] but its package is not exported");
}
}
return hasExport;
}
示例8: _eq
import org.osgi.framework.Version; //导入方法依赖的package包/类
private boolean _eq(String lName, Version lVersion, String rName, Version rVersion) {
if(!lName.equals(rName)) return false;
if(lVersion==null) return rVersion==null;
return lVersion.equals(rVersion);
}
示例9: changeVersionTo
import org.osgi.framework.Version; //导入方法依赖的package包/类
public void changeVersionTo(Version version, Password password, IdentificationWeb id) throws PageException {
checkWriteAccess();
ConfigServerImpl cs=(ConfigServerImpl) ConfigImpl.getConfigServer(config,password);
try {
CFMLEngineFactory factory = cs.getCFMLEngine().getCFMLEngineFactory();
cleanUp(factory);
// do we have the core file?
final File patchDir = factory.getPatchDirectory();
File localPath=new File(version.toString()+".lco");
if(!localPath.isFile()) {
localPath=null;
Version v;
final File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { ".lco" }));
for (final File patch : patches) {
v=CFMLEngineFactory.toVersion(patch.getName(),null);
// not a valid file get deleted
if(v==null){
patch.delete();
}
else {
if(v.equals(version)) { // match!
localPath=patch;
}
// delete newer files
else if(OSGiUtil.isNewerThan(v,version)) {
patch.delete();
}
}
}
}
// download patch
if(localPath==null) {
downloadCore(factory, version, id);
}
factory.restart(password);
}
catch (Exception e) {
throw Caster.toPageException(e);
}
}