KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > control > IntraProcessServerControl


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc 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 JavaDoc {
23     throw new UnsupportedOperationException JavaDoc("Can't crash an in-process server.");
24   }
25
26   public synchronized void start(long timeout) throws Exception JavaDoc {
27     if (isRunning()) throw new RuntimeException JavaDoc("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 JavaDoc {
34     if (!isStarted) return;
35     if (server == null) throw new AssertionError JavaDoc("Server is null!");
36     server.stop();
37     isStarted = false;
38   }
39
40   public void attemptShutdown() throws Exception JavaDoc {
41     new Thread JavaDoc(getClass().getName() + ".attemptShutdown()") {
42       public void run() {
43         try {
44           shutdown();
45         } catch (Exception JavaDoc 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 JavaDoc {
61     throw new UnsupportedOperationException JavaDoc();
62   }
63
64 }
65
Popular Tags