Examples of EventPublisher


Examples of org.apache.stratos.messaging.broker.publish.EventPublisher

            try {
                if(log.isInfoEnabled()) {
                    log.info(String.format("Publishing tenant removed event: [tenant-id] %d", tenantId));
                }
                TenantRemovedEvent event = new TenantRemovedEvent(tenantId);
                EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TENANT_TOPIC);
                eventPublisher.publish(event);
            }
            catch (Exception e) {
                log.error("Could not publish tenant removed event");
            }
        }
View Full Code Here

Examples of org.apache.stratos.messaging.broker.publish.EventPublisher

    public InstanceNotificationPublisher() {
    }

    private void publish(Event event) {
        EventPublisher depsyncEventPublisher = EventPublisherPool.getPublisher(Constants.INSTANCE_NOTIFIER_TOPIC);
        depsyncEventPublisher.publish(event);
    }
View Full Code Here

Examples of org.ff4j.audit.EventPublisher

public class EventRepositoryTest {

    @Test
    public void testAudit() throws InterruptedException {
        int nb = 500;
        EventPublisher pub = new EventPublisher();
        for (int i = 0; i < nb; i++) {
            pub.publish(new Event("aer", EventType.HIT_FLIPPED));
            Thread.sleep(2);
        }
        Assert.assertEquals(nb, pub.getRepository().getTotalEventCount());
    }
View Full Code Here

Examples of org.ff4j.audit.EventPublisher

    @Test
    public void testAuditWithLimit() throws InterruptedException {
        int nb = 500;
        int limit = 25;
        EventPublisher pub = new EventPublisher();
        pub.setRepository(new InMemoryEventRepository(limit));
        for (int i = 0; i < nb; i++) {
            pub.publish(new Event("aer", EventType.HIT_FLIPPED));
            Thread.sleep(2);
        }
        Assert.assertEquals(limit, pub.getRepository().getTotalEventCount());
    }
View Full Code Here

Examples of org.ff4j.audit.EventPublisher

    @Test
    public void testCurve() throws InterruptedException {
        // Events to generate
        int nbEvent = 100;

        EventPublisher pub = new EventPublisher();
        for (int i = 0; i < nbEvent; i++) {
            pub.publish(new Event("aer", EventType.HIT_FLIPPED));
            Thread.sleep(2);
        }
        Assert.assertEquals(nbEvent, pub.getRepository().getTotalEventCount());
        long now = System.currentTimeMillis();
        pub.getRepository().getFeatureHitsCurve("aer", now - 3 * nbEvent, now, 10);
    }
View Full Code Here

Examples of org.ff4j.audit.EventPublisher

     *
     * @return current value of 'eventPublisher'
     */
    public EventPublisher getEventPublisher() {
        if (eventPublisher == null) {
            eventPublisher = new EventPublisher(eventRepository);
        }
        return eventPublisher;
    }
View Full Code Here

Examples of org.openhab.core.events.EventPublisher

   * @param args array which contains the arguments for the update command
   * @param console the console for printing messages for the user
   */
  static public void handleUpdate(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ConsoleActivator.eventPublisherTracker.getService();
    if(publisher!=null) {
      if(registry!=null) {
        if(args.length>0) {
          String itemName = args[0];
          try {
            Item item = registry.getItemByPattern(itemName);
            if(args.length>1) {
              String stateName = args[1];
              State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateName);
              if(state!=null) {
                publisher.postUpdate(item.getName(), state);
                console.println("Update has been sent successfully.");
              } else {
                console.println("Error: State '" + stateName +
                    "' is not valid for item '" + itemName + "'");
                console.print("Valid data types are: ( ");
View Full Code Here

Examples of org.openhab.core.events.EventPublisher

   * @param args array which contains the arguments for the send command
   * @param console the console for printing messages for the user
   */
  static public void handleSend(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ConsoleActivator.eventPublisherTracker.getService();
    if(publisher!=null) {
      if(registry!=null) {
        if(args.length>0) {
          String itemName = args[0];
          try {
            Item item = registry.getItemByPattern(itemName);
            if(args.length>1) {
              String commandName = args[1];
              Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandName);
              if(command!=null) {
                publisher.sendCommand(itemName, command);
                console.println("Command has been sent successfully.");
              } else {
                console.println("Error: Command '" + commandName +
                    "' is not valid for item '" + itemName + "'");
                console.print("Valid command types are: ( ");
View Full Code Here

Examples of org.openhab.core.events.EventPublisher

  static private final Logger logger = LoggerFactory.getLogger(BusEvent.class);
 
  static public void sendCommand(String itemName, String commandString) {
    ItemRegistry registry = (ItemRegistry) RulesActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) RulesActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandString);
        publisher.sendCommand(itemName, command);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
  }
View Full Code Here

Examples of org.openhab.core.events.EventPublisher

    }
  }

  static public void postUpdate(String itemName, String stateString) {
    ItemRegistry registry = (ItemRegistry) RulesActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) RulesActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateString);
        publisher.postUpdate(itemName, state);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.