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


Java GrizzlyWebServer.start方法代码示例

本文整理汇总了Java中com.sun.grizzly.http.embed.GrizzlyWebServer.start方法的典型用法代码示例。如果您正苦于以下问题:Java GrizzlyWebServer.start方法的具体用法?Java GrizzlyWebServer.start怎么用?Java GrizzlyWebServer.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.grizzly.http.embed.GrizzlyWebServer的用法示例。


在下文中一共展示了GrizzlyWebServer.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import com.sun.grizzly.http.embed.GrizzlyWebServer; //导入方法依赖的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();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:38,代码来源:RestMain.java

示例2: main

import com.sun.grizzly.http.embed.GrizzlyWebServer; //导入方法依赖的package包/类
static public void main(String[] args) throws Exception {
    GrizzlyWebServer ws = new GrizzlyWebServer(9080);
    try {
        GrizzlyAdapter ga = new HttpServerMain();
        ws.addGrizzlyAdapter(ga, new String[] {"/"});
        ws.start();
    } catch (IOException e){
        logger.error("", e);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:11,代码来源:HttpServerMain.java

示例3: start

import com.sun.grizzly.http.embed.GrizzlyWebServer; //导入方法依赖的package包/类
/**
 * Start HTTP server.
 * @see #RestfulServer()
 * @todo #1 Would be nice to add exception mapping here, in order
 *  to properly wrap exception messages sent to clients
 */
private void start() {
    final java.util.logging.Logger root =
        LogManager.getLogManager().getLogger("");
    final Handler[] handlers = root.getHandlers();
    for (int pos = 0; pos < handlers.length; pos += 1) {
        root.removeHandler(handlers[pos]);
    }
    SLF4JBridgeHandler.install();
    final GrizzlyWebServer gws = new GrizzlyWebServer(this.port(), ".");
    final ServletAdapter adapter = new ServletAdapter();
    adapter.addInitParameter(
        "com.sun.jersey.config.property.packages",
        "com.ymock.server"
    );
    adapter.setContextPath(RestfulServer.CONTEXT);
    adapter.setServletInstance(new ServletContainer());
    gws.addGrizzlyAdapter(adapter, new String[] {RestfulServer.CONTEXT});
    try {
        gws.start();
    } catch (java.io.IOException ex) {
        throw new IllegalStateException(ex);
    }
    Logger.debug(
        this,
        "#start(): server started"
    );
}
 
开发者ID:yegor256,项目名称:ymock,代码行数:34,代码来源:RestfulServer.java

示例4: main

import com.sun.grizzly.http.embed.GrizzlyWebServer; //导入方法依赖的package包/类
public static void main(String[] args) {
          
    // static content is linked from here
    GrizzlyWebServer server = new GrizzlyWebServer(8010);
    
    
    
    //For very slow response extractors:
    SelectorThread st = server.getSelectorThread();
    st.setTransactionTimeout(700000);
    
    
   
    //create UI resources
    ServletAdapter ui = new ServletAdapter();
    ui.addInitParameter(
          "javax.ws.rs.Application",
          "fr.eurecom.hotspots.web.hypertext.RegisterUI");
    ui.setServletInstance(new ServletContainer());

    // REST resources       
    ServletAdapter api = new ServletAdapter();
    api.addInitParameter(
          "javax.ws.rs.Application",
          "fr.eurecom.hotspots.web.api.RegisterAPI");
    api.setContextPath("/api");
    api.setServletInstance(new ServletContainer());
    

    
    // static content adapter
    ServletAdapter staticContent = new ServletAdapter("ui");
    staticContent.setContextPath("/");
    staticContent.setHandleStaticResources(true);
            
    // register all above defined adapters
    server.addGrizzlyAdapter(api, new String[] {"/api"});
    server.addGrizzlyAdapter(staticContent, new String[] {"/"});
    
    
          
    // let's Grizzly run
    try {
        server.start();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jluisred,项目名称:HotSpots,代码行数:49,代码来源:Server.java


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