Package org.osgi.service.event

Examples of org.osgi.service.event.EventAdmin


        }
        eventAdmin.postEvent(new Event(topic, props));
    }

    public void repositoryEvent(RepositoryEvent event) {
        EventAdmin eventAdmin = tracker.getService();
        if (eventAdmin == null) {
            return;
        }
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(EventConstants.TYPE, event.getType());
        props.put(EventConstants.EVENT, event);
        props.put(EventConstants.TIMESTAMP, System.currentTimeMillis());
        props.put(EventConstants.REPOSITORY_URI, event.getRepository().getURI().toString());
        String topic;
        switch (event.getType()) {
        case RepositoryAdded:
            topic = EventConstants.TOPIC_REPOSITORY_ADDED;
            break;
        case RepositoryRemoved:
            topic = EventConstants.TOPIC_REPOSITORY_REMOVED;
            break;
        default:
            throw new IllegalStateException("Unknown repository event type: " + event.getType());
        }
        eventAdmin.postEvent(new Event(topic, props));
    }
View Full Code Here


        tracker.close();
    }

    public void beforeExecute(CommandSession session, CharSequence command) {
        if (command.toString().trim().length() > 0) {
            EventAdmin admin = tracker.getService();
            if (admin != null) {
                Map<String, Object> props = new HashMap<String, Object>();
                props.put("command", command.toString());
                Event event = new Event("org/apache/karaf/shell/console/EXECUTING", props);
                admin.postEvent(event);
            }
        }
    }
View Full Code Here

    eventProperties.put("timestamp", new Long(new Date().getTime())); //$NON-NLS-1$
    eventProperties.put("event", event); //$NON-NLS-1$
    if (registrationTypeName != null)
      eventProperties.put(registrationTypeName, endpointDescription);

    final EventAdmin eventAdmin = AccessController
    .doPrivileged(new PrivilegedAction<EventAdmin>() {
      public EventAdmin run() {
        synchronized (eventAdminTrackerLock) {
          eventAdminTracker = new ServiceTracker(
              getRSABundleContext(), EventAdmin.class
                  .getName(), null);
          eventAdminTracker.open();
        }
        return (EventAdmin) eventAdminTracker.getService();
      }
    });
    if (eventAdmin == null) {
      logError("postEvent", //$NON-NLS-1$
          "No EventAdmin service available to send eventTopic=" //$NON-NLS-1$
              + topic + " eventProperties=" + eventProperties); //$NON-NLS-1$
      return;
    }
    // post via event admin
    AccessController.doPrivileged(new PrivilegedAction<Object>() {
      public Object run() {
        eventAdmin.postEvent(new Event(topic, eventProperties));
        return null;
      }
    });
  }
View Full Code Here

    // placeholder
  }

  public boolean send(String topic, Object data) {
    Event event = constructEvent(topic, data);
    EventAdmin eventAdmin = Activator.getEventAdmin();
    if (eventAdmin == null) {
      logger.error("No event admin found");
      return false;
    }
    eventAdmin.sendEvent(event);
    return true;
  }
View Full Code Here

    return true;
  }

  public boolean post(String topic, Object data) {
    Event event = constructEvent(topic, data);
    EventAdmin eventAdmin = Activator.getEventAdmin();
    if (eventAdmin == null) {
      logger.error("No event admin found");
      return false;
    }
    eventAdmin.postEvent(event);
    return true;
  }
View Full Code Here

TOP

Related Classes of org.osgi.service.event.EventAdmin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.