This method adds and registers the ShanksAgent

@param agent
The ShanksAgent
@throws ShanksException
540073
public void registerShanksAgent(ShanksAgent agent)
            throws ShanksException {
        if (!this.agents.containsKey(agent.getID())) {
            this.agents.put(agent.getID(), agent);
        } else {
            throw new DuplicatedAgentIDException(agent.getID());
        }
    }
240122
function onRequestCreateAgent(session, channel, message) {
  var agent = agents.createAgent(channel, message.body)
  channel.addAgent(agent)

  channel.sendMessage({
    type:  "response",
    name:  message.name,
    from:  message.to,
    id:    message.id,
    body:  agent.info
  })
}
492450
protected void genCounter(final String agent) {
        idsCounter.inc();
        if (!agentCounters.containsKey(agent)) {
            agentCounters.put(agent, registry.counter(MetricRegistry.name(
                    IdWorker.class, "ids_generated_" + agent)));
        }
        agentCounters.get(agent).inc();
    }
440487
public static void applyUserAgent(String agent) {
    LOGGER.info("Applying agent: " + agent);
    System.setProperty("http.agent", agent);
    System.setProperty("https.agent", agent);
  }
1013346
protected void fireAgentSpawnedInAgent(UUID spawningAgent, AgentContext context, Agent agent, Object... initializationParameters) {
		// Notify the listeners on the lifecycle events inside
		// the just spawned agent.
		// Usually, only BICs and the AgentLifeCycleSupport in
		// io.janusproject.kernel.bic.StandardBuiltinCapacitiesProvider
		// is invoked.
		final ListenerCollection<SpawnServiceListener> list;
		synchronized (this.agentLifecycleListeners) {
			list = this.agentLifecycleListeners.get(agent.getID());
		}
		if (list != null) {
			final List<Agent> singleton = Collections.singletonList(agent);
			for (final SpawnServiceListener l : list.getListeners(SpawnServiceListener.class)) {
				l.agentSpawned(spawningAgent, context, singleton, initializationParameters);
			}
		}
	}
99371
public final void addTarget(@NotNull final Target target) {
        Contract.requireArgNotNull("target", target);
        if (targets == null) {
            targets = new ArrayList<>();
        }
        targets.add(target);
    }
76111
public static void loadNetwork(BayesianReasonerShanksAgent agent)
            throws ShanksException {
        Network bn = ShanksAgentBayesianReasoningCapability.loadNetwork(agent
                .getBayesianNetworkFilePath());
        agent.setBayesianNetwork(bn);
    }
151106
public static void addSoftEvidences(BayesianReasonerShanksAgent agent,
            HashMap<String, HashMap<String, Double>> softEvidences)
            throws ShanksException {
        ShanksAgentBayesianReasoningCapability.addSoftEvidences(
                agent.getBayesianNetwork(), softEvidences);
    }
259970
async def set_agent(self, msg, context):
        """"""

        service = msg.get('name')
        client = context.user_data

        self.service_manager.set_agent(service, client)
767249
public void setAgents(java.util.Collection<AgentListEntry> agents) {
        if (agents == null) {
            this.agents = null;
            return;
        }

        this.agents = new java.util.ArrayList<AgentListEntry>(agents);
    }
1276018
@Override
    public void loadAgent(String agent, String options)
        throws AgentLoadException, AgentInitializationException, IOException
    {
        String args = agent;
        if (options != null) {
            args = args + "=" + options;
        }
        try {
            loadAgentLibrary("instrument", args);
        } catch (AgentLoadException x) {
            throw new InternalError("instrument library is missing in target VM");
        } catch (AgentInitializationException x) {
            /*
             * Translate interesting errors into the right exception and
             * message (FIXME: create a better interface to the instrument
             * implementation so this isn't necessary)
             */
            int rc = x.returnValue();
            switch (rc) {
                case JNI_ENOMEM:
                    throw new AgentLoadException("Insuffient memory");
                case ATTACH_ERROR_BADJAR:
                    throw new AgentLoadException("Agent JAR not found or no Agent-Class attribute");
                case ATTACH_ERROR_NOTONCP:
                    throw new AgentLoadException("Unable to add JAR file to system class path");
                case ATTACH_ERROR_STARTFAIL:
                    throw new AgentInitializationException("Agent JAR loaded but agent failed to initialize");
                default :
                    throw new AgentLoadException("Failed to load agent - unknown reason: " + rc);
            }
        }
    }
30673
private void setDefaultUserAgent() {
        setUserAgent(
                MwsUtl.escapeAppName(applicationName),
                MwsUtl.escapeAppVersion(applicationVersion),
                MwsUtl.escapeAttributeValue("Java/"
                        + System.getProperty("java.version") + "/"
                        + System.getProperty("java.class.version") + "/"
                        + System.getProperty("java.vendor")),

                MwsUtl.escapeAttributeName("Platform"),
                MwsUtl.escapeAttributeValue("" + System.getProperty("os.name")
                        + "/" + System.getProperty("os.arch") + "/"
                        + System.getProperty("os.version")),

                MwsUtl.escapeAttributeName("MWSClientVersion"),
                MwsUtl.escapeAttributeValue(libraryVersion));
    }
701145
def set_agent(self, agent):
        
        self.agent = agent
        self.queue = asyncio.Queue(loop=self.agent.loop)
        self.presence = agent.presence
        self.web = agent.web
1283345
private void updateAgentState(AsteriskAgentImpl agent, AgentState newState)
    {
        logger.info("Set state of agent " + agent.getAgentId() + " to " + newState);
        synchronized (agent)
        {
            agent.updateState(newState);
        }
    }
58850
protected synchronized void createAgent (int agentId)
    {
        Subscriber<AgentObject> delegator = new Subscriber<AgentObject>() {
            public void objectAvailable (AgentObject agentObject) {
                BureauDirector.this.objectAvailable(agentObject);
            }
            public void requestFailed (int oid, ObjectAccessException cause) {
                BureauDirector.this.requestFailed(oid, cause);
            }
        };

        log.info("Subscribing to object " + agentId);

        SafeSubscriber<AgentObject> subscriber =
            new SafeSubscriber<AgentObject>(agentId, delegator);
        _subscribers.put(agentId, subscriber);
        subscriber.subscribe(_ctx.getDObjectManager());
    }
1205603
def register_agent(self, host, sweep_id=None, project_name=None):
        
        mutation = gql('''
        mutation CreateAgent(
            $host: String!
            $projectName: String!,
            $entityName: String!,
            $sweep: String!
        ) {
            createAgent(input: {
                host: $host,
                projectName: $projectName,
                entityName: $entityName,
                sweep: $sweep,
            }) {
                agent {
                    id
                }
            }
        }
        ''')
        if project_name is None:
            project_name = self.settings('project')

        # don't retry on validation errors
        def no_retry_400(e):
            if not isinstance(e, requests.HTTPError):
                return True
            if e.response.status_code != 400:
                return True
            body = json.loads(e.response.content)
            raise UsageError(body['errors'][0]['message'])

        response = self.gql(mutation, variable_values={
            'host': host,
            'entityName': self.settings("entity"),
            'projectName': project_name,
            'sweep': sweep_id}, check_retry_fn=no_retry_400)
        return response['createAgent']['agent']
926463
void handleAgentsEvent(AgentsEvent event)
    {
        AsteriskAgentImpl agent = new AsteriskAgentImpl(server,
                event.getName(), "Agent/" + event.getAgent(), AgentState.valueOf(event.getStatus()));
        logger.info("Adding agent " + agent.getName() + "(" + agent.getAgentId() + ")");

        addAgent(agent);
    }