Ejemplo n.º 1
0
  private void processIQ(IQ iq) {
    long start = System.currentTimeMillis();
    Element childElement = iq.getChildElement();
    String namespace = childElement.getNamespaceURI();

    // 构造返回dom
    IQ reply = IQ.createResultIQ(iq);
    Element childElementCopy = childElement.createCopy();
    reply.setChildElement(childElementCopy);

    if (XConstants.PROTOCOL_DISCO_INFO.equals(namespace)) {
      generateDisco(childElementCopy); // 构造disco反馈信息
      if (LOG.isInfoEnabled()) {
        LOG.info(
            "[spend time:{}ms],reqId: {},IRComponent服务发现,response:{}",
            System.currentTimeMillis() - start,
            iq.getID(),
            reply.toXML());
      }
    }

    try {
      ComponentManagerFactory.getComponentManager().sendPacket(this, reply);
    } catch (Throwable t) {
      LOG.error(
          "[spend time:{}ms],reqId: {},IRComponent IQ处理异常! iq:{},replay:{}",
          System.currentTimeMillis() - start,
          iq.getID(),
          reply.toXML(),
          t);
    }
  }
Ejemplo n.º 2
0
  /**
   * Adds agents to a request queue.
   *
   * @param queue the <code>RequestQueue</code> to add agents to.
   * @param agents a comma-delimited list of agents.
   */
  public static void addAgents(RequestQueue queue, String agents) {
    WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
    AgentManager agentManager = workgroupManager.getAgentManager();

    // loop thru all params
    StringTokenizer tokenizer = new StringTokenizer(agents, ", \t\n\r\f");
    while (tokenizer.hasMoreTokens()) {
      String usernameToken = tokenizer.nextToken();
      if (usernameToken.indexOf('@') != -1) {
        usernameToken = JID.escapeNode(usernameToken);
      }
      try {
        // See if they are a user in the system.
        UserManager.getInstance().getUser(usernameToken);
        usernameToken += ("@" + ComponentManagerFactory.getComponentManager().getServerName());
        JID address = new JID(usernameToken.trim());
        Agent agent;

        if (agentManager.hasAgent(address)) {
          agent = agentManager.getAgent(address);
        } else {
          agent = agentManager.createAgent(address);
        }
        queue.addMember(agent);
      } catch (Exception e) {
        Log.error(e.getMessage(), e);
      }
    }
  }
Ejemplo n.º 3
0
  @Override
  public void start() {
    // Set this ComponentManager as the current component manager
    ComponentManagerFactory.setComponentManager(instance);

    XMPPServer server = XMPPServer.getInstance();
    serverDomain = server.getServerInfo().getXMPPDomain();
    // Set the address of this internal service. component.[domain]
    serviceAddress = new JID(null, "component." + serverDomain, null);
    if (!server.isSetupMode()) {
      // Add a route to this service
      server.getRoutingTable().addComponentRoute(getAddress(), this);
    }
  }
Ejemplo n.º 4
0
  public void initializePlugin(PluginManager manager, File pluginDirectory) {
    SipXOpenfirePlugin.instance = this;

    InputStream in = getClass().getResourceAsStream("/config.properties");
    Properties properties = new Properties();
    componentManager = ComponentManagerFactory.getComponentManager();

    try {
      properties.load(in);
    } catch (IOException ex) {
      componentManager.getLog().error(ex);
    }

    try {
      if (new File("/tmp/sipx.properties").exists()) {
        System.getProperties().load(new FileInputStream(new File("/tmp/sipx.properties")));
      }
    } catch (Exception ex) {
      componentManager.getLog().error(ex);
      throw new SipXOpenfirePluginException("Error reading config file ", ex);
    }

    pluginManager = manager;
    ClassLoader classLoader = pluginManager.getPluginClassloader(this);
    classLoader.setPackageAssertionStatus("org.sipfoundry", true);
    Thread.currentThread().setContextClassLoader(classLoader);
    configurationPath = System.getProperty("conf.dir", "/etc/sipxpbx");
    parseConfigurationFile();
    initializeLogging();
    CallWatcher.setWatcherConfig(watcherConfig);
    /*
     * This initializes the SIP side of the show.
     */
    try {
      CallWatcher.pluginInit();
      log.info("completed init");
      ResourceStateChangeListener resourceStateChangeListener =
          new ResourceStateChangeListenerImpl(this);
      CallWatcher.getSubscriber().setResourceStateChangeListener(resourceStateChangeListener);
    } catch (Exception e) {
      log.error("Error initializing CallWatcher");
      throw new SipXOpenfirePluginException("Init error", e);
    }

    server = XMPPServer.getInstance();

    userManager = server.getUserManager();
    presenceManager = server.getPresenceManager();

    hostname = server.getServerInfo().getXMPPDomain();
    log.info("HostName = " + hostname);

    probedPresence = new ConcurrentHashMap<String, Presence>();
    componentJID = new JID(subdomain + "." + hostname);

    groupManager = GroupManager.getInstance();

    multiUserChatManager = server.getMultiUserChatManager();
    /*
     * Load up the database.
     */
    multiUserChatManager.start();
    log.info("hostname " + hostname);
    try {
      componentManager.addComponent(subdomain, this);
    } catch (Exception e) {
      componentManager.getLog().error(e);
      log.error(e);
      throw new SipXOpenfirePluginException("Init error", e);
    }

    String accountConfigurationFile = configurationPath + "/xmpp-account-info.xml";
    if (!new File(accountConfigurationFile).exists()) {
      System.err.println("User account file not found");
      throw new SipXOpenfirePluginException("Cannot find user accounts file");
    } else {
      this.accountsParser = new AccountsParser(accountConfigurationFile);
      this.accountsParser.startScanner();
    }
    // config and instantiate and the presence unifier used to gather all presence info

    PresenceUnifier.setPlugin(this);
    PresenceUnifier.getInstance();
    // add packet interceptor

    InterceptorManager.getInstance().addInterceptor(new MessagePacketInterceptor(this));
    log.info("plugin initializaton completed");
    log.info("DONE");
  }