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


Java GrizzlyHttpServerFactory类代码示例

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


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

示例1: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的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;
}
 
开发者ID:bcdev,项目名称:esa-pfa,代码行数:24,代码来源:ServerMain.java

示例2: createHttpsServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
private HttpServer createHttpsServer() {
    SSLContextConfigurator sslContextConfig = new SSLContextConfigurator();

    // set up security context
    sslContextConfig.setKeyStoreFile(this.serverKeystore); // contains server cert and key
    sslContextConfig.setKeyStorePass(this.serverKeystorePwd);

    // Create context and have exceptions raised if anything wrong with keystore or password
    SSLContext sslContext = sslContextConfig.createSSLContext(true);
            
    // Create server but do not start it
    HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(this.baseUri),false);

    
    //LOGGER.debug("About to loop through listeners");
    //for (NetworkListener listener : server.getListeners()) {
    //	LOGGER.debug("About to setSecure on listener name: " + listener.getName());
    //}
    
    // grizzly is the default listener name
    server.getListener("grizzly").setSecure(true);
    // One way authentication
    server.getListener("grizzly").setSSLEngineConfig(new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
    return server;
}
 
开发者ID:IBMStreams,项目名称:streamsx.jmxclients,代码行数:26,代码来源:RestServer.java

示例3: httpBuilder

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
public static HttpServer httpBuilder (String connectionUrl, String profileName) {
    try {
        URL url = new URL(connectionUrl);

        System.setProperty("spring.profiles.active", profileName);
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(SpringAnnotationConfig.class);

        ResourceConfig resourceConfig = new ResourceConfig();
        resourceConfig.register(RequestContextFilter.class);
        resourceConfig.property("contextConfig", annotationConfigApplicationContext);
        resourceConfig.register(RestSupport.class);

        URI baseUri = URI.create(url.getProtocol() + "://" + url.getAuthority());
        return  GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, false);
    } catch (Exception e) {
        Assert.fail("Could'n parse configfile." + e.getMessage());
    }
    return null;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:20,代码来源:WebServiceClientHelper.java

示例4: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
public void startServer() throws TelegramApiException {
    SSLContextConfigurator sslContext = new SSLContextConfigurator();

    // set up security context
    sslContext.setKeyStoreFile(KEYSTORE_SERVER_FILE); // contains server keypair
    sslContext.setKeyStorePass(KEYSTORE_SERVER_PWD);

    ResourceConfig rc = new ResourceConfig();
    rc.register(restApi);
    rc.register(JacksonFeature.class);
    rc.property(JSONConfiguration.FEATURE_POJO_MAPPING, true);
    final HttpServer grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(
            getBaseURI(),
            rc,
            true,
            new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
    try {
        grizzlyServer.start();
    } catch (IOException e) {
        throw new TelegramApiException("Error starting webhook server", e);
    }
}
 
开发者ID:gomgomdev,项目名称:telegram-bot_misebot,代码行数:23,代码来源:Webhook.java

示例5: start

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
void start() {
    try {
        Config config = core.getConfig();
        String urlStr = config.getString("networking.rest-url");
        ResourceConfig rc = new ResourceConfig();
        rc.register(LoggingFilter.class);
        rc.register(JacksonFeature.class);
        rc.register(CatchAllExceptionMapper.class);
        rc.register(SerializationExceptionMapper.class);
        rc.register(AdminResourceImpl.class);
        rc.register(new KBResourceImpl(core));
        rc.register(new QueryResourceImpl(core));
        httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(urlStr), rc, true);
        logger.info(marker, "Stargraph listening on {}", urlStr);
    } catch (Exception e) {
        throw new StarGraphException(e);
    }
}
 
开发者ID:Lambda-3,项目名称:Stargraph,代码行数:19,代码来源:Server.java

示例6: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
public void startServer() throws TelegramApiRequestException {
    ResourceConfig rc = new ResourceConfig();
    rc.register(restApi);
    rc.register(JacksonFeature.class);

    final HttpServer grizzlyServer;
    if (keystoreServerFile != null && keystoreServerPwd != null) {
        SSLContextConfigurator sslContext = new SSLContextConfigurator();

        // set up security context
        sslContext.setKeyStoreFile(keystoreServerFile); // contains server keypair
        sslContext.setKeyStorePass(keystoreServerPwd);

        grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true,
                new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
    } else {
        grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
    }

    try {
        grizzlyServer.start();
    } catch (IOException e) {
        throw new TelegramApiRequestException("Error starting webhook server", e);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:26,代码来源:DefaultWebhook.java

示例7: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
protected void startServer() {
        WifiManager wifiMgr = (WifiManager) getApplicationContext()
                .getSystemService(Service.WIFI_SERVICE);
        if (wifiMgr.isWifiEnabled()) {
            // Deprecated. Does not support ipv6. *shrug* :)
            String ipAddress = Formatter.formatIpAddress(wifiMgr.getConnectionInfo()
                    .getIpAddress());

            URI baseUri = UriBuilder.fromUri("http://" + ipAddress)
                    .port(49152)
                    .build();
            ResourceConfig config = new ResourceConfig(SseFeature.class)
                    .register(JacksonFeature.class);
            config.registerInstances(new SecureFilter(this));
            config.registerInstances(new DeskDroidResource(this));
//            server = JettyHttpContainerFactory.createServer(baseUri, config);
            server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
        }
    }
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:20,代码来源:DeskDroidService.java

示例8: start

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
@Override
public void start() {
    System.out.println("Starting GrizzlyTestContainer...");
    try {
        this.server = GrizzlyHttpServerFactory.createHttpServer(uri, rc);

        // Initialize and register Jersey Servlet
        WebappContext context = new WebappContext("WebappContext", "");
        ServletRegistration registration = context.addServlet("ServletContainer", ServletContainer.class);
        registration.setInitParameter("javax.ws.rs.Application", rc.getClass().getName());
        // Add an init parameter - this could be loaded from a parameter in the constructor
        registration.setInitParameter("myparam", "myvalue");

        registration.addMapping("/*");
        context.deploy(server);
    } catch (ProcessingException e) {
        throw new TestContainerException(e);
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:20,代码来源:MCRJerseyTest.java

示例9: init

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
@EventHandler
public void init(FMLInitializationEvent event) throws Exception
{
    if(event.getSide().isServer())
        modpack = new Modpack(logger, solderConfig, gson);
    if(event.getSide().isServer() && solderConfig.isEnabled()) {

        logger.info("Loading mod MinecraftSolder");
        ResourceConfig config = new ResourceConfig()
                .packages("it.admiral0")
                .register(new AbstractBinder() {
                    @Override
                    protected void configure() {
                        bind(solderConfig);
                        bind(Loader.instance());
                        bind(modpack);
                        bind(gson);
                    }
                });
        HttpServer server = GrizzlyHttpServerFactory.createHttpServer(solderConfig.getBaseUri(), config);
        server.getServerConfiguration().addHttpHandler(
                new StaticHttpHandler(modpack.getSolderCache().toAbsolutePath().toString()), "/download"
        );
        server.start();
        logger.info("Server running on " + solderConfig.getBaseUri().toString());
    }else{
        logger.info("Mod is disabled.");
    }
}
 
开发者ID:admiral0,项目名称:MinecraftSolder,代码行数:30,代码来源:MinecraftSolder.java

示例10: setup

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  // create ResourceConfig from Resource class
  ResourceConfig rc = new ResourceConfig();
  MultiCube cube = new MultiCubeTest(null);
  rc.registerInstances(new CubeResource(cube));
  rc.register(JsonIteratorConverter.class);

  // create the Grizzly server instance
  httpServer = GrizzlyHttpServerFactory.createHttpServer(baseUri, rc);
  // start the server
  httpServer.start();

  // configure client with the base URI path
  Client client = ClientBuilder.newClient();
  client.register(JsonIteratorConverter.class);
  webTarget = client.target(baseUri);
}
 
开发者ID:cubedb,项目名称:cubedb,代码行数:19,代码来源:CubeResourceTest.java

示例11: setup

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  //create ResourceConfig from Resource class
  ResourceConfig rc = new ResourceConfig();
  cube = new MultiCubeImpl(null);
  rc.registerInstances(new CubeResource(cube));
  rc.register(JsonIteratorConverter.class);

  //create the Grizzly server instance
  httpServer = GrizzlyHttpServerFactory.createHttpServer(baseUri, rc);
  //start the server
  httpServer.start();

  //configure client with the base URI path
  Client client = ClientBuilder.newClient();
  client.register(JsonIteratorConverter.class);
  webTarget = client.target(baseUri);
}
 
开发者ID:cubedb,项目名称:cubedb,代码行数:19,代码来源:CubeResourceGeneralTest.java

示例12: start

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
public static void start(int port) throws IOException {
	String baseUrl = "http://localhost:"+port+"/";
	System.out.println("Starting Weather App local testing server: " + baseUrl);
	System.out.println("Not for production use");

	final ResourceConfig resourceConfig = new ResourceConfig();
	resourceConfig.register(RestWeatherCollectorEndpoint.class);
	resourceConfig.register(RestWeatherQueryEndpoint.class);
	resourceConfig.register(GenericExceptionMapper.class);
	resourceConfig.register(new MyApplicationBinder());
	server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUrl), resourceConfig, false);

	HttpServerProbe probe = new HttpServerProbe.Adapter() {
		@Override
		public void onRequestReceiveEvent(HttpServerFilter filter, @SuppressWarnings("rawtypes") Connection connection, Request request) {
			System.out.println(request.getRequestURI());
		}
	};

	server.getServerConfiguration().getMonitoringConfig().getWebServerConfig().addProbes(probe);
	System.out.println(format("Weather Server started.\n url=%s\n", baseUrl));
	server.start();
}
 
开发者ID:victorrentea,项目名称:training,代码行数:24,代码来源:WeatherServer.java

示例13: startManagementHttpServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
private void startManagementHttpServer() throws Exception {
    final String httpManagementServerUrl = _properties.getProperty("managementurl", HTTP_MANAGEMENTSERVER_URL);
    final ResourceConfig config = new ResourceConfig().register(RaqetService.class).register(new RaqetBinder(_raqetControll));
    final CLStaticHttpHandler staticHttpHandler = new CLStaticHttpHandler(this.getClass().getClassLoader(), "/static/");


    _httpManagementServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(httpManagementServerUrl), config);
    _httpManagementServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/gui/");
    /* Redirect users to the GUI */
    _httpManagementServer.getServerConfiguration().addHttpHandler(new HttpHandler() {
        @Override
        public void service(final Request request, final Response response) throws Exception {
            response.sendRedirect("/gui/");
        }
    }, "/index.html");
    _httpManagementServer.start();
}
 
开发者ID:raqet,项目名称:acquisition-server,代码行数:18,代码来源:Main.java

示例14: SwiftProxy

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
public SwiftProxy(Properties properties, BlobStoreLocator locator, URI endpoint) {
    this.endpoint = requireNonNull(endpoint);

    rc = new BounceResourceConfig(properties, locator);
    if (logger.isDebugEnabled()) {
        rc.register(new LoggingFilter(java.util.logging.Logger.getGlobal(), false));
    }
    server = GrizzlyHttpServerFactory.createHttpServer(endpoint, rc, false);
    server.getListeners().forEach(listener -> {
        listener.registerAddOn(new ContentLengthAddOn());
    });

    // allow HTTP DELETE to have payload for multi-object delete
    server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true);

    RuntimeDelegate.setInstance(new RuntimeDelegateImpl(RuntimeDelegate.getInstance()));
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:18,代码来源:SwiftProxy.java

示例15: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入依赖的package包/类
/**
 * Starts the HTTP server exposing the resources defined in the RestRules class.
 * It takes a reference to an object that implements the RestListener interface,
 * which will be notified every time the REST API receives a request of some type.
 *
 * @param wsUri The base URL of the HTTP REST API
 * @param rl The RestListener object that will be notified when a user sends
 *           an HTTP request to the API
 * @see RestRules
 * @see RestListener
 */

public static void startServer(String wsUri, RestListener rl) {
    // Create a resource config that scans for JAX-RS resources and providers
    ResourceConfig rc = new ResourceConfig()
            .register(RestRules.class)
            .register(JacksonFeature.class);

    // Set the listener for the petitions
    listener = rl;

    // Create a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    server = GrizzlyHttpServerFactory.createHttpServer(URI.create(wsUri), rc);

    // start the server
    try {
        server.start();
    } catch (IOException e) {
        log.error(e.getMessage());
    }

    log.info("HTTP server started");
}
 
开发者ID:redBorder,项目名称:cep,代码行数:35,代码来源:RestManager.java


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