Package net.jini.core.event

Examples of net.jini.core.event.EventRegistration


        evntLeaseDurMS = 5*QATestUtils.N_MS_PER_SEC;
        srvcItems = super.createServiceItems(TEST_SRVC_CLASSES);
  srvcRegs = super.registerAll();
  proxy = super.getProxy();
  emptyTmpl = new ServiceTemplate(null,null,null);
  EventRegistration evntReg
      = proxy.notify(emptyTmpl,
         ServiceRegistrar.TRANSITION_NOMATCH_MATCH |
         ServiceRegistrar.TRANSITION_MATCH_NOMATCH |
         ServiceRegistrar.TRANSITION_MATCH_MATCH,
         listener, null, evntLeaseDurMS);
View Full Code Here


  tmpl     = new ServiceTemplate[srvcRegs.length];
  evntRegs = new EventRegistration[srvcRegs.length];
        for (i=0;i<srvcRegs.length;i++) {
            curSrvcID = srvcRegs[i].getServiceID();
            tmpl[i] = new ServiceTemplate(curSrvcID,null,null);
      EventRegistration er;
      er = proxy.notify(tmpl[i], regTransitions, listener,
            new MarshalledObject(curSrvcID),
            Long.MAX_VALUE);
      evntRegs[i] = prepareEventRegistration(er);
  }
View Full Code Here

      srvcRegs[i].addAttributes(addAttrs[j]);
  }
  evntRegs = new EventRegistration[srvcRegs.length];
        for (i=0;i<srvcRegs.length;i++) {
            curSrvcID = srvcRegs[i].getServiceID();
      EventRegistration er;
      er = proxy.notify(srvcIDTmpl[i],regTransitions,listener,
            new MarshalledObject(curSrvcID),
            Long.MAX_VALUE);
      evntRegs[i] = prepareEventRegistration(er);
  }
View Full Code Here

  srvcIDTmpl = new ServiceTemplate[srvcRegs.length];
  evntRegs = new EventRegistration[srvcRegs.length];
        for (i=0;i<srvcRegs.length;i++) {
            curSrvcID = srvcRegs[i].getServiceID();
            srvcIDTmpl[i] = new ServiceTemplate(curSrvcID,null,null);
      EventRegistration er;
      er = proxy.notify(srvcIDTmpl[i], regTransitions, listener,
            new MarshalledObject(curSrvcID),
            Long.MAX_VALUE);
      evntRegs[i] = prepareEventRegistration(er);
  }
View Full Code Here

      srvcRegs[i].addAttributes(addAttrs[j]);
  }
  evntRegs = new EventRegistration[srvcRegs.length];
        for (i=0;i<srvcRegs.length;i++) {
            curSrvcID = srvcRegs[i].getServiceID();
      EventRegistration er;
      er = proxy.notify(srvcIDTmpl[i],regTransitions,listener,
            new MarshalledObject(curSrvcID),
            Long.MAX_VALUE);
      evntRegs[i] = prepareEventRegistration(er);
  }
View Full Code Here

  // create a handback object
  MarshalledObject handback = new MarshalledObject(new Integer(99));

  // register listener to receive events
  EventRegistration evReg =
      set.setRenewalFailureListener(rrl, handback);
  evReg = prepareRegistration(evReg);

  // create a lease that will fail to renew
  logger.log(Level.FINE, "Creating the lease to be managed.");
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

  // create a handback object
  MarshalledObject handback = new MarshalledObject(new Integer(99));

  // register listener to receive events
  EventRegistration evReg =
      set.setExpirationWarningListener(rrl, minWarning, handback);
  evReg = prepareRegistration(evReg);

  if (rstUtil.isValidExpWarnEventReg(evReg, set) == false) {
      String message = "Event Registration is invalid.";
View Full Code Here

     * <P>Notes:<BR>For more information see the JavaSpaces specification
     * sections 2.6, 2.7.</P>
     */
    public void run() throws Exception {
        SnapshotNotifyCounter[] ncs = new SnapshotNotifyCounter[12];
        EventRegistration er;
        long[] leaseMatrix = new long[] {
            -199, -5000, -13999, Long.MIN_VALUE, -2, Long.MIN_VALUE, -345,
            -8999, -15000, -16000000, Long.MIN_VALUE, -3 };
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
        SimpleEntry template;
        Transaction txn;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException(
                    "Space is not empty in the beginning.");
        }

        // create the non null transaction
        txn = getTransaction();

        /*
         * init 3 RemoteEvent counters for snapshot for each
         * of sample entries
         */
        ncs[0] = new SnapshotNotifyCounter(sampleEntry1, leaseMatrix[0],
                space);
        ncs[1] = new SnapshotNotifyCounter(sampleEntry2, leaseMatrix[1],
                space);
        ncs[2] = new SnapshotNotifyCounter(sampleEntry3, leaseMatrix[2],
                space);

        // init 5 counters with snapshots of wrong templates
        template = new SimpleEntry("TestEntry #3", 1);
        ncs[3] = new SnapshotNotifyCounter(template, leaseMatrix[3], space);

        // 2-nd wrong template
        template = new SimpleEntry("TestEntry #1", 3);
        ncs[4] = new SnapshotNotifyCounter(template, leaseMatrix[4], space);

        // 3-rd wrong template
        template = new SimpleEntry("TestEntry #3", 3);
        ncs[5] = new SnapshotNotifyCounter(template, leaseMatrix[5], space);

        // 4-th wrong template
        template = new SimpleEntry(null, 3);
        ncs[6] = new SnapshotNotifyCounter(template, leaseMatrix[6], space);

        // 5-th wrong template
        template = new SimpleEntry("TestEntry #3", null);
        ncs[7] = new SnapshotNotifyCounter(template, leaseMatrix[7], space);

        // init counter with snapshot of null entry as a template
        ncs[8] = new SnapshotNotifyCounter(null, leaseMatrix[8], space);

        /*
         * init 3 counters with snapshots for templates with null values
         * for different fields
         */
        template = new SimpleEntry("TestEntry #1", null);
        ncs[9] = new SnapshotNotifyCounter(template, leaseMatrix[9], space);

        // snapshot of 2-nd template
        template = new SimpleEntry(null, 2);
        ncs[10] = new SnapshotNotifyCounter(template, leaseMatrix[10],
                space);

        // snapshot 3-rd template
        template = new SimpleEntry(null, null);
        ncs[11] = new SnapshotNotifyCounter(template, leaseMatrix[11],
                space);

        // try to register them
        for (int i = 0; i < 12; i++) {
            try {
                er = space.notify(ncs[i].getSnapshot(), txn, ncs[i],
                        ncs[i].getLeaseTime(), null);
                throw new TestException(" Notify operation for "
                        + ncs[i]
                        + " has not thrown IllegalArgumentException"
                        + " and returned " + er.toString());
            } catch (IllegalArgumentException iae) {
                logDebugText("IllegalArgumentException has been catched"
                        + " while trying to register " + ncs[i]
                        + " as expected.");
            }
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.