/** * Returns the string representation of this version range. * * <p> * The format of the version range string will be a version string if the * right end point is <i>Infinity</i> ({@code null}) or an interval string. * * @return The string representation of this version range. */ @Override public String toString() { String s = versionRangeString; if (s != null) { return s; } String leftVersion = left.toString(); if (right == null) { StringBuffer result = new StringBuffer(leftVersion.length() + 1); result.append(left.toString0()); return versionRangeString = result.toString(); } String rightVerion = right.toString(); StringBuffer result = new StringBuffer(leftVersion.length() + rightVerion.length() + 5); result.append(leftClosed ? LEFT_CLOSED : LEFT_OPEN); result.append(left.toString0()); result.append(ENDPOINT_DELIMITER); result.append(right.toString0()); result.append(rightClosed ? RIGHT_CLOSED : RIGHT_OPEN); return versionRangeString = result.toString(); }
if (rightClosed) { return left.equals(right); } else { Version adjacent1 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "-"); return adjacent1.compareTo(right) >= 0; Version adjacent1 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "-"); return adjacent1.equals(right); } else { Version adjacent2 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "--"); return adjacent2.compareTo(right) >= 0;
throw iae; return Version.parseVersion(version);
LongJsonDeserializer deserializer = new LongJsonDeserializer(); SimpleModule module = new SimpleModule("LongDeserializerModule", new Version(1, 0, 0, null)); module.addDeserializer(Long.class, deserializer); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(module);
ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1,0,0,null)); // simpleModule.addSerializer(new ItemSerializer()); simpleModule.addSerializer(Item.class, new ItemSerializer()); mapper.registerModule(simpleModule);
private Version getBundleVersion(Bundle bundle) { Dictionary<?, ?> headers = bundle.getHeaders(); String version = (String) headers.get(Constants.BUNDLE_VERSION); return (version != null) ? Version.parseVersion(version) : Version.emptyVersion; }
SimpleModule module = new SimpleModule("ProductDeserializerModule", new Version(1, 0, 0, null)); module.addDeserializer(Product.class, new ProductJsonDeserializer()); mapper = new ObjectMapper(); mapper.registerModule(module);
ObjectMapper mapper = new ObjectMapper(); // add module for meta data permissions SimpleModule module = new SimpleModule("IncludeMetaData", new Version(0, 1, 0, "alpha")); module.addSerializer(MetaClass.class, new MetaDataSerializer(permissions, p instanceof AbstractBean ? ((AbstractBean) p).isOwner() : false)); mapper.registerModule(module); // ignore missing filters mapper.setFilters(new SimpleFilterProvider().setFailOnUnknownId(false)); return mapper.writerWithView(Views.Admin.class).writeValueAsString(p)
private void assignPersistenceUnit(PersistenceUnitInfoImpl puInfo) { PersistenceProvider provider = puInfo.getProvider(); Bundle bundle = puInfo.getBundle(); EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilderImpl(puInfo); Dictionary<String, String> emfBuilderServiceProps = new Hashtable<String, String>(); emfBuilderServiceProps.put(JPA_UNIT_NAME, puInfo.getPersistenceUnitName()); emfBuilderServiceProps.put(JPA_UNIT_VERSION, bundle.getVersion().toString()); emfBuilderServiceProps.put(JPA_UNIT_PROVIDER, provider.getClass().getName()); ServiceRegistration<EntityManagerFactoryBuilder> builderReg = bundle.getBundleContext() .registerService(EntityManagerFactoryBuilder.class, builder, emfBuilderServiceProps); puInfo.setEmfBuilderRegistration(builderReg); puInfo.setState(PersistenceUnitState.READY); }
private Bundle getBundle(String bsn, String version) { Version v = new Version(version); BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext(); for (Bundle b : context.getBundles()) { if (bsn.equals(b.getSymbolicName()) && v.equals(b.getVersion())) return b; } return null; }
@Override public void startBundle(String symbolicName, String version) throws Exception { for (Bundle bundle : syscontext.getBundles()) { if (bundle.getSymbolicName().equals(symbolicName) && bundle.getVersion().toString().equals(version)) { bundle.start(); return; } } throw new IllegalStateException("Bundle '" + symbolicName + ":" + version + "' was not found"); }
public OSGiJdbcDriver(BundleContext context, JdbcRegistry registry) { String versionString = (String) context.getBundle().getHeaders().get(Constants.BUNDLE_VERSION); Version version = new Version(versionString); majorVersion = version.getMajor(); minorVersion = version.getMinor(); this.registry = registry; }
/** * @return the Java Language Server version */ public static String getVersion() { return context == null ? "Unknown" : context.getBundle().getVersion().toString(); }
public static BundleDTO newBundleDTO(Bundle bundle) { if (bundle == null) { return null; } BundleDTO dto = new BundleDTO(); dto.id = bundle.getBundleId(); dto.lastModified = bundle.getLastModified(); dto.state = bundle.getState(); dto.symbolicName = bundle.getSymbolicName(); dto.version = bundle.getVersion().toString(); return dto; }
private Version getExpandedVersion(String versionStr) { Version version = Version.parseVersion( versionStr ); if ( VERSION_QUALIFIER.equals(version.getQualifier()) ) { return new Version(version.getMajor(), version.getMinor(), version.getMicro(), qualifier); } return version; }
public static String getVersion(Bundle bundle) { if (osgiVersion >= OSGI_1_5) { return bundle.getVersion().toString(); } return (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION); }
@Override public String getVersion() { return FrameworkUtil.getBundle(getClass()).getBundleContext().getBundle().getVersion().toString(); }
private static boolean checkMDCSupport(BundleContext context) { //MDC support is present since 1.0.9 s Version versionWithMDCSupport = new Version(1, 0, 9); for (Bundle b : context.getBundles()) { if ("org.apache.jackrabbit.oak-core".equals(b.getSymbolicName())) { return versionWithMDCSupport.compareTo(b.getVersion()) <= 0; } } //By default it is assumed that MDC support is present return true; }
@Override public boolean apply(Bundle input) { return input.getSymbolicName() != null && input.getVersion() != null && symbolicName.matcher(input.getSymbolicName()).matches() && (version == null || version.matcher(input.getVersion().toString()).matches()); } }
private URL getEndpoint(URL serverURL, String identification, Version version) { try { return new URL(serverURL, "agent/" + identification + "/" + m_bundleContext.getBundle().getSymbolicName() + "/versions/" + (version == null ? "" : version.toString())); } catch (MalformedURLException e) { throw new IllegalStateException(e); } }