Exemplo n.º 1
0
  /** Register an agent on login */
  public void registerAgent(org.opensims.agent.Agent agent) {
    boolean internalScanAvail = false;

    try {
      // avoiding the proverbial chicken-and-the-egg problem, we
      // obtain some scan parameters from the config file...

      if (agent.getNetworkNode("internal") != null) {
        StringBuffer path = new StringBuffer("//");
        path.append(org.opensims.xml.Node.NETWORK_NODE);
        path.append("[@topology = 'internal']/");
        path.append(org.opensims.xml.Node.SCAN_NODE);
        path.append("[@enabled = 'true']");

        org.jdom.Element internal_net_node = (org.jdom.Element) agent.getNetworkNode("internal");
        org.jdom.Element internal_scan_node =
            (org.jdom.Element)
                org.jdom.xpath.XPath.selectSingleNode(internal_net_node, path.toString());

        if (internal_scan_node != null) {
          // create a Scan object, to maintain the state of autodiscovery

          String class_name = internal_scan_node.getAttributeValue("class");
          Class c = Class.forName(class_name);

          org.opensims.model.Scan scan = (org.opensims.model.Scan) c.newInstance();

          scan.init(
              this,
              agent,
              internal_scan_node,
              agent.getNetworkNode("internal"),
              agent.getNetworkNumber("internal"),
              agent.getNetworkDevice("internal"));

          // Restructure Hash Table to use network_number as a key, as opposed to the agent key
          // put(scan.getKey(), scan);
          put(agent.getNetworkNumber("internal"), scan);

          // Use this scan as the default for all agents that aren't directly assigned one (using
          // the createThreads() method on the agent object --ME
          agent.setScan(scan);
          internalScanAvail = true;
        }
      }

      if (agent.getNetworkNode("dmz") != null) {
        StringBuffer path = new StringBuffer("//");
        path.append(org.opensims.xml.Node.NETWORK_NODE);
        path.append("[@topology = 'dmz']/");
        path.append(org.opensims.xml.Node.SCAN_NODE);
        path.append("[@enabled = 'true']");

        org.jdom.Element external_net_node = (org.jdom.Element) agent.getNetworkNode("dmz");
        org.jdom.Element external_scan_node =
            (org.jdom.Element)
                org.jdom.xpath.XPath.selectSingleNode(external_net_node, path.toString());

        if (external_scan_node != null) {
          // create a Scan object, to maintain the state of autodiscovery

          String class_name = external_scan_node.getAttributeValue("class");
          Class c = Class.forName(class_name);

          org.opensims.model.Scan scan = (org.opensims.model.Scan) c.newInstance();

          scan.init(
              this,
              agent,
              external_scan_node,
              agent.getNetworkNode("dmz"),
              agent.getNetworkNumber("dmz"),
              agent.getNetworkDevice("dmz"));
          // Restructure Hash Table to use network_number as a key, as opposed to the agent key
          // put(scan.getKey(), scan);
          put(agent.getNetworkNumber("dmz"), scan);

          // First check if we have an "internal" scan, if not, then set this scan as default
          if (!internalScanAvail) {
            agent.setScan(scan);
          }
        }
      }
    } catch (Exception e) {
      log_.error("register agent", e);
    }
  }
Exemplo n.º 2
0
  /**
   * Lookup for Plugins that do not use the Autodiscovery Engine (FSM) Somewhat circuitous and in
   * need of revision
   */
  public org.opensims.model.Scan getScan(org.opensims.agent.Agent agent) {
    org.opensims.model.Scan scan = agent.getScan();

    return scan;
  }