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.deployment;
023:
024: import java.util.Map;
025:
026: import javax.management.ObjectName;
027:
028: import org.jboss.mx.util.ObjectNameFactory;
029: import org.jboss.system.ServiceMBeanSupport;
030:
031: import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
032:
033: /**
034: * An EAR Deployment
035: *
036: * @see EARDeployer
037: *
038: * @author <a href="mailto:adrian@jboss.com">Adrian.Brock</a>
039: * @version $Revision: 57209 $
040: *
041: * @jmx:mbean extends="org.jboss.system.ServiceMBean"
042: */
043: public class EARDeployment extends ServiceMBeanSupport implements
044: EARDeploymentMBean {
045: // Constants -----------------------------------------------------
046:
047: public static final String BASE_EAR_DEPLOYMENT_NAME = "jboss.j2ee:service=EARDeployment";
048:
049: public static final ObjectName EAR_DEPLOYMENT_QUERY_NAME = ObjectNameFactory
050: .create(BASE_EAR_DEPLOYMENT_NAME + ",*");
051:
052: // Attributes ----------------------------------------------------
053:
054: private DeploymentInfo deploymentInfo;
055: private ConcurrentReaderHashMap metadata = new ConcurrentReaderHashMap();
056:
057: // Static --------------------------------------------------------
058:
059: public static String getJMXName(J2eeApplicationMetaData metaData,
060: DeploymentInfo di) {
061: String name = metaData.getJMXName();
062: if (name == null)
063: name = BASE_EAR_DEPLOYMENT_NAME + ",url='" + di.shortName
064: + "'";
065: return name;
066: }
067:
068: // Constructors --------------------------------------------------
069:
070: public EARDeployment(final DeploymentInfo di) {
071: this .deploymentInfo = di;
072: }
073:
074: // Public --------------------------------------------------------
075:
076: public String getJMXName() throws Exception {
077: J2eeApplicationMetaData metaData = (J2eeApplicationMetaData) deploymentInfo.metaData;
078: return getJMXName(metaData, deploymentInfo);
079: }
080:
081: /**
082: * @jmx:managed-operation
083: *
084: */
085: public Object resolveMetaData(Object key) {
086: return metadata.get(key);
087: }
088:
089: /**
090: * @jmx:managed-operation
091: *
092: */
093: public void addMetaData(Object key, Object value) {
094: metadata.put(key, value);
095: }
096:
097: /**
098: * @jmx:managed-operation
099: *
100: */
101: public Map getMetaData() {
102: return metadata;
103: }
104: }
|