[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/samples/detection/jndi ...
Ron Sigal
ron_sigal at yahoo.com
Wed Oct 11 16:28:20 EDT 2006
User: rsigal
Date: 06/10/11 16:28:20
Modified: src/main/org/jboss/remoting/samples/detection/jndi
SimpleDetectorServer.java
Log:
JBREM-581, JBREM-603: (1) Added overridable getConfiguration() method which returns configuration map to be passed to Connector and JNDIDetector. (2) Refactored main() to facilitate subclassing.
Revision Changes Path
1.3 +53 -34 JBossRemoting/src/main/org/jboss/remoting/samples/detection/jndi/SimpleDetectorServer.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SimpleDetectorServer.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/samples/detection/jndi/SimpleDetectorServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- SimpleDetectorServer.java 21 Jul 2006 05:23:07 -0000 1.2
+++ SimpleDetectorServer.java 11 Oct 2006 20:28:20 -0000 1.3
@@ -12,6 +12,8 @@
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
/**
* A simple JBoss/Remoting remoting server. This uses an inner class SampleInvocationHandler as the invocation
@@ -23,9 +25,9 @@
public class SimpleDetectorServer
{
// Default locator values - command line args can override transport and port
- private static String transport = "socket";
- private static String host = "localhost";
- private static int port = 5400;
+ protected static String transport = "socket";
+ protected static String host = "localhost";
+ protected static int port = 5400;
private int detectorPort = 1099;
private String contextFactory = "org.jnp.interfaces.NamingContextFactory";
@@ -47,7 +49,7 @@
String detectorHost = InetAddress.getLocalHost().getHostName();
// multicast detector will detect new network registries that come online
- JNDIDetector detector = new JNDIDetector();
+ JNDIDetector detector = new JNDIDetector(getConfiguration());
// set config info for detector and start it.
detector.setPort(detectorPort);
detector.setHost(detectorHost);
@@ -72,7 +74,7 @@
{
InvokerLocator locator = new InvokerLocator(locatorURI);
println("Starting remoting server with locator uri of: " + locatorURI);
- Connector connector = new Connector();
+ Connector connector = new Connector(getConfiguration());
connector.setInvokerLocator(locator.getLocatorURI());
connector.create();
@@ -94,6 +96,42 @@
*/
public static void main(String[] args)
{
+ println("Starting JBoss/Remoting server... to stop this server, kill it manually via Control-C");
+ String locatorURI = getLocatorURI(args);
+ println("This server's endpoint will be: " + locatorURI);
+
+ SimpleDetectorServer server = new SimpleDetectorServer();
+ try
+ {
+ server.setupDetector();
+ server.setupServer(locatorURI);
+
+ // wait forever, let the user kill us at any point (at which point, the client will detect we went down)
+ while(true)
+ {
+ Thread.sleep(1000);
+ }
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ println("Stopping JBoss/Remoting server");
+ }
+
+ /**
+ * Outputs a message to stdout.
+ *
+ * @param msg the message to output
+ */
+ public static void println(String msg)
+ {
+ System.out.println(new java.util.Date() + ": [SERVER]: " + msg);
+ }
+
+ protected static String getLocatorURI(String[] args)
+ {
// get system property -Dargs that is in format "transport:port"
String prop = System.getProperty("args");
if(prop != null)
@@ -131,39 +169,20 @@
}
}
- println("Starting JBoss/Remoting server... to stop this server, kill it manually via Control-C");
-
- String locatorURI = transport + "://" + host + ":" + port;
- println("This server's endpoint will be: " + locatorURI);
-
- SimpleDetectorServer server = new SimpleDetectorServer();
- try
- {
- server.setupDetector();
- server.setupServer(locatorURI);
-
- // wait forever, let the user kill us at any point (at which point, the client will detect we went down)
- while(true)
- {
- Thread.sleep(1000);
- }
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
-
- println("Stopping JBoss/Remoting server");
+ return transport + "://" + host + ":" + port;
}
/**
- * Outputs a message to stdout.
- *
- * @param msg the message to output
+ * @return configuration map for Connector and JNDIDetector
*/
- public static void println(String msg)
+ protected Map getConfiguration()
{
- System.out.println(new java.util.Date() + ": [SERVER]: " + msg);
+ return new HashMap();
+ }
+
+ protected SimpleDetectorServer getDetectorServer()
+ {
+ return new SimpleDetectorServer();
}
/**
More information about the jboss-cvs-commits
mailing list