KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > pojo > test > NetworkDomain


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.pojo.test;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.List JavaDoc;
11
12 /**
13  * <p>Top level sample Pojo for a sample network management software. It is a logical object that can be presented to
14  * the user. Example of domain is like temperature or vibration sensor domains.</p>
15  * <p>This object is used to illustrate the pojo cache capability of PojoCache. Note the absence of <code>Serializable</code>
16  * interface.</p>
17  *
18  * @author <a HREF="mailto:ben.wang@jboss.com">Ben Wang</a>
19  */

20 // We are using JDK1.5 annotation.
21
@org.jboss.cache.pojo.annotation.Replicable
22 public class NetworkDomain
23 {
24    String JavaDoc name_;
25    // The associated nodes from the elements
26
List JavaDoc nodes_;
27    // All the elements to be managed in this domain
28
List JavaDoc elements_;
29    // Adminstration such id, pass
30
NetworkAdmin admin_;
31
32    static final int TEMP_SENSOR = 0;
33    static final int VIBRATION_SENSOR = 1;
34
35    public String JavaDoc getName()
36    {
37       return name_;
38    }
39
40    public void setName(String JavaDoc name)
41    {
42       name_ = name;
43    }
44
45    public List JavaDoc getNodes()
46    {
47       return nodes_;
48    }
49
50    protected void setNodes(List JavaDoc nodes)
51    {
52       nodes_ = nodes;
53    }
54
55    public List JavaDoc getElements()
56    {
57       return nodes_;
58    }
59
60    protected void addNode(NetworkNode node)
61    {
62       if (nodes_ == null)
63          nodes_ = new ArrayList JavaDoc();
64
65       nodes_.add(node);
66    }
67
68    public void addElement(NetworkElement element)
69    {
70       if (elements_ == null)
71          elements_ = new ArrayList JavaDoc();
72
73       elements_.add(element);
74
75       if (element.getParentNode() == null)
76          throw new RuntimeException JavaDoc("NetworkDomain.addElement(): parent node of element is null: " + element);
77
78       addNode(element.getParentNode());
79    }
80
81    public NetworkAdmin getAdmin()
82    {
83       return admin_;
84    }
85
86    public void setAdmin(NetworkAdmin admin)
87    {
88       admin_ = admin;
89    }
90
91    public String JavaDoc toString()
92    {
93       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
94       sb.append("* Damain * name= ").append(getName()).append(" + admin +: ").append(getAdmin());
95       sb.append(" + nodes +: ").append(getNodes());
96       return sb.toString();
97    }
98 }
99
Popular Tags