public void startAgent ( AgentObject agent ) { agent . setLocal ( AgentData . class , new AgentData ( ) ) ; Bureau bureau = _bureaus . get ( agent . bureauId ) ; if ( bureau != null && bureau . ready ( ) ) { _omgr . registerObject ( agent ) ; log . info ( "Bureau ready, sending createAgent" , "agent" , agent . which ( ) ) ; BureauSender . createAgent ( bureau . clientObj , agent . getOid ( ) ) ; bureau . agentStates . put ( agent , AgentState . STARTED ) ; bureau . summarize ( ) ; return ; } if ( bureau == null ) { LauncherEntry launcherEntry = _launchers . get ( agent . bureauType ) ; if ( launcherEntry == null ) { log . warning ( "Launcher not found" , "agent" , agent . which ( ) ) ; return ; } log . info ( "Creating new bureau" , "bureauId" , agent . bureauId , "launcher" , launcherEntry ) ; bureau = new Bureau ( ) ; bureau . bureauId = agent . bureauId ; bureau . token = generateToken ( bureau . bureauId ) ; bureau . launcherEntry = launcherEntry ; _invoker . postUnit ( new LauncherUnit ( bureau , _omgr ) ) ; _bureaus . put ( agent . bureauId , bureau ) ; } _omgr . registerObject ( agent ) ; bureau . agentStates . put ( agent , AgentState . PENDING ) ; log . info ( "Bureau not ready, pending agent" , "agent" , agent . which ( ) ) ; bureau . summarize ( ) ; }
Starts a new agent using the data in the given object creating a new bureau if necessary .