1 6 package org.jfox.ioc.connector.jrmps; 7 8 import java.rmi.RemoteException ; 9 import java.rmi.server.UnicastRemoteObject ; 10 11 import org.jfox.ioc.connector.ServerNode; 12 import org.jfox.ioc.connector.jrmp.JRMPConnectorRemote; 13 import org.jfox.ioc.ext.ManagableComponent; 14 15 18 19 public class JRMPSConnectorRemote extends JRMPConnectorRemote implements ManagableComponent { 20 21 private String SSLKeyFile = "jfox.keystore"; 22 private String SSLTrustKeyFile = "jfox.truststore"; 23 private String password = "jfox.org"; 24 25 private JRMPSServerSocketFactory serverFactory = null; 26 private JRMPSClientSocketFactory clientFactory = null; 27 28 protected void doInit() throws Exception { 29 super.doInit(); 30 clientFactory = new JRMPSClientSocketFactory(SSLTrustKeyFile, password); 31 serverFactory = new JRMPSServerSocketFactory(SSLKeyFile, password); 32 } 33 34 39 protected void doStart() throws Exception { 40 UnicastRemoteObject.exportObject(this, getPort(), clientFactory, serverFactory); 41 ServerNode.THE_NODE.registerConnector(getProtocol(), this); 43 44 Thread pingThread = new Thread (this, getClass().getName()); 46 pingThread.setPriority(Thread.MIN_PRIORITY); 47 pingThread.start(); 48 } 49 50 protected void doStop() throws Exception { 51 ServerNode.THE_NODE.removeConnector(getProtocol()); 52 UnicastRemoteObject.unexportObject(this, true); 53 } 54 55 protected synchronized void doDestroy() throws Exception { 56 super.doDestroy(); 57 serverFactory = null; 58 clientFactory = null; 59 } 60 61 public String getProtocol() throws RemoteException { 62 return "JRMPS"; 64 } 65 66 public void setSSLKeyFile(String SSLKeyFile) { 67 this.SSLKeyFile = SSLKeyFile; 68 } 69 70 public void setSSLTrustKeyFile(String SSLTrustKeyFile) { 71 this.SSLTrustKeyFile = SSLTrustKeyFile; 72 } 73 74 public void setPassword(String password) { 75 this.password = password; 76 } 77 78 public String getSSLKeyFile() { 79 return SSLKeyFile; 80 } 81 82 public String getSSLTrustKeyFile() { 83 return SSLTrustKeyFile; 84 } 85 86 public static void main(String [] args) { 87 88 } 89 } | Popular Tags |