本文整理汇总了Java中org.glassfish.grizzly.http.server.HttpServer.getServerConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServer.getServerConfiguration方法的具体用法?Java HttpServer.getServerConfiguration怎么用?Java HttpServer.getServerConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.glassfish.grizzly.http.server.HttpServer
的用法示例。
在下文中一共展示了HttpServer.getServerConfiguration方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
/**
* Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
* @return Grizzly HTTP server.
* @param serverURI
*/
public static HttpServer startServer(URI serverURI) throws IOException {
// create a resource config that scans for JAX-RS resources and providers
// in org.esa.pfa.ws package
final ResourceConfig resourceConfig = new ResourceConfig()
.packages("org.esa.pfa.ws")
.property("jersey.config.server.tracing.type ", "ALL");
// create and start a new instance of grizzly http server
// exposing the Jersey application at BASE_URI
HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(serverURI, resourceConfig, false);
ServerConfiguration serverConfiguration = httpServer.getServerConfiguration();
final AccessLogBuilder builder = new AccessLogBuilder("access.log");
builder.instrument(serverConfiguration);
httpServer.start();
return httpServer;
}
示例2: startServer
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public static HttpServer startServer() {
HttpServer server = new HttpServer();
server.addListener(new NetworkListener("grizzly", "0.0.0.0", 8080));
final TCPNIOTransportBuilder transportBuilder = TCPNIOTransportBuilder.newInstance();
//transportBuilder.setIOStrategy(WorkerThreadIOStrategy.getInstance());
transportBuilder.setIOStrategy(SameThreadIOStrategy.getInstance());
server.getListener("grizzly").setTransport(transportBuilder.build());
final ResourceConfig rc = new ResourceConfig().packages("xyz.muetsch.jersey");
rc.register(JacksonFeature.class);
final ServerConfiguration config = server.getServerConfiguration();
config.addHttpHandler(RuntimeDelegate.getInstance().createEndpoint(rc, GrizzlyHttpContainer.class), "/rest/todo/");
try {
server.start();
} catch (IOException e) {
e.printStackTrace();
}
return server;
}
示例3: startServer
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public static HttpServer startServer() throws IOException {
String baseUri = ConfigProperties.getInstance().getProperty("BASE_URI");
if(baseUri != null) {
BASE_URI = baseUri;
LOG.info("base uri set to: "+baseUri);
}
final ResourceConfig rc = new ResourceConfig().packages("org.eu.eark.hsink");
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
URI.create(BASE_URI), rc, false);
ServerConfiguration serverConfig = server.getServerConfiguration();
NetworkListener nL = server.getListener(server.getListeners().iterator()
.next().getName()); // grizzly
// disable server timeouts
nL.setChunkingEnabled(true);
nL.setDisableUploadTimeout(true);
nL.getKeepAlive().setIdleTimeoutInSeconds(-1); // 256
// server.getServerConfiguration();
server.start();
return server;
}
示例4: runHttpServer
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
private static void runHttpServer() throws IOException, InterruptedException {
logger.info("Http Server starting");
final HttpServer server = HttpServer.createSimpleServer("/",10024);
final ServerConfiguration config = server.getServerConfiguration();
config.addHttpHandler(new UpdateLocationApi(), "/yelli/update");
config.addHttpHandler(new CreateTrackerApi(), "/yelli/create");
config.addHttpHandler(new TestServelet(), "/yelli/test");
config.setJmxEnabled(true);
server.start();
}
示例5: setup
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
@Inject
private void setup(Injector injector, HttpServer server) {
final ServerConfiguration configuration = server.getServerConfiguration();
configuration.setDefaultErrorPageGenerator(generator != null ? generator :
injector.getInstance(key));
log.info("Configured default error page generator on server \"%s\"", configuration.getName());
}
示例6: setup
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
@Inject
private void setup(HttpServer server) {
final ServerConfiguration configuration = server.getServerConfiguration();
configuration.getMonitoringConfig().getWebServerConfig().addProbes(probe);
log.info("Configured access log writing to \"%s\" on server \"%s\"", accessLog, configuration.getName());
}
示例7: initServer
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
final HttpServer initServer(Bck2Brwsr.Resources... extraResources) throws IOException {
xRes.addAll(Arrays.asList(extraResources));
HttpServer s = HttpServer.createSimpleServer(".", new PortRange(8080, 65535));
final ServerConfiguration conf = s.getServerConfiguration();
conf.addHttpHandler(new VM(resources), "/bck2brwsr.js");
conf.addHttpHandler(new VMInit(), "/vm.js");
conf.addHttpHandler(new Classes(resources), "/classes/");
return s;
}
示例8: startServer
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
/**
* Starts Grizzly HTTP server exposing static content, JAX-RS resources
* and web sockets defined in this application.
*
* @param webRootPath static content root path.
* @return Grizzly HTTP server.
*/
public static HttpServer startServer(String webRootPath)
{
final HttpServer server = new HttpServer();
final NetworkListener listener = new NetworkListener("grizzly", BASE_URI, PORT);
server.addListener(listener);
final ServerConfiguration config = server.getServerConfiguration();
// add handler for serving static content
config.addHttpHandler(new StaticContentHandler(webRootPath), APP_PATH);
// add handler for serving JAX-RS resources
config.addHttpHandler( RuntimeDelegate
.getInstance()
.createEndpoint(new ResourceConfig().packages("it.unito.geosummly.api"),
GrizzlyHttpContainer.class),
API_PATH
);
try {
// Start the server.
server.start();
} catch (Exception ex) {
throw new ProcessingException("Exception thrown when trying to start grizzly server", ex);
}
return server;
}
示例9: Server
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public Server(PropertiesConfiguration properties) throws IOException {
m_properties = properties;
m_httpServer = new HttpServer();
int port = properties.getInt(PROPERTY_PORT, DEFAULT_PORT);
String host = properties.getString(PROPERTY_HOST, DEFAULT_HOST);
final NetworkListener networkListener = new NetworkListener(
NET_LISTENER_NAME,
host,
port);
// Enable SSL on the listener
networkListener.setSecure(true);
networkListener.setSSLEngineConfig(makeSSLConfig(m_properties));
CompressionConfig compressionConfig =
networkListener.getCompressionConfig();
compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON); // the mode
compressionConfig.setCompressionMinSize(100); // the min amount of bytes to compress
compressionConfig.setCompressableMimeTypes("text/plain", "text/html", "application/x-protobuf", "application/pdf"); // the mime types to compress
m_httpServer.addListener(networkListener);
// Create a concurrent, nonblocking, asynchronous, batching JPA-based store for persistence
// of request data. Async is OK, as persistence failures do not need to be handled by the client.
m_store = new JPABatchStore(ConfigurationConverter.getMap(m_properties));
m_batchPersister = new AsyncConcurrentBatchingProcessor<PersistEntityEvent>(
m_store,
PersistEntityEvent::new,
PersistEntityEvent::translate
);
final ServerConfiguration config = m_httpServer.getServerConfiguration();
config.setMaxPostSize(MAX_POST_SIZE);
AsyncPostHandler.ErrorHandler errorHandler =
(ByteBuffer postBytes, Response resp, Throwable t) -> {
LogManager.getLogger(this).warn("Invalid submission.", t);
resp.sendError(300);
resp.finish();
};
AsyncPostHandler certHandler =
new AsyncPostHandler(new CertificateHandler(m_batchPersister, CERT_TEMPLATE_PATH, errorHandler),
errorHandler);
AsyncPostHandler versionHandler =
new AsyncPostHandler(new VersionCheckHandler(m_batchPersister, properties), errorHandler);
config.addHttpHandler(certHandler, PATH_SUBMIT);
config.addHttpHandler(versionHandler, PATH_VERSION_CHECK);
}
示例10: createServer
import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的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;
}