本文整理汇总了Java中org.osgi.framework.Version类的典型用法代码示例。如果您正苦于以下问题:Java Version类的具体用法?Java Version怎么用?Java Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Version类属于org.osgi.framework包,在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFromManifest
import org.osgi.framework.Version; //导入依赖的package包/类
private Bundle readFromManifest ( final String location, final Manifest m ) throws IOException
{
final Object sn = m.getMainAttributes ().getValue ( Constants.BUNDLE_SYMBOLICNAME );
if ( ! ( sn instanceof String ) )
{
return null;
}
final Object version = m.getMainAttributes ().getValue ( Constants.BUNDLE_VERSION );
if ( ! ( version instanceof String ) )
{
return null;
}
String symName = (String)sn;
symName = symName.split ( ";", 2 )[0];
return new Bundle ( symName, new Version ( (String)version ), location );
}
示例2: extractFeatureFromDependency
import org.osgi.framework.Version; //导入依赖的package包/类
protected Feature extractFeatureFromDependency(final Dependency dependency) throws Exception {
Feature[] features = featuresService.listFeatures();
VersionRange range = org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION.equals(dependency
.getVersion()) ? VersionRange.ANY_VERSION : new VersionRange(dependency.getVersion(), true, true);
Feature fi = null;
for (Feature f : features) {
if (f.getName().equals(dependency.getName())) {
Version version = VersionTable.getVersion(f.getVersion());
if (range.contains(version) && (fi == null || VersionTable.getVersion(fi.getVersion())
.compareTo(version) < 0)) {
fi = f;
break;
}
}
}
return fi;
}
示例3: makeQualifiedVersion
import org.osgi.framework.Version; //导入依赖的package包/类
private Version makeQualifiedVersion() {
try {
final ReactorProject rp = (ReactorProject) this.project.getContextValue(ReactorProject.CTX_REACTOR_PROJECT);
if (rp != null) {
return new Version(rp.getExpandedVersion());
}
} catch (final Exception e) {
getLog().debug("Failed to get qualified tycho version", e);
}
String version = this.project.getVersion();
if (version.endsWith("-SNAPSHOT")) {
version = version.replaceAll("-SNAPSHOT$", "." + TIMESTAMP_FORMAT.format(this.session.getStartTime()));
}
return new Version(version);
}
示例4: test1
import org.osgi.framework.Version; //导入依赖的package包/类
@Test
public void test1 ()
{
final FeatureInformation fi = new FeatureInformation ();
fi.setId ( "f1" );
fi.setVersion ( Version.parseVersion ( "1.2.3" ) );
fi.setQualifiers ( new Qualifiers () );
fi.getRequirements ().add ( new Requirement ( Type.FEATURE, "f2", null, MatchRule.DEFAULT ) );
fi.getRequirements ().add ( new Requirement ( Type.PLUGIN, "b1", null, MatchRule.DEFAULT ) );
final List<InstallableUnit> ius = InstallableUnit.fromFeature ( fi );
assertEquals ( 2, ius.size () );
assertFeatureGroup1 ( ius.get ( 0 ) );
assertFeatureJar1 ( ius.get ( 1 ) );
}
示例5: 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() + ")");
}
}
}
示例6: writeFilterProfile_10_Root
import org.osgi.framework.Version; //导入依赖的package包/类
private static XMLMemento writeFilterProfile_10_Root() {
final XMLMemento xmlRoot = XMLMemento.createWriteRoot(TAG_ROOT);
// date/time
xmlRoot.putString(Util.ATTR_ROOT_DATETIME, TimeTools.now().toString());
// plugin version
final Version version = _bundle.getVersion();
xmlRoot.putInteger(Util.ATTR_ROOT_VERSION_MAJOR, version.getMajor());
xmlRoot.putInteger(Util.ATTR_ROOT_VERSION_MINOR, version.getMinor());
xmlRoot.putInteger(Util.ATTR_ROOT_VERSION_MICRO, version.getMicro());
xmlRoot.putString(Util.ATTR_ROOT_VERSION_QUALIFIER, version.getQualifier());
// layer structure version
xmlRoot.putInteger(ATTR_TOUR_FILTER_VERSION, TOUR_FILTER_VERSION);
return xmlRoot;
}
示例7: isCompatibleVersionsRegex
import org.osgi.framework.Version; //导入依赖的package包/类
private static boolean isCompatibleVersionsRegex(Map<String, Version> installed, String required)
{
// compile the regex.
Pattern pattern = null;
try
{
pattern = Pattern.compile(required);
}
catch (PatternSyntaxException e)
{
IdeLog.logError(CorePlugin.getDefault(), MessageFormat.format(
"The required version '{0}' should be defined as a regular-expression", required)); //$NON-NLS-1$
return false;
}
// Do a match on the installed-versions original String values
for (String installedVersion : installed.keySet())
{
Matcher matcher = pattern.matcher(installedVersion);
if (matcher.find())
{
return true;
}
}
return false;
}
示例8: update
import org.osgi.framework.Version; //导入依赖的package包/类
@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig,
IJavaProject javaProject, List<String> programArgs, List<String> vmArgs)
throws CoreException {
// As of Eclipse Kepler(4.3), the use of -XStartOnFirstThread is a built-in launch config
// attribute so it is not necessary to make it an explicit argument. This prevents issues when
// sharing a launch config file across multiple OS platforms.
Bundle bundle = Platform.getBundle("org.eclipse.platform");
if (bundle != null) {
Version bundleVersion = bundle.getVersion();
if (bundleVersion.getMajor() == 4 && bundleVersion.getMinor() >= 3) {
updateEclipse43(launchConfig, javaProject, programArgs, vmArgs);
} else {
updateNonEclipse43(launchConfig, javaProject, programArgs, vmArgs);
}
}
}
示例9: 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;
}
示例10: create_Root
import org.osgi.framework.Version; //导入依赖的package包/类
private static XMLMemento create_Root() {
final XMLMemento xmlRoot = XMLMemento.createWriteRoot(TAG_ROOT);
// date/time
xmlRoot.putString(Util.ATTR_ROOT_DATETIME, TimeTools.now().toString());
// plugin version
final Version version = _bundle.getVersion();
xmlRoot.putInteger(Util.ATTR_ROOT_VERSION_MAJOR, version.getMajor());
xmlRoot.putInteger(Util.ATTR_ROOT_VERSION_MINOR, version.getMinor());
xmlRoot.putInteger(Util.ATTR_ROOT_VERSION_MICRO, version.getMicro());
xmlRoot.putString(Util.ATTR_ROOT_VERSION_QUALIFIER, version.getQualifier());
// config version
xmlRoot.putInteger(ATTR_CONFIG_VERSION, CONFIG_VERSION);
return xmlRoot;
}
示例11: checkForUpdates
import org.osgi.framework.Version; //导入依赖的package包/类
@Override
public void checkForUpdates() throws PluginException {
boolean updatesFound = false;
synchronized (pluginUpdates) {
pluginUpdates.clear();
for (PluginSite pluginSite : pluginSiteManager.getPluginSites()) {
List<PluginVersions> plugins = pluginSiteManager.getPlugins(pluginSite);
for (PluginVersions plugin : plugins) {
if (installedPlugins.containsKey(plugin.getId())) {
Plugin installedPlugin = installedPlugins.get(plugin.getId());
if (installedPlugin.getFile().toFile().canWrite()) {
Version latestVersion = Version.parseVersion(plugin.getLatestVersion()
.getVersion());
if (latestVersion.compareTo(installedPlugin.getVersion()) > 0) {
pluginUpdates.put(plugin.getId(), plugin);
updatesFound = true;
}
}
}
}
}
}
if (updatesFound) {
postEvent(PluginManager.UPDATES_AVAILABLE);
}
}
示例12: runTest
import org.osgi.framework.Version; //导入依赖的package包/类
private void runTest(Map<String, Bundle> installed, DataInputStream input, DataOutputStream output) throws Exception {
String symbolicName = input.readUTF();
Version version = Version.parseVersion(input.readUTF());
String testClass = input.readUTF();
String testName = input.readUTF();
Bundle testBundle = getTestBundle(installed, input, output, symbolicName, version);
Class<?> testClazz = testBundle.loadClass(testClass);
Result result = new JUnitCore().run(Request.method(testClazz, testName));
if(result.wasSuccessful()) {
output.writeUTF(SUCCESS);
} else {
Failure failure = result.getFailures().get(0);
output.writeUTF(FAIL);
output.writeUTF(failure.getMessage());
}
output.flush();
}
示例13: getVersion
import org.osgi.framework.Version; //导入依赖的package包/类
/**
* Loads the version information to this instance.
*/
public Version getVersion() {
if (version==null) {
Bundle bundle = Platform.getBundle(this.plugInID);
version = bundle.getVersion();
}
return version;
}
示例14: setup
import org.osgi.framework.Version; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
when(punit.getPersistenceUnitName()).thenReturn("test-props");
when(punit.getPersistenceProviderClassName())
.thenReturn(ECLIPSE_PERSISTENCE_PROVIDER);
when(punit.getTransactionType()).thenReturn(PersistenceUnitTransactionType.JTA);
when(punit.getBundle()).thenReturn(punitBundle);
when(punit.getProperties()).thenReturn(punitProperties);
when(punitBundle.getBundleContext()).thenReturn(punitContext);
when(punitBundle.getVersion()).thenReturn(Version.parseVersion("1.2.3"));
when(containerContext.registerService(eq(ManagedService.class),
any(ManagedService.class), any(Dictionary.class))).thenReturn(msReg);
when(containerContext.getService(dsfRef)).thenReturn(dsf);
when(containerContext.getService(dsRef)).thenReturn(ds);
when(containerContext.createFilter(Mockito.anyString()))
.thenAnswer(new Answer<Filter>() {
@Override
public Filter answer(InvocationOnMock i) throws Throwable {
return FrameworkUtil.createFilter(i.getArguments()[0].toString());
}
});
when(punitContext.registerService(eq(EntityManagerFactory.class), any(EntityManagerFactory.class),
any(Dictionary.class))).thenReturn(emfReg);
when(emf.isOpen()).thenReturn(true);
Properties jdbcProps = new Properties();
jdbcProps.setProperty("url", JDBC_URL);
jdbcProps.setProperty("user", JDBC_USER);
jdbcProps.setProperty("password", JDBC_PASSWORD);
when(dsf.createDataSource(jdbcProps)).thenReturn(ds);
}
示例15: readQualifier
import org.osgi.framework.Version; //导入依赖的package包/类
private static String readQualifier ( final Path jarFile ) throws IOException
{
final String version = readManifest ( jarFile ).getMainAttributes ().getValue ( Constants.BUNDLE_VERSION );
if ( version == null )
{
return version;
}
return Version.parseVersion ( version ).getQualifier ();
}