summaryrefslogtreecommitdiff
path: root/java/src/IceGrid/TreeNode/Application.java
blob: 84ee0c1f9f5cae423888f3b379f7e6df2786fb30 (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
// **********************************************************************
//
// 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 IceGrid.ApplicationDescriptor;

class Application extends Parent
{
    //
    // Builds the application and all its subtrees
    //
    Application(ApplicationDescriptor descriptor, NodeViewRoot nodeViewRoot)
    {
	_nodeViewRoot = nodeViewRoot;
	update(descriptor, false);
    }

    void update(ApplicationDescriptor newDescriptor, boolean fireEvent)
    {
	assert(newDescriptor != null);
	clearChildren();
	
	_descriptor = newDescriptor;

	_serverTemplates = new ServerTemplates(_descriptor.serverTemplates, _descriptor.serviceTemplates);
	addChild(_serverTemplates);
	_serverTemplates.addParent(this); // no-op when this is not yet attached to its root
	                                  // (i.e. during construction)
	
	_serviceTemplates = new ServiceTemplates(_descriptor.serviceTemplates);
	addChild(_serviceTemplates);
	_serviceTemplates.addParent(this);

	_nodeVars = new NodeVars(_descriptor.nodes);
	addChild(_nodeVars);
	_nodeVars.addParent(this);
	
	_serverInstances = new ServerInstances(_descriptor.servers,
					       _descriptor.serverTemplates, 
					       _descriptor.serviceTemplates,
					       _nodeViewRoot);
	addChild(_serverInstances);
	_serverInstances.addParent(this);

	if(fireEvent)
	{
	    //    fireStructureChanged(this);
	}
    }
 
    public String toString()
    {
	return _descriptor.name;
    }

    
    private ApplicationDescriptor _descriptor;
    private NodeViewRoot _nodeViewRoot;

    //
    // Children
    //
    private ServerTemplates _serverTemplates;
    private ServiceTemplates _serviceTemplates;
    private NodeVars _nodeVars;
    private ServerInstances _serverInstances;
  
}