示例#1
0
    /** Handles service change events. */
    public void serviceChanged(ServiceEvent event) {
      ServiceReference serviceRef = event.getServiceReference();

      // if the event is caused by a bundle being stopped, we don't want to
      // know
      if (serviceRef.getBundle().getState() == Bundle.STOPPING) {
        return;
      }

      Object service = MUCActivator.bundleContext.getService(serviceRef);

      // we don't care if the source service is not a protocol provider
      if (!(service instanceof ProtocolProviderService)) {
        return;
      }

      switch (event.getType()) {
        case ServiceEvent.REGISTERED:
          addQueryToProviderPresenceListeners((ProtocolProviderService) service);
          break;
        case ServiceEvent.UNREGISTERING:
          removeQueryFromProviderPresenceListeners((ProtocolProviderService) service);
          break;
      }
    }
示例#2
0
    /**
     * When a service is registered or unregistered, we update the provider tables and add/remove
     * listeners (if it supports BasicInstantMessenging implementation)
     *
     * @param event ServiceEvent
     */
    public void serviceChanged(ServiceEvent event) {
      // if the event is caused by a bundle being stopped, we don't want to
      // know
      if (event.getServiceReference().getBundle().getState() == Bundle.STOPPING) {
        return;
      }

      Object service = SystrayActivator.bundleContext.getService(event.getServiceReference());

      if (!(service instanceof ProtocolProviderService)) return;

      ProtocolProviderService provider = (ProtocolProviderService) service;

      if (event.getType() == ServiceEvent.REGISTERED) addAccount(provider);

      if (event.getType() == ServiceEvent.UNREGISTERING) removeAccount(provider);
    }