12
12
import io .eigr .spawn .api .Value ;
13
13
import io .eigr .spawn .api .actors .ActorContext ;
14
14
import io .eigr .spawn .api .actors .ActorFactory ;
15
- import io .eigr .spawn .api .exceptions .ActorInvokeException ;
16
15
import io .eigr .spawn .api .actors .workflows .Broadcast ;
17
16
import io .eigr .spawn .api .actors .workflows .Forward ;
18
17
import io .eigr .spawn .api .actors .workflows .Pipe ;
19
18
import io .eigr .spawn .api .actors .workflows .SideEffect ;
19
+ import io .eigr .spawn .api .exceptions .ActorInvokeException ;
20
20
import io .eigr .spawn .internal .Entity ;
21
21
import org .slf4j .Logger ;
22
22
import org .slf4j .LoggerFactory ;
@@ -63,10 +63,10 @@ public void handle(HttpExchange exchange) throws IOException {
63
63
64
64
if ("POST" .equals (exchange .getRequestMethod ())) {
65
65
Protocol .ActorInvocationResponse response = handleRequest (exchange );
66
- try (OutputStream os = exchange .getResponseBody ()) {
66
+ try (OutputStream os = exchange .getResponseBody ()) {
67
67
byte [] bytes = response .toByteArray ();
68
68
exchange .getResponseHeaders ().set ("Content-Type" , "application/octet-stream" );
69
- exchange . sendResponseHeaders (200 , bytes .length );
69
+ exchange .sendResponseHeaders (200 , bytes .length );
70
70
os .write (bytes );
71
71
}
72
72
}
@@ -80,11 +80,12 @@ private Protocol.ActorInvocationResponse handleRequest(HttpExchange exchange) th
80
80
ActorId actorId = actorInvocationRequest .getActor ();
81
81
String actor = actorId .getName ();
82
82
String system = actorId .getSystem ();
83
+ String parent = actorId .getParent ();
83
84
String commandName = actorInvocationRequest .getActionName ();
84
85
85
86
Any value = actorInvocationRequest .getValue ();
86
87
87
- Optional <Value > maybeValueResponse = callAction (system , actor , commandName , value , context );
88
+ Optional <Value > maybeValueResponse = callAction (system , actor , parent , commandName , value , context );
88
89
log .info ("Actor {} return ActorInvocationResponse for command {}. Result value: {}" ,
89
90
actor , commandName , maybeValueResponse );
90
91
@@ -114,8 +115,8 @@ private Protocol.ActorInvocationResponse handleRequest(HttpExchange exchange) th
114
115
throw new ActorInvokeException ("Action result is null" );
115
116
}
116
117
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 );
119
120
if (optionalEntity .isPresent ()) {
120
121
Entity entity = optionalEntity .get ();
121
122
@@ -183,10 +184,18 @@ private Object buildInstanceByArg(Entity entity) throws NoSuchMethodException, I
183
184
return constructor .newInstance ();
184
185
}
185
186
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 ()
188
189
.filter (e -> e .getActorName ().equalsIgnoreCase (actor ))
189
190
.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 ();
190
199
}
191
200
192
201
private Protocol .Workflow buildWorkflow (Value valueResponse ) {
0 commit comments