本文整理汇总了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;
}
示例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();
}
示例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));
}
}
示例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;
}