1212import io .eigr .spawn .api .Value ;
1313import io .eigr .spawn .api .actors .ActorContext ;
1414import io .eigr .spawn .api .actors .ActorFactory ;
15- import io .eigr .spawn .api .exceptions .ActorInvokeException ;
1615import io .eigr .spawn .api .actors .workflows .Broadcast ;
1716import io .eigr .spawn .api .actors .workflows .Forward ;
1817import io .eigr .spawn .api .actors .workflows .Pipe ;
1918import io .eigr .spawn .api .actors .workflows .SideEffect ;
19+ import io .eigr .spawn .api .exceptions .ActorInvokeException ;
2020import io .eigr .spawn .internal .Entity ;
2121import org .slf4j .Logger ;
2222import org .slf4j .LoggerFactory ;
@@ -63,10 +63,10 @@ public void handle(HttpExchange exchange) throws IOException {
6363
6464 if ("POST" .equals (exchange .getRequestMethod ())) {
6565 Protocol .ActorInvocationResponse response = handleRequest (exchange );
66- try (OutputStream os = exchange .getResponseBody ()) {
66+ try (OutputStream os = exchange .getResponseBody ()) {
6767 byte [] bytes = response .toByteArray ();
6868 exchange .getResponseHeaders ().set ("Content-Type" , "application/octet-stream" );
69- exchange . sendResponseHeaders (200 , bytes .length );
69+ exchange .sendResponseHeaders (200 , bytes .length );
7070 os .write (bytes );
7171 }
7272 }
@@ -80,11 +80,12 @@ private Protocol.ActorInvocationResponse handleRequest(HttpExchange exchange) th
8080 ActorId actorId = actorInvocationRequest .getActor ();
8181 String actor = actorId .getName ();
8282 String system = actorId .getSystem ();
83+ String parent = actorId .getParent ();
8384 String commandName = actorInvocationRequest .getActionName ();
8485
8586 Any value = actorInvocationRequest .getValue ();
8687
87- Optional <Value > maybeValueResponse = callAction (system , actor , commandName , value , context );
88+ Optional <Value > maybeValueResponse = callAction (system , actor , parent , commandName , value , context );
8889 log .info ("Actor {} return ActorInvocationResponse for command {}. Result value: {}" ,
8990 actor , commandName , maybeValueResponse );
9091
@@ -114,8 +115,8 @@ private Protocol.ActorInvocationResponse handleRequest(HttpExchange exchange) th
114115 throw new ActorInvokeException ("Action result is null" );
115116 }
116117
117- private Optional <Value > callAction (String system , String actor , String commandName , Any value , Protocol .Context context ) {
118- Optional <Entity > optionalEntity = getEntityByActor (actor );
118+ private Optional <Value > callAction (String system , String actor , String parent , String commandName , Any value , Protocol .Context context ) {
119+ Optional <Entity > optionalEntity = getEntityByActor (actor , parent );
119120 if (optionalEntity .isPresent ()) {
120121 Entity entity = optionalEntity .get ();
121122
@@ -183,10 +184,18 @@ private Object buildInstanceByArg(Entity entity) throws NoSuchMethodException, I
183184 return constructor .newInstance ();
184185 }
185186
186- private Optional <Entity > getEntityByActor (String actor ) {
187- return this .entities .stream ()
187+ private Optional <Entity > getEntityByActor (String actor , String parent ) {
188+ Optional < Entity > entity = this .entities .stream ()
188189 .filter (e -> e .getActorName ().equalsIgnoreCase (actor ))
189190 .findFirst ();
191+
192+ if (entity .isPresent ()) {
193+ return entity ;
194+ }
195+
196+ return this .entities .stream ()
197+ .filter (e -> e .getActorName ().equalsIgnoreCase (parent ))
198+ .findFirst ();
190199 }
191200
192201 private Protocol .Workflow buildWorkflow (Value valueResponse ) {
0 commit comments