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


Java GrizzlyHttpServerFactory.createHttpServer方法代码示例

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


在下文中一共展示了GrizzlyHttpServerFactory.createHttpServer方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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.
 */
public static HttpServer startServer() {
    // create a resource config that scans for JAX-RS resources and providers
    // in edu.upc.eetac.dsa.where package
    /*final ResourceConfig rc = new WhereResourceConfig();
    HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(getBaseURI()), rc);
    HttpHandler httpHandler = new StaticHttpHandler("../web");
    httpServer.getServerConfiguration().addHttpHandler(httpHandler, "/");
    for (NetworkListener l : httpServer.getListeners()){
        l.getFileCache().setEnabled(false);
    }
    return httpServer;*/
    final ResourceConfig rc = new WhereResourceConfig();
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(getBaseURI()), rc);

}
 
开发者ID:dsaqt1516g7m,项目名称:Where-to-eat-in-Barcelona,代码行数:20,代码来源:Main.java

示例10: 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

示例11: 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.
 */
public static HttpServer startServer() {
    // create a resource config that scans for JAX-RS resources and providers
    // in com.ccoe.build.service.health package
    final ResourceConfig rc = new ResourceConfig().packages("com.ccoe.build.service");

    // uncomment the following line if you want to enable
    // support for JSON on the service (you also have to uncomment
    // dependency on jersey-media-json module in pom.xml)
    // --
    //rc.addBinder(org.glassfish.jersey.media.json.JsonJaxbBinder);
    
    rc.register(MoxyJsonFeature.class);
    rc.register(MultiPartFeature.class);
    rc.register(JsonMoxyConfigurationContextResolver.class);


    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
}
 
开发者ID:eBay,项目名称:mTracker,代码行数:25,代码来源:Main.java

示例12: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入方法依赖的package包/类
public static HttpServer startServer() 
{
    // create a resource config that scans for JAX-RS resources and providers
    // in fr.eurecom.nerd package
    final ResourceConfig rc = new ResourceConfig().packages("fr.eurecom.nerd.api.rest");
    //rc.register(AuthorizationFilter.class, Priorities.AUTHENTICATION);
    //rc.register(RolesAllowedDynamicFeature.class);
    rc.register(LoggingFilter.class);
    //rc.property(ServerProperties.TRACING, "ALL");
    //rc.property(ServerProperties.TRACING_THRESHOLD, "VERBOSE");
    
    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    HttpServer server =  GrizzlyHttpServerFactory.
                         createHttpServer(URI.create(BASE_URI), rc);
            
    Logger logger = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
    logger.setLevel(Level.FINE);
    logger.setUseParentHandlers(false);
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.ALL);
    logger.addHandler(ch);
    
    return server;
}
 
开发者ID:NERD-project,项目名称:nerd-api,代码行数:26,代码来源:Server.java

示例13: testSimple

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入方法依赖的package包/类
@Test
public void testSimple()
{
    try
    {
        System.out.println("\"Hello World\" Jersey Example App");

        final ResourceConfig resourceConfig = new ResourceConfig(HiApp.class);
        final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig);

        System.out.println(String.format("Application started.\nTry out %s%s\nHit enter to stop it...",
                BASE_URI, ROOT_PATH));
        System.in.read();
        server.shutdownNow();
    } catch (IOException ex)
    {
        Logger.getLogger(TelletsLauncher.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
开发者ID:wenerme,项目名称:tellets,代码行数:21,代码来源:TelletsLauncher.java

示例14: startAPIServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入方法依赖的package包/类
public HttpServer startAPIServer(Player player, int port) {
	logger.debug("Starting Player API server at " + getURI(port));

	player.setEndpoint(getURI(port));
	
	PlayerAPI api = new PlayerAPI(player);
	final ResourceConfig rc = new ResourceConfig().register(api);

	HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create("http://0.0.0.0:" + port + BASE_PATH),
			rc);
	return server;
}
 
开发者ID:Azure,项目名称:acs-demos,代码行数:13,代码来源:AbstractPlayerEngine.java

示例15: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; //导入方法依赖的package包/类
/**
 * Starts Grizzly HTTP server exposing SMAPH JAX-RS resources.
 * 
 * @throws URISyntaxException
 * @throws ProcessingException
 */
public static void startServer(String serverUri, Path storageBase, String watGcubeToken) throws ProcessingException, URISyntaxException {
	LOG.info("Initializing SMAPH services.");
	LOG.info("Storage path: {}", storageBase.toAbsolutePath());

	HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(new URI(serverUri));
	httpServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler("src/main/webapp/"), "/*");

	WebappContext context = new WebappContext("smaph");
	ResourceConfig rc = new ResourceConfig().packages("it.unipi.di.acube.smaph.servlet");
	ServletRegistration registration = context.addServlet("ServletContainer", new ServletContainer(rc));
	registration.addMapping("/smaph/*");
	context.addListener(SmaphContextListener.class);
	context.setInitParameter(SmaphContextListener.WIKI_PAGES_DB, storageBase.resolve("mapdb/wikipedia_pages.db").toString());
	context.setInitParameter(SmaphContextListener.FREEBASE_DIR, storageBase.resolve("mapdb/freebase.db").toString());
	context.setInitParameter(SmaphContextListener.ENTITY_TO_ANCHORS_DB, storageBase.resolve("mapdb/e2a.db").toString());
	context.setInitParameter(SmaphContextListener.WAT_GCUBE_TOKEN, watGcubeToken);
	context.deploy(httpServer);
	try {
		httpServer.start();
		LOG.info("Smaph started with WADL available at " + "{}application.wadl\nPress CTRL^C (SIGINT) to terminate.",
		        serverUri);
		Thread.currentThread().join();
		LOG.info("Shutting server down..");
	} catch (Exception e) {
		LOG.error("There was an error while starting Grizzly HTTP server.", e);
	}
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:34,代码来源:ServerMain.java


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