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


Java Server类代码示例

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


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

示例1: exceptionCaught

import play.server.Server; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    // We have to redirect to https://, as it was targeting http://
    // Redirect to the root as we don't know the url at that point
    if (e.getCause() instanceof SSLException) {
        Logger.debug(e.getCause(), "");
        InetSocketAddress inet = ((InetSocketAddress) ctx.getAttachment());
        ctx.getPipeline().remove("ssl");
        HttpResponse nettyResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.TEMPORARY_REDIRECT);
        nettyResponse.setHeader(LOCATION, "https://" + inet.getHostName() + ":" + Server.httpsPort + "/");
        ChannelFuture writeFuture = ctx.getChannel().write(nettyResponse);
        writeFuture.addListener(ChannelFutureListener.CLOSE);
    } else {
        Logger.error(e.getCause(), "");
        e.getChannel().close();
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:18,代码来源:SslPlayHandler.java

示例2: main

import play.server.Server; //导入依赖的package包/类
public static void main(String[] args) {
    Router router = new RoutingDsl().
            GET("/").routeTo(() -> ok("Hello World!")).
            build();
    Server server = Server.forRouter(router, 8080);

    System.out.println("Server started on " + server.httpPort());
}
 
开发者ID:greenlaw110,项目名称:simple-webframework-benchmark,代码行数:9,代码来源:Main.java

示例3: main

import play.server.Server; //导入依赖的package包/类
public static void main( String[] args )
    throws Exception
{
    String outFile = System.getProperty( "outFile" );
    if ( outFile != null )
    {
        PrintStream out = new PrintStream( new File( outFile ) );
        System.setOut( out );
        System.setErr( out );
        System.getProperties().remove( "outFile" );
    }

    String pidFileName = System.getProperty( "pidFile" );
    if ( pidFileName != null )
    {
        // http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html
        String name = ManagementFactory.getRuntimeMXBean().getName();
        String pidStr = "unknown";
        int p = name.indexOf( '@' );
        if ( p > 0 )
        {
            pidStr = name.substring( 0, p );
        }
        File pidFile = new File( pidFileName );
        PrintWriter fw = new PrintWriter( pidFile, "UTF-8" );
        try
        {
            fw.write( pidStr );
        }
        finally
        {
            fw.close();
        }
        System.getProperties().remove( "pidFile" );
    }

    Play.frameworkPath = new File( System.getProperty( "play.home" ) );
    Server.main( args );
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:40,代码来源:PlayServerBooter.java

示例4: runStatusServer

import play.server.Server; //导入依赖的package包/类
@Test
public void runStatusServer() {
    Server server = StatusServer.startServer(new InMemoryStatusStorage(), 65236);
    server.stop();
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:6,代码来源:StatusServerTests.java


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