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


Java Endpoint类代码示例

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


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

示例1: createJerseyAdapter

import org.apache.zookeeper.server.jersey.cfg.Endpoint; //导入依赖的package包/类
private ServletAdapter createJerseyAdapter(Endpoint e) {
    ServletAdapter jersey = new ServletAdapter();

    jersey.setServletInstance(new ServletContainer());
    jersey.addInitParameter("com.sun.jersey.config.property.packages",
            "org.apache.zookeeper.server.jersey.resources");
    jersey.setContextPath(e.getContext());

    Credentials c = Credentials.join(e.getCredentials(), cfg
            .getCredentials());
    if (!c.isEmpty()) {
        jersey.addFilter(new HTTPBasicAuth(c), e.getContext()
                + "-basic-auth", null);
    }

    return jersey;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:18,代码来源:RestMain.java

示例2: start

import org.apache.zookeeper.server.jersey.cfg.Endpoint; //导入依赖的package包/类
public void start() throws IOException {
    System.out.println("Starting grizzly ...");

    boolean useSSL = cfg.useSSL();
    gws = new GrizzlyWebServer(cfg.getPort(), "/tmp/23cxv45345/2131xc2/", useSSL);
    // BUG: Grizzly needs a doc root if you are going to register multiple adapters

    for (Endpoint e : cfg.getEndpoints()) {
        ZooKeeperService.mapContext(e.getContext(), e);
        gws.addGrizzlyAdapter(createJerseyAdapter(e), new String[] { e
                .getContext() });
    }
    
    if (useSSL) {
        System.out.println("Starting SSL ...");
        String jks = cfg.getJKS("keys/rest.jks");
        String jksPassword = cfg.getJKSPassword();

        SSLConfig sslConfig = new SSLConfig();
        URL resource = getClass().getClassLoader().getResource(jks);
        if (resource == null) {
            LOG.error("Unable to find the keystore file: " + jks);
            System.exit(2);
        }
        try {
            sslConfig.setKeyStoreFile(new File(resource.toURI())
                    .getAbsolutePath());
        } catch (URISyntaxException e1) {
            LOG.error("Unable to load keystore: " + jks, e1);
            System.exit(2);
        }
        sslConfig.setKeyStorePass(jksPassword);
        gws.setSSLConfig(sslConfig);
    }

    gws.start();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:38,代码来源:RestMain.java

示例3: printEndpoints

import org.apache.zookeeper.server.jersey.cfg.Endpoint; //导入依赖的package包/类
private static void printEndpoints(RestCfg cfg) {
    int port = cfg.getPort();

    for (Endpoint e : cfg.getEndpoints()) {

        String context = e.getContext();
        if (context.charAt(context.length() - 1) != '/') {
            context += "/";
        }

        System.out.println(String.format(
                "Started %s - WADL: http://localhost:%d%sapplication.wadl",
                context, port, context));
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:16,代码来源:RestMain.java

示例4: getClient

import org.apache.zookeeper.server.jersey.cfg.Endpoint; //导入依赖的package包/类
/**
 * Return a ZooKeeper client which may or may not be connected, but it will
 * not be expired. This method can be called multiple times, the same object
 * will be returned except in the case where the session expires (at which
 * point a new session will be returned)
 */
synchronized public static ZooKeeper getClient(String contextPath,
        String session, int expireTime) throws IOException {
    final String connectionId = concat(contextPath, session);

    ZooKeeper zk = zkMap.get(connectionId);
    if (zk == null) {

        if (LOG.isInfoEnabled()) {
            LOG.info(String.format("creating new "
                    + "connection for : '%s'", connectionId));
        }
        Endpoint e = contextMap.get(contextPath);
        zk = new ZooKeeper(e.getHostPort(), 30000, new MyWatcher(
                connectionId));
        
        for (Map.Entry<String, String> p : e.getZooKeeperAuthInfo().entrySet()) {
            zk.addAuthInfo("digest", String.format("%s:%s", p.getKey(),
                    p.getValue()).getBytes());
        }
        
        zkMap.put(connectionId, zk);

        // a session should automatically expire after an amount of time
        if (session != null) {
            zkSessionTimers.put(connectionId, new SessionTimerTask(
                    expireTime, session, contextPath, timer));
        }
    }
    return zk;
}
 
开发者ID:jdc91,项目名称:StreamProcessingInfrastructure,代码行数:37,代码来源:ZooKeeperService.java


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