Package com.almende.eve.state

Examples of com.almende.eve.state.State


      return agent;
    }
    //No agent found, normal initialization:
   
    // load the State
    State state = null;
    state = getStateFactory().get(agentId);
    if (state == null) {
      // agent does not exist
      return null;
    }
    state.init();
   
    // read the agents class name from state
    Class<?> agentType = state.getAgentType();
    if (agentType == null) {
      throw new Exception("Cannot instantiate agent. " +
          "Class information missing in the agents state " +
          "(agentId='" + agentId + "')");
    }
View Full Code Here


      logger.warning("Validation error class: " + agentType.getName() +
          ", message: " + error);
    }
   
    // create the state
    State state = getStateFactory().create(agentId);
    state.setAgentType(agentType);
    state.destroy();

    // instantiate the agent
    Agent agent = (Agent) agentType.getConstructor().newInstance();
    agent.setAgentFactory(this);
    agent.setState(state);
View Full Code Here

      return agent;
    }
    // No agent found, normal initialization:
   
    // load the State
    final State state = getStateFactory().get(agentId);
    if (state == null) {
      // agent does not exist
      return null;
    }
    state.init();
   
    // read the agents class name from state
    final Class<?> agentType = state.getAgentType();
    if (agentType == null) {
      LOG.warning("Cannot instantiate agent. "
          + "Class information missing in the agents state "
          + "(agentId='" + agentId + "')");
      return null;
View Full Code Here

      final String agentId) throws InstantiationException,
      IllegalAccessException, InvocationTargetException,
      NoSuchMethodException, IOException {
   
    // create the state
    final State state = getStateFactory().create(agentId);
    state.setAgentType(agentType);
    state.init();
   
    // instantiate the agent
    final T agent = agentType.getConstructor().newInstance();
    agent.constr(this, state);
    agent.signalAgent(new AgentSignal<Void>(AgentSignal.CREATE));
View Full Code Here

   * @return the conns
   * @throws IOException
   *             Signals that an I/O exception has occurred.
   */
  private ArrayNode getConns(final String agentId) throws IOException {
    final State state = agentHost.getStateFactory().get(agentId);
   
    ArrayNode conns = null;
    if (state.containsKey(CONNKEY)) {
      conns = (ArrayNode) JOM.getInstance().readTree(
          state.get(CONNKEY, String.class));
    }
    return conns;
  }
View Full Code Here

      InvalidKeyException, InvalidAlgorithmParameterException,
      NoSuchAlgorithmException, InvalidKeySpecException,
      NoSuchPaddingException, IllegalBlockSizeException,
      BadPaddingException {
   
    final State state = agentHost.getStateFactory().get(agentId);
   
    final String conns = state.get(CONNKEY, String.class);
    ArrayNode newConns;
    if (conns != null) {
      newConns = (ArrayNode) JOM.getInstance().readTree(conns);
    } else {
      newConns = JOM.createArrayNode();
    }
   
    final ObjectNode params = JOM.createObjectNode();
    params.put("username", EncryptionUtil.encrypt(username));
    params.put("password", EncryptionUtil.encrypt(password));
    if (resource != null && !resource.equals("")) {
      params.put("resource", EncryptionUtil.encrypt(resource));
    }
    for (final JsonNode item : newConns) {
      if (item.get("username").equals(params.get("username"))) {
        return;
      }
    }
    newConns.add(params);
    if (!state.putIfUnchanged(CONNKEY, JOM.getInstance()
        .writeValueAsString(newConns), conns)) {
      // recursive retry
      storeConnection(agentId, username, password, resource);
    }
  }
View Full Code Here

   *
   * @param agentId
   *            the agent id
   */
  private void delConnections(final String agentId) {
    final State state = agentHost.getStateFactory().get(agentId);
    if (state != null) {
      state.remove(CONNKEY);
    }
  }
View Full Code Here

      return agent;
    }
    // No agent found, normal initialization:

    // load the State
    State state = null;
    state = getStateFactory().get(agentId);
    if (state == null) {
      // agent does not exist
      return null;
    }
    state.init();

    // read the agents class name from state
    Class<?> agentType = state.getAgentType();
    if (agentType == null) {
      throw new Exception("Cannot instantiate agent. "
          + "Class information missing in the agents state "
          + "(agentId='" + agentId + "')");
    }
View Full Code Here

      logger.warning("Validation error class: " + agentType.getName()
          + ", message: " + error);
    }

    // create the state
    State state = getStateFactory().create(agentId);
    state.setAgentType(agentType);
    state.init();

    // instantiate the agent
    T agent = (T) agentType.getConstructor().newInstance();
    agent.setAgentFactory(this);
    agent.setState(state);
View Full Code Here

   * @return agentUrl
   */
  @Override
  public String getAgentUrl(String agentId) {
    try {
      State state = agentFactory.getStateFactory().get(agentId);
      ArrayNode conns = null;
      if (state.containsKey("_XMPP_Connections")) {
        conns = (ArrayNode) JOM.getInstance().readTree(
            (String) state.get("_XMPP_Connections"));
      }
      if (conns != null) {
        for (JsonNode conn : conns) {
          ObjectNode params = (ObjectNode) conn;
         
View Full Code Here

TOP

Related Classes of com.almende.eve.state.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.