001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mx.server.registry;
023:
024: import java.util.Map;
025:
026: import javax.management.ObjectName;
027:
028: import org.jboss.mx.server.MBeanInvoker;
029: import org.jboss.mx.server.ServerConstants;
030:
031: /**
032: * info@todo this docs
033: *
034: * @see org.jboss.mx.server.registry.MBeanRegistry
035: * @see org.jboss.mx.server.MBeanServerImpl
036: *
037: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
038: * @version $Revision: 57200 $
039: */
040: public class MBeanEntry implements ServerConstants {
041: // Attributes ----------------------------------------------------
042:
043: /**
044: * The registered object name of the mbean
045: */
046: private ObjectName objectName = null;
047:
048: /**
049: * The class name of the mbean
050: */
051: private String resourceClassName = null;
052:
053: /**
054: * The object used to invoke the mbean
055: */
056: private MBeanInvoker invoker = null;
057:
058: /**
059: * The mbean registered
060: */
061: private Object resource = null;
062:
063: /**
064: * The context classloader of the mbean
065: */
066: private ClassLoader cl = null;
067:
068: /**
069: * The value map of the mbean
070: */
071: private Map valueMap = null;
072:
073: // Constructors --------------------------------------------------
074:
075: /**
076: * Construct a new mbean registration entry.
077: *
078: * @param objectName the name with which the mbean is registered
079: * @param invoker the dynamic mbean used to invoke the mbean
080: * @param resource the mbean
081: * @param valueMap any other information to include in the registration
082: */
083: public MBeanEntry(ObjectName objectName, MBeanInvoker invoker,
084: Object resource, Map valueMap) {
085: this .objectName = objectName;
086: this .invoker = invoker;
087: this .resourceClassName = resource.getClass().getName();
088: this .resource = resource;
089: this .valueMap = valueMap;
090:
091: // Adrian: Unpack the classloader because this is used alot
092: if (valueMap != null)
093: this .cl = (ClassLoader) valueMap.get(CLASSLOADER);
094: }
095:
096: // Public --------------------------------------------------------
097:
098: /**
099: * Retrieve the object name with the mbean is registered.
100: *
101: * @return the object name
102: */
103: public ObjectName getObjectName() {
104: return objectName;
105: }
106:
107: /** A protected method used to set the entry object name when access
108: * to the entry is needed before the ultimate name under which the
109: * mbean is registered is known.
110: *
111: * @param objectName - the object name under which the mbean is registered
112: */
113: protected void setObjectName(ObjectName objectName) {
114: this .objectName = objectName;
115: }
116:
117: /**
118: * Retrieve the invoker for the mbean.
119: *
120: * @return the invoker
121: */
122: public MBeanInvoker getInvoker() {
123: return invoker;
124: }
125:
126: /**
127: * Retrieve the class name for the mbean.
128: *
129: * @return the class name
130: */
131: public String getResourceClassName() {
132: return resourceClassName;
133: }
134:
135: /**
136: * Retrieve the class name for the mbean.
137: *
138: * @param resourceClassName the class name
139: */
140: public void setResourceClassName(String resourceClassName) {
141: this .resourceClassName = resourceClassName;
142: }
143:
144: /**
145: * Retrieve the mbean.
146: *
147: * @return the mbean
148: */
149: public Object getResourceInstance() {
150: return resource;
151: }
152:
153: /**
154: * Retrieve the context class loader with which to invoke the mbean.
155: *
156: * @return the class loader
157: */
158: public ClassLoader getClassLoader() {
159: return cl;
160: }
161:
162: /**
163: * Retrieve a value from the map.
164: *
165: * @return key the key to value
166: * @return the value or null if there is no entry
167: */
168: public Object getValue(String key) {
169: if (valueMap != null)
170: return valueMap.get(key);
171: return null;
172: }
173: }
|