Exemplo n.º 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;
      }
    }
Exemplo n.º 2
0
  public long[] getServiceEvents() {
    synchronized (serviceEvents) {
      long[] r = new long[serviceEvents.size() * 2];
      int i = 0;

      for (Iterator it = serviceEvents.iterator(); it.hasNext(); ) {
        ServiceEvent ev = (ServiceEvent) it.next();
        r[i * 2] = ((Long) ev.getServiceReference().getProperty(Constants.SERVICE_ID)).longValue();
        r[i * 2 + 1] = ev.getType();
        i++;
      }

      serviceEvents.clear();
      return r;
    }
  }
Exemplo n.º 3
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);
    }