[JBoss-dev] CVS update: jnp/src/main/org/jnp/server Main.java MainMBean.java
User: starksm Date: 01/07/25 19:25:45 Modified:src/main/org/jnp/server Main.java MainMBean.java Log: Add support for binding the jnp port on a specific address Revision ChangesPath 1.8 +255 -208 jnp/src/main/org/jnp/server/Main.java Index: Main.java === RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/server/Main.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Main.java 2001/06/22 19:08:25 1.7 +++ Main.java 2001/07/26 02:25:45 1.8 @@ -8,10 +8,13 @@ package org.jnp.server; import java.io.FileNotFoundException; +import java.io.InputStream; import java.io.IOException; import java.io.ObjectOutputStream; +import java.net.InetAddress; import java.net.Socket; import java.net.ServerSocket; +import java.net.UnknownHostException; import java.net.URL; import java.rmi.Remote; import java.rmi.RemoteException; @@ -31,219 +34,263 @@ import org.jnp.interfaces.java.javaURLContextFactory; /** A main() entry point for running the jnp naming service implementation as -a standalone process. - -@author oberg -@author [EMAIL PROTECTED] -@version $Revision: 1.7 $ -*/ -public class Main - implements Runnable, MainMBean + a standalone process. + + @author oberg + @author [EMAIL PROTECTED] + @version $Revision: 1.8 $ + */ +public class Main implements Runnable, MainMBean { -// Constants - - -// Attributes -/** The Naming interface server implementation */ -protected NamingServer theServer; -protected MarshalledObject serverStub; -/** The jnp server socket through which the NamingServer stub is vended */ -protected ServerSocket serverSocket; -/** An optional custom client socket factory */ -protected RMIClientSocketFactory clientSocketFactory; -/** An optional custom server socket factory */ -protected RMIServerSocketFactory serverSocketFactory; -/** The class name of the optional custom client socket factory */ -protected String clientSocketFactoryName; -/** The class name of the optional custom server socket factory */ -protected String serverSocketFactoryName; -/** The jnp protocol listening port. The default is 1099, the same as -the RMI registry default port. */ -protected int port = 1099; -/** The RMI port on which the Naming implementation will be exported. The -default is 0 which means use any available port. */ -protected int rmiPort = 0; -protected Category log; + // Constants - + + // Attributes + /** The Naming interface server implementation */ + protected NamingServer theServer; + protected MarshalledObject serverStub; + /** The jnp server socket through which the NamingServer stub is vended */ + protected ServerSocket serverSocket; + /** An optional custom client socket factory */ + protected RMIClientSocketFactory clientSocketFactory; + /** An optional custom server socket factory */ + protected RMIServerSocketFactory serverSocketFactory; + /** The class name of the optional custom client socket factory */ + protected String clientSocketFactoryName; + /** The class name of the optional custom server socket factory */ + protected String serverSocketFactoryName; + /** The interface to bind to. This is useful for multi-homed hosts +that want control over which interfaces accept connections. +*/ + protected InetAddress bindAddress; + /** The serverSocket listen queue depth */ + protected int backlog = 50; + /** The jnp protocol listening port. The default is 1099, the same as +the RMI registry default port. */ + protected int port = 1099; + /** The RMI port on which the Naming implementation will be exported. The +default is 0 which means use any available port. */ + protected int rmiPort = 0; + protected Category log; -// Static -public static void main(String[] args) + // Static + public static void main(String[] args) throws Exception -{ -// Make sure the config file can be found -ClassLoader loader = Thread.currentThread().getContextClassLoader(); -URL url = loader.getResource("log4j.properties"); -if( url == null ) -System.err.println("Failed to find log4j.properties"); -else -PropertyConfigurator.configure(url); -new Main().start(); -} - -// Constructors --
[JBoss-dev] CVS update: jnp/src/main/org/jnp/server Main.java MainMBean.java
User: starksm Date: 01/07/19 13:09:40 Modified:src/main/org/jnp/server Tag: Branch_2_4 Main.java MainMBean.java Log: Add support for binding the jnp port on a specific address Revision ChangesPath No revision No revision 1.7.2.1 +255 -208 jnp/src/main/org/jnp/server/Main.java Index: Main.java === RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/server/Main.java,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -r1.7 -r1.7.2.1 --- Main.java 2001/06/22 19:08:25 1.7 +++ Main.java 2001/07/19 20:09:40 1.7.2.1 @@ -8,10 +8,13 @@ package org.jnp.server; import java.io.FileNotFoundException; +import java.io.InputStream; import java.io.IOException; import java.io.ObjectOutputStream; +import java.net.InetAddress; import java.net.Socket; import java.net.ServerSocket; +import java.net.UnknownHostException; import java.net.URL; import java.rmi.Remote; import java.rmi.RemoteException; @@ -31,219 +34,263 @@ import org.jnp.interfaces.java.javaURLContextFactory; /** A main() entry point for running the jnp naming service implementation as -a standalone process. - -@author oberg -@author [EMAIL PROTECTED] -@version $Revision: 1.7 $ -*/ -public class Main - implements Runnable, MainMBean + a standalone process. + + @author oberg + @author [EMAIL PROTECTED] + @version $Revision: 1.7.2.1 $ + */ +public class Main implements Runnable, MainMBean { -// Constants - - -// Attributes -/** The Naming interface server implementation */ -protected NamingServer theServer; -protected MarshalledObject serverStub; -/** The jnp server socket through which the NamingServer stub is vended */ -protected ServerSocket serverSocket; -/** An optional custom client socket factory */ -protected RMIClientSocketFactory clientSocketFactory; -/** An optional custom server socket factory */ -protected RMIServerSocketFactory serverSocketFactory; -/** The class name of the optional custom client socket factory */ -protected String clientSocketFactoryName; -/** The class name of the optional custom server socket factory */ -protected String serverSocketFactoryName; -/** The jnp protocol listening port. The default is 1099, the same as -the RMI registry default port. */ -protected int port = 1099; -/** The RMI port on which the Naming implementation will be exported. The -default is 0 which means use any available port. */ -protected int rmiPort = 0; -protected Category log; + // Constants - + + // Attributes + /** The Naming interface server implementation */ + protected NamingServer theServer; + protected MarshalledObject serverStub; + /** The jnp server socket through which the NamingServer stub is vended */ + protected ServerSocket serverSocket; + /** An optional custom client socket factory */ + protected RMIClientSocketFactory clientSocketFactory; + /** An optional custom server socket factory */ + protected RMIServerSocketFactory serverSocketFactory; + /** The class name of the optional custom client socket factory */ + protected String clientSocketFactoryName; + /** The class name of the optional custom server socket factory */ + protected String serverSocketFactoryName; + /** The interface to bind to. This is useful for multi-homed hosts +that want control over which interfaces accept connections. +*/ + protected InetAddress bindAddress; + /** The serverSocket listen queue depth */ + protected int backlog = 50; + /** The jnp protocol listening port. The default is 1099, the same as +the RMI registry default port. */ + protected int port = 1099; + /** The RMI port on which the Naming implementation will be exported. The +default is 0 which means use any available port. */ + protected int rmiPort = 0; + protected Category log; -// Static -public static void main(String[] args) + // Static + public static void main(String[] args) throws Exception -{ -// Make sure the config file can be found -ClassLoader loader = Thread.currentThread().getContextClassLoader(); -URL url = loader.getResource("log4j.properties"); -if( url == null ) -System.err.println("Failed to find log4j.properties"); -
[JBoss-dev] CVS update: jnp/src/main/org/jnp/server Main.java MainMBean.java
User: starksm Date: 01/05/30 09:09:00 Modified:src/main/org/jnp/server Tag: Branch_2_2 Main.java MainMBean.java Log: Add support for externalization of the RMI client and server socket factories Revision ChangesPath No revision No revision 1.5.2.2 +60 -14jnp/src/main/org/jnp/server/Main.java Index: Main.java === RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/server/Main.java,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -r1.5.2.1 -r1.5.2.2 --- Main.java 2001/05/24 16:24:04 1.5.2.1 +++ Main.java 2001/05/30 16:09:00 1.5.2.2 @@ -16,6 +16,8 @@ import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.MarshalledObject; +import java.rmi.server.RMIClientSocketFactory; +import java.rmi.server.RMIServerSocketFactory; import java.rmi.server.UnicastRemoteObject; import java.util.Properties; @@ -33,7 +35,7 @@ @author oberg @author [EMAIL PROTECTED] -@version $Revision: 1.5.2.1 $ +@version $Revision: 1.5.2.2 $ */ public class Main implements Runnable, MainMBean @@ -41,13 +43,26 @@ // Constants - // Attributes -NamingServer theServer; -MarshalledObject serverStub; -ServerSocket serverSocket; - -int port = 1099; -int rmiPort = 0; // Anonymous -Category log; +/** The Naming interface server implementation */ +protected NamingServer theServer; +protected MarshalledObject serverStub; +/** The jnp server socket through which the NamingServer stub is vended */ +protected ServerSocket serverSocket; +/** An optional custom client socket factory */ +protected RMIClientSocketFactory clientSocketFactory; +/** An optional custom server socket factory */ +protected RMIServerSocketFactory serverSocketFactory; +/** The class name of the optional custom client socket factory */ +protected String clientSocketFactoryName; +/** The class name of the optional custom server socket factory */ +protected String serverSocketFactoryName; +/** The jnp protocol listening port. The default is 1099, the same as +the RMI registry default port. */ +protected int port = 1099; +/** The RMI port on which the Naming implementation will be exported. The +default is 0 which means use any available port. */ +protected int rmiPort = 0; +protected Category log; // Static public static void main(String[] args) @@ -78,7 +93,7 @@ // Set configuration from the system properties setPort(Integer.getInteger("jnp.port",getPort()).intValue()); setRmiPort(Integer.getInteger("jnp.rmiPort",getRmiPort()).intValue()); -//log = Category.getInstance("Naming"); +log = Category.getInstance("Naming"); } // Public @@ -88,6 +103,32 @@ public void setPort(int p) { port = p; } public int getPort() { return port; } +public String getClientSocketFactory() +{ +return serverSocketFactoryName; +} +public void setClientSocketFactory(String factoryClassName) +throws ClassNotFoundException, InstantiationException, IllegalAccessException +{ +this.clientSocketFactoryName = factoryClassName; +ClassLoader loader = Thread.currentThread().getContextClassLoader(); +Class clazz = loader.loadClass(clientSocketFactoryName); +clientSocketFactory = (RMIClientSocketFactory) clazz.newInstance(); +} + +public String getServerSocketFactory() +{ +return serverSocketFactoryName; +} +public void setServerSocketFactory(String factoryClassName) +throws ClassNotFoundException, InstantiationException, IllegalAccessException +{ +this.serverSocketFactoryName = factoryClassName; +ClassLoader loader = Thread.currentThread().getContextClassLoader(); +Class clazz = loader.loadClass(serverSocketFactoryName); +serverSocketFactory = (RMIServerSocketFactory) clazz.newInstance(); +} + public void start() throws Exception { @@ -99,18 +140,24 @@ NamingContext.setLocal(theServer); // Export server -serverStub = new MarshalledObject(UnicastRemoteObject.exportObject(theServer, rmiPort)); +Remote stub = UnicastRemoteObject.exportObject(theServer, rmiPort, clientSocketFactory, serverSocketFactory); +serverStub = new MarshalledObject(stub); // Start l
[JBoss-dev] CVS update: jnp/src/main/org/jnp/server Main.java MainMBean.java
User: starksm Date: 01/05/29 18:59:10 Modified:src/main/org/jnp/server Main.java MainMBean.java Log: Add support for setting the RMI client and server socket factories on which the Naming interface implementation is exported. Revision ChangesPath 1.6 +60 -13jnp/src/main/org/jnp/server/Main.java Index: Main.java === RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/server/Main.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Main.java 2001/04/26 07:50:52 1.5 +++ Main.java 2001/05/30 01:59:10 1.6 @@ -16,6 +16,8 @@ import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.MarshalledObject; +import java.rmi.server.RMIClientSocketFactory; +import java.rmi.server.RMIServerSocketFactory; import java.rmi.server.UnicastRemoteObject; import java.util.Properties; @@ -33,7 +35,7 @@ @author oberg @author [EMAIL PROTECTED] -@version $Revision: 1.5 $ +@version $Revision: 1.6 $ */ public class Main implements Runnable, MainMBean @@ -41,13 +43,26 @@ // Constants - // Attributes -NamingServer theServer; -MarshalledObject serverStub; -ServerSocket serverSocket; - -int port = 1099; -int rmiPort = 0; // Anonymous -Category log; +/** The Naming interface server implementation */ +protected NamingServer theServer; +protected MarshalledObject serverStub; +/** The jnp server socket through which the NamingServer stub is vended */ +protected ServerSocket serverSocket; +/** An optional custom client socket factory */ +protected RMIClientSocketFactory clientSocketFactory; +/** An optional custom server socket factory */ +protected RMIServerSocketFactory serverSocketFactory; +/** The class name of the optional custom client socket factory */ +protected String clientSocketFactoryName; +/** The class name of the optional custom server socket factory */ +protected String serverSocketFactoryName; +/** The jnp protocol listening port. The default is 1099, the same as +the RMI registry default port. */ +protected int port = 1099; +/** The RMI port on which the Naming implementation will be exported. The +default is 0 which means use any available port. */ +protected int rmiPort = 0; +protected Category log; // Static public static void main(String[] args) @@ -88,6 +103,32 @@ public void setPort(int p) { port = p; } public int getPort() { return port; } +public String getClientSocketFactory() +{ +return serverSocketFactoryName; +} +public void setClientSocketFactory(String factoryClassName) +throws ClassNotFoundException, InstantiationException, IllegalAccessException +{ +this.clientSocketFactoryName = factoryClassName; +ClassLoader loader = Thread.currentThread().getContextClassLoader(); +Class clazz = loader.loadClass(clientSocketFactoryName); +clientSocketFactory = (RMIClientSocketFactory) clazz.newInstance(); +} + +public String getServerSocketFactory() +{ +return serverSocketFactoryName; +} +public void setServerSocketFactory(String factoryClassName) +throws ClassNotFoundException, InstantiationException, IllegalAccessException +{ +this.serverSocketFactoryName = factoryClassName; +ClassLoader loader = Thread.currentThread().getContextClassLoader(); +Class clazz = loader.loadClass(serverSocketFactoryName); +serverSocketFactory = (RMIServerSocketFactory) clazz.newInstance(); +} + public void start() throws Exception { @@ -99,18 +140,24 @@ NamingContext.setLocal(theServer); // Export server -serverStub = new MarshalledObject(UnicastRemoteObject.exportObject(theServer, rmiPort)); +Remote stub = UnicastRemoteObject.exportObject(theServer, rmiPort, clientSocketFactory, serverSocketFactory); +serverStub = new MarshalledObject(stub); // Start listener try { serverSocket = null; -serverSocket = new ServerSocket(getPort()); -log.info("Started jnpPort=" + getPort()+", rmiPort="+getRmiPort()); +serverSocket = new ServerSocket(port); +// If an anonymous port was specified get the actual port used +if( port == 0 ) +port = serverSocket.getLocalPort(); +String msg = "Started jnpPort=" + port +", rmiPort=" + rmiPort +
[JBoss-dev] CVS update: jnp/src/main/org/jnp/server Main.java MainMBean.java NamingServer.java
User: starksm Date: 01/04/22 23:08:06 Modified:src/main/org/jnp/server Main.java MainMBean.java NamingServer.java Log: Add support for PROVIDER_URL values that refer to subcontexts Revision ChangesPath 1.3 +162 -161 jnp/src/main/org/jnp/server/Main.java Index: Main.java === RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/server/Main.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Main.java 2000/12/12 10:57:11 1.2 +++ Main.java 2001/04/23 06:08:06 1.3 @@ -7,10 +7,12 @@ */ package org.jnp.server; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.ObjectOutputStream; import java.net.Socket; import java.net.ServerSocket; +import java.net.URL; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.MarshalledObject; @@ -19,178 +21,177 @@ import javax.naming.*; +import org.apache.log4j.Category; +import org.apache.log4j.PropertyConfigurator; + import org.jnp.interfaces.Naming; import org.jnp.interfaces.NamingContext; import org.jnp.interfaces.java.javaURLContextFactory; + +/** A main() entry point for running the jnp naming service implementation as +a standalone process. -/** - * - * - * @see - * @author $Author: oberg $ - * @version $Revision: 1.2 $ - */ +@author $Author: starksm $ +@author [EMAIL PROTECTED] +@version $Revision: 1.3 $ +*/ public class Main implements Runnable, MainMBean { - // Constants - - - // Attributes - NamingServer theServer; - MarshalledObject serverStub; - ServerSocket serverSocket; - - int port = 1099; - int rmiPort = 0; // Anonymous - boolean logging = false; - - // Static - public static void main(String[] args) +// Constants - + +// Attributes +NamingServer theServer; +MarshalledObject serverStub; +ServerSocket serverSocket; + +int port = 1099; +int rmiPort = 0; // Anonymous +Category log; + +// Static +public static void main(String[] args) throws Exception - { - new Main().start(); - } - - // Constructors -- - public Main() - { - // Load properties from properties file - try - { - System.getProperties().load(getClass().getClassLoader().getResourceAsStream("jnp.properties")); - } catch (Exception e) - { +{ +new Main().start(); +} + +// Constructors -- +public Main() +{ +// Load properties from properties file +try +{ + System.getProperties().load(getClass().getClassLoader().getResourceAsStream("jnp.properties")); +} catch (Exception e) +{ // Ignore - } - - // Set configuration - setPort(Integer.getInteger("jnp.port",getPort()).intValue()); - setLogging(Boolean.getBoolean("jnp.log")); - } - - // Public - public void setRmiPort(int p) { rmiPort = p; } - public int getRmiPort() { return rmiPort; } - - public void setPort(int p) { port = p; } - public int getPort() { return port; } +} - public void setLogging(boolean l) { logging = l; } - public boolean getLogging() { return logging; } +// Set configuration +setPort(Integer.getInteger("jnp.port",getPort()).intValue()); +log = Category.getInstance("org.jnp.Naming"); +} - public void start() +// Public +public void setRmiPort(int p) { rmiPort = p; } +public int getRmiPort() { return rmiPort; } + +public void setPort(int p) { port = p; } +public int getPort() { return port; } + +public void start() throws Exception - { - // Create remote object - theServer = new NamingServer(); - - // Set local server reference - NamingContext.setLocal(theServer); - - // Export server - serverStub = new MarshalledObject(UnicastRemoteObject.exportObject(theServer, rmiPort)); - - // Start listener - try - { - serverSocket = null; - serverSocket = new ServerSocket(getPort());