mx4j/src/tools/mx4j/tools/naming NamingServiceMBean.java,1.6,1.7 NamingService.java,1.10,1.11

Simone Bordet <[email protected]> Wed, 23 Feb 2005 11:35:37 +0000
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/naming
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25194/src/tools/mx4j/tools/naming

Modified Files:
	NamingServiceMBean.java NamingService.java 
Log Message:
Implemented RFE #1064681: added list() and unbind() to management interface

Index: NamingServiceMBean.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/naming/NamingServiceMBean.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** NamingServiceMBean.java	13 Nov 2004 16:38:40 -0000	1.6
--- NamingServiceMBean.java	23 Feb 2005 11:35:35 -0000	1.7
***************
*** 10,13 ****
--- 10,14 ----
  
  import java.rmi.NoSuchObjectException;
+ import java.rmi.NotBoundException;
  import java.rmi.RemoteException;
  
***************
*** 21,24 ****
--- 22,26 ----
     /**
      * Sets the port on which rmiregistry listens for incoming connections.
+     * Can be called only if this service is not {@link #isRunning() running}.
      *
      * @see #getPort
***************
*** 54,56 ****
--- 56,72 ----
      */
     public void stop() throws NoSuchObjectException;
+ 
+    /**
+     * Returns an array of the names bound in the rmiregistry
+     *
+     * @see java.rmi.registry.Registry#list()
+     */
+    public String[] list() throws RemoteException;
+ 
+    /**
+     * Removes the binding for the specified <code>name</code> in the rmiregistry
+     *
+     * @see java.rmi.registry.Registry#unbind(String)
+     */
+    public void unbind(String name) throws RemoteException, NotBoundException;
  }

Index: NamingService.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/naming/NamingService.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** NamingService.java	13 Nov 2004 16:38:40 -0000	1.10
--- NamingService.java	23 Feb 2005 11:35:35 -0000	1.11
***************
*** 10,14 ****
  
  import java.rmi.NoSuchObjectException;
! import java.rmi.Remote;
  import java.rmi.RemoteException;
  import java.rmi.registry.LocateRegistry;
--- 10,14 ----
  
  import java.rmi.NoSuchObjectException;
! import java.rmi.NotBoundException;
  import java.rmi.RemoteException;
  import java.rmi.registry.LocateRegistry;
***************
*** 26,30 ****
  {
     private int m_port;
!    private Remote m_registry;
     private boolean m_running;
  
--- 26,30 ----
  {
     private int m_port;
!    private Registry m_registry;
     private boolean m_running;
  
***************
*** 42,63 ****
     public NamingService(int port)
     {
!       m_port = port;
     }
  
-    /**
-     * Sets the port on which rmiregistry listens for incoming connections.
-     *
-     * @see #getPort
-     */
     public void setPort(int port)
     {
        m_port = port;
     }
  
-    /**
-     * Returns the port on which rmiregistry listens for incoming connections
-     *
-     * @see #setPort
-     */
     public int getPort()
     {
--- 42,54 ----
     public NamingService(int port)
     {
!       setPort(port);
     }
  
     public void setPort(int port)
     {
+       if (isRunning()) throw new IllegalStateException("NamingService is running, cannot change the port");
        m_port = port;
     }
  
     public int getPort()
     {
***************
*** 65,73 ****
     }
  
-    /**
-     * Returns whether this MBean has been started and not yet stopped.
-     *
-     * @see #start
-     */
     public boolean isRunning()
     {
--- 56,59 ----
***************
*** 75,84 ****
     }
  
-    /**
-     * Starts this MBean: rmiregistry can now accept incoming calls
-     *
-     * @see #stop
-     * @see #isRunning
-     */
     public void start() throws RemoteException
     {
--- 61,64 ----
***************
*** 90,98 ****
     }
  
-    /**
-     * Stops this MBean: rmiregistry cannot accept anymore incoming calls
-     *
-     * @see #start
-     */
     public void stop() throws NoSuchObjectException
     {
--- 70,73 ----
***************
*** 102,104 ****
--- 77,91 ----
        }
     }
+ 
+    public String[] list() throws RemoteException
+    {
+       if (!isRunning()) throw new IllegalStateException("NamingService is not running");
+       return m_registry.list();
+    }
+ 
+    public void unbind(String name) throws RemoteException, NotBoundException
+    {
+       if (!isRunning()) throw new IllegalStateException("NamingService is not running");
+       m_registry.unbind(name);
+    }
  }



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click