当前位置: 首页>>代码示例>>Java>>正文


Java VersionInfo类代码示例

本文整理汇总了Java中org.apache.http.util.VersionInfo的典型用法代码示例。如果您正苦于以下问题:Java VersionInfo类的具体用法?Java VersionInfo怎么用?Java VersionInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VersionInfo类属于org.apache.http.util包,在下文中一共展示了VersionInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
/**
 * Prints version information.
 *
 * @param args      command line arguments. Leave empty to print version
 *                  information for the default packages. Otherwise, pass
 *                  a list of packages for which to get version info.
 */
public static void main(String args[]) {
    String[]    pckgs = (args.length > 0) ? args : MODULE_LIST;
    VersionInfo[] via = VersionInfo.loadVersionInfo(pckgs, null);
    System.out.println("version info for thread context classloader:");
    for (int i=0; i<via.length; i++)
        System.out.println(via[i]);

    System.out.println();

    // if the version information for the classloader of this class
    // is different from that for the thread context classloader,
    // there may be a problem with multiple versions in the classpath

    via = VersionInfo.loadVersionInfo
        (pckgs, PrintVersionInfo.class.getClassLoader());
    System.out.println("version info for static classloader:");
    for (int i=0; i<via.length; i++)
        System.out.println(via[i]);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:PrintVersionInfo.java

示例2: setDefaultHttpParams

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
/**
 * Saves the default set of HttpParams in the provided parameter. These are:
 * <ul>
 * <li>{@link CoreProtocolPNames#PROTOCOL_VERSION}: 1.1</li>
 * <li>{@link CoreProtocolPNames#HTTP_CONTENT_CHARSET}: ISO-8859-1</li>
 * <li>{@link CoreConnectionPNames#TCP_NODELAY}: true</li>
 * <li>{@link CoreConnectionPNames#SOCKET_BUFFER_SIZE}: 8192</li>
 * <li>{@link CoreProtocolPNames#USER_AGENT}: Apache-HttpClient/<release>
 * (java 1.5)</li>
 * </ul>
 */
public void setDefaultHttpParams(HttpParams params) {
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    if (charset == null)
        HttpProtocolParams.setContentCharset(params,
            HTTP.DEF_CONTENT_CHARSET.name());
    else
        HttpProtocolParams.setContentCharset(params, charset);
    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);

    // determine the release version from packaged version info
    final VersionInfo vi = VersionInfo.loadVersionInfo(
        "org.apache.http.client",
        DefaultHttpClient.class.getClassLoader());
    final String release = (vi != null) ? vi.getRelease()
        : VersionInfo.UNAVAILABLE;
    if (getUserAgent() == null)
        HttpProtocolParams.setUserAgent(params, "Navi-HttpClient/"
            + release + " (java 1.5, navi 2.x)");
    else
        HttpProtocolParams.setUserAgent(params, getUserAgent());
    HttpConnectionParams.setConnectionTimeout(params, getConnectTimeout());
    HttpConnectionParams.setSoTimeout(params, getSocketTimeout());
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:36,代码来源:NaviHttpBasicConfig.java

示例3: generateViaHeader

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
private String generateViaHeader(final HttpMessage msg) {

        final ProtocolVersion pv = msg.getProtocolVersion();
        final String existingEntry = viaHeaders.get(pv);
        if (existingEntry != null) {
            return existingEntry;
        }

        final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader());
        final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;

        String value;
        if ("http".equalsIgnoreCase(pv.getProtocol())) {
            value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getMajor(), pv.getMinor(),
                    release);
        } else {
            value = String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getProtocol(), pv.getMajor(),
                    pv.getMinor(), release);
        }
        viaHeaders.put(pv, value);

        return value;
    }
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:CachingHttpClient.java

示例4: generateViaHeader

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
private String generateViaHeader(final HttpMessage msg) {

        final ProtocolVersion pv = msg.getProtocolVersion();
        final String existingEntry = viaHeaders.get(pv);
        if (existingEntry != null) {
            return existingEntry;
        }

        final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader());
        final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;

        String value;
        final int major = pv.getMajor();
        final int minor = pv.getMinor();
        if ("http".equalsIgnoreCase(pv.getProtocol())) {
            value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", major, minor,
                    release);
        } else {
            value = String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getProtocol(), major,
                    minor, release);
        }
        viaHeaders.put(pv, value);

        return value;
    }
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:26,代码来源:CachingExec.java

示例5: MinimalClientExec

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
public MinimalClientExec(
        final HttpRequestExecutor requestExecutor,
        final HttpClientConnectionManager connManager,
        final ConnectionReuseStrategy reuseStrategy,
        final ConnectionKeepAliveStrategy keepAliveStrategy) {
    Args.notNull(requestExecutor, "HTTP request executor");
    Args.notNull(connManager, "Client connection manager");
    Args.notNull(reuseStrategy, "Connection reuse strategy");
    Args.notNull(keepAliveStrategy, "Connection keep alive strategy");
    this.httpProcessor = new ImmutableHttpProcessor(
            new RequestContent(),
            new RequestTargetHost(),
            new RequestClientConnControl(),
            new RequestUserAgent(VersionInfo.getUserAgent(
                    "Apache-HttpClient", "org.apache.http.client", getClass())));
    this.requestExecutor    = requestExecutor;
    this.connManager        = connManager;
    this.reuseStrategy      = reuseStrategy;
    this.keepAliveStrategy  = keepAliveStrategy;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:MinimalClientExec.java

示例6: createHttpParams

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
@Override
protected HttpParams createHttpParams() {
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, 
            HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, 
            HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, 
            true);
    HttpConnectionParams.setTcpNoDelay(params, 
            true);
    HttpConnectionParams.setSocketBufferSize(params, 
            8192);

    // determine the release version from packaged version info
    final VersionInfo vi = VersionInfo.loadVersionInfo
        ("org.apache.http.client", getClass().getClassLoader());
    final String release = (vi != null) ?
        vi.getRelease() : VersionInfo.UNAVAILABLE;
    HttpProtocolParams.setUserAgent(params, 
            "Apache-HttpClient/" + release + " (java 1.5)");

    return params;
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:25,代码来源:DefaultHttpClient.java

示例7: createDefaultHttpParams

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
/**
 * Default Http parameters got from the DefaultHttpClient implementation.
 *
 * @return
 * Default HTTP connection parameters
 */
public static HttpParams createDefaultHttpParams() {
    HttpParams params = new SyncBasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params,
            HTTP.DEFAULT_CONTENT_CHARSET);
    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);

    // determine the release version from packaged version info
    final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client",
            HttpClient.class.getClassLoader());
    final String release = (vi != null)
            ? vi.getRelease()
            : VersionInfo.UNAVAILABLE;
    HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release
            + " (java 1.5)");

    return params;
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:26,代码来源:RestUtils.java

示例8: generateViaHeader

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
private String generateViaHeader(HttpMessage msg) {
	final VersionInfo vi = VersionInfo.loadVersionInfo(
			"org.apache.http.client", getClass().getClassLoader());
	final String release = (vi != null) ? vi.getRelease()
			: VersionInfo.UNAVAILABLE;
	final ProtocolVersion pv = msg.getProtocolVersion();
	if ("http".equalsIgnoreCase(pv.getProtocol())) {
		return String.format(
				"%d.%d localhost (Apache-HttpClient/%s (cache))",
				pv.getMajor(), pv.getMinor(), release);
	} else {
		return String.format(
				"%s/%d.%d localhost (Apache-HttpClient/%s (cache))",
				pv.getProtocol(), pv.getMajor(), pv.getMinor(), release);
	}
}
 
开发者ID:apigee,项目名称:apigee-android-sdk,代码行数:17,代码来源:CachingHttpClient.java

示例9: getFallbackDomain

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
/**
 * Get the appropriate fallback domain depending on the current SNI support.
 * Checks Java version and Apache HTTP Client's version.
 *
 * @return algolianet.com if the current setup supports SNI, else algolia.net.
 */
static String getFallbackDomain() {
  String version = System.getProperty("java.version");
  int pos = version.indexOf('.');
  pos = version.indexOf('.', pos + 1);
  boolean javaHasSNI = Double.parseDouble(version.substring(0, pos)) >= 1.7;

  final VersionInfo vi = VersionInfo.loadVersionInfo
    ("org.apache.http.client", APIClient.class.getClassLoader());
  version = vi.getRelease();
  String[] split = version.split("\\.");
  int major = Integer.parseInt(split[0]);
  int minor = Integer.parseInt(split[1]);
  int patch = Integer.parseInt(split[2]);
  boolean apacheClientHasSNI = major > 4 ||
    major == 4 && minor > 3 ||
    major == 4 && minor == 3 && patch >= 2; // if version >= 4.3.2

  if (apacheClientHasSNI && javaHasSNI) {
    return "algolianet.com";
  } else {
    return "algolia.net";
  }
}
 
开发者ID:algolia,项目名称:algoliasearch-client-java,代码行数:30,代码来源:APIClient.java

示例10: setDefaultHttpParams

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
/**
 * Saves the default set of HttpParams in the provided parameter.
 * These are:
 * <ul>
 * <li>{@link CoreProtocolPNames#PROTOCOL_VERSION}: 1.1</li>
 * <li>{@link CoreProtocolPNames#HTTP_CONTENT_CHARSET}: ISO-8859-1</li>
 * <li>{@link CoreConnectionPNames#TCP_NODELAY}: true</li>
 * <li>{@link CoreConnectionPNames#SOCKET_BUFFER_SIZE}: 8192</li>
 * <li>{@link CoreProtocolPNames#USER_AGENT}: Apache-HttpClient/<release> (java 1.5)</li>
 * </ul>
 */
public static void setDefaultHttpParams(HttpParams params) {
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);

    // determine the release version from packaged version info
    final VersionInfo vi = VersionInfo.loadVersionInfo
        ("org.apache.http.client", DefaultHttpClient.class.getClassLoader());
    final String release = (vi != null) ?
        vi.getRelease() : VersionInfo.UNAVAILABLE;
    HttpProtocolParams.setUserAgent(params,
            "Apache-HttpClient/" + release + " (java 1.5)");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:DefaultHttpClient.java

示例11: getNaviHttpParams

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
private HttpParams getNaviHttpParams(NaviHttpPoolConfig httpPoolConfig) {
    params = new SyncBasicHttpParams();

    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    if (httpPoolConfig.getCharset() == null) {
        HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
    } else {
        HttpProtocolParams.setContentCharset(params, httpPoolConfig.getCharset());
    }

    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);

    // determine the release version from packaged version info
    final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", DefaultHttpClient.class.getClassLoader());
    final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
    if (httpPoolConfig.getUserAgent() == null) {
        HttpProtocolParams.setUserAgent(params, "Navi-HttpClient/" + release + " (java 1.5, navi 2.x)");
    } else {
        HttpProtocolParams.setUserAgent(params, httpPoolConfig.getUserAgent());
    }

    HttpConnectionParams.setConnectionTimeout(params, httpPoolConfig.getConnectTimeout());
    HttpConnectionParams.setSoTimeout(params, httpPoolConfig.getSocketTimeout());

    if (httpPoolConfig.getProxy() != null) {
        try {
            String[] connectionString = httpPoolConfig.getProxy().split(":");
            HttpHost proxy = new HttpHost(connectionString[0], Integer.valueOf(connectionString[1]));
            // Integer.getInteger(connectionString[1]));
            params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        } catch (Exception e) {
            log.info(e.getMessage());
        }
    }
    return params;
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:38,代码来源:NaviHttpClientDriver.java

示例12: getUserAgent

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
private String getUserAgent() {
    final Package pkg = Package.getPackage("com.gooddata");
    final String clientVersion = pkg != null && pkg.getImplementationVersion() != null
            ? pkg.getImplementationVersion() : UNKNOWN_VERSION;

    final VersionInfo vi = loadVersionInfo("org.apache.http.client", HttpClientBuilder.class.getClassLoader());
    final String apacheVersion = vi != null ? vi.getRelease() : UNKNOWN_VERSION;

    return String.format("%s/%s (%s; %s) %s/%s", "GoodData-Java-SDK", clientVersion,
            System.getProperty("os.name"), System.getProperty("java.specification.version"),
            "Apache-HttpClient", apacheVersion);
}
 
开发者ID:gooddata,项目名称:gooddata-java,代码行数:13,代码来源:GoodData.java

示例13: appendTo

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
@Override
public void appendTo(StringBuilder sb)
{
    sb.append(VersionInfo.getUserAgent("Apache-HttpClient",
            "org.apache.http.client", HttpClient.class));
}
 
开发者ID:dmfs,项目名称:http-client-essentials-suite,代码行数:7,代码来源:ApacheProduct.java

示例14: getClientConfig

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
public static ClientConfig getClientConfig(final ServerContext.Type type,
                                           final Credentials credentials,
                                           final String serverUri,
                                           final boolean includeProxySettings) {

    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, credentials);

    final ConnectorProvider connectorProvider = new ApacheConnectorProvider();
    // custom json provider ignores new fields that aren't recognized
    final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    final ClientConfig clientConfig = new ClientConfig(jacksonJsonProvider).connectorProvider(connectorProvider);
    clientConfig.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
    clientConfig.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED);

    // For TFS OnPrem we only support NTLM authentication right now. Since 2016 servers support Basic as well,
    // we need to let the server and client negotiate the protocol instead of preemptively assuming Basic.
    // TODO: This prevents PATs from being used OnPrem. We need to fix this soon to support PATs onPrem.
    clientConfig.property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, type != ServerContext.Type.TFS);

    //Define a local HTTP proxy
    if (includeProxySettings) {
        final HttpProxyService proxyService = PluginServiceProvider.getInstance().getHttpProxyService();
        final String proxyUrl = proxyService.getProxyURL();
        clientConfig.property(ClientProperties.PROXY_URI, proxyUrl);
        if (proxyService.isAuthenticationRequired()) {
            // To work with authenticated proxies and TFS, we provide the proxy credentials if they are registered
            final AuthScope ntlmAuthScope =
                    new AuthScope(proxyService.getProxyHost(), proxyService.getProxyPort(),
                            AuthScope.ANY_REALM, AuthScope.ANY_SCHEME);
            credentialsProvider.setCredentials(ntlmAuthScope,
                    new UsernamePasswordCredentials(proxyService.getUserName(), proxyService.getPassword()));
        }
    }

    // if this is a onPrem server and the uri starts with https, we need to setup ssl
    if (isSSLEnabledOnPrem(type, serverUri)) {
        clientConfig.property(ApacheClientProperties.SSL_CONFIG, getSslConfigurator());
    }

    // register a filter to set the User Agent header
    clientConfig.register(new ClientRequestFilter() {
        @Override
        public void filter(final ClientRequestContext requestContext) throws IOException {
            // The default user agent is something like "Jersey/2.6"
            final String defaultUserAgent = VersionInfo.getUserAgent("Apache-HttpClient", "org.apache.http.client", HttpClientBuilder.class);
            // We get the user agent string from the Telemetry context
            final String userAgent = PluginServiceProvider.getInstance().getTelemetryContextInitializer().getUserAgent(defaultUserAgent);
            // Finally, we can add the header
            requestContext.getHeaders().add(HttpHeaders.USER_AGENT, userAgent);
        }
    });

    return clientConfig;
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:58,代码来源:RestClientHelper.java

示例15: getUserAgent

import org.apache.http.util.VersionInfo; //导入依赖的package包/类
public String getUserAgent() {
	Package pack = getClass().getPackage();
	String httpClientVersion = VersionInfo.getUserAgent("Apache-HttpClient", "org.apache.http.client",
			Request.class);
	return "Apache-Taverna-OSGi" + "/" + pack.getImplementationVersion() + " (" + httpClientVersion + ")";
}
 
开发者ID:apache,项目名称:incubator-taverna-osgi,代码行数:7,代码来源:DownloadManagerImpl.java


注:本文中的org.apache.http.util.VersionInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。