Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
[spawn] Use the given agent identifier when spawning.
Browse files Browse the repository at this point in the history
see #81.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 5, 2014
1 parent 34a4c6a commit 2174dc2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,12 @@ public DefaultAgentFactory(Injector injector) {

@Override
public <T extends Agent> T newInstance(Class<T> type, UUID agentID, UUID contextID) throws Exception {
Agent agent = type.getConstructor(UUID.class).newInstance(contextID);
Agent agent;
if (agentID == null) {
agent = type.getConstructor(UUID.class).newInstance(contextID);
} else {
agent = type.getConstructor(UUID.class, UUID.class).newInstance(contextID, agentID);
}
assert (agent != null);
this.injector.injectMembers(agent);
return type.cast(agent);
Expand Down

0 comments on commit 2174dc2

Please sign in to comment.