@Override
 public void initialize(XMPPServer server) {
   super.initialize(server);
   localServer = server;
   serverName = server.getServerInfo().getXMPPDomain();
   routingTable = server.getRoutingTable();
   deliverer = server.getPacketDeliverer();
   presenceManager = server.getPresenceManager();
   rosterManager = server.getRosterManager();
   userManager = server.getUserManager();
 }
Esempio n. 2
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");
  }