Detect & re-register in Rmi Server

PawanModi <[email protected]> Thu, 26 Mar 2009 03:56:22 -0700
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
Hi,
I am running rmi registry in separate console. My application is registering
an URL in RMI server. Now I am stopping rmi registry & restarting it again. 
Now rmi registry is a new process & all previous registration entries are
gone. So my application has to re-register.

How my application can detect that rmi server is stopped & restarted so that
I can re-register it again?
Any help?
Here is my code where I am registering


public void initializeExternalManagementInterface(String serviceURL)
{         
        mbeanServer = MBeanServerFactory.createMBeanServer();
         
        String domain = m_mbeanServer.getDefaultDomain();       

        String mbeanObjectNameStr = domain + ":type=" +
EXTERNAL_MBEAN_CLASS_NAME + ",index=1";
         
      	objectName =  ObjectName.getInstance(mbeanObjectNameStr);

        Attribute serviceURLAttribute = new Attribute("ServiceURL",
serviceURL);
                      
        m_mbeanServer.setAttribute(m_mbeanObjectName, serviceURLAttribute);
 }

public void startManagementInterface(String jmxServiceURL, String
mbeanClassName)
    {
         
        	env.put(RMIConnectorServer.JNDI_REBIND_ATTRIBUTE,"true");
            
        	JMXServiceURL p_jmxServiceURL = new JMXServiceURL(jmxServiceURL);
        	
        	LoggerManager.getLogger().info("Starting JMX Server: " +
p_jmxServiceURL);
        	
        	m_mbeanServerConnector =
JMXConnectorServerFactory.newJMXConnectorServer(p_jmxServiceURL, env,
m_mbeanServer);        	
        	
            	m_mbeanServerConnector.start();   
                        
        	LoggerManager.getLogger().info("THE MANAGEMENT INTERFACE STARTED
FOR SERVICE URL :" + jmxServiceURL);
	
            	m_jmxConnector = JMXConnectorFactory.connect(p_jmxServiceURL,
null);
              
            	m_mbeanConnection = m_jmxConnector.getMBeanServerConnection();            
 
            	String domain = m_mbeanConnection.getDefaultDomain();
             
            	m_mbeanObjectName = new ObjectName(domain + ":type=" +
mbeanClassName + ",index=1");
             
        }

-- 
View this message in context: http://www.nabble.com/Detect---re-register-in-Rmi-Server-tp22719692p22719692.html
Sent from the Java - RMI mailing list archive at Nabble.com.

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html