Re: Detect & re-register in Rmi Server
PawanModi <[email protected]> Mon, 30 Mar 2009 00:22:35 -0700
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <[email protected]> |
Hi Niclas, Many thanks for your response. It would be great help if you provide me sample code to list if the service is still there & for binding again. I am new to Mgmt interface & rmi. Need some help Thanks & regards, Pawan Modi Niclas Hedhman wrote: >=20 > I suggest that you create the Registry inside the server JVM. >=20 > LocateRegistry.createRegistry() >=20 > If that is not a viable option, then I think you need to regularly do > a list() on the Registry instance and see if the service is still > there. If missing, then bind it again. >=20 > Cheers > Niclas >=20 > On Thu, Mar 26, 2009 at 6:56 PM, PawanModi <[email protected]> > wrote: >> 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 ar= e >> 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) >> { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0mbeanServer =3D MBeanServerFactory.createMBea= nServer(); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0String domain =3D m_mbeanServer.getDefaultDom= ain(); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0String mbeanObjectNameStr =3D domain + ":type= =3D" + >> EXTERNAL_MBEAN_CLASS_NAME + ",index=3D1"; >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0objectName =3D =C2=A0ObjectName.getInstance(m= beanObjectNameStr); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0Attribute serviceURLAttribute =3D new Attribu= te("ServiceURL", >> serviceURL); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0m_mbeanServer.setAttribute(m_mbeanObjectName, >> serviceURLAttribute); >> =C2=A0} >> >> public void startManagementInterface(String jmxServiceURL, String >> mbeanClassName) >> =C2=A0 =C2=A0{ >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env.put(RMIConnec= torServer.JNDI_REBIND_ATTRIBUTE,"true"); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0JMXServiceURL p_j= mxServiceURL =3D new >> JMXServiceURL(jmxServiceURL); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0LoggerManager.get= Logger().info("Starting JMX Server: " + >> p_jmxServiceURL); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0m_mbeanServerConn= ector =3D >> JMXConnectorServerFactory.newJMXConnectorServer(p_jmxServiceURL, env, >> m_mbeanServer); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0m_mbeanServerConn= ector.start(); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0LoggerManager.get= Logger().info("THE MANAGEMENT INTERFACE >> STARTED >> FOR SERVICE URL :" + jmxServiceURL); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0m_jmxConnector = =3D >> JMXConnectorFactory.connect(p_jmxServiceURL, >> null); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0m_mbeanConnection= =3D >> m_jmxConnector.getMBeanServerConnection(); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String domain =3D= m_mbeanConnection.getDefaultDomain(); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0m_mbeanObjectName= =3D new ObjectName(domain + ":type=3D" + >> mbeanClassName + ",index=3D1"); >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >> >> -- >> View this message in context: >> http://www.nabble.com/Detect---re-register-in-Rmi-Server-tp22719692p2271= 9692.html >> Sent from the Java - RMI mailing list archive at Nabble.com. >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D >> To unsubscribe, send email to [email protected] and include in the >> body >> of the message "signoff RMI-USERS". =C2=A0For general help, send email t= o >> [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 >> >=20 >=20 >=20 > --=20 > -- > Niclas Hedhman, Software Developer > http://www.qi4j.org - New Energy for Java >=20 > I live here; http://tinyurl.com/2qq9er > I work here; http://tinyurl.com/2ymelc > I relax here; http://tinyurl.com/2cgsug >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > 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". >=20 > For a list of frequently asked RMI questions please refer to: > http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html >=20 > To view past RMI-USERS postings, please see: > http://archives.java.sun.com/archives/rmi-users.html >=20 >=20 --=20 View this message in context: http://www.nabble.com/Detect---re-register-in= -Rmi-Server-tp22719692p22777598.html Sent from the Java - RMI mailing list archive at Nabble.com. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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