Examples of MessageBus


Examples of org.jboss.errai.bus.client.framework.MessageBus

  @SuppressWarnings({"UnusedDeclaration", "CdiInjectionPointsInspection"})
  public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
    // Errai Service wrapper
    ErraiService<?> service = CDIServerUtil.lookupErraiService();

    final MessageBus bus = service.getBus();

    if (bus.isSubscribed(CDI.SERVER_DISPATCHER_SUBJECT)) {
      return;
    }

    abd.addBean(new ErraiServiceBean(bm, service));
    // event dispatcher
    EventDispatcher eventDispatcher = new EventDispatcher(bm, observableEvents, eventQualifiers);

    for (EventConsumer ec : eventConsumers) {
      if (ec.getEventBeanType() != null) {
        abd.addBean(new ConversationalEventBean(ec.getEventBeanType(), (BeanManagerImpl) bm, bus));
      }

      if (ec.isConversational()) {
        abd.addObserverMethod(new ConversationalEventObserverMethod(ec.getRawType(), bus, ec.getQualifiers()));
      }
      else {
        abd.addObserverMethod(new EventObserverMethod(ec.getRawType(), bus, ec.getQualifiers()));
      }
    }

    for (MessageSender ms : messageSenders) {
      abd.addBean(new SenderBean(ms.getSenderType(), ms.getQualifiers(), bus));
    }

    // Errai bus injection
    abd.addBean(new MessageBusBean(bus));

    // Support to inject the request dispatcher.
    abd.addBean(new RequestDispatcherMetaData(bm, service.getDispatcher()));

    // Register observers
    abd.addObserverMethod(new ShutdownEventObserver(managedTypes, bus));

    // subscribe service and rpc endpoints
    subscribeServices(bm, bus);

    // subscribe event dispatcher
    bus.subscribe(CDI.SERVER_DISPATCHER_SUBJECT, eventDispatcher);
  }
View Full Code Here

Examples of org.jboss.errai.bus.client.framework.MessageBus

  @SuppressWarnings({ "UnusedDeclaration", "CdiInjectionPointsInspection" })
  public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
    // Errai Service wrapper
    ErraiService<?> service = ErraiServiceSingleton.getService();

    final MessageBus bus = service.getBus();

    if (bus.isSubscribed(CDI.SERVER_DISPATCHER_SUBJECT)) {
      return;
    }

    abd.addBean(new ErraiServiceBean(bm));
    // event dispatcher
    EventDispatcher eventDispatcher = new EventDispatcher(bm, observableEvents, eventQualifiers);

    for (EventConsumer ec : eventConsumers) {
      if (ec.getEventBeanType() != null) {
        abd.addBean(new ConversationalEventBean(ec.getEventBeanType(), (BeanManagerImpl) bm, bus));
      }

      if (ec.isConversational()) {
        abd.addObserverMethod(new ConversationalEventObserverMethod(ec.getRawType(), bus, ec.getQualifiers()));
      }
      else {
        abd.addObserverMethod(new EventObserverMethod(ec.getRawType(), bus, ec.getQualifiers()));
      }
    }

    for (MessageSender ms : messageSenders) {
      abd.addBean(new SenderBean(ms.getSenderType(), ms.getQualifiers(), bus));
    }

    // Errai bus injection
    abd.addBean(new MessageBusBean(bus));

    // Support to inject the request dispatcher.
    abd.addBean(new RequestDispatcherMetaData(bm, service.getDispatcher()));

    // Register observers
    abd.addObserverMethod(new ShutdownEventObserver(managedTypes, bus));

    // subscribe service and rpc endpoints
    subscribeServices(bm, bus);

    // subscribe event dispatcher
    bus.subscribe(CDI.SERVER_DISPATCHER_SUBJECT, eventDispatcher);
  }
View Full Code Here

Examples of org.jboss.errai.bus.client.framework.MessageBus

      @Override
      public void onInit(final ErraiService service) {
        // subscribe event dispatcher
        // Errai Service wrapper

        final MessageBus bus = service.getBus();

        if (bus.isSubscribed(CDI.SERVER_DISPATCHER_SUBJECT)) {
          return;
        }

        final byte[] randBytes = new byte[32];
        final Random random = new Random(System.currentTimeMillis());

        random.nextBytes(randBytes);

        abd.addBean(new ErraiServiceBean(bm, SecureHashUtil.hashToHexString(randBytes)));

        final Set<ObserversMarshallingExtension.ObserverPoint> observerPoints
                = new HashSet<ObserversMarshallingExtension.ObserverPoint>();

        for (EventConsumer ec : eventConsumers) {
          if (ec.getEventBeanType() != null) {
            abd.addBean(new ConversationalEventBean(ec.getEventBeanType(), (BeanManagerImpl) bm, bus));
          }

          observerPoints.add(new ObserversMarshallingExtension.ObserverPoint(ec.getRawType(), ec.getQualifiers()));
        }

        observerPoints.addAll(org.jboss.errai.enterprise.rebind.ObserversMarshallingExtension.scanForObserverPointsInClassPath());

        for (org.jboss.errai.enterprise.rebind.ObserversMarshallingExtension.ObserverPoint observerPoint :
                observerPoints) {

          if (org.jboss.errai.common.rebind.EnvUtil.isPortableType(observerPoint.getObservedType())) {
            if (observerPoint.getObservedType().isAnnotationPresent(Conversational.class)) {
              abd.addObserverMethod(new ConversationalEventObserverMethod(observerPoint.getObservedType(), bus, observerPoint.getQualifiers()));
            }
            else {
              abd.addObserverMethod(new EventObserverMethod(observerPoint.getObservedType(), bus, observerPoint.getQualifiers()));
            }
          }
        }

        for (MessageSender ms : messageSenders) {
          abd.addBean(new SenderBean(ms.getSenderType(), ms.getQualifiers(), bus));
        }

        final EventDispatcher eventDispatcher = new EventDispatcher(bm, observableEvents, eventQualifiers);

        bus.subscribe(CDI.SERVER_DISPATCHER_SUBJECT, eventDispatcher);

        // Errai bus injection
        abd.addBean(new MessageBusBean(bus));

        // Support to inject the request dispatcher.
View Full Code Here

Examples of org.jboss.errai.bus.client.framework.MessageBus

  public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
    // Errai Service wrapper
    this.service = CDIServerUtil.lookupErraiService();

    final MessageBus bus = service.getBus();

    if (bus.isSubscribed(CDI.DISPATCHER_SUBJECT)) {
      return;
    }

    abd.addBean(new ErraiServiceBean(bm, this.service));
    // event dispatcher
    EventDispatcher eventDispatcher = new EventDispatcher(bm, observableEvents, eventQualifiers);

    for (EventConsumer ec : eventConsumers) {
      if (ec.getEventBeanType() != null) {
        abd.addBean(new ConversationalEventBean(ec.getEventBeanType(), (BeanManagerImpl) bm, bus));
      }

      if (ec.isConversational()) {
        abd.addObserverMethod(new ConversationalEventObserverMethod(ec.getRawType(), bus, ec.getQualifiers()));
      }
      else {
        abd.addObserverMethod(new EventObserverMethod(ec.getRawType(), bus, ec.getQualifiers()));
      }
    }

    for (MessageSender ms : messageSenders) {
      abd.addBean(new SenderBean(ms.getSenderType(), ms.getQualifiers(), bus));
    }


    // Errai bus injection
    abd.addBean(new MessageBusBean(bm, bus));

    // Support to inject the request dispatcher.
    abd.addBean(new RequestDispatcherMetaData(bm, service.getDispatcher()));

    //   abd.addBean(new SenderBean((BeanManagerImpl) bm, service.getDispatcher()));

    // Register observers
    abd.addObserverMethod(new ShutdownEventObserver(managedTypes, bus, uuid));

    // subscribe service and rpc endpoints
    subscribeServices(bm, bus);

    // subscribe event dispatcher
    bus.subscribe(CDI.DISPATCHER_SUBJECT, eventDispatcher);
  }
View Full Code Here

Examples of org.jboss.errai.bus.client.framework.MessageBus

            toolSetLauncher.getElement().setId(id);
            toolSetLauncher.setVisible(false);
            RootPanel.get().add(toolSetLauncher);
        }

        MessageBus bus = ErraiBus.get();


        createMessage()
                .toSubject("org.jboss.errai.WorkspaceLayout")
                .command(LayoutCommands.RegisterToolSet)
View Full Code Here

Examples of org.jboss.errai.bus.client.framework.MessageBus

        _openTab(DOMID, initSubject, componentId, name, componentId, icon);
    }

    private void _openTab(final String DOMID, final String initSubject, final String componentId, final String name, final String instanceId, final Image icon) {
        final MessageBus bus = ErraiBus.get();

        bus.conversationWith(
                createMessage().getMessage().set(LayoutParts.DOMID, DOMID)
                        .toSubject(initSubject),
                new MessageCallback() {
                    public void callback(Message message) {
                        final ExtSimplePanel panel = new ExtSimplePanel();
                        panel.getElement().getStyle().setProperty("overflow", "hidden");

                        Effects.setOpacity(panel.getElement(), 0);

                        WSElementWrapper toolWidget = new WSElementWrapper(getElementById(DOMID));
                        toolWidget.setVisible(true);
                        panel.setWidget(toolWidget);

                        Image app = new Image(erraiImageBundle.application());

                        final Image newIcon = new Image(icon != null || "".equals(icon) ? icon.getUrl() :
                                app.getUrl());
                        newIcon.setSize("16px", "16px");

                        final WSTab newWSTab = new WSTab(name, panel, newIcon);
                        tabPanel.add(panel, newWSTab);
                        newWSTab.activate();


                        newWSTab.clearTabCloseHandlers();
                        newWSTab.addTabCloseHandler(new TabCloseHandler(instanceId));

                        tabDragController.makeDraggable(newWSTab, newWSTab.getLabel());
                        tabDragController.makeDraggable(newWSTab, newWSTab.getIcon());

                        newWSTab.getLabel().addMouseOverHandler(new MouseOverHandler() {
                            public void onMouseOver(MouseOverEvent event) {
                                newWSTab.getLabel().getElement().getStyle().setProperty("cursor", "default");
                            }
                        });

                        newWSTab.getLabel().addMouseDownHandler(new MouseDownHandler() {
                            public void onMouseDown(MouseDownEvent event) {
                                newWSTab.activate();
                            }
                        });

                        tabDragController.setBehaviorDragProxy(true);
                        tabDragController.registerDropController(newWSTab.getTabDropController());

                        newWSTab.reset();

                        activateTool(componentId);

                        Map<String, Object> tabProperties = new HashMap<String, Object>();
                        tabProperties.put(LayoutParts.Name.name(), name);
                        tabProperties.put(LayoutParts.IconURI.name(), newIcon.getUrl());
                        tabProperties.put(LayoutParts.ComponentID.name(), componentId);
                        tabProperties.put(LayoutParts.Subject.name(), getInstanceSubject(instanceId));

                        tabInstances.put(instanceId, JSONUtilCli.encodeMap(tabProperties));

                        bus.subscribe(getInstanceSubject(instanceId),
                                new MessageCallback() {
                                    private Map<String, List<Object>> toUnregister = ((ClientMessageBus) bus).getCapturedRegistrations();

                                    public void callback(Message message) {
                                        switch (LayoutCommands.valueOf(message.getCommandType())) {
View Full Code Here

Examples of org.jboss.errai.bus.client.framework.MessageBus

        // Errai Service wrapper
        this.service = Util.lookupErraiService();

        abd.addBean(new ServiceMetaData(bm, this.service));

        final MessageBus bus = service.getBus();

        // context handling hooks
        this.contextManager = new ContextManager(uuid, bm, bus);

        // Custom Conversation
        abd.addBean(new ConversationMetaData(bm, new ErraiConversation(
                (Conversation) Util.lookupCallbackBean(bm, Conversation.class),
                this.contextManager
        )));

        // event dispatcher
        EventDispatcher eventDispatcher = new EventDispatcher(bm, bus, this.contextManager);

        EventSubscriptionListener listener = new EventSubscriptionListener(abd, bus);
        bus.addSubscribeListener(listener);


        // Errai bus injection
        abd.addBean(new MessageBusMetaData(bm, bus));


        // Register observers       
        abd.addObserverMethod(new ShutdownEventObserver(managedTypes, bus, uuid));

        // subscribe service and rpc endpoints
        subscribeServices(bm, bus);

        // subscribe event dispatcher
        bus.subscribe(EventDispatcher.NAME, eventDispatcher);

    }
View Full Code Here

Examples of org.springframework.xd.dirt.integration.bus.MessageBus

    this.singleNodeApplication.close();
  }

  @Test
  public final void environmentMatchesTransport() {
    MessageBus messageBus = this.containerContext.getBean(MessageBus.class);
    assertEquals(getExpectedMessageBusType(), messageBus.getClass());
  }
View Full Code Here

Examples of org.springframework.xd.dirt.integration.bus.MessageBus

    return true;
  }

  @Test
  public void testSendAndReceiveBad() throws Exception {
    MessageBus messageBus = getMessageBus();
    DirectChannel moduleOutputChannel = new DirectChannel();
    DirectChannel moduleInputChannel = new DirectChannel();
    messageBus.bindProducer("bad.0", moduleOutputChannel, null);
    messageBus.bindConsumer("bad.0", moduleInputChannel, null);
    Message<?> message = MessageBuilder.withPayload("bad").setHeader(MessageHeaders.CONTENT_TYPE, "foo/bar").build();
    final CountDownLatch latch = new CountDownLatch(3);
    moduleInputChannel.subscribe(new MessageHandler() {

      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        latch.countDown();
        throw new RuntimeException("bad");
      }
    });
    moduleOutputChannel.send(message);
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    messageBus.unbindConsumers("bad.0");
    messageBus.unbindProducers("bad.0");
  }
View Full Code Here

Examples of org.springframework.xd.dirt.integration.bus.MessageBus

    messageBus.unbindProducers("bad.0");
  }

  @Test
  public void testConsumerProperties() throws Exception {
    MessageBus bus = getMessageBus();
    Properties properties = new Properties();
    properties.put("transacted", "true"); // test transacted with defaults; not allowed with ackmode NONE
    bus.bindConsumer("props.0", new DirectChannel(), properties);
    @SuppressWarnings("unchecked")
    List<Binding> bindings = TestUtils.getPropertyValue(bus, "messageBus.bindings", List.class);
    assertEquals(1, bindings.size());
    AbstractEndpoint endpoint = bindings.get(0).getEndpoint();
    SimpleMessageListenerContainer container = TestUtils.getPropertyValue(endpoint, "messageListenerContainer",
        SimpleMessageListenerContainer.class);
    assertEquals(AcknowledgeMode.AUTO, container.getAcknowledgeMode());
    assertEquals("xdbus.props.0", container.getQueueNames()[0]);
    assertTrue(TestUtils.getPropertyValue(container, "transactional", Boolean.class));
    assertEquals(1, TestUtils.getPropertyValue(container, "concurrentConsumers"));
    assertNull(TestUtils.getPropertyValue(container, "maxConcurrentConsumers"));
    assertTrue(TestUtils.getPropertyValue(container, "defaultRequeueRejected", Boolean.class));
    assertEquals(1, TestUtils.getPropertyValue(container, "prefetchCount"));
    assertEquals(1, TestUtils.getPropertyValue(container, "txSize"));
    Advice retry = TestUtils.getPropertyValue(container, "adviceChain", Advice[].class)[0];
    assertEquals(3, TestUtils.getPropertyValue(retry, "retryOperations.retryPolicy.maxAttempts"));
    assertEquals(1000L, TestUtils.getPropertyValue(retry, "retryOperations.backOffPolicy.initialInterval"));
    assertEquals(10000L, TestUtils.getPropertyValue(retry, "retryOperations.backOffPolicy.maxInterval"));
    assertEquals(2.0, TestUtils.getPropertyValue(retry, "retryOperations.backOffPolicy.multiplier"));
    bus.unbindConsumers("props.0");
    assertEquals(0, bindings.size());

    properties = new Properties();
    properties.put("ackMode", "NONE");
    properties.put("backOffInitialInterval", "2000");
    properties.put("backOffMaxInterval", "20000");
    properties.put("backOffMultiplier", "5.0");
    properties.put("concurrency", "2");
    properties.put("maxAttempts", "23");
    properties.put("maxConcurrency", "3");
    properties.put("prefix", "foo.");
    properties.put("prefetch", "20");
    properties.put("requestHeaderPatterns", "foo");
    properties.put("requeue", "false");
    properties.put("txSize", "10");
    properties.put("partitionIndex", 0);
    bus.bindConsumer("props.0", new DirectChannel(), properties);

    @SuppressWarnings("unchecked")
    List<Binding> bindingsNow = TestUtils.getPropertyValue(bus, "messageBus.bindings", List.class);
    assertEquals(1, bindingsNow.size());
    endpoint = bindingsNow.get(0).getEndpoint();
    container = verifyContainer(endpoint);

    assertEquals("foo.props.0", container.getQueueNames()[0]);

    try {
      bus.bindPubSubConsumer("dummy", null, properties);
      fail("Expected exception");
    }
    catch (IllegalArgumentException e) {
      assertThat(e.getMessage(), allOf(
          containsString("RabbitMessageBus does not support consumer properties: "),
          containsString("partitionIndex"),
          containsString("concurrency"),
          containsString(" for dummy.")));
    }
    try {
      bus.bindConsumer("queue:dummy", null, properties);
      fail("Expected exception");
    }
    catch (IllegalArgumentException e) {
      assertEquals("RabbitMessageBus does not support consumer property: partitionIndex for queue:dummy.",
          e.getMessage());
    }

    bus.unbindConsumers("props.0");
    assertEquals(0, bindingsNow.size());
  }
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.