Package mx4j.remote

Examples of mx4j.remote.NotificationTuple


   }

   public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback)
           throws InstanceNotFoundException, IOException
   {
      NotificationTuple tuple = new NotificationTuple(observed, listener, filter, handback);
      if (notificationHandler.contains(tuple)) return;

      MarshalledObject f = null;
      try
      {
         f = RMIMarshaller.marshal(filter);
      }
      catch (NotSerializableException x)
      {
         // Invoke the filter on client side
         tuple.setInvokeFilter(true);
      }
      Integer[] ids = connection.addNotificationListeners(new ObjectName[]{observed}, new MarshalledObject[]{f}, new Subject[]{delegate});
      notificationHandler.addNotificationListener(ids[0], tuple);
   }
View Full Code Here


   }

   public void removeNotificationListener(ObjectName observed, NotificationListener listener)
           throws InstanceNotFoundException, ListenerNotFoundException, IOException
   {
      Integer[] ids = notificationHandler.getNotificationListeners(new NotificationTuple(observed, listener));
      if (ids == null) throw new ListenerNotFoundException("Could not find listener " + listener);
      connection.removeNotificationListeners(observed, ids, delegate);
      notificationHandler.removeNotificationListeners(ids);
   }
View Full Code Here

   }

   public void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback)
           throws InstanceNotFoundException, ListenerNotFoundException, IOException
   {
      Integer id = notificationHandler.getNotificationListener(new NotificationTuple(observed, listener, filter, handback));
      if (id == null) throw new ListenerNotFoundException("Could not find listener " + listener + " with filter " + filter + " and handback " + handback);
      Integer[] ids = new Integer[]{id};
      connection.removeNotificationListeners(observed, ids, delegate);
      notificationHandler.removeNotificationListeners(ids);
   }
View Full Code Here

            {
            }
         };

         ObjectName name = ObjectName.getInstance(":name=emitter");
         handler.addNotificationListener(new Integer(1), new NotificationTuple(name, listener, null, null));
         handler.addNotificationListener(new Integer(2), new NotificationTuple(name, listener, null, new Object()));

         assertTrue(handler.isActive());

         Integer[] ids = handler.getNotificationListeners(new NotificationTuple(name, listener));
         assertEquals(ids.length, 2);

         handler.removeNotificationListeners(new Integer[]{new Integer(1), new Integer(2)});
         assertTrue(handler.isActive());
View Full Code Here

      try
      {
         handler.start();

         ObjectName name = ObjectName.getInstance(":name=emitter");
         handler.addNotificationListener(new Integer(1), new NotificationTuple(name, listener, null, null));
         Object handback = new Object();
         handler.addNotificationListener(new Integer(2), new NotificationTuple(name, listener, null, handback));
         handler.removeNotificationListeners(new Integer[]{new Integer(2)});

         assertFalse(handler.contains(new NotificationTuple(name, listener, null, handback)));
         assertTrue(handler.contains(new NotificationTuple(name, listener, null, null)));

         Integer id = handler.getNotificationListener(new NotificationTuple(name, listener, null, null));
         assertEquals(id.intValue(), 1);

         handler.removeNotificationListeners(new Integer[]{new Integer(1)});
         assertFalse(handler.contains(new NotificationTuple(name, listener, null, null)));
      }
      finally
      {
         handler.stop();
      }
View Full Code Here

      try
      {
         handler.start();

         handler.addNotificationListener(new Integer(1), new NotificationTuple(name, listener, null, null));

         synchronized (holder)
         {
            // This wait time is much less than the sleep time for the fetcher thread
            while (holder.get() == null) holder.wait(10);
View Full Code Here

      try
      {
         handler.start();

         handler.addNotificationListener(id, new NotificationTuple(name, listener, null, null));

         synchronized (holder)
         {
            while (lost.get() == 0) holder.wait(10);
            assertEquals(lost.get(), losts);
View Full Code Here

      {
         handler.start();

         ObjectName name = ObjectName.getInstance(":name=emitter");
         Integer id = new Integer(1);
         handler.addNotificationListener(id, new NotificationTuple(name, listener, null, null));

         sleep(5000 + period * retries);

         assertTrue(!handler.isActive());
      }
View Full Code Here

      };

      try
      {
         handler.start();
         handler.addNotificationListener(id, new NotificationTuple(name, listener, null, null));
         // Wait until we empty the client's queue
         synchronized (lock)
         {
            while (notify.get())
            {
View Full Code Here

      this.notificationHandler = notificationHandler;
   }

   public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException
   {
      NotificationTuple tuple = new NotificationTuple(observed, listener, filter, handback);
      // Filters are always invoked on client side, for now
      tuple.setInvokeFilter(true);
      if (notificationHandler.contains(tuple)) return;
      Integer id = ((HTTPConnection)getConnection()).addNotificationListener(observed, null, getDelegateSubject());
      notificationHandler.addNotificationListener(id, tuple);
   }
View Full Code Here

TOP

Related Classes of mx4j.remote.NotificationTuple

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.