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