#19440 replace Scala Future usage with CompletionStage in javadsl
This entails:
* adding akka.pattern.PatternCS.* to enable ask etc. with
CompletionStage
* changing RequestContext to offer an ExecutionContextExecutor for the
CompletionStage.*Async combinators
* splitting up akka.stream.Queue for JavaDSL consistency
This commit is contained in:
parent
396f4370e9
commit
4c72495581
118 changed files with 1646 additions and 1379 deletions
|
|
@ -7,12 +7,13 @@ package akka.http.impl.server
|
|||
import akka.http.javadsl.model.ContentType
|
||||
import akka.http.scaladsl.model.HttpEntity
|
||||
import akka.stream.Materializer
|
||||
|
||||
import scala.concurrent.{ ExecutionContext, Future }
|
||||
import scala.concurrent.{ ExecutionContextExecutor, Future }
|
||||
import akka.http.javadsl.{ model ⇒ jm }
|
||||
import akka.http.impl.util.JavaMapping.Implicits._
|
||||
import akka.http.scaladsl.server.{ RequestContext ⇒ ScalaRequestContext }
|
||||
import akka.http.javadsl.server._
|
||||
import java.util.concurrent.CompletionStage
|
||||
import scala.compat.java8.FutureConverters._
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
|
|
@ -28,6 +29,7 @@ private[http] final case class RequestContextImpl(underlying: ScalaRequestContex
|
|||
futureResult.flatMap {
|
||||
case r: RouteResultImpl ⇒ r.underlying
|
||||
}(executionContext())
|
||||
def completeWith(futureResult: CompletionStage[RouteResult]): RouteResult = completeWith(futureResult.toScala)
|
||||
def complete(text: String): RouteResult = underlying.complete(text)
|
||||
def complete(contentType: ContentType.NonBinary, text: String): RouteResult =
|
||||
underlying.complete(HttpEntity(contentType.asScala, text))
|
||||
|
|
@ -48,6 +50,6 @@ private[http] final case class RequestContextImpl(underlying: ScalaRequestContex
|
|||
|
||||
def reject(customRejection: CustomRejection): RouteResult = underlying.reject(CustomRejectionWrapper(customRejection))
|
||||
|
||||
def executionContext(): ExecutionContext = underlying.executionContext
|
||||
def executionContext(): ExecutionContextExecutor = underlying.executionContext
|
||||
def materializer(): Materializer = underlying.materializer
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue