2016-03-24 10 views
1

SSLをサポートするAkka HTTPサーバーを作成しようとしています。JavaでSSLをサポートするAkka HTTPサーバー - 設定を作成するには?

私はスケーラAkka HTTP 2.0 to use SSL (HTTPS)についてこの問題を認識しています。私はJavaコードに変換しようとしていますが、紛失しています。

DSL akka.http.javadsl.HttpクラスはJavaと異なり、akka.actor.ExtendedActorSystemが必要です。インスタンスを作成しようとするとcom.typesafe.configでアプリケーション構成を作成する必要があります.Configクラスは、インスタンス化する方法と配置する方法を理解できません。

もっと簡単な方法はありますか?または、必要な設定をすべて作成するために使用できるクラスはありますか?

これは、コードのスニペットです:

// boot up server using the route as defined below 
    final ActorSystem system = ActorSystem.create(); 
    final ActorMaterializer materializer = ActorMaterializer.create(system); 

    // Run the server bound to the local machine IP 
    String hostAddress = InetAddress.getLocalHost().getHostAddress(); 

    // No implementation here????? 
    Config applicationConfig = new Config() { 
    } 
    ExtendedActorSystem extendedActorSystem = new ActorSystemImpl("HttpProxy", applicationConfig, ClassLoader.getSystemClassLoader(), Option.empty()); 
    // todo: missing handler, settings, httpsContext and log 
    Flow<HttpRequest, HttpResponse, ?> handler; 
    ServerSettings settings; 
    akka.japi.Option<HttpsContext> httpsContext; 
    LoggingAdapter log; 
    new Http(extendedActorSystem).bindAndHandle(handler, hostAddress, PORT, settings, httpsContext, log, materializer); 

    System.out.println("Starting server on " + hostAddress + ":" + PORT); 

    // The server would stop if carriage return is entered in the system cosole 
    System.out.println("Type RETURN to exit"); 
    System.in.read(); 
    system.shutdown(); 

答えて

1

それはこのようなものになるはず:

//

// Run the server bound to the local machine IP 
String hostAddress = InetAddress.getLocalHost().getHostAddress(); 

// No implementation here????? 
Config applicationConfig = ConfigFactory.load(); 
ActorSystem system = ActorSystem.create("HttpProxy", applicationConfig); 
final ActorMaterializer materializer = ActorMaterializer.create(system); 


// todo: missing handler, settings, httpsContext and log 
Flow<HttpRequest, HttpResponse, ?> handler; 
ServerSettings settings; 
akka.japi.Option<HttpsContext> httpsContext; 
LoggingAdapter log; 
Http.get(system).bindAndHandle(handler, hostAddress, 9000, settings, httpsContext, log, materializer); 

System.out.println("Starting server on " + hostAddress + ":" + 9000); 
の下に定義された経路を使用してサーバを起動
関連する問題