Package net.jini.core.event

Examples of net.jini.core.event.EventRegistration


  RemoteEventListener mbRel = getMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION);

  // Create our target listener
  TestListener listener = TestUtils.createListener(manager);
  int evtCnt = 0;

  logger.log(Level.INFO, "Generating an event" + listener);
  myGen.generateEvent(evtReg.getID(), 3);

  logger.log(Level.INFO, "Enabling delivery to our REL" + listener);
  mr.enableDelivery(listener);

  logger.log(Level.INFO, "Wating for event delivery");
        evtCnt++;
        waitForEvents(listener, evtCnt, MAX_WAIT);
  logger.log(Level.INFO, "Verifying event delivery");
  assertCount(listener, evtCnt);

  logger.log(Level.INFO, "Disabling delivery to our REL");
  mr.enableDelivery(null);

  shutdown(0);

  logger.log(Level.INFO, "Generating an event" + listener);
  myGen.generateEvent(evtReg.getID(), 3);

  logger.log(Level.INFO, "Wating for event delivery");
        Thread.sleep(MAX_WAIT);
  logger.log(Level.INFO, "Verifying no events were delivered");
  assertCount(listener, evtCnt);
View Full Code Here


  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  logger.log(Level.FINEST,
      "Test generator class tree"
      + getClassLoaderTree(myGen.getClass().getClassLoader()));
  EventRegistration evtReg =
      myGen.register(EVENT_ID,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  // Create another event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen2 = TestUtils.createGenerator(manager);
  logger.log(Level.FINEST,
      "Test generator class tree"
      + getClassLoaderTree(myGen2.getClass().getClassLoader()));
  EventRegistration evtReg2 =
      myGen2.register(EVENT_ID2,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION1)// Lease duration
  Lease tgl2 = evtReg2.getLease();
  checkLease(tgl2, DURATION1);
       
        int expectedEventCount = 0;
  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  ArrayList generatedEvents = new ArrayList();
        RemoteEvent[] genEvents = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
            genEvents[i] = myGen.generateEvent(evtReg.getID(), 3);
      generatedEvents.add(genEvents[i]);
  }
        expectedEventCount += NUM_EVENTS;
       
  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  for (i = 0; i < NUM_EVENTS; i++) {
      generatedEvents.add(myGen2.generateEvent(evtReg2.getID(), 3));
  }
  logger.log(Level.INFO, "Sent events {0}", generatedEvents);       
        expectedEventCount += NUM_EVENTS;

        // Get events and verify
  logger.log(Level.INFO, "Getting events.");
        RemoteEventIterator rei = mr.getRemoteEvents();
        ArrayList receivedEvents = new ArrayList();
        RemoteEvent rei_event;
        while ((rei_event = rei.next(MAX_WAIT)) != null) {
            receivedEvents.add(rei_event);
        }
  logger.log(Level.INFO, "Received events {0}", receivedEvents);
       
   logger.log(Level.INFO, "Verifying received events");
        assertEvents(generatedEvents, receivedEvents);

        if (receivedEvents.size() != expectedEventCount) {
            throw new TestException("Received " + receivedEvents.size()
                + " events, but expected " + expectedEventCount);
        }
       
        // Set myGen events as unknown events
   logger.log(Level.INFO, "Calling addUnknownEvents");
        mr.addUnknownEvents(java.util.Arrays.asList(genEvents));
       
        // Send some myGen events -- should be rejected
        int exceptionCount = 0;
   logger.log(Level.INFO, "Generating some unknown events");
  for (i = 0; i < NUM_EVENTS; i++) {
            try {
                genEvents[i] = myGen.generateEvent(evtReg.getID(), 3);
            } catch (UnknownEventException uue) {
                exceptionCount++;
                logger.log(Level.INFO, "Caught expected exception -- ignoring",
                    uue);

            }
  }
        if (exceptionCount != NUM_EVENTS) {
            throw new TestException("Unexpected number of exceptions "
                + exceptionCount);
        }
       
        //Verify that events weren't delivered
        RemoteEvent re = null;
        if ((re = rei.next(MAX_WAIT)) != null) {
            throw new TestException("Unexpected event received " + re);
        }
    logger.log(Level.INFO, "Did not receive any unknown events");

  // Generate some myGen2 events -- should be accepted
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  for (i = 0; i < NUM_EVENTS; i++) {
      generatedEvents.add(myGen2.generateEvent(evtReg2.getID(), 3));
  }
       expectedEventCount += NUM_EVENTS;
      
       logger.log(Level.INFO, "Sent events {0}", generatedEvents);               
       
View Full Code Here

                    ServiceTemplate tmpl,
                    RemoteEventListener listenerProxy,
                    long durationthrows RemoteException
    {
        /* Register with the event mechanism of the given lookup service */
        EventRegistration e = null;
        int transition = (   ServiceRegistrar.TRANSITION_NOMATCH_MATCH
                           | ServiceRegistrar.TRANSITION_MATCH_NOMATCH
                           | ServiceRegistrar.TRANSITION_MATCH_MATCH   );
        e = proxy.notify(tmpl, transition, listenerProxy, null, duration);
        /* Proxy preparation -
         *
         * Prepare the proxy to the lease on the event registration just
         * returned. Because lease management (renewal and cancellation)
         * involves remote calls, lease proxies should be prepared before
         * management of the associated leases begins. This allows one to
         * verify trust in the lease, and ensures that the appropriate
         * constraints are attached to the lease.
         */
        Lease eventLease = e.getLease();
        eventLease = (Lease)eventLeasePreparer.prepareProxy(eventLease);
        logger.log(Level.FINEST, "ServiceDiscoveryManager - proxy to event "
                   +"registration lease prepared: {0}", eventLease);
        /* Management the lease on the event registration */
        leaseRenewalMgr.renewFor(eventLease,
                                 duration,
                                 new LeaseListenerImpl(proxy));
        /* Wrap source, id, event sequence & lease in EventReg, and return. */
        return ( new EventReg(e.getSource(),
                              e.getID(),
                              e.getSequenceNumber(),
                              eventLease) );
    }//end registerListener
View Full Code Here

  throws RemoteException
   
  concurrentObj.writeLock();
  try {
      ready.check();
      EventRegistration reg = notifyDo(
    tmpl, transitions, listener, handback, leaseDuration);
      if (logger.isLoggable(Level.FINE)) {
    logger.log(
        Level.FINE,
        "registered event listener {0} as {1}",
        new Object[]{
      listener,
      ((ReferentUuid) reg.getLease()).getReferentUuid()
        });
      }
      return reg;
  } finally {
      concurrentObj.writeUnlock();
View Full Code Here

  /* see if the expire thread needs to wake up earlier */
  if (reg.leaseExpiration < minEventExpiration) {
      minEventExpiration = reg.leaseExpiration;
      concurrentObj.waiterNotify(eventNotifier);
  }
  return new EventRegistration(
      reg.eventID,
      proxy,
      EventLease.getInstance(
    myRef,
    myServiceID,
View Full Code Here

        JavaSpace05 space05 = (JavaSpace05) space;
        reset();

        TestEventListener05 testEventListener0 = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        EventRegistration er0 = space05.registerForAvailabilityEvent(templates,
                null, true, testEventListener0, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        final long gotER0Timestamp = System.currentTimeMillis();
        List notifications = testEventListener0.getNotifications();
        expectedResult.add(sampleEntry1)// this entry is to trigger the event
        space.write(sampleEntry1, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing one entry to trigger an event");
        registrations.add(er0);
        reset();

        TestEventListener05 testEventListener1 = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        templates.add((SimpleEntry) sampleEntry2.clone());
        EventRegistration er1 = space05.registerForAvailabilityEvent(templates,
                null, true, testEventListener1, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener1.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry2, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events");
        registrations.add(er1);
        reset();

        TestEventListener05 testEventListener2 = new TestEventListener05();
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er2 = space05.registerForAvailabilityEvent(templates,
                null, true, testEventListener2, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener2.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, null, leaseForeverTime);
        space.write(sampleEntry3, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                "Writing 2 entries to trigger 2 events (with single template)");
        registrations.add(er2);
        reset();

        TestEventListener05 testEventListener3 = new TestEventListener05();
        templates.add(new SimpleEntry(null, null));
        EventRegistration er3 = space05.registerForAvailabilityEvent(templates,
                null, true, testEventListener3, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener3.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry2, null, leaseForeverTime);
        space.write(sampleEntry3, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                "Writing 3 entries to trigger 3 events (with single template)");
        registrations.add(er3);
        reset();

        TestEventListener05 testEventListener4 = new TestEventListener05();
        templates.add(null);
        EventRegistration er4 = space05.registerForAvailabilityEvent(templates,
                null, true, testEventListener4, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener4.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry2, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                "Writing 2 entries to trigger 2 events (with null template)");
        registrations.add(er4);
        reset();

        TestEventListener05 testEventListener5 = new TestEventListener05();
        templates.add(null);
        EventRegistration er5 = space05.registerForAvailabilityEvent(templates,
                null, true, testEventListener5, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener5.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry1);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry1, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 duplicate entries to trigger 2 events "
                           + "(with null template)");

        /*
         * not adding this as a registration for such set
         * of templates (null) already exists
         */
        //registrations.add(er5);
        reset();

        TestEventListener05 testEventListener6 = new TestEventListener05();
        templates.add(null);
        templates.add(new SimpleEntry(null, null));
        templates.add((SimpleEntry) sampleEntry2.clone());
        templates.add((SimpleEntry) sampleEntry3.clone());
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er6 = space05.registerForAvailabilityEvent(templates,
                null, true, testEventListener6, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener6.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, null, leaseForeverTime);
        space.write(sampleEntry3, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events " +
                           "(with multiple matching templates)");
        registrations.add(er6);
        reset();

        /*
         * Section below is the same as above but
         * with visibilityOnly flag set to false.
         * "a" stands for availability.
         */
        TestEventListener05 testEventListener0a = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        EventRegistration er0a = space05.registerForAvailabilityEvent(
                templates, null, false,
                testEventListener0a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener0a.getNotifications();
        expectedResult.add(sampleEntry1)// this entry is to trigger the event
        space.write(sampleEntry1, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing one entry to trigger an event");
        registrations.add(er0a);
        reset();

        TestEventListener05 testEventListener1a = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        templates.add((SimpleEntry) sampleEntry2.clone());
        EventRegistration er1a = space05.registerForAvailabilityEvent(
                templates, null, false,
                testEventListener1a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener1a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry2, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events");
        registrations.add(er1a);
        reset();

        TestEventListener05 testEventListener2a = new TestEventListener05();
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er2a = space05.registerForAvailabilityEvent(
                templates, null, false,
                testEventListener2a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener2a.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, null, leaseForeverTime);
        space.write(sampleEntry3, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events "
                           + "(with single template)");
        registrations.add(er2a);
        reset();

        TestEventListener05 testEventListener3a = new TestEventListener05();
        templates.add(new SimpleEntry(null, null));
        EventRegistration er3a = space05.registerForAvailabilityEvent(
                templates, null, false,
                testEventListener3a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener3a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry2, null, leaseForeverTime);
        space.write(sampleEntry3, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 3 entries to trigger 3 events "
                           + "(with single template)");
        registrations.add(er3a);
        reset();

        TestEventListener05 testEventListener4a = new TestEventListener05();
        templates.add(null);
        EventRegistration er4a = space05.registerForAvailabilityEvent(
                templates, null, false,
                testEventListener4a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener4a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry2, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events "
                           + "(with null template)");
        registrations.add(er4a);
        reset();

        TestEventListener05 testEventListener5a = new TestEventListener05();
        templates.add(null);
        EventRegistration er5a = space05.registerForAvailabilityEvent(
                templates, null, false,
                testEventListener5a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener5a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry1);
        space.write(sampleEntry1, null, leaseForeverTime);
        space.write(sampleEntry1, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 duplicate entries to trigger 2 events "
                           + "(with null template)");

        /*
         * not adding this as a registration for such set
         * of templates (null) already exists
         */
        //registrations.add(er5a);
        reset();

        TestEventListener05 testEventListener6a = new TestEventListener05();
        templates.add(null);
        templates.add(new SimpleEntry(null, null));
        templates.add((SimpleEntry) sampleEntry2.clone());
        templates.add((SimpleEntry) sampleEntry3.clone());
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er6a = space05.registerForAvailabilityEvent(
                templates, null, false,
                testEventListener6a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener6a.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, null, leaseForeverTime);
        space.write(sampleEntry3, null, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events " +
                           "(with multiple matching templates)");
        registrations.add(er6a);
        reset();

        ArrayList eventIDs = new ArrayList();
        Iterator registrationsItr = registrations.iterator();
        while (registrationsItr.hasNext()) {
            EventRegistration er = (EventRegistration) registrationsItr.next();
            if (er == null) {
                throw new TestException("Event registration is null");
            }
            Long id = new Long(er.getID());
            if (eventIDs.contains(id)) {
                throw new TestException("Event registrations have "
                                        + "identical IDs");
            }
            eventIDs.add(id);
View Full Code Here

  RemoteEventListener mbRel = getPullMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,       // Event ID to use
         null,      // handback
         mbRel,          // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  // Create "listener" to collect events for this test
  TestPullListener tpl = TestUtils.createPullListener(manager);
  int eventCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
  };

  logger.log(Level.INFO, "Wating for event delivery");
  eventCount = NUM_EVENTS;
        getCollectedRemoteEvents(tpl, mr, eventCount, MAX_WAIT);
  logger.log(Level.INFO, "Verifying event delivery count of " + eventCount);
  assertCount(tpl, eventCount);
  logger.log(Level.INFO, "Verifying events ");
  assertEvents(tpl, events);
  if(tpl.verifyEvents(bogus)) {
      throw new TestException("Successfully verified bogus events");
  }

  logger.log(Level.INFO, "Cancelling registration lease");
  mrl.cancel();

  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " more events");
  try {
      for (i = 0; i < NUM_EVENTS; i++) {
          events[i] = myGen.generateEvent(evtReg.getID(), 3);
      }
  } catch (ServerException se) {
      if (se.detail != null &&
          se.detail instanceof NoSuchObjectException) {
    // can safely ignore this since we expect
View Full Code Here

      concurrentObj.waiterNotify(leaseExpireThreadSyncObj);
  }
        FiddlerLease regLease =
                   FiddlerLease.createLease
                           (innerProxy, proxyID, regID, leaseID, expiration);
        EventRegistration eventReg = new EventRegistration( regInfo.eventID,
                                                            outerProxy,
                                                            regLease,
                                                            regInfo.seqNum );
        logInfoGroups();
        logInfoLocators();
View Full Code Here

  RemoteEventListener mbRel = getPullMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,       // Event ID to use
         null,      // handback
         mbRel,          // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  // Create "listener" to collect events for this test
  TestPullListener tpl = TestUtils.createPullListener(manager);
  int eventCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
  };

  logger.log(Level.INFO, "Wating for event delivery");
  eventCount = NUM_EVENTS;
        getCollectedRemoteEvents(tpl, mr, eventCount, MAX_WAIT);
  logger.log(Level.INFO, "Verifying event delivery count of " + eventCount);
  assertCount(tpl, eventCount);
  logger.log(Level.INFO, "Verifying events ");
  assertEvents(tpl, events);
  if(tpl.verifyEvents(bogus)) {
      throw new TestException("Successfully verified bogus events");
  }

        // Get iterator handle before cancelling associated reg
        RemoteEventIterator rei = mr.getRemoteEvents();
       
  logger.log(Level.INFO, "Cancelling registration lease");
  mrl.cancel();

  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " more events");
  try {
      for (i = 0; i < NUM_EVENTS; i++) {
          events[i] = myGen.generateEvent(evtReg.getID(), 3);
      }
  } catch (ServerException se) {
      if (se.detail != null &&
          se.detail instanceof NoSuchObjectException) {
    // can safely ignore this since we expect
View Full Code Here

  RemoteEventListener mbRel = getPullMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,       // Event ID to use
         null,      // handback
         mbRel,          // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

        // Get iterator handle and exercise it
        RemoteEventIterator rei = mr.getRemoteEvents();
        rei.next(MAX_WAIT); // ignore result
       
  // Generate some more events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }
       
        // Get new iterator handle and exercise it
        RemoteEventIterator rei_2 = mr.getRemoteEvents();
        rei_2.next(MAX_WAIT); // ignore result
View Full Code Here

TOP

Related Classes of net.jini.core.event.EventRegistration

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.