Package org.jboss.errai.bus.client.framework

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


  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

            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

        _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

        // 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

  @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

  }

  public void onClick(ClickEvent event) {
    String initSubject = tool.getId() + ":init";

    final MessageBus bus = ErraiBus.get();

    if (!bus.isSubscribed(initSubject)) {
      bus.subscribe(initSubject, new MessageCallback() {
        public void callback(final Message message) {

          try {

            tool.provideWidget(new ProvisioningCallback()
View Full Code Here

  }

  @SuppressWarnings({"UnusedDeclaration", "CdiInjectionPointsInspection"})
  public void afterBeanDiscovery(@Observes final AfterBeanDiscovery abd, final BeanManager bm) {
    final ErraiService service = ErraiServiceSingleton.getService();
    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

TOP

Related Classes of org.jboss.errai.bus.client.framework.MessageBus

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.