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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
// **********************************************************************
//
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
package IceGrid.TreeNode;
import javax.swing.JPopupMenu;
import javax.swing.JPanel;
import IceGrid.TreeModelI;
import IceGrid.IceBoxDescriptor;
import IceGrid.ServerInstanceDescriptor;
import IceGrid.ServerState;
import IceGrid.TemplateDescriptor;
class ServerInstance extends Parent
{
public JPopupMenu getPopupMenu()
{
return null;
}
public JPanel getProperties(int view)
{
return null;
}
//
// Builds the server instance and all its sub-tree
//
ServerInstance(ServerInstanceDescriptor descriptor,
NodeViewRoot nodeViewRoot,
boolean fireNodeViewEvent)
{
super(descriptor.descriptor.name);
_state = ServerState.Inactive;
_pid = 0;
_nodeViewRoot = nodeViewRoot;
rebuild(descriptor, fireNodeViewEvent);
}
//
// Update the server instance and all its subtree
//
void rebuild(ServerInstanceDescriptor newDescriptor,
boolean fireNodeViewEvent)
{
assert(newDescriptor != null);
clearChildren();
//
// First check if my node changed [node view]
// For the application view, the only way a server instance can change application
// is by being removed and then re-added (i.e. not with an update)
//
boolean newNode = false;
if(_descriptor == null)
{
newNode = true;
}
else if(_descriptor.node != newDescriptor.node)
{
newNode = true;
//
// Remove from existing node
//
CommonBase parent = _parents[TreeModelI.NODE_VIEW];
assert(parent != null); // must be connected
removeParent(parent);
((Parent)parent).removeChild(this);
}
_descriptor = newDescriptor;
if(_descriptor.descriptor instanceof IceBoxDescriptor)
{
_iceBoxDescriptor = (IceBoxDescriptor)_descriptor.descriptor;
_serviceInstances = new ServiceInstances(_iceBoxDescriptor.services);
addChild(_serviceInstances);
_serviceInstances.addParent(this); // no-op when newNode == true
}
else
{
_iceBoxDescriptor = null;
}
_adapters = new Adapters(_descriptor.descriptor.adapters, false);
addChild(_adapters);
_adapters.addParent(this); // no-op when newNode == true
_dbEnvs = new DbEnvs(_descriptor.descriptor.dbEnvs, false);
addChild(_dbEnvs);
_dbEnvs.addParent(this); // no-op when newNode == true
if(newNode)
{
Node node = _nodeViewRoot.findNode(_descriptor.node);
addParent(node); // propagates to children
node.addChild(this, fireNodeViewEvent);
}
}
void updateDynamicInfo(ServerState state, int pid)
{
if(state != _state)
{
_state = state;
_pid = pid;
//
// Change the node representation in all views
//
fireNodeChangedEvent(this);
}
else
{
//
// We don't show the pid on the GUI, so no need
// to fire any event.
//
_pid = pid;
}
}
public String toString()
{
String result = _descriptor.descriptor.name;
if(!_descriptor.template.equals(""))
{
result += ": " + templateLabel(_descriptor.template,
_descriptor.parameterValues.values());
}
return result;
}
private NodeViewRoot _nodeViewRoot;
private ServerState _state;
private int _pid;
private ServerInstanceDescriptor _descriptor;
private TemplateDescriptor _templateDescriptor;
private IceBoxDescriptor _iceBoxDescriptor;
//
// Children
//
private ServiceInstances _serviceInstances;
private Adapters _adapters;
private DbEnvs _dbEnvs;
}
|