RE: [Simpleweb-Support] How to get noticed when Simple Servergoesdown ...
Brought to you by:
niallg
From: bagas <ba...@in...> - 2004-05-11 10:18:53
|
I currently init Https like this : String source = "keystore"; char[] storePassword = {'p'}; char[] keyPassword = {'p'}; KeyStore store = KeyStore.getInstance("JKS"); store.load(new FileInputStream(source), storePassword); KeyManagerFactory keyFactory = KeyManagerFactory.getInstance("SunX509"); keyFactory.init(store, keyPassword); SSLContext sslContext = SSLContext.getInstance("SSLv3"); sslContext.init(keyFactory.getKeyManagers(), null, null); ServerSocketFactory socketFactory = sslContext.getServerSocketFactory(); Server.connection.connect(socketFactory.createServerSocket(sslPort)); If I want to use interface Monitor (like you advice earlier for ServerSocket), how can I do that? Thank you very much Regards, Rahmat Bagas Santoso > In this case what you could do is extend the ServerSocket, this may not > be the most elegant solution but it is quite easy. Try somthing like > public class MonitoredServerSocket extends ServerSocket { > private Monitor monitor; > public MonitoredServerSocket(Monitor monitor, int port) { > super(port); > this.monitor = monitor; > } > public Socket accept() throws IOException { > try { > return super.accept(); > } catch(IOException e){ > monitor.notifyException(this, e); > throw e; > } > } > } > public interface Monitor { > > public void notifyException(ServerSocket sock, IOException e); > } |