Java 类org.apache.zookeeper.server.jersey.cfg.Endpoint 实例源码

项目:fuck_zookeeper    文件:RestMain.java   
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;
}
项目:https-github.com-apache-zookeeper    文件:RestMain.java   
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;
}
项目:ZooKeeper    文件:RestMain.java   
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;
}
项目:StreamProcessingInfrastructure    文件:RestMain.java   
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;
}
项目:bigstreams    文件:RestMain.java   
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;
}
项目:bigstreams    文件:RestMain.java   
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;
}
项目:SecureKeeper    文件:RestMain.java   
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;
}
项目:SecureKeeper    文件:RestMain.java   
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;
}
项目:StreamBench    文件:RestMain.java   
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;
}
项目:LoadBalanced_zk    文件:RestMain.java   
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;
}
项目:LoadBalanced_zk    文件:RestMain.java   
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;
}
项目:zookeeper-pkg    文件:RestMain.java   
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;
}
项目:fuck_zookeeper    文件:RestMain.java   
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();
}
项目:fuck_zookeeper    文件:RestMain.java   
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));
    }
}
项目:https-github.com-apache-zookeeper    文件:RestMain.java   
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();
}
项目:https-github.com-apache-zookeeper    文件:RestMain.java   
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));
    }
}
项目:ZooKeeper    文件:RestMain.java   
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();
}
项目:ZooKeeper    文件:RestMain.java   
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));
    }
}
项目:StreamProcessingInfrastructure    文件:ZooKeeperService.java   
/**
 * 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;
}
项目:StreamProcessingInfrastructure    文件:RestMain.java   
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();
}
项目:StreamProcessingInfrastructure    文件:RestMain.java   
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));
    }
}
项目:bigstreams    文件:ZooKeeperService.java   
/**
 * 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;
}
项目:bigstreams    文件:RestMain.java   
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();
}
项目:bigstreams    文件:RestMain.java   
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));
    }
}
项目:bigstreams    文件:ZooKeeperService.java   
/**
 * 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;
}
项目:bigstreams    文件:RestMain.java   
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();
}
项目:bigstreams    文件:RestMain.java   
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));
    }
}
项目:SecureKeeper    文件:ZooKeeperService.java   
/**
 * 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;
}
项目:SecureKeeper    文件:RestMain.java   
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();
}
项目:SecureKeeper    文件:RestMain.java   
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));
    }
}
项目:SecureKeeper    文件:ZooKeeperService.java   
/**
 * 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;
}
项目:SecureKeeper    文件:RestMain.java   
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();
}
项目:SecureKeeper    文件:RestMain.java   
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));
    }
}
项目:StreamBench    文件:ZooKeeperService.java   
/**
 * 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;
}
项目:StreamBench    文件:RestMain.java   
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();
}
项目:StreamBench    文件:RestMain.java   
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));
    }
}
项目:LoadBalanced_zk    文件:ZooKeeperService.java   
/**
 * 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;
}
项目:LoadBalanced_zk    文件:RestMain.java   
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();
}
项目:LoadBalanced_zk    文件:RestMain.java   
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));
    }
}
项目:LoadBalanced_zk    文件:ZooKeeperService.java   
/**
 * 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;
}