org.jboss.remoting.samples.detection.multicast
Class SimpleDetectorClient

java.lang.Object
  extended by org.jboss.remoting.samples.detection.multicast.SimpleDetectorClient
All Implemented Interfaces:
java.util.EventListener, javax.management.NotificationListener

public class SimpleDetectorClient
extends java.lang.Object
implements javax.management.NotificationListener

Simple remoting client that uses detection to discover the remoting server to make invocation on. Note that this class is a standard JMX NotificationListener so it can listen for discovery JMX notifications coming from the NetworkRegistry. This is how the NetworkRegistry tells us when new servers have come online and when dead servers go offline.

Author:
Tom Elrod, John Mazzitelli

Constructor Summary
SimpleDetectorClient()
           
 
Method Summary
 void handleNotification(javax.management.Notification notification, java.lang.Object handback)
          Callback method from the broadcaster MBean this listener implementation is registered to.
static void main(java.lang.String[] args)
          Starts the JBoss/Remoting client.
 void makeInvocation(java.lang.String locatorURI)
          Make call on remoting server based on locator uri provided.
static void println(java.lang.String msg)
          Outputs a message to stdout.
 void setupDetector()
          Sets up NetworkRegistry and MulticastDetector so we can listen for any additions or removals of remoting servers on the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDetectorClient

public SimpleDetectorClient()
Method Detail

setupDetector

public void setupDetector()
                   throws java.lang.Exception
Sets up NetworkRegistry and MulticastDetector so we can listen for any additions or removals of remoting servers on the network.

Throws:
java.lang.Exception

handleNotification

public void handleNotification(javax.management.Notification notification,
                               java.lang.Object handback)
Callback method from the broadcaster MBean this listener implementation is registered to. When a new server is detected, a welcome message will immediately be sent to the newly discovered server.

Specified by:
handleNotification in interface javax.management.NotificationListener
Parameters:
notification - the notification object
handback - the handback object given to the broadcaster upon listener registration

makeInvocation

public void makeInvocation(java.lang.String locatorURI)
                    throws java.lang.Throwable
Make call on remoting server based on locator uri provided.

Parameters:
locatorURI - the URI of the remote server we want to send the message to
Throws:
java.lang.Throwable

main

public static void main(java.lang.String[] args)
Starts the JBoss/Remoting client.

Parameters:
args - unused

println

public static void println(java.lang.String msg)
Outputs a message to stdout.

Parameters:
msg - the message to output


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.