java.lang.Package.getImplementationTitle()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中java.lang.Package.getImplementationTitle()方法的一些代码示例,展示了Package.getImplementationTitle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Package.getImplementationTitle()方法的具体详情如下:
包路径:java.lang.Package
类名称:Package
方法名:getImplementationTitle

Package.getImplementationTitle介绍

[英]Returns the title of the implementation of this package, or nullif this is unknown. The format of this string is unspecified.
[中]返回此包的实现的标题,如果未知,则返回null。此字符串的格式未指定。

代码示例

代码示例来源:origin: org.mockito/mockito-core

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.");
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public String getName() {
  String title = GlowServer.class.getPackage().getImplementationTitle();
  if (title == null) {
    title = "Glowstone"; // NON-NLS
  }
  return title;
}

代码示例来源:origin: org.springframework.boot/spring-boot

protected String getApplicationTitle(Class<?> sourceClass) {
  Package sourcePackage = (sourceClass != null) ? sourceClass.getPackage() : null;
  return (sourcePackage != null) ? sourcePackage.getImplementationTitle() : null;
}

代码示例来源:origin: spockframework/spock

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.");
}

代码示例来源:origin: apache/incubator-druid

/**
  * 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;
 }
}

代码示例来源:origin: kairosdb/kairosdb

@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();
}

代码示例来源:origin: kairosdb/kairosdb

@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");
  }
}

代码示例来源:origin: Netflix/EVCache

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);
}

代码示例来源:origin: palantir/atlasdb

@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);
  }
}

代码示例来源:origin: prometheus/jmx_exporter

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;
 }
}

代码示例来源:origin: hcoles/pitest

@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;
}

代码示例来源:origin: haraldk/TwelveMonkeys

/**
 * 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);
}

代码示例来源:origin: palantir/atlasdb

@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));
}

代码示例来源:origin: palantir/atlasdb

@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));
}

代码示例来源:origin: palantir/atlasdb

@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));
  }
}

代码示例来源:origin: org.apache.flex.flexjs.compiler/compiler

/**
 * The name of the compiler.
 * 
 * @return name of the compiler.
 */
public static String getCompilerName()
{
  String title = VersionInfo.class.getPackage().getImplementationTitle();
  return title != null ? title : "";
}

代码示例来源:origin: org.omnifaces/omnifaces

/**
 * 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();
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core

@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);
}

代码示例来源:origin: org.jboss.osgi.runtime/jboss-osgi-runtime-equinox

@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;
}

代码示例来源:origin: org.carewebframework/org.carewebframework.shell

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());
}

相关文章