Package net.jini.core.event

Examples of net.jini.core.event.EventRegistration


  lrm.renewFor(prepareLease(set.getRenewalSetLease()), Lease.FOREVER, null);

  // register a listener to receive renewal failure events
  logger.log(Level.FINE, "Registering listener to receive " +
        "RenewalFailureEvents.");
  EventRegistration reg = set.setRenewalFailureListener(rrl, null);
  reg = prepareRegistration(reg);

  // validate the registration (just for grins)
  if (rstUtil.isValidRenewFailEventReg(reg, set) == false) {
      String message = "Registration is invalid because:\n" +
View Full Code Here


  // register the listener to receive expiration events
  logger.log(Level.FINE, "Registering listener to receive " +
        "ExpirationWarngingEvents for set #1.");
  long minWarning = renewSetDur / 3;
  logger.log(Level.FINE, "minWarning = " + minWarning + " milliseconds");
  EventRegistration reg01 =
      set01.setExpirationWarningListener(rrl, minWarning, null);
  reg01 = prepareRegistration(reg01);

  // validate the registration (just for grins)
  if (rstUtil.isValidExpWarnEventReg(reg01, set01) == false) {
      String message = "Registration #1 is invalid because:\n" +
    rstUtil.getFailureReason();
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Registering listener to receive " +
        "ExpirationWarngingEvents for set #2.");
  logger.log(Level.FINE, "minWarning = " + minWarning + " milliseconds");
  EventRegistration reg02 =
      set02.setExpirationWarningListener(rrl, minWarning, null);
  reg02 = prepareRegistration(reg02);

  // validate the registration (just for grins)
  if (rstUtil.isValidExpWarnEventReg(reg02, set02) == false) {
      String message = "Registration #2 is invalid because:\n" +
    rstUtil.getFailureReason();
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Registering listener to receive " +
        "ExpirationWarngingEvents for set #3.");
  logger.log(Level.FINE, "minWarning = " + minWarning + " milliseconds");
  EventRegistration reg03 =
      set03.setExpirationWarningListener(rrl, minWarning, null);
  reg03 = prepareRegistration(reg03);

  // validate the registration (just for grins)
  if (rstUtil.isValidExpWarnEventReg(reg03, set03) == false) {
View Full Code Here

      logger.log(Level.FINE, "Creating remote listener #" + i);
      listener[i] = new RememberingRemoteListener(getExporter());
  }

  // register first listener for ExpirationWarningEvents
  EventRegistration evReg =
      renewalSet[0].setExpirationWarningListener(listener[0], 1,
                   null);
  evReg = prepareRegistration(evReg);
 
  /* ASSERTION #1
     The set lease and the registration lease are the same. */
  Lease lease01 = prepareLease(renewalSet[0].getRenewalSetLease());
  Lease lease02 = evReg.getLease();
  if (lease01.equals(lease02) == false) {
      String message = "The renewal set lease and the warning " +
           "event registration lease are not the same.";
      throw new TestException(message);
  }

  // register for RenewalFailureEvents
  evReg = renewalSet[0].setRenewalFailureListener(listener[0], null);
  evReg = prepareRegistration(evReg);
 
  /* ASSERTION #1 cont'd
     The set lease and the registration lease are the same. */
  Lease lease03 = evReg.getLease();
  if (lease01.equals(lease03) == false) {
      String message = "The renewal set lease and the failure" +
    "event registration lease are not the same.";
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Assertion #1 passed.");

  // register all twenty remote listeners
  for (int i = 0; i < NUMBER_OF_RENEWAL_SETS; ++i) {
      evReg =
    renewalSet[i].setExpirationWarningListener(listener[i], 1,
                 null);
      evReg = prepareRegistration(evReg);
      warnReg[i] = evReg;
      evReg =
    renewalSet[i].setRenewalFailureListener(listener[i], null);
      evReg = prepareRegistration(evReg);
      failReg[i] = evReg;
  }

  /* ASSERTION #2
     The registrations are unique and event ids are valid across
     all active registrations. */
  for (int i = 0; i < NUMBER_OF_RENEWAL_SETS; ++i) {

      if (rstUtil.isValidExpWarnEventReg(warnReg[i],
               renewalSet[i]) == false) {
    String message = "Warning event registration # " + i +
        " is invalid." + rstUtil.getFailureReason();
    throw new TestException(message);
      }

      if (rstUtil.isValidRenewFailEventReg(failReg[i],
           renewalSet[i]) == false) {
    String message = "Failure event registration # " + i +
        " is invalid." + rstUtil.getFailureReason();
    throw new TestException(message);
      }

      // create yet another RemoteEventListener
      Exporter exp = null;
      RememberingRemoteListener newListener =
    new RememberingRemoteListener(getExporter());
      evReg =
    renewalSet[0].setExpirationWarningListener(newListener,
                 1, null);
      evReg = prepareRegistration(evReg);

      /* ASSERTION #3
         When a listener is replaced the event registration has
         the same event id */
      if (! (evReg.getID() == warnReg[0].getID())) {
    String message = "When a warning registration is " +
        "replaced, the event id is not preserved.";
    throw new TestException(message);
      }
     
      // and just for grins check the lease as well
      if (evReg.getLease().equals(warnReg[0].getLease()) == false) {
    String message = "When a warning registration is " +
        "replaced, the lease is not preserved.";
    throw new TestException(message);
      }
     
      /* ASSERTION #3 (cont'd for renewal failure events)
         When a listener is replaced the event registration has
         the same event id */
      evReg =
    renewalSet[0].setRenewalFailureListener(newListener,
              null);
      evReg = prepareRegistration(evReg);
      if (! (evReg.getID() == failReg[0].getID())) {
    String message = "When a failure registration is " +
        "replaced, the event id is not preserved.";
    throw new TestException(message);
      }
     
      // and just for grins check the lease as well
      if (evReg.getLease().equals(failReg[0].getLease()) == false) {
    String message = "When a failure registration is " +
        "replaced, the lease is not preserved.";
    throw new TestException(message);
      }

View Full Code Here

  setText(false);
  cancelLease();
  if (lookup == null)
      return;
  try {
      EventRegistration reg =
    lookup.notify(tmpl,
            ServiceRegistrar.TRANSITION_MATCH_NOMATCH |
            ServiceRegistrar.TRANSITION_NOMATCH_MATCH |
            ServiceRegistrar.TRANSITION_MATCH_MATCH,
            listen.proxy, null, Lease.ANY);
      elease = (Lease) leasePreparer.prepareProxy(reg.getLease());
      leaseMgr.renewUntil(elease, Lease.ANY, lnotify);
      eventSource = reg.getSource();
      eventID = reg.getID();
      seqNo = reg.getSequenceNumber();
  } catch (Throwable t) {
      failure(t);
  }
    }
View Full Code Here

             new StorableObject[]{tmpl});

      templates.add(reg, tmpl);
  }

  return new EventRegistration(eventID, spaceProxy,
      leaseFactory.newLease(cookie, reg.getExpiration()),
      0);
    }
View Full Code Here

      for (int i=0; i<tmpls.length; i++) {
    templates.add(reg, tmpls[i]);
      }
  }

  return new EventRegistration(eventID, spaceProxy,
      leaseFactory.newLease(cookie, reg.getExpiration()),
      0);
    }
View Full Code Here

  if (listener == null)
      return null;
 
  final SetProxy proxy = newSetProxy();

  return new EventRegistration(
      warningEventType.getEventID(),
      proxy,
      proxy.getRenewalSetLease(),
      warningEventType.getLastSequenceNumber());
    }
View Full Code Here

  if (listener == null)
      return null;

  final SetProxy proxy = newSetProxy();

  return new EventRegistration(
      failureEventType.getEventID(),
      proxy,
      proxy.getRenewalSetLease(),
      failureEventType.getLastSequenceNumber());
    }
View Full Code Here

      synchronized (set) {
    ensureCurrent(set);

    try {
        final boolean haveBefore = set.haveWarningRegistration();
        final EventRegistration rslt =
      set.setExpirationWarningListener(
          listener, minWarning, handback);
        final boolean haveAfter = set.haveWarningRegistration();

        if (haveAfter || (haveBefore != haveAfter)) {
View Full Code Here

  warningListener = new WarningListener(failureFails?null:throwThis);
  failureListener = new BaseListener(failureFails?throwThis:null);

  MarshalledObject handback = new MarshalledObject(new Long(3));
  logger.log(Level.FINER, "setting expiration warning listener");
  EventRegistration reg =
      set.setExpirationWarningListener(warningListener,
    eventWaitFor - whenWarning, handback);
  logger.log(Level.FINER, "preparing returned registration");
        reg = prepareNormEventRegistration(reg);
  logger.log(Level.FINER, "completing initialization of listener");
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.