001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.geronimo.farm.config;
021
022 import java.util.Collection;
023
024 import org.apache.geronimo.gbean.GBeanInfo;
025 import org.apache.geronimo.gbean.GBeanInfoBuilder;
026
027 /**
028 *
029 * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
030 */
031 public class BasicClusterInfo implements ClusterInfo {
032 private final String name;
033 private final Collection<NodeInfo> nodes;
034
035 public BasicClusterInfo(String name, Collection<NodeInfo> nodes) {
036 if (null == name) {
037 throw new IllegalArgumentException("name is required");
038 } else if (null == nodes) {
039 throw new IllegalArgumentException("nodes is required");
040 }
041 this.name = name;
042 this.nodes = nodes;
043 }
044
045 public String getName() {
046 return name;
047 }
048
049 public Collection<NodeInfo> getNodeInfos() {
050 return nodes;
051 }
052
053 public static final GBeanInfo GBEAN_INFO;
054
055 public static final String GBEAN_J2EE_TYPE = "ClusterInfo";
056 public static final String GBEAN_ATTR_CLUSTER_NAME = "name";
057 public static final String GBEAN_REF_NODE_INFOS = "NodeInfos";
058
059 static {
060 GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(BasicClusterInfo.class, GBEAN_J2EE_TYPE);
061 builder.addAttribute(GBEAN_ATTR_CLUSTER_NAME, String.class, true);
062 builder.addReference(GBEAN_REF_NODE_INFOS, NodeInfo.class, "NodeInfo");
063 builder.addInterface(ClusterInfo.class);
064 builder.setConstructor(new String[]{GBEAN_ATTR_CLUSTER_NAME, GBEAN_REF_NODE_INFOS});
065 GBEAN_INFO = builder.getBeanInfo();
066 }
067
068 public static GBeanInfo getGBeanInfo() {
069 return GBEAN_INFO;
070 }
071
072 }