public String addItemListener(ItemListener<E> listener, boolean includeValue) {
   final EventService eventService = getNodeEngine().getEventService();
   final EventRegistration registration =
       eventService.registerListener(
           getServiceName(), name, new CollectionEventFilter(includeValue), listener);
   return registration.getId();
 }
示例#2
0
 private void sendClientEvent(ClientEndpoint endpoint) {
   if (endpoint.isFirstConnection()) {
     final EventService eventService = nodeEngine.getEventService();
     final Collection<EventRegistration> regs =
         eventService.getRegistrations(SERVICE_NAME, SERVICE_NAME);
     eventService.publishEvent(SERVICE_NAME, regs, endpoint, endpoint.getUuid().hashCode());
   }
 }
  @Test
  public void shouldUpdateEvent() {
    @SuppressWarnings("unchecked")
    Set<Student> newAttendees = new HashSet();
    newAttendees.add(pat);
    newAttendees.add(jim);

    EventForm updateParameter =
        new EventUpdateParameterBuilder()
            .id(1)
            .title("Spice Girls")
            .date(new Date(12, 12, 2011))
            .time("10:10")
            .description("Spice Girls 4 Lyf")
            .venue("P-81")
            .coordinator("Joel Tellez")
            .notes("Sick as party")
            .attendees(newAttendees)
            .build();

    Event newEvent =
        new EventBuilder()
            .title("Spice Girls")
            .attendees(newAttendees)
            .date(new Date(12, 12, 2011))
            .description("Spice Girls 4 Lyf")
            .venue("P-81")
            .coordinator("Joel Tellez")
            .notes("Sick as party")
            .build();

    when(eventRepository.load(1)).thenReturn(sportsEvent);
    when(service.update(updateParameter)).thenReturn(newEvent);
    Event updatedEvent = service.update(updateParameter);
    assertEquals(newEvent, updatedEvent);
  }
 public boolean removeItemListener(String registrationId) {
   EventService eventService = getNodeEngine().getEventService();
   return eventService.deregisterListener(getServiceName(), name, registrationId);
 }
 @Test
 public void shouldListAllEvents() {
   when(eventRepository.list()).thenReturn(events);
   assertThat(service.list(), hasItems(sportsEvent, annualEvent));
 }