From 48fe57a3f7f9bb04b0ce27ea57a826d15a3d95c2 Mon Sep 17 00:00:00 2001 From: hepin1989 Date: Wed, 13 Mar 2019 11:42:52 +0800 Subject: [PATCH] Add a create method with context and namePrefix to ActorMaterializer's Java API. --- .../scala/akka/stream/ActorMaterializer.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala b/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala index fe229af487..f824b64ef5 100644 --- a/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala +++ b/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala @@ -126,6 +126,24 @@ object ActorMaterializer { def create(context: ActorRefFactory): ActorMaterializer = apply()(context) + /** + * Java API: Creates an ActorMaterializer that can materialize stream blueprints as running streams. + * + * The required [[akka.actor.ActorRefFactory]] + * (which can be either an [[akka.actor.ActorSystem]] or an [[akka.actor.ActorContext]]) + * will be used to create these actors, therefore it is *forbidden* to pass this object + * to another actor if the factory is an ActorContext. + * + * The `namePrefix` is used as the first part of the names of the actors running + * the processing steps. The default `namePrefix` is `"flow"`. The actor names are built up of + * `namePrefix-flowNumber-flowStepNumber-stepName`. + */ + def create(context: ActorRefFactory, namePrefix: String): ActorMaterializer = { + val system = actorSystemOf(context) + val settings = ActorMaterializerSettings(system) + apply(settings, namePrefix)(context) + } + /** * Java API: Creates an ActorMaterializer that can materialize stream blueprints as running streams. *