@Test public void testSubscribe() { ServiceChannel serviceChannel = ServiceChannel.getInstance(); ServiceElement serviceElement = TestUtil.makeServiceElement("bar", "foo"); Listener l1 = new Listener(); serviceChannel.subscribe(l1, serviceElement, ServiceChannelEvent.Type.PROVISIONED); Listener l2 = new Listener(); serviceChannel.subscribe(l2, serviceElement, ServiceChannelEvent.Type.FAILED); Listener l3 = new Listener(); serviceChannel.subscribe(l3, serviceElement, ServiceChannelEvent.Type.IDLE); serviceChannel.broadcast(new ServiceChannelEvent(new Object(), serviceElement, ServiceChannelEvent.Type.PROVISIONED)); Assert.assertTrue(l1.notified); Assert.assertFalse(l2.notified); Assert.assertFalse(l3.notified); l1.notified = false; serviceChannel.broadcast(new ServiceChannelEvent(new Object(), serviceElement, ServiceChannelEvent.Type.FAILED)); Assert.assertFalse(l1.notified); Assert.assertTrue(l2.notified); Assert.assertFalse(l3.notified); l2.notified = false; serviceChannel.broadcast(new ServiceChannelEvent(new Object(), serviceElement, ServiceChannelEvent.Type.IDLE)); Assert.assertFalse(l1.notified); Assert.assertFalse(l2.notified); Assert.assertTrue(l3.notified); l3.notified = false; }
public void subscribe(final ServiceChannelListener listener, final AssociationDescriptor associationDescriptor, final ServiceChannelEvent.Type type) { subscribe(listener, associationDescriptor.getName(), associationDescriptor.getInterfaceNames(), associationDescriptor.getOperationalStringName(), type); }
ServiceChannel { public void subscribe(final ServiceChannelListener listener, final AssociationDescriptor associationDescriptor, final ServiceChannelEvent.Type type) { subscribe(listener, associationDescriptor.getName(), associationDescriptor.getInterfaceNames(), associationDescriptor.getOperationalStringName(), type); } }
ServiceChannel { public void subscribe(final ServiceChannelListener listener, final AssociationDescriptor associationDescriptor, final ServiceChannelEvent.Type type) { subscribe(listener, associationDescriptor.getName(), associationDescriptor.getInterfaceNames(), associationDescriptor.getOperationalStringName(), type); }  }
ServiceChannel { public void subscribe(final ServiceChannelListener listener, final AssociationDescriptor associationDescriptor, final ServiceChannelEvent.Type type) { subscribe(listener, associationDescriptor.getName(), associationDescriptor.getInterfaceNames(), associationDescriptor.getOperationalStringName(), type); }  static ServiceChannel getInstance(); void subscribe(final ServiceChannelListener listener,
                          final AssociationDescriptor associationDescriptor,
                          final ServiceChannelEvent.Type type); void subscribe(final ServiceChannelListener listener,
                          final ServiceElement serviceElement,
                          final ServiceChannelEvent.Type type); void unsubscribe(final ServiceChannelListener listener); void broadcast(final ServiceChannelEvent event); }
ServiceChannel { public void subscribe(final ServiceChannelListener listener, final AssociationDescriptor associationDescriptor, final ServiceChannelEvent.Type type) { subscribe(listener, associationDescriptor.getName(), associationDescriptor.getInterfaceNames(), associationDescriptor.getOperationalStringName(), type); }  static ServiceChannel getInstance(); void subscribe(final ServiceChannelListener listener,
                          final AssociationDescriptor associationDescriptor,
                          final ServiceChannelEvent.Type type); void subscribe(final ServiceChannelListener listener,
                          final ServiceElement serviceElement,
                          final ServiceChannelEvent.Type type); void unsubscribe(final ServiceChannelListener listener); void broadcast(final ServiceChannelEvent event);  }