Package com.almende.eve.agent

Examples of com.almende.eve.agent.Agent


   * @return urls
   * @throws Exception
   */
  public List<String> create(@Name("id") String id,
      @Name("type") String type) throws Exception {
    Agent agent = getAgentFactory().createAgent(type, id);
    return (agent != null) ? agent.getUrls() : null;
  }
View Full Code Here


   * @param id
   * @return urls
   * @throws Exception
   */
  public List<String> get(@Name("id") String id) throws Exception {
    Agent agent = getAgentFactory().getAgent(id);
    return (agent != null) ? agent.getUrls() : null;
  }
View Full Code Here

   * @param id
   * @return exists
   * @throws Exception
   */
  public boolean exists(@Name("id") String id) throws Exception {
    Agent agent = getAgentFactory().getAgent(id);
    return (agent != null);
  }
View Full Code Here

      resp.sendError(400, "Query parameter 'type' missing in url.");
      return;
    }
   
    try {
      Agent agent = agentFactory.createAgent(agentType, agentId);
      for (String url : agent.getUrls()) {
        resp.getWriter().println(url);
      }
      agent.destroy();
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
View Full Code Here

      throw new Exception("Cannot initialize agent: " +
          "Init Parameter 'agentId' missing in servlet configuration web.xml.");
    }
   
    // create the agent if it does not yet exist
    Agent agent = agentFactory.getAgent(agentId);
    if (agent == null) {
      String agentType = getInitParameter("agentType");
      if (agentId == null) {
        throw new Exception("Cannot create agent: " +
            "Init Parameter 'agentClass' missing in servlet configuration web.xml.");
      }
     
      agent = agentFactory.createAgent(agentType, agentId);
      logger.info("Agent created: " + agent.toString());
    }

    logger.info("Agent initialized: " + agent.toString());
  }
View Full Code Here

  public List<String> create(@Name("id") final String id,
      @Name("type") final String type) throws JSONRPCException,
      InstantiationException, IllegalAccessException,
      InvocationTargetException, NoSuchMethodException,
      ClassNotFoundException, IOException {
    final Agent agent = getAgentHost().createAgent(type, id);
    return (agent != null) ? agent.getUrls() : null;
  }
View Full Code Here

    final Config config = YamlReader.load(is).expand();
   
    final ArrayNode agents = (ArrayNode) config.get("agents");
    for (final JsonNode agent : agents) {
      final AgentConfig agentConfig = new AgentConfig((ObjectNode) agent);
      final Agent newAgent = new AgentBuilder().withWakeService(ws)
          .withClassLoader(cl).with(agentConfig).build();
      LOG.info("Created agent:" + newAgent.getId());
    }
  }
View Full Code Here

      resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
          "No agentId found in url.");
      resp.flushBuffer();
      return;
    }
    Agent agent = null;
    try {
      agent = host.getAgent(agentId);
    } catch (final Exception e) {
      LOG.log(Level.WARNING, "Couldn't get agent:" + agentId, e);
    }
    if (agent == null) {
      resp.sendError(HttpServletResponse.SC_NOT_FOUND,
          "Agent not found at this host.");
      resp.flushBuffer();
      return;
    }
   
    if (agent.hasPrivate() && !handleSession(req, resp)) {
      if (!resp.isCommitted()) {
        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
      }
      resp.flushBuffer();
      return;
View Full Code Here

          "Query parameter 'type' missing in url.");
      return;
    }
   
    try {
      final Agent agent = host.createAgent(agentType, agentId);
      for (final String url : agent.getUrls()) {
        resp.getWriter().println(url);
      }
      agent.signalAgent(new AgentSignal<Void>(AgentSignal.DESTROY, null));
    } catch (final Exception e) {
      throw new ServletException(e);
    }
  }
View Full Code Here

      throw new Exception("Cannot initialize agent: " +
          "Init Parameter 'agentId' missing in servlet configuration web.xml.");
    }
   
    // create the agent if it does not yet exist
    Agent agent = agentFactory.getAgent(agentId);
    if (agent == null) {
      String agentType = getInitParameter("agentType");
      if (agentId == null) {
        throw new Exception("Cannot create agent: " +
            "Init Parameter 'agentClass' missing in servlet configuration web.xml.");
      }
     
      agent = agentFactory.createAgent(agentType, agentId);
      logger.info("Agent created: " + agent.toString());
    }

    logger.info("Agent initialized: " + agent.toString());
  }
View Full Code Here

TOP

Related Classes of com.almende.eve.agent.Agent

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.