blob: 72b761ee1dd8b2c3a058d2b1658eba0abcd1eeb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/**************************************************************************
* StandardServer
*
* $Revision: 1.47 $
* $Date: 2005/04/28 13:49:43 $
*
* Copyright (C) 2001 CERN - European Organization for Nuclear Research
* All rights reserved.
**************************************************************************/
package com.c2kernel.process;
import org.tanukisoftware.wrapper.WrapperListener;
import org.tanukisoftware.wrapper.WrapperManager;
import com.c2kernel.utils.Logger;
/**************************************************************************
* Base class for all servers i.e. c2k processes that serve Entities
*
* @author $Author: abranson $ $Date: 2005/04/28 13:49:43 $
* @version $Revision: 1.47 $
**************************************************************************/
public class StandardServer extends AbstractMain implements WrapperListener
{
protected static StandardServer server;
/**************************************************************************
* C2KRootPOA suitable for Factory objects
**************************************************************************/
/**************************************************************************
* void StandardInitalisation( String[] )
*
* Set-up calls to ORB, POA and Factorys, both optional and required.
**************************************************************************/
protected void standardInitialisation( String[] args )
throws Exception
{
// read args and init Gateway
standardSetUp(args);
// connect to LDAP as root
Gateway.connect();
//start console
Logger.initConsole("ItemServer");
//initialize the server objects
Gateway.startServer();
Logger.msg(5, "StandardServer::standardInitialisation - complete.");
}
/**************************************************************************
* Sets up and runs and item server
**************************************************************************/
@Override
public Integer start(String[] args)
{
try
{
//initialise everything
standardInitialisation( args );
}
catch( Exception ex )
{
Logger.error(ex);
Logger.die("Startup failed");
}
return null;
}
public static void main(String[] args) {
server = new StandardServer();
AbstractMain.runningAsWrapper = true;
WrapperManager.start( server, args );
}
/**
*
*/
@Override
public void controlEvent(int event) {
if (WrapperManager.isControlledByNativeWrapper()) {
// The Wrapper will take care of this event
} else {
// We are not being controlled by the Wrapper, so
// handle the event ourselves.
if ((event == WrapperManager.WRAPPER_CTRL_C_EVENT) ||
(event == WrapperManager.WRAPPER_CTRL_CLOSE_EVENT) ||
(event == WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT)){
WrapperManager.stop(0);
}
}
}
/**************************************************************************
* Closes all listeners, quits the VM.
* This method should be called to kill the server process
* e.g. from the NT service wrapper
**************************************************************************/
@Override
public int stop(int arg0) {
try
{
// close gateway
standardTearDown();
}
catch( Exception ex )
{
Logger.error(ex);
return 1;
}
Logger.msg("StandardServer::shutdown - complete. ");
return 0;
}
}
|