01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.geronimo.farm.config;
21:
22: import java.util.Collection;
23:
24: import org.apache.geronimo.gbean.GBeanInfo;
25: import org.apache.geronimo.gbean.GBeanInfoBuilder;
26:
27: /**
28: *
29: * @version $Rev:$ $Date:$
30: */
31: public class BasicClusterInfo implements ClusterInfo {
32: private final String name;
33: private final Collection<NodeInfo> nodes;
34:
35: public BasicClusterInfo(String name, Collection<NodeInfo> nodes) {
36: if (null == name) {
37: throw new IllegalArgumentException("name is required");
38: } else if (null == nodes) {
39: throw new IllegalArgumentException("nodes is required");
40: }
41: this .name = name;
42: this .nodes = nodes;
43: }
44:
45: public String getName() {
46: return name;
47: }
48:
49: public Collection<NodeInfo> getNodeInfos() {
50: return nodes;
51: }
52:
53: public static final GBeanInfo GBEAN_INFO;
54:
55: public static final String GBEAN_J2EE_TYPE = "ClusterInfo";
56: public static final String GBEAN_ATTR_CLUSTER_NAME = "name";
57: public static final String GBEAN_REF_NODE_INFOS = "NodeInfos";
58:
59: static {
60: GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(
61: BasicClusterInfo.class, GBEAN_J2EE_TYPE);
62: builder.addAttribute(GBEAN_ATTR_CLUSTER_NAME, String.class,
63: true);
64: builder.addReference(GBEAN_REF_NODE_INFOS, NodeInfo.class,
65: "NodeInfo");
66: builder.addInterface(ClusterInfo.class);
67: builder.setConstructor(new String[] { GBEAN_ATTR_CLUSTER_NAME,
68: GBEAN_REF_NODE_INFOS });
69: GBEAN_INFO = builder.getBeanInfo();
70: }
71:
72: public static GBeanInfo getGBeanInfo() {
73: return GBEAN_INFO;
74: }
75:
76: }
|