Examples of EventBus


Examples of org.axonframework.eventhandling.EventBus

                new DefaultClusterSelector(standardCluster)
        ));

        // create the event bus and subscribe two listeners
        // notice how the registration process itself is unaware of clustering
        EventBus eventBus = new ClusteringEventBus(clusterSelector);
        eventBus.subscribe(new AnnotationEventListenerAdapter(new ThreadPrintingEventListener()));
        eventBus.subscribe(new AnnotationEventListenerAdapter(new AnotherThreadPrintingEventListener()));

        // publish an event
        eventBus.publish(asEventMessage(new ToDoItemCompletedEvent("todo1")));

        // we need to shutdown the executor we have created to prevent the JVM from hanging on shutdown
        // this also wait until all scheduled tasks for that thread have been executed
        executor.shutdown();
    }

Examples of org.eurekastreams.web.client.events.EventBus

     * {@inheritDoc}
     */
    @Override
    public void show()
    {
        final EventBus eventBus = Session.getInstance().getEventBus();
        if (groups == null)
        {
            eventBus.addObserver(GotPersonJoinedGroupsResponseEvent.class,
                    new Observer<GotPersonJoinedGroupsResponseEvent>()
                    {
                        public void update(final GotPersonJoinedGroupsResponseEvent event)
                        {
                            eventBus.removeObserver(event, this);

                            groups = event.getResponse();
                            if (subscribedGroupIds != null)
                            {
                                populate();
                            }
                        }
                    });
            PersonJoinedGroupsModel.getInstance().fetch(
                    new GetFollowersFollowingRequest(EntityType.GROUP, Session.getInstance().getCurrentPerson()
                            .getAccountId(), 0, Integer.MAX_VALUE), true);
        }
        if (subscribedGroupIds == null)
        {
            eventBus.addObserver(GotGroupActivitySubscriptionsResponseEvent.class,
                    new Observer<GotGroupActivitySubscriptionsResponseEvent>()
                    {
                        public void update(final GotGroupActivitySubscriptionsResponseEvent event)
                        {
                            eventBus.removeObserver(event, this);

                            subscribedGroupIds = event.getResponse();
                            if (groups != null)
                            {
                                populate();

Examples of org.metawb.lib.EventBus

    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
        eb = new EventBus();
        daf = new DefaultAspectFinder();
        daf.attachEventBus(eb);
        List<Class<?>> l = new ArrayList<Class<?>>(1);
        l.add(AspectFinderEvent.class);
        eb.addReceiver(q, listener, l);

Examples of org.olat.core.util.event.EventBus

  private String serviceName;
 
  public SingleService( String serviceName) {
    this.serviceName = serviceName;
    final OLATResourceable ores = OresHelper.createOLATResourceableType(SingleService.class.getCanonicalName());
    EventBus eventBus = CoordinatorManager.getCoordinator().getEventBus();
    // first fire event, second register as listener because we want not to receive our 'Started event'
    eventBus.fireEventToListenersOf(new ServiceStartedEvent(serviceName), ores );
    log.debug("fireEventToListenersOf serviceName=" + serviceName + "  ores=" + ores.getResourceableTypeName() + ":" + ores.getResourceableId());
    eventBus.registerFor(this, null, ores);
  }

Examples of org.olat.core.util.event.EventBus

   * @param locale
   */
  void applyPublishSet(Identity identity, Locale locale) {
    // the active runstructure and the new created runstructure
    Structure existingCourseRun = course.getRunStructure();
    EventBus orec = CoordinatorManager.getCoordinator().getEventBus();
    /*
     * use book keeping lists for publish event
     */
    Set<String> deletedCourseNodeIds = new HashSet<String>();
    if (editorModelDeletedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        deletedCourseNodeIds.add(cn.getIdent());
      }
    }
    Set<String> insertedCourseNodeIds = new HashSet<String>();
    if (editorModelInsertedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        insertedCourseNodeIds.add(cn.getIdent());
      }
    }
    Set<String> modifiedCourseNodeIds = new HashSet<String>();
    if (editorModelModifiedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        modifiedCourseNodeIds.add(cn.getIdent());
      }
    }
    /*
     * broadcast PRE PUBLISH event that a publish will take place
     */
    PublishEvent beforePublish = new PublishEvent(editorTreeModel.getLatestPublishTimestamp(), course, PublishEvent.EVENT_IDENTIFIER);
    beforePublish.setDeletedCourseNodeIds(deletedCourseNodeIds);
    beforePublish.setInsertedCourseNodeIds(insertedCourseNodeIds);
    beforePublish.setModifiedCourseNodeIds(modifiedCourseNodeIds);
    beforePublish.setState(PublishEvent.PRE_PUBLISH);
    // old course structure accessible
    orec.fireEventToListenersOf(beforePublish, course);
    /*
     * TODO:pb: disucss with fj: listeners could add information to
     * beforePublish event such as a right to veto or add identities who is
     * currently in the course, thus stopping the publishing author from
     * publishing! i.e. if people are in a test or something like this.... we
     * could the ask here beforePublish.accepted() and proceed only in this
     * case.
     */
    //
    /*
     * remove new nodes which were marked as delete and deletion is published.
     */
    File exportDirectory = CourseFactory.getOrCreateDataExportDirectory(identity, course.getCourseTitle());
    UserManager um = UserManager.getInstance();
    String charset = um.getUserCharset(identity);
    if (editorModelDeletedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        // moved node with a parent deleted (deletion published) -> oldCn ==
        // null
        if (oldCn != null) {
          if (!(cn.getIdent().equals(oldCn.getIdent()))) { throw new AssertException("deleted cn.getIdent != oldCn.getIdent"); }
        }
        cetn.removeFromParent();
        if (!cetn.isNewnode()) {
          // only clean up and archive of nodes which were already in run
          // save data, remove references
          deleteRefs(oldCn);
          oldCn.archiveNodeData(locale, course, exportDirectory, charset);
          // 2) delete all user data
          oldCn.cleanupOnDelete(course);
        }
      }
    }
    /*
     * mark modified ones as no longer dirty
     */
    if (editorModelModifiedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        // moved node with a parent deleted (deletion published) -> oldCn ==
        // null
        if (oldCn != null) {
          if (!(cn.getIdent().equals(oldCn.getIdent()))) { throw new AssertException("deleted cn.getIdent != oldCn.getIdent"); }
        }
        cetn.setDirty(false);
        //
        updateRefs(cn, oldCn);
      }
    }
    /*
     * mark newly published ones is no longer new and dirty
     */
    if (editorModelInsertedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        if (oldCn != null) { throw new AssertException("new node has an oldCN??"); }
        cetn.setDirty(false);
        cetn.setNewnode(false);
        //
        updateRefs(cn, null);
      }
    }
    /*
     * saving
     */
    long pubtimestamp = System.currentTimeMillis();
    editorTreeModel.setLatestPublishTimestamp(pubtimestamp);
    // set the new runstructure and save it.
    existingCourseRun.setRootNode(resultingCourseRun.getRootNode());
    CourseFactory.saveCourse(course.getResourceableId());
   
    /*
     * broadcast event
     */
    PublishEvent publishEvent = new PublishEvent(pubtimestamp, course, PublishEvent.EVENT_IDENTIFIER);
    publishEvent.setDeletedCourseNodeIds(deletedCourseNodeIds);
    publishEvent.setInsertedCourseNodeIds(insertedCourseNodeIds);
    publishEvent.setModifiedCourseNodeIds(modifiedCourseNodeIds);
    // new course structure accessible
    // CourseFactory is one listener, which removes the course from the
    // cache.
    orec.fireEventToListenersOf(publishEvent, course);
    /*
     * END NEW STYLE PUBLISH
     */

  }
 

Examples of org.olat.core.util.event.EventBus

            // delete really the efficiencies of the users.
            RepositoryEntry courseRepoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
            EfficiencyStatementManager.getInstance().deleteEfficiencyStatementsFromCourse(courseRepoEntry.getKey());           
          }
          //inform everybody else   
          EventBus eventBus = CoordinatorManager.getCoordinator().getEventBus();
          CourseConfigEvent courseConfigEvent = new CourseConfigEvent(CourseConfigEvent.EFFICIENCY_STATEMENT_TYPE, course.getResourceableId());
          eventBus.fireEventToListenersOf(courseConfigEvent, course);
          ThreadLocalUserActivityLogger.log(ceffC.getLoggingAction(), getClass());
        }
        // CourseCalendarConfigController
        if(changedCourseConfig.isCalendarEnabled()!= initialCourseConfig.isCalendarEnabled() && calCfgCtr.getLoggingAction()!=null) {
          ThreadLocalUserActivityLogger.log(calCfgCtr.getLoggingAction(), getClass());
          // notify calendar components to refresh their calendars
          CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new KalendarModifiedEvent(), OresHelper.lookupType(CalendarManager.class));
        }
        // CourseConfigGlossaryController
        if((changedCourseConfig.getGlossarySoftKey()==null && initialCourseConfig.getGlossarySoftKey()!=null)
            || (changedCourseConfig.getGlossarySoftKey()!=null && initialCourseConfig.getGlossarySoftKey()==null)
            && cglosCtr.getLoggingAction()!=null) {
         
          final String glossarySoftKey = changedCourseConfig.getGlossarySoftKey();
          LoggingResourceable lri = null;
          if (glossarySoftKey!=null) {
            lri = LoggingResourceable.wrapNonOlatResource(StringResourceableType.glossarySoftKey, glossarySoftKey, glossarySoftKey);
          }
          ThreadLocalUserActivityLogger.log(cglosCtr.getLoggingAction(), getClass(), lri);
          if(changedCourseConfig.getGlossarySoftKey()==null) {
            // update references
            ReferenceManager refM = ReferenceManager.getInstance();
            List repoRefs = refM.getReferences(course);
            for (Iterator iter = repoRefs.iterator(); iter.hasNext();) {
              ReferenceImpl ref = (ReferenceImpl) iter.next();
              if (ref.getUserdata().equals(GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER)) {
                refM.delete(ref);
                continue;
              }
            }
          } else if(changedCourseConfig.getGlossarySoftKey()!=null) {
            // update references
            RepositoryManager rm = RepositoryManager.getInstance();
            RepositoryEntry repoEntry = rm.lookupRepositoryEntryBySoftkey(changedCourseConfig.getGlossarySoftKey(), false);
            ReferenceManager.getInstance().addReference(course, repoEntry.getOlatResource(), GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER);
          }
        }
        //course config transaction fihished
        initialCourseConfig = course.getCourseEnvironment().getCourseConfig().clone();       
       
        //fire CourseConfigEvent for this course channel
        EventBus eventBus = CoordinatorManager.getCoordinator().getEventBus();
        CourseConfigEvent courseConfigEvent = new CourseConfigEvent(CourseConfigEvent.CALENDAR_TYPE, course.getResourceableId());
        eventBus.fireEventToListenersOf(courseConfigEvent, course);
       
        this.fireEvent(ureq, Event.DONE_EVENT);
      } else if(!DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isYesEvent(event)) {       
        this.fireEvent(ureq, Event.DONE_EVENT);
      }

Examples of org.olat.core.util.event.EventBus

        InfoMessageManager.infoMessage = message;
        pm.updateProperty(p);
      }
     
    });//end syncerCallback
    EventBus eb = CoordinatorManager.getCoordinator().getEventBus();
    MultiUserEvent mue = new MultiUserEvent(message);
    eb.fireEventToListenersOf(mue, INFO_MESSAGE_ORES);
  }

Examples of org.olat.core.util.event.EventBus

   */
  public void testSendReceive() {
    // enable test only if we have the cluster configuration enabled.
    // this test requires that an JMS Provider is running
    // (see file serviceconfig/org/olat/core/_spring/coreextconfig.xml)
    EventBus bus = CoordinatorManager.getCoordinator().getEventBus();
    if (bus instanceof ClusterEventBus) {
      // send and wait some time until a message should arrive at the latest.
      ores1 = OresHelper.createOLATResourceableInstance("hellojms", new Long(123));
     
      bus.registerFor(new GenericEventListener(){

        public void event(Event event) {
          // TODO Auto-generated method stub
          System.out.println("event received!"+event);
          JMSTest.this.event = event;
        }}, id1, ores1);
     
     
      MultiUserEvent mue = new MultiUserEvent("amuecommand");
      bus.fireEventToListenersOf(mue, ores1);
      try {
        Thread.sleep(2000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

Examples of org.rstudio.studio.client.application.events.EventBus

   // show the satellite window (subclasses shouldn't override this method,
   // rather they should override the abstract onInitialize method)
   public void show(JavaScriptObject params)
   {
      // react to font size changes
      EventBus eventBus = pEventBus_.get();
      eventBus.addHandler(ChangeFontSizeEvent.TYPE, new ChangeFontSizeHandler()
      {
         public void onChangeFontSize(ChangeFontSizeEvent event)
         {
            FontSizer.setNormalFontSize(Document.get(), event.getFontSize());
         }

Examples of org.sonatype.sisu.goodies.eventbus.EventBus

  @Mock
  private CryptoHelper crypto;

  @Before
  public void setUp() throws Exception {
    EventBus eventBus = mock(EventBus.class);
    condition = new CipherRequiredCondition(eventBus, crypto, FAKE_TRANSFORMATION);
  }
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.