1 8 package mx4j.examples.mbeans.iiop; 9 10 import java.rmi.RemoteException ; 11 import javax.naming.Context ; 12 import javax.naming.InitialContext ; 13 import javax.rmi.PortableRemoteObject ; 14 15 25 public class HelloImpl implements Hello, HelloImplMBean 26 { 27 private boolean m_isRunning; 28 29 public HelloImpl() throws RemoteException 30 { 31 } 32 33 public void sayHello(String name) throws RemoteException 34 { 35 String hello = "Hello"; 36 System.out.println(hello + " " + name); 37 } 38 39 public void start() throws Exception 40 { 41 if (!m_isRunning) 42 { 43 PortableRemoteObject.exportObject(this); 45 Context ctx = new InitialContext (); 47 ctx.rebind(IIOP_JNDI_NAME, this); 48 System.out.println("My Service servant started successfully"); 49 m_isRunning = true; 50 } 51 } 52 53 public void stop() throws Exception 54 { 55 if (m_isRunning) 56 { 57 PortableRemoteObject.unexportObject(this); 58 Context ctx = new InitialContext (); 59 ctx.unbind(IIOP_JNDI_NAME); 60 m_isRunning = false; 61 System.out.println("My Service Servant stopped successfully"); 62 } 63 } 64 65 public boolean isRunning() 66 { 67 return m_isRunning; 68 } 69 } 70 | Popular Tags |