本文整理汇总了Java中org.glassfish.jersey.server.ContainerFactory类的典型用法代码示例。如果您正苦于以下问题:Java ContainerFactory类的具体用法?Java ContainerFactory怎么用?Java ContainerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContainerFactory类属于org.glassfish.jersey.server包,在下文中一共展示了ContainerFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createServer
import org.glassfish.jersey.server.ContainerFactory; //导入依赖的package包/类
private HttpServer createServer(URI uri, ResourceConfig resourceCfg) {
final String host = uri.getHost();
final int port = uri.getPort();
final HttpServer server = new HttpServer();
final NetworkListener listener = new NetworkListener("grizzly", host, port);
listener.getTransport().setWorkerThreadPoolConfig(adjustThreadPool());
server.addListener(listener);
final ServerConfiguration config = server.getServerConfiguration();
final HttpHandler handler = ContainerFactory.createContainer(HttpHandler.class, resourceCfg);
if (handler != null)
config.addHttpHandler(handler, uri.getPath());
return server;
}
开发者ID:odiszapc,项目名称:stem,代码行数:17,代码来源:ClusterManagerDaemon.java
示例2: configureHttpContainer
import org.glassfish.jersey.server.ContainerFactory; //导入依赖的package包/类
@Override
protected void configureHttpContainer() {
container = ContainerFactory.createContainer(GrizzlyHttpContainer.class, getApplication().getConfig());
ServerConfiguration serverConfiguration = httpServer.getServerConfiguration();
serverConfiguration.setSendFileEnabled(true);
String charset = StringUtils.defaultIfBlank((String) getApplication().getProperty("app.encoding"), "utf-8");
serverConfiguration.setDefaultQueryEncoding(Charset.forName(charset));
container.setRequestURIEncoding(charset);
serverConfiguration.addHttpHandler(container);
}
开发者ID:icode,项目名称:ameba-container-grizzly,代码行数:13,代码来源:GrizzlyContainer.java
示例3: playJersey
import org.glassfish.jersey.server.ContainerFactory; //导入依赖的package包/类
@Test
public void playJersey()
{
JdkHttpHandlerContainer container = ContainerFactory
.createContainer(JdkHttpHandlerContainer.class, new TelletsApplication());
}
开发者ID:wenerme,项目名称:tellets,代码行数:9,代码来源:TelletsLauncher.java
示例4: getNettyContainer
import org.glassfish.jersey.server.ContainerFactory; //导入依赖的package包/类
private NettyContainer getNettyContainer(Resource resource, Class... classes) throws URISyntaxException {
ResourceConfig rc = new ResourceConfig()
.property(NettyContainer.PROPERTY_BASE_URI, new URI("http:/localhost:0"))
.registerResources(resource)
.registerInstances(new NettyContainerProvider())
.register(JacksonJsonProvider.class);
for (Class aClass : classes) {
rc.register(aClass);
}
return ContainerFactory.createContainer(NettyContainer.class, rc);
}
开发者ID:graylog-labs,项目名称:jersey-netty,代码行数:13,代码来源:NettyContainerTest.java
示例5: run
import org.glassfish.jersey.server.ContainerFactory; //导入依赖的package包/类
public static Server run(ResourceConfig application, Properties properties, int port, String originFilter,
String aliasName, File keystoreFile, String password, String frontendRoot, String apiPathPattern, boolean copyWebDir) {
try {
QueuedThreadPool threadPool = new QueuedThreadPool(
Integer.valueOf(properties.getProperty("jetty.maxThreads")),
Integer.valueOf(properties.getProperty("jetty.minThreads")),
Integer.valueOf(properties.getProperty("jetty.idleTimeout")),
new ArrayBlockingQueue<>(Integer.valueOf(properties.getProperty("jetty.maxQueueSize"))));
Server server = new Server(threadPool);
HttpConfiguration config = new HttpConfiguration();
if (keystoreFile != null) {
log.info("Jetty runner {}. SSL enabled.", application.getClass());
SslContextFactory sslFactory = new SslContextFactory();
sslFactory.setCertAlias(aliasName);
String path = keystoreFile.getAbsolutePath();
if (!keystoreFile.exists()) {
log.error("Couldn't load keystore file: {}", path);
return null;
}
sslFactory.setKeyStorePath(path);
sslFactory.setKeyStorePassword(password);
sslFactory.setKeyManagerPassword(password);
sslFactory.setTrustStorePath(path);
sslFactory.setTrustStorePassword(password);
config.setSecureScheme("https");
config.setSecurePort(port);
config.addCustomizer(new SecureRequestCustomizer());
ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslFactory, "http/1.1"),
new HttpConnectionFactory(config));
https.setPort(port);
server.setConnectors(new Connector[]{https});
} else {
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(config));
http.setPort(port);
server.setConnectors(new Connector[]{http});
}
Handler handler = ContainerFactory.createContainer(JettyHttpContainer.class, application);
if (originFilter != null)
handler = new CrossDomainFilter(handler, originFilter);
if (frontendRoot != null) {
WebAppContext htmlHandler = new WebAppContext();
htmlHandler.setResourceBase(frontendRoot);
htmlHandler.setCopyWebDir(copyWebDir);
Map<Pattern, Handler> pathToHandler = new HashMap<>();
pathToHandler.put(Pattern.compile(apiPathPattern), handler);
SessionManager sm = new HashSessionManager();
SessionHandler sh = new SessionHandler(sm);
htmlHandler.setSessionHandler(sh);
DefaultServlet defaultServlet = new DefaultServlet();
ServletHolder holder = new ServletHolder(defaultServlet);
holder.setInitParameter("useFileMappedBuffer", Boolean.toString(!copyWebDir));
holder.setInitParameter("cacheControl", "no-store,no-cache,must-revalidate,max-age=-1,public");
htmlHandler.addServlet(holder, "/");
handler = new RequestsRouter(htmlHandler, pathToHandler, frontendRoot);
}
server.setHandler(handler);
server.start();
while (!server.isStarted()) {
Thread.sleep(50);
}
log.info("Jetty server started {} on port {}", application.getClass(), port);
return server;
} catch (Exception e) {
log.error(String.format("Jetty start failed %s.", application.getClass()), e);
return null;
}
}
开发者ID:dsx-tech,项目名称:e-voting,代码行数:78,代码来源:JettyRunner.java
示例6: createServer
import org.glassfish.jersey.server.ContainerFactory; //导入依赖的package包/类
private HttpServer createServer(URI uri, ResourceConfig configuration) {
GrizzlyHttpContainer handler = ContainerFactory.createContainer(GrizzlyHttpContainer.class, configuration);
boolean secure = false;
SSLEngineConfigurator sslEngineConfigurator = null;
boolean start = false;
final String host = (uri.getHost() == null) ? NetworkListener.DEFAULT_NETWORK_HOST
: uri.getHost();
final int port = (uri.getPort() == -1) ? 80 : uri.getPort();
final HttpServer server = new HttpServer();
final NetworkListener listener = new NetworkListener("grizzly", host, port);
listener.setSecure(secure);
if (sslEngineConfigurator != null) {
listener.setSSLEngineConfig(sslEngineConfigurator);
}
// insert
// listener.
CompressionConfig cg = listener.getCompressionConfig();
cg.setCompressionMode(CompressionConfig.CompressionMode.ON);
// cg.setCompressableMimeTypes("text","application/json");
// end insert
server.addListener(listener);
// Map the path to the processor.
final ServerConfiguration config = server.getServerConfiguration();
if (handler != null) {
config.addHttpHandler(handler, uri.getPath());
}
config.setPassTraceRequest(true);
if (start) {
try {
// Start the server.
server.start();
} catch (IOException ex) {
throw new ProcessingException("IOException thrown when trying to start grizzly server", ex);
}
}
return server;
}
开发者ID:jakobwenzel,项目名称:rallye-server,代码行数:46,代码来源:RallyeServer.java
注:本文中的org.glassfish.jersey.server.ContainerFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论