KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > connector > jrmp > JRMPConnectorRemote


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.ioc.connector.jrmp;
8
9 import java.rmi.RemoteException JavaDoc;
10 import java.rmi.server.UnicastRemoteObject JavaDoc;
11
12 import org.jfox.ioc.connector.AbstractConnectorRemote;
13 import org.jfox.ioc.connector.ServerNode;
14
15 /**
16  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
17  */

18
19 public class JRMPConnectorRemote extends AbstractConnectorRemote {
20
21     protected void doInit() throws Exception JavaDoc {
22         try {
23             UnicastRemoteObject.unexportObject(this, true);
24         }
25         catch(Exception JavaDoc e) {
26             // ignore
27
}
28     }
29
30     /**
31      * export this invoker and set container's invoker to this stub
32      *
33      * @throws Exception
34      */

35     protected void doStart() throws Exception JavaDoc {
36         UnicastRemoteObject.exportObject(this,getPort());
37         // register this Connector
38
ServerNode.THE_NODE.registerConnector(getProtocol(),this);
39
40         // 启动一个线程,用来每隔一段时间 ping 一下,防止 rmi 线程死掉
41
Thread JavaDoc pingThread = new Thread JavaDoc(this, getName());
42         pingThread.setPriority(Thread.MIN_PRIORITY);
43         pingThread.start();
44     }
45
46     protected void doStop() throws Exception JavaDoc {
47         ServerNode.THE_NODE.removeConnector(getProtocol());
48         UnicastRemoteObject.unexportObject(this, true);
49     }
50
51     public String JavaDoc getProtocol() throws RemoteException JavaDoc {
52         return "JRMP";
53     }
54
55     protected void doDestroy() throws Exception JavaDoc {
56         try {
57             UnicastRemoteObject.unexportObject(this, true);
58         }
59         catch(Exception JavaDoc e) {
60             // ignore
61
}
62     }
63
64 }
65
Popular Tags