private boolean isComingFromJDK(Class<?> type) { // Comes from the manifest entry : // Implementation-Title: Java Runtime Environment // This entry is not necessarily present in every jar of the JDK return type.getPackage() != null && "Java Runtime Environment".equalsIgnoreCase(type.getPackage().getImplementationTitle()) || type.getName().startsWith("java.") || type.getName().startsWith("javax."); }
@Override public String getName() { String title = GlowServer.class.getPackage().getImplementationTitle(); if (title == null) { title = "Glowstone"; // NON-NLS } return title; }
protected String getApplicationTitle(Class<?> sourceClass) { Package sourcePackage = (sourceClass != null) ? sourceClass.getPackage() : null; return (sourcePackage != null) ? sourcePackage.getImplementationTitle() : null; }
private static boolean isComingFromJDK(Class<?> type) { // Try to read Implementation-Title entry from manifest which isn't present in every JDK JAR return type.getPackage() != null && "Java Runtime Environment".equalsIgnoreCase(type.getPackage().getImplementationTitle()) || type.getName().startsWith("java.") || type.getName().startsWith("javax."); }
/** * Load the unique extensions and return their implementation-versions * * @return map of extensions loaded with their respective implementation versions. */ private List<ModuleVersion> getExtensionVersions(Collection<DruidModule> druidModules) { List<ModuleVersion> moduleVersions = new ArrayList<>(); for (DruidModule module : druidModules) { String artifact = module.getClass().getPackage().getImplementationTitle(); String version = module.getClass().getPackage().getImplementationVersion(); moduleVersions.add(new ModuleVersion(module.getClass().getCanonicalName(), artifact, version)); } return moduleVersions; } }
@GET @Produces(MediaType.APPLICATION_JSON + "; charset=UTF-8") @Path("/version") public Response getVersion() { Package thisPackage = getClass().getPackage(); String versionString = thisPackage.getImplementationTitle() + " " + thisPackage.getImplementationVersion(); ResponseBuilder responseBuilder = Response.status(Response.Status.OK).entity("{\"version\": \"" + versionString + "\"}\n"); setHeaders(responseBuilder); return responseBuilder.build(); }
@Override public void execute(Channel chan, List<String> command) throws DatastoreException { m_counter.incrementAndGet(); if (chan.isConnected()) { Package thisPackage = getClass().getPackage(); String versionString = thisPackage.getImplementationTitle()+" "+thisPackage.getImplementationVersion(); chan.write(versionString+"\n"); } }
public void run() { // init the version information if(versionGauge == null) { final String fullVersion; final String jarName; if(this.getClass().getPackage().getImplementationVersion() != null) { fullVersion = this.getClass().getPackage().getImplementationVersion(); } else { fullVersion = "unknown"; } if(this.getClass().getPackage().getImplementationVersion() != null) { jarName = this.getClass().getPackage().getImplementationTitle(); } else { jarName = "unknown"; } if(log.isErrorEnabled()) log.error("fullVersion : " + fullVersion + "; jarName : " + jarName); versionGauge = EVCacheMetricsFactory.getLongGauge("evcache-client", BasicTagList.of("version", fullVersion, "jarName", jarName)); } versionGauge.set(Long.valueOf(1)); poolManager.getEVCacheScheduledExecutor().schedule(this, 30, TimeUnit.SECONDS); }
@VisibleForTesting static String fromPackage(Package classPackage) { String agent = Optional.ofNullable(classPackage.getImplementationTitle()).orElse(DEFAULT_VALUE); String version = Optional.ofNullable(classPackage.getImplementationVersion()).orElse(DEFAULT_VALUE); return fromStrings(agent, version); } }
public List<Collector.MetricFamilySamples> collect() { List<Collector.MetricFamilySamples> mfs = new ArrayList<Collector.MetricFamilySamples>(); GaugeMetricFamily artifactInfo = new GaugeMetricFamily( "jmx_exporter_build_info", "A metric with a constant '1' value labeled with the version of the JMX exporter.", asList("version", "name")); Package pkg = this.getClass().getPackage(); String version = pkg.getImplementationVersion(); String name = pkg.getImplementationTitle(); artifactInfo.addMetric(asList( version != null ? version : "unknown", name != null ? name : "unknown" ), 1L); mfs.add(artifactInfo); return mfs; } }
@Override public GroupIdPair apply(final ClientClasspathPlugin a) { final Package p = a.getClass().getPackage(); final GroupIdPair g = new GroupIdPair(p.getImplementationVendor(), p.getImplementationTitle()); if (g.id == null) { reportBadPlugin("title", a); } if (g.group == null) { reportBadPlugin("vendor", a); } return g; }
/** * Creates a provider information instance based on the given package. * * @param pPackage the package to get provider information from. * This should typically be the package containing the Spi class. * * @throws IllegalArgumentException if {@code pPackage == null} */ public ProviderInfo(final Package pPackage) { Validate.notNull(pPackage, "package"); String title = pPackage.getImplementationTitle(); this.title = title != null ? title : pPackage.getName(); String vendor = pPackage.getImplementationVendor(); vendorName = vendor != null ? vendor : fakeVendor(pPackage); String version = pPackage.getImplementationVersion(); this.version = version != null ? version : fakeVersion(pPackage); }
@Test public void canGetUserAgentDataFromPackage() { Package classPackage = mock(Package.class); when(classPackage.getImplementationVersion()).thenReturn(PACKAGE_VERSION); when(classPackage.getImplementationTitle()).thenReturn(PACKAGE_TITLE); MatcherAssert.assertThat(UserAgents.fromPackage(classPackage), is(PACKAGE_USER_AGENT)); }
@Test public void addsDefaultUserAgentDataIfUnknown() { Package classPackage = mock(Package.class); when(classPackage.getImplementationTitle()).thenReturn(null); when(classPackage.getImplementationVersion()).thenReturn(null); MatcherAssert.assertThat(UserAgents.fromPackage(classPackage), is(DEFAULT_USER_AGENT)); }
@Test public void canGetUserAgentDataFromClass() { Class<BlockingDeque> clazz = BlockingDeque.class; String expectedUserAgent = UserAgents.fromStrings( clazz.getPackage().getImplementationTitle(), clazz.getPackage().getImplementationVersion()); MatcherAssert.assertThat(UserAgents.fromClass(clazz), is(expectedUserAgent)); } }
/** * The name of the compiler. * * @return name of the compiler. */ public static String getCompilerName() { String title = VersionInfo.class.getPackage().getImplementationTitle(); return title != null ? title : ""; }
/** * Returns the implementation information of currently loaded JSF implementation. E.g. "Mojarra 2.1.7-FCS". * <p> * This is also available in EL as <code>#{faces.implInfo}</code>. * @return The implementation information of currently loaded JSF implementation. * @see Package#getImplementationTitle() * @see Package#getImplementationVersion() */ public static String getImplInfo() { Package jsfPackage = FacesContext.class.getPackage(); return jsfPackage.getImplementationTitle() + " " + jsfPackage.getImplementationVersion(); }
@Override public void appendHtml(final Writer writer) throws IOException { final Package pack = ODataDebugResponseWrapper.class.getPackage(); writer.append("<h2>Library Version</h2>\n") .append("<p>").append(pack.getImplementationTitle()) .append(" Version ").append(pack.getImplementationVersion()).append("</p>\n") .append("<h2>Server Environment</h2>\n"); ODataDebugResponseWrapper.appendHtmlTable(writer, environment); }
@Override protected Framework createFramework(Map<String, Object> properties) { // Log INFO about this implementation String implTitle = getClass().getPackage().getImplementationTitle(); String impVersion = getClass().getPackage().getImplementationVersion(); log.info(implTitle + " - " + impVersion); // Load the framework instance FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class); Framework framework = factory.newFramework(properties); return framework; }
public AboutParams(Class<?> clazz) { super(); Package pkg = clazz.getPackage(); String name = clazz.getSimpleName(); title = pkg.getImplementationTitle(); title = StringUtils.isEmpty(title) ? name : title; source = pkg.getImplementationVendor(); set("name", name); set("pkg", pkg.getName()); set("version", pkg.getImplementationVersion()); }