1 4 package com.tc.objectserver.control; 5 6 import com.tc.config.schema.setup.L2TVSConfigurationSetupManager; 7 import com.tc.exception.TCRuntimeException; 8 import com.tc.server.TCServer; 9 import com.tc.server.TCServerImpl; 10 11 public class IntraProcessServerControl extends ServerControlBase { 12 private boolean isStarted = false; 13 private TCServer server; 14 private final L2TVSConfigurationSetupManager configSetupManager; 15 16 public IntraProcessServerControl(L2TVSConfigurationSetupManager configSetupManager, String host) { 17 super(host, configSetupManager.dsoL2Config().listenPort().getInt(), configSetupManager.commonl2Config().jmxPort() 18 .getInt()); 19 this.configSetupManager = configSetupManager; 20 } 21 22 public void crash() throws Exception { 23 throw new UnsupportedOperationException ("Can't crash an in-process server."); 24 } 25 26 public synchronized void start(long timeout) throws Exception { 27 if (isRunning()) throw new RuntimeException ("Server is already running!"); 28 server = new TCServerImpl(this.configSetupManager); 29 server.start(); 30 isStarted = true; 31 } 32 33 public synchronized void shutdown() throws Exception { 34 if (!isStarted) return; 35 if (server == null) throw new AssertionError ("Server is null!"); 36 server.stop(); 37 isStarted = false; 38 } 39 40 public void attemptShutdown() throws Exception { 41 new Thread (getClass().getName() + ".attemptShutdown()") { 42 public void run() { 43 try { 44 shutdown(); 45 } catch (Exception e) { 46 throw new TCRuntimeException(e); 47 } 48 } 49 }.start(); 50 } 51 52 public void mergeSTDOUT() { 53 return; 54 } 55 56 public void mergeSTDERR() { 57 return; 58 } 59 60 public void waitUntilShutdown() throws Exception { 61 throw new UnsupportedOperationException (); 62 } 63 64 } 65 | Popular Tags |