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