0001: /**
0002: * JOnAS: Java(TM) Open Application Server
0003: * Copyright (C) 1999-2004 Bull S.A.
0004: * Contact: jonas-team@objectweb.org
0005: *
0006: * This library is free software; you can redistribute it and/or
0007: * modify it under the terms of the GNU Lesser General Public
0008: * License as published by the Free Software Foundation; either
0009: * version 2.1 of the License, or any later version.
0010: *
0011: * This library is distributed in the hope that it will be useful,
0012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014: * Lesser General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU Lesser General Public
0017: * License along with this library; if not, write to the Free Software
0018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
0019: * USA
0020: *
0021: * --------------------------------------------------------------------------
0022: * $Id: J2eeObjectName.java 9899 2006-12-15 10:32:43Z danesa $
0023: * --------------------------------------------------------------------------
0024: */package org.objectweb.jonas.jmx;
0025:
0026: import java.util.ArrayList;
0027: import java.util.Collections;
0028: import java.util.Iterator;
0029: import java.util.List;
0030:
0031: import javax.management.MBeanServer;
0032: import javax.management.MBeanServerConnection;
0033: import javax.management.ObjectName;
0034:
0035: /**
0036: * A set of static methods used to create object names for J2EE managed object.
0037: * This implementation is conformant to the JSR77.
0038: * @author Adriana Danes
0039: * @author Michel-Ange Anton
0040: */
0041: public class J2eeObjectName {
0042:
0043: private static MBeanServerConnection localManagementRepr = null;
0044:
0045: /**
0046: * private constructor
0047: */
0048: private J2eeObjectName() {
0049: }
0050:
0051: // --------------------------------------------------------- Constants
0052: /**
0053: * Constant used in pattern ObjectNames
0054: */
0055: public static final String ALL = "*";
0056:
0057: /**
0058: * Constant used in ObjectNames of standalone modules
0059: */
0060: public static final String NONE = "none";
0061:
0062: // --------------------------------------------------------- Public Methods
0063: /**
0064: * @param pObjectName Stringified ObjectName
0065: * @return ObjectName instance corresponding to the received argument
0066: */
0067: public static ObjectName getObjectName(String pObjectName) {
0068: try {
0069: return ObjectName.getInstance(pObjectName);
0070: } catch (javax.management.MalformedObjectNameException e) {
0071: // this should never occur
0072: return null;
0073: }
0074: }
0075:
0076: /**
0077: * Return the list of <code>ObjectName</code> gotten by the query in the
0078: * current MbeanServer.
0079: * @param pOn Query Mbeans to search
0080: * @return The list of <code>ObjectName</code>
0081: * @throws ManagementException
0082: */
0083: public static List queryObjectNames(ObjectName pOn)
0084: throws ManagementException {
0085: ArrayList al = new ArrayList();
0086: if (localManagementRepr == null) {
0087: localManagementRepr = ManagementReprFactory
0088: .getLocalManagementRepr();
0089: if (localManagementRepr == null) {
0090: return al;
0091: }
0092: }
0093: Iterator itNames = ((MBeanServer) localManagementRepr)
0094: .queryNames(pOn, null).iterator();
0095: while (itNames.hasNext()) {
0096: al.add(itNames.next());
0097: }
0098: return al;
0099: }
0100:
0101: /**
0102: * Return the list of ObjectName's String gotten by the query in the current
0103: * MbeanServer.
0104: * @param pOn Query Mbeans to search
0105: * @return A list of <code>ObjectName</code> convert to String
0106: * @throws ManagementException
0107: */
0108: public static List queryStrings(ObjectName pOn)
0109: throws ManagementException {
0110: ArrayList al = new ArrayList();
0111: if (localManagementRepr == null) {
0112: localManagementRepr = ManagementReprFactory
0113: .getLocalManagementRepr();
0114: if (localManagementRepr == null) {
0115: return al;
0116: }
0117: }
0118: Iterator itNames = ((MBeanServer) localManagementRepr)
0119: .queryNames(pOn, null).iterator();
0120: while (itNames.hasNext()) {
0121: ObjectName item = (ObjectName) itNames.next();
0122: al.add(item.toString());
0123: }
0124: Collections.sort(al);
0125: return al;
0126: }
0127:
0128: /**
0129: * @param pDomain The Domain name
0130: * @return ObjectName for a J2EEDomain MBean
0131: */
0132: public static ObjectName J2EEDomain(String pDomain) {
0133: try {
0134: StringBuffer sb = new StringBuffer(pDomain);
0135: sb.append(":j2eeType=J2EEDomain");
0136: sb.append(",name=");
0137: sb.append(pDomain);
0138: return new ObjectName(sb.toString());
0139: } catch (javax.management.MalformedObjectNameException e) {
0140: // this should never occur
0141: return null;
0142: }
0143: }
0144:
0145: /**
0146: * Return an ObjectName for a J2EEDomain MBean corresponding to a Cluster
0147: * directly attached to the domain (root cluster)
0148: * @param pDomain The domain name
0149: * @param pCluster The cluster name
0150: * @return ObjectName for a root cluster in the domain
0151: */
0152: public static ObjectName J2EECluster(String pDomain, String pCluster) {
0153: try {
0154: StringBuffer sb = new StringBuffer(pDomain);
0155: sb.append(":j2eeType=J2EEDomain");
0156: sb.append(",name=");
0157: sb.append(pDomain);
0158: sb.append(",clusterName=");
0159: sb.append(pCluster);
0160: sb.append(",parentClusterName=");
0161: sb.append(pDomain);
0162: return new ObjectName(sb.toString());
0163: } catch (javax.management.MalformedObjectNameException e) {
0164: // this should never occur
0165: return null;
0166: }
0167: }
0168:
0169: /**
0170: * Return an ObjectName for a J2EEDomain MBean corresponding to a Cluster
0171: * who's parent is not determined
0172: * @param pDomain The domain name
0173: * @param pCluster The cluster name
0174: * @return ObjectName for all the cluster having the given cluster name
0175: */
0176: public static ObjectName J2EEClusters(String pDomain,
0177: String pCluster) {
0178: try {
0179: StringBuffer sb = new StringBuffer(pDomain);
0180: sb.append(":j2eeType=J2EEDomain");
0181: sb.append(",name=");
0182: sb.append(pDomain);
0183: sb.append(",clusterName=");
0184: sb.append(pCluster);
0185: sb.append(",");
0186: sb.append(ALL);
0187: return new ObjectName(sb.toString());
0188: } catch (javax.management.MalformedObjectNameException e) {
0189: // this should never occur
0190: return null;
0191: }
0192: }
0193:
0194: /**
0195: * Return an ObjectName for a J2EEDomain MBean corresponding to a sub-cluster
0196: * attached to a parent-cluster
0197: * @param pDomain The domain name
0198: * @param pCluster The cluster name
0199: * @param pParentCluster The parent cluster name
0200: * @return
0201: */
0202: public static ObjectName J2EECluster(String pDomain,
0203: String pCluster, String pParentCluster) {
0204: try {
0205: StringBuffer sb = new StringBuffer(pDomain);
0206: sb.append(":j2eeType=J2EEDomain");
0207: sb.append(",name=");
0208: sb.append(pDomain);
0209: sb.append(",clusterName=");
0210: sb.append(pCluster);
0211: sb.append(",parentClusterName=");
0212: sb.append(pParentCluster);
0213: return new ObjectName(sb.toString());
0214: } catch (javax.management.MalformedObjectNameException e) {
0215: // this should never occur
0216: return null;
0217: }
0218: }
0219:
0220: public static ObjectName J2EEDomains() {
0221: try {
0222: StringBuffer sb = new StringBuffer(ALL);
0223: sb.append(":j2eeType=J2EEDomain");
0224: sb.append(",");
0225: sb.append(ALL);
0226: return new ObjectName(sb.toString());
0227: } catch (javax.management.MalformedObjectNameException e) {
0228: // this should never occur
0229: return null;
0230: }
0231: }
0232:
0233: public static ObjectName J2EEServers() {
0234: try {
0235: StringBuffer sb = new StringBuffer(ALL);
0236: sb.append(":j2eeType=J2EEServer");
0237: sb.append(",");
0238: sb.append(ALL);
0239: return new ObjectName(sb.toString());
0240: } catch (javax.management.MalformedObjectNameException e) {
0241: // this should never occur
0242: return null;
0243: }
0244: }
0245:
0246: public static ObjectName J2EEServers(String pDomain) {
0247: try {
0248: StringBuffer sb = new StringBuffer(pDomain);
0249: sb.append(":j2eeType=J2EEServer");
0250: sb.append(",");
0251: sb.append(ALL);
0252: return new ObjectName(sb.toString());
0253: } catch (javax.management.MalformedObjectNameException e) {
0254: // this should never occur
0255: return null;
0256: }
0257: }
0258:
0259: public static ObjectName J2EEServer(String pDomain, String pServer) {
0260: try {
0261: StringBuffer sb = new StringBuffer(pDomain);
0262: sb.append(":j2eeType=J2EEServer");
0263: sb.append(",name=");
0264: sb.append(pServer);
0265: return new ObjectName(sb.toString());
0266: } catch (javax.management.MalformedObjectNameException e) {
0267: // this should never occur
0268: return null;
0269: }
0270: }
0271:
0272: public static ObjectName JVM(String pDomain, String pServer,
0273: String pName) {
0274: try {
0275: StringBuffer sb = new StringBuffer(pDomain);
0276: sb.append(":j2eeType=JVM");
0277: sb.append(",name=");
0278: sb.append(pName);
0279: sb.append(",J2EEServer=");
0280: sb.append(pServer);
0281: return new ObjectName(sb.toString());
0282: } catch (javax.management.MalformedObjectNameException e) {
0283: // this should never occur
0284: return null;
0285: }
0286: }
0287:
0288: public static ObjectName JVMs(String pDomain, String pServer) {
0289: try {
0290: StringBuffer sb = new StringBuffer(pDomain);
0291: sb.append(":j2eeType=JVM");
0292: sb.append(",J2EEServer=");
0293: sb.append(pServer);
0294: sb.append(",");
0295: sb.append(ALL);
0296: return new ObjectName(sb.toString());
0297: } catch (javax.management.MalformedObjectNameException e) {
0298: // this should never occur
0299: return null;
0300: }
0301: }
0302:
0303: public static ObjectName J2EEApplications() {
0304: try {
0305: StringBuffer sb = new StringBuffer(ALL);
0306: sb.append(":j2eeType=J2EEApplication");
0307: sb.append(",");
0308: sb.append(ALL);
0309: return new ObjectName(sb.toString());
0310: } catch (javax.management.MalformedObjectNameException e) {
0311: // this should never occur
0312: return null;
0313: }
0314: }
0315:
0316: public static ObjectName J2EEApplications(String pDomain) {
0317: try {
0318: StringBuffer sb = new StringBuffer(pDomain);
0319: sb.append(":j2eeType=J2EEApplication");
0320: sb.append(",");
0321: sb.append(ALL);
0322: return new ObjectName(sb.toString());
0323: } catch (javax.management.MalformedObjectNameException e) {
0324: // this should never occur
0325: return null;
0326: }
0327: }
0328:
0329: public static ObjectName J2EEApplications(String pDomain,
0330: String pServer) {
0331: try {
0332: StringBuffer sb = new StringBuffer(pDomain);
0333: sb.append(":j2eeType=J2EEApplication");
0334: sb.append(",J2EEServer=");
0335: sb.append(pServer);
0336: sb.append(",");
0337: sb.append(ALL);
0338: return new ObjectName(sb.toString());
0339: } catch (javax.management.MalformedObjectNameException e) {
0340: // this should never occur
0341: return null;
0342: }
0343: }
0344:
0345: public static ObjectName J2EEApplication(String pDomain,
0346: String pServer, String pName) {
0347: try {
0348: StringBuffer sb = new StringBuffer(pDomain);
0349: sb.append(":j2eeType=J2EEApplication");
0350: sb.append(",name=");
0351: sb.append(pName);
0352: sb.append(",J2EEServer=");
0353: sb.append(pServer);
0354: return new ObjectName(sb.toString());
0355: } catch (javax.management.MalformedObjectNameException e) {
0356: // this should never occur
0357: return null;
0358: }
0359: }
0360:
0361: /**
0362: * Create generic name for all AppClientModules deployed in a given server, possibly belonging
0363: * to a given J2EE application
0364: * @param pDomain domain name
0365: * @param pServer server name
0366: * @param pApplication application name
0367: * @return generic name for the AppClientModules in a given server and application
0368: */
0369: public static ObjectName getAppClientModules(String pDomain,
0370: String pServer, String pApplication) {
0371: try {
0372: StringBuffer sb = new StringBuffer(pDomain);
0373: sb.append(":j2eeType=AppClientModule");
0374: sb.append(",J2EEApplication=");
0375: if ((pApplication != null) && (pApplication.length() > 0)) {
0376: sb.append(pApplication);
0377: } else {
0378: sb.append(NONE);
0379: }
0380: sb.append(",J2EEServer=");
0381: sb.append(pServer);
0382: sb.append(",");
0383: sb.append(ALL);
0384: return new ObjectName(sb.toString());
0385: } catch (javax.management.MalformedObjectNameException e) {
0386: // this should never occur
0387: return null;
0388: }
0389: }
0390:
0391: /**
0392: * Create ObjectName for an AppClientModule
0393: * @param pDomain domain name
0394: * @param pServer server name
0395: * @param pApplication J2ee application name
0396: * @param pName module name
0397: * @return ObjectName for an AppClientModule
0398: */
0399: public static ObjectName getAppClientModule(String pDomain,
0400: String pServer, String pApplication, String pName) {
0401: try {
0402: StringBuffer sb = new StringBuffer(pDomain);
0403: sb.append(":j2eeType=AppClientModule");
0404: sb.append(",name=");
0405: sb.append(pName);
0406: sb.append(",J2EEApplication=");
0407: if ((pApplication != null) && (pApplication.length() > 0)) {
0408: sb.append(pApplication);
0409: } else {
0410: sb.append(NONE);
0411: }
0412: sb.append(",J2EEServer=");
0413: sb.append(pServer);
0414: return new ObjectName(sb.toString());
0415: } catch (javax.management.MalformedObjectNameException e) {
0416: // this should never occur
0417: return null;
0418: }
0419: }
0420:
0421: public static ObjectName getEJBModules() {
0422: try {
0423: StringBuffer sb = new StringBuffer(ALL);
0424: sb.append(":j2eeType=EJBModule");
0425: sb.append(",");
0426: sb.append(ALL);
0427: return new ObjectName(sb.toString());
0428: } catch (javax.management.MalformedObjectNameException e) {
0429: // this should never occur
0430: return null;
0431: }
0432: }
0433:
0434: public static ObjectName getEJBModules(String pDomain) {
0435: try {
0436: StringBuffer sb = new StringBuffer(pDomain);
0437: sb.append(":j2eeType=EJBModule");
0438: sb.append(",");
0439: sb.append(ALL);
0440: return new ObjectName(sb.toString());
0441: } catch (javax.management.MalformedObjectNameException e) {
0442: // this should never occur
0443: return null;
0444: }
0445: }
0446:
0447: public static ObjectName getEJBModules(String pDomain,
0448: String pServer) {
0449: try {
0450: StringBuffer sb = new StringBuffer(pDomain);
0451: sb.append(":j2eeType=EJBModule");
0452: sb.append(",J2EEServer=");
0453: sb.append(pServer);
0454: sb.append(",");
0455: sb.append(ALL);
0456: return new ObjectName(sb.toString());
0457: } catch (javax.management.MalformedObjectNameException e) {
0458: // this should never occur
0459: return null;
0460: }
0461: }
0462:
0463: public static ObjectName getEJBModules(String pDomain,
0464: String pServer, String pApplication) {
0465: try {
0466: StringBuffer sb = new StringBuffer(pDomain);
0467: sb.append(":j2eeType=EJBModule");
0468: sb.append(",J2EEApplication=");
0469: if ((pApplication != null) && (pApplication.length() > 0)) {
0470: sb.append(pApplication);
0471: } else {
0472: sb.append(NONE);
0473: }
0474: sb.append(",J2EEServer=");
0475: sb.append(pServer);
0476: sb.append(",");
0477: sb.append(ALL);
0478: return new ObjectName(sb.toString());
0479: } catch (javax.management.MalformedObjectNameException e) {
0480: // this should never occur
0481: return null;
0482: }
0483: }
0484:
0485: /**
0486: * Create ObjectName for an EJB Module
0487: * @param pDomain domain name
0488: * @param pServer server name
0489: * @param pApplication j2eeapplication name
0490: * @param pName module name - currently the container name
0491: * @return
0492: */
0493: public static ObjectName getEJBModule(String pDomain,
0494: String pServer, String pApplication, String pName) {
0495: try {
0496: StringBuffer sb = new StringBuffer(pDomain);
0497: sb.append(":j2eeType=EJBModule");
0498: sb.append(",name=");
0499: sb.append(pName);
0500: sb.append(",J2EEApplication=");
0501: if ((pApplication != null) && (pApplication.length() > 0)) {
0502: sb.append(pApplication);
0503: } else {
0504: sb.append(NONE);
0505: }
0506: sb.append(",J2EEServer=");
0507: sb.append(pServer);
0508: return new ObjectName(sb.toString());
0509: } catch (javax.management.MalformedObjectNameException e) {
0510: // this should never occur
0511: return null;
0512: }
0513: }
0514:
0515: public static ObjectName getEntityBean(String pDomain,
0516: String pModule, String pServer, String pApplication,
0517: String pName) {
0518: try {
0519: StringBuffer sb = new StringBuffer(pDomain);
0520: sb.append(":j2eeType=EntityBean");
0521: sb.append(",name=");
0522: sb.append(pName);
0523: sb.append(",EJBModule=");
0524: sb.append(pModule);
0525: sb.append(",J2EEApplication=");
0526: if ((pApplication != null) && (pApplication.length() > 0)) {
0527: sb.append(pApplication);
0528: } else {
0529: sb.append(NONE);
0530: }
0531: sb.append(",J2EEServer=");
0532: sb.append(pServer);
0533: return new ObjectName(sb.toString());
0534: } catch (javax.management.MalformedObjectNameException e) {
0535: // this should never occur
0536: return null;
0537: }
0538: }
0539:
0540: public static ObjectName getEntityBeans(String pDomain) {
0541: try {
0542: StringBuffer sb = new StringBuffer(pDomain);
0543: sb.append(":j2eeType=EntityBean");
0544: sb.append(",");
0545: sb.append(ALL);
0546: return new ObjectName(sb.toString());
0547: } catch (javax.management.MalformedObjectNameException e) {
0548: // this should never occur
0549: return null;
0550: }
0551: }
0552:
0553: public static ObjectName getEntityBeans(String pDomain,
0554: String pModule) {
0555: try {
0556: StringBuffer sb = new StringBuffer(pDomain);
0557: sb.append(":j2eeType=EntityBean");
0558: sb.append(",EJBModule=");
0559: sb.append(pModule);
0560: sb.append(",");
0561: sb.append(ALL);
0562: return new ObjectName(sb.toString());
0563: } catch (javax.management.MalformedObjectNameException e) {
0564: // this should never occur
0565: return null;
0566: }
0567: }
0568:
0569: public static ObjectName getEntityBeans(String pDomain,
0570: String pModule, String pServer) {
0571: try {
0572: StringBuffer sb = new StringBuffer(pDomain);
0573: sb.append(":j2eeType=EntityBean");
0574: sb.append(",EJBModule=");
0575: sb.append(pModule);
0576: sb.append(",J2EEServer=");
0577: sb.append(pServer);
0578: sb.append(",");
0579: sb.append(ALL);
0580: return new ObjectName(sb.toString());
0581: } catch (javax.management.MalformedObjectNameException e) {
0582: // this should never occur
0583: return null;
0584: }
0585: }
0586:
0587: public static ObjectName getStatefulSessionBean(String pDomain,
0588: String pModule, String pServer, String pApplication,
0589: String pName) {
0590: try {
0591: StringBuffer sb = new StringBuffer(pDomain);
0592: sb.append(":j2eeType=StatefulSessionBean");
0593: sb.append(",name=");
0594: sb.append(pName);
0595: sb.append(",EJBModule=");
0596: sb.append(pModule);
0597: sb.append(",J2EEApplication=");
0598: if ((pApplication != null) && (pApplication.length() > 0)) {
0599: sb.append(pApplication);
0600: } else {
0601: sb.append(NONE);
0602: }
0603: sb.append(",J2EEServer=");
0604: sb.append(pServer);
0605: return new ObjectName(sb.toString());
0606: } catch (javax.management.MalformedObjectNameException e) {
0607: // this should never occur
0608: return null;
0609: }
0610: }
0611:
0612: public static ObjectName getStatefulSessionBeans(String pDomain) {
0613: try {
0614: StringBuffer sb = new StringBuffer(pDomain);
0615: sb.append(":j2eeType=StatefulSessionBean");
0616: sb.append(",");
0617: sb.append(ALL);
0618: return new ObjectName(sb.toString());
0619: } catch (javax.management.MalformedObjectNameException e) {
0620: // this should never occur
0621: return null;
0622: }
0623: }
0624:
0625: public static ObjectName getStatefulSessionBeans(String pDomain,
0626: String pModule) {
0627: try {
0628: StringBuffer sb = new StringBuffer(pDomain);
0629: sb.append(":j2eeType=StatefulSessionBean");
0630: sb.append(",EJBModule=");
0631: sb.append(pModule);
0632: sb.append(",");
0633: sb.append(ALL);
0634: return new ObjectName(sb.toString());
0635: } catch (javax.management.MalformedObjectNameException e) {
0636: // this should never occur
0637: return null;
0638: }
0639: }
0640:
0641: public static ObjectName getStatefulSessionBeans(String pDomain,
0642: String pModule, String pServer) {
0643: try {
0644: StringBuffer sb = new StringBuffer(pDomain);
0645: sb.append(":j2eeType=StatefulSessionBean");
0646: sb.append(",EJBModule=");
0647: sb.append(pModule);
0648: sb.append(",J2EEServer=");
0649: sb.append(pServer);
0650: sb.append(",");
0651: sb.append(ALL);
0652: return new ObjectName(sb.toString());
0653: } catch (javax.management.MalformedObjectNameException e) {
0654: // this should never occur
0655: return null;
0656: }
0657: }
0658:
0659: public static ObjectName getStatelessSessionBean(String pDomain,
0660: String pModule, String pServer, String pApplication,
0661: String pName) {
0662: try {
0663: StringBuffer sb = new StringBuffer(pDomain);
0664: sb.append(":j2eeType=StatelessSessionBean");
0665: sb.append(",name=");
0666: sb.append(pName);
0667: sb.append(",EJBModule=");
0668: sb.append(pModule);
0669: sb.append(",J2EEApplication=");
0670: if ((pApplication != null) && (pApplication.length() > 0)) {
0671: sb.append(pApplication);
0672: } else {
0673: sb.append(NONE);
0674: }
0675: sb.append(",J2EEServer=");
0676: sb.append(pServer);
0677: return new ObjectName(sb.toString());
0678: } catch (javax.management.MalformedObjectNameException e) {
0679: // this should never occur
0680: return null;
0681: }
0682: }
0683:
0684: public static ObjectName getStatelessSessionBeans(String pDomain,
0685: String pModule) {
0686: try {
0687: StringBuffer sb = new StringBuffer(pDomain);
0688: sb.append(":j2eeType=StatelessSessionBean");
0689: sb.append(",EJBModule=");
0690: sb.append(pModule);
0691: sb.append(",");
0692: sb.append(ALL);
0693: return new ObjectName(sb.toString());
0694: } catch (javax.management.MalformedObjectNameException e) {
0695: // this should never occur
0696: return null;
0697: }
0698: }
0699:
0700: public static ObjectName getStatelessSessionBeans(String pDomain) {
0701: try {
0702: StringBuffer sb = new StringBuffer(pDomain);
0703: sb.append(":j2eeType=StatelessSessionBean");
0704: sb.append(",");
0705: sb.append(ALL);
0706: return new ObjectName(sb.toString());
0707: } catch (javax.management.MalformedObjectNameException e) {
0708: // this should never occur
0709: return null;
0710: }
0711: }
0712:
0713: public static ObjectName getStatelessSessionBeans(String pDomain,
0714: String pModule, String pServer) {
0715: try {
0716: StringBuffer sb = new StringBuffer(pDomain);
0717: sb.append(":j2eeType=StatelessSessionBean");
0718: sb.append(",EJBModule=");
0719: sb.append(pModule);
0720: sb.append(",J2EEServer=");
0721: sb.append(pServer);
0722: sb.append(",");
0723: sb.append(ALL);
0724: return new ObjectName(sb.toString());
0725: } catch (javax.management.MalformedObjectNameException e) {
0726: // this should never occur
0727: return null;
0728: }
0729: }
0730:
0731: public static ObjectName getMessageDrivenBean(String pDomain,
0732: String pModule, String pServer, String pApplication,
0733: String pName) {
0734: try {
0735: StringBuffer sb = new StringBuffer(pDomain);
0736: sb.append(":j2eeType=MessageDrivenBean");
0737: sb.append(",name=");
0738: sb.append(pName);
0739: sb.append(",EJBModule=");
0740: sb.append(pModule);
0741: sb.append(",J2EEApplication=");
0742: if ((pApplication != null) && (pApplication.length() > 0)) {
0743: sb.append(pApplication);
0744: } else {
0745: sb.append(NONE);
0746: }
0747: sb.append(",J2EEServer=");
0748: sb.append(pServer);
0749: return new ObjectName(sb.toString());
0750: } catch (javax.management.MalformedObjectNameException e) {
0751: // this should never occur
0752: return null;
0753: }
0754: }
0755:
0756: public static ObjectName getMessageDrivenBeans(String pDomain) {
0757: try {
0758: StringBuffer sb = new StringBuffer(pDomain);
0759: sb.append(":j2eeType=MessageDrivenBean");
0760: sb.append(",");
0761: sb.append(ALL);
0762: return new ObjectName(sb.toString());
0763: } catch (javax.management.MalformedObjectNameException e) {
0764: // this should never occur
0765: return null;
0766: }
0767: }
0768:
0769: public static ObjectName getMessageDrivenBeans(String pDomain,
0770: String pModule, String pServer) {
0771: try {
0772: StringBuffer sb = new StringBuffer(pDomain);
0773: sb.append(":j2eeType=MessageDrivenBean");
0774: sb.append(",EJBModule=");
0775: sb.append(pModule);
0776: sb.append(",J2EEServer=");
0777: sb.append(pServer);
0778: sb.append(",");
0779: sb.append(ALL);
0780: return new ObjectName(sb.toString());
0781: } catch (javax.management.MalformedObjectNameException e) {
0782: // this should never occur
0783: return null;
0784: }
0785: }
0786:
0787: public static ObjectName getMessageDrivenBeans(String pDomain,
0788: String pModule) {
0789: try {
0790: StringBuffer sb = new StringBuffer(pDomain);
0791: sb.append(":j2eeType=MessageDrivenBean");
0792: sb.append(",EJBModule=");
0793: sb.append(pModule);
0794: sb.append(",");
0795: sb.append(ALL);
0796: return new ObjectName(sb.toString());
0797: } catch (javax.management.MalformedObjectNameException e) {
0798: // this should never occur
0799: return null;
0800: }
0801: }
0802:
0803: public static ObjectName getWebServices(String pDomain,
0804: String pServer) {
0805: //TODO: Add a proper web service mbean instead.
0806: try {
0807: StringBuffer sb = new StringBuffer(pDomain);
0808: sb.append(":type=WebService");
0809: sb.append(",");
0810: sb.append(ALL);
0811: sb.append(",J2EEServer=");
0812: sb.append(pServer);
0813: sb.append(",");
0814: sb.append(ALL);
0815: return new ObjectName(sb.toString());
0816: } catch (javax.management.MalformedObjectNameException e) {
0817: // this should never occur
0818: return null;
0819: }
0820: }
0821:
0822: public static ObjectName getWebServices() {
0823: try {
0824: StringBuffer sb = new StringBuffer(ALL);
0825: sb.append(":type=WebService");
0826: sb.append(",");
0827: sb.append(ALL);
0828: return new ObjectName(sb.toString());
0829: } catch (javax.management.MalformedObjectNameException e) {
0830: // this should never occur
0831: return null;
0832: }
0833: }
0834:
0835: public static ObjectName JavaMailResource(String pDomain,
0836: String pName, String pServer, String p_Type) {
0837: try {
0838: StringBuffer sb = new StringBuffer(pDomain);
0839: sb.append(":j2eeType=JavaMailResource");
0840: sb.append(",name=");
0841: sb.append(pName);
0842: sb.append(",J2EEServer=");
0843: sb.append(pServer);
0844: sb.append(",type=");
0845: sb.append(p_Type);
0846: return new ObjectName(sb.toString());
0847: } catch (javax.management.MalformedObjectNameException e) {
0848: // this should never occur
0849: return null;
0850: }
0851: }
0852:
0853: public static ObjectName JavaMailResources(String pDomain,
0854: String pServer, String p_Type) {
0855: try {
0856: StringBuffer sb = new StringBuffer(pDomain);
0857: sb.append(":j2eeType=JavaMailResource");
0858: sb.append(",");
0859: sb.append(ALL);
0860: sb.append(",J2EEServer=");
0861: sb.append(pServer);
0862: sb.append(",type=");
0863: sb.append(p_Type);
0864: return new ObjectName(sb.toString());
0865: } catch (javax.management.MalformedObjectNameException e) {
0866: // this should never occur
0867: return null;
0868: }
0869: }
0870:
0871: public static ObjectName JNDIResources(String pDomain,
0872: String pServer) {
0873: try {
0874: StringBuffer sb = new StringBuffer(pDomain);
0875: sb.append(":j2eeType=JNDIResource");
0876: sb.append(",J2EEServer=");
0877: sb.append(pServer);
0878: sb.append(",");
0879: sb.append(ALL);
0880: return new ObjectName(sb.toString());
0881: } catch (javax.management.MalformedObjectNameException e) {
0882: // this should never occur
0883: return null;
0884: }
0885: }
0886:
0887: public static ObjectName getWebModules() {
0888: try {
0889: return new ObjectName("*:j2eeType=WebModule,*");
0890: } catch (javax.management.MalformedObjectNameException e) {
0891: // this should never occur
0892: return null;
0893: }
0894: }
0895:
0896: public static ObjectName getWebModules(String pDomain) {
0897: try {
0898: return new ObjectName(pDomain + ":j2eeType=WebModule,*");
0899: } catch (javax.management.MalformedObjectNameException e) {
0900: // this should never occur
0901: return null;
0902: }
0903: }
0904:
0905: public static ObjectName getWebModules(String pDomain,
0906: String pServer) {
0907: try {
0908: StringBuffer sb = new StringBuffer(pDomain);
0909: sb.append(":j2eeType=WebModule");
0910: if ((pServer != null) && (pServer.length() > 0)) {
0911: sb.append(",J2EEServer=");
0912: sb.append(pServer);
0913: }
0914: sb.append(",*");
0915: return new ObjectName(sb.toString());
0916: } catch (javax.management.MalformedObjectNameException e) {
0917: // this should never occur
0918: return null;
0919: }
0920: }
0921:
0922: public static ObjectName getWebModules(String pDomain,
0923: String pServer, String pApplication) {
0924: try {
0925: StringBuffer sb = new StringBuffer(pDomain);
0926: sb.append(":j2eeType=WebModule");
0927: if ((pServer != null) && (pServer.length() > 0)) {
0928: sb.append(",J2EEServer=");
0929: sb.append(pServer);
0930: }
0931: if ((pApplication != null) && (pApplication.length() > 0)) {
0932: sb.append(",J2EEApplication=");
0933: sb.append(pApplication);
0934: }
0935: sb.append(",*");
0936: return new ObjectName(sb.toString());
0937: } catch (javax.management.MalformedObjectNameException e) {
0938: // this should never occur
0939: return null;
0940: }
0941: }
0942:
0943: public static ObjectName getWebModule(String pDomain,
0944: String pServer, String pApplication, String pName) {
0945: try {
0946: StringBuffer sb = new StringBuffer(pDomain);
0947: sb.append(":j2eeType=WebModule");
0948: sb.append(",name=");
0949: sb.append(pName);
0950: sb.append(",J2EEServer=");
0951: sb.append(pServer);
0952: sb.append(",J2EEApplication=");
0953: if ((pApplication != null) && (pApplication.length() > 0)) {
0954: sb.append(pApplication);
0955: } else {
0956: sb.append(NONE);
0957: }
0958:
0959: return new ObjectName(sb.toString());
0960: } catch (javax.management.MalformedObjectNameException e) {
0961: // this should never occur
0962: return null;
0963: }
0964: }
0965:
0966: public static ObjectName getResourceAdapterModule(String pDomain,
0967: String pServer, String pApplication, String pName) {
0968: try {
0969: StringBuffer sb = new StringBuffer(pDomain);
0970: sb.append(":j2eeType=ResourceAdapterModule");
0971: sb.append(",name=");
0972: sb.append(pName);
0973: sb.append(",J2EEServer=");
0974: sb.append(pServer);
0975: sb.append(",J2EEApplication=");
0976: if ((pApplication == null) || (pApplication.length() == 0)) {
0977: sb.append(NONE);
0978: } else {
0979: sb.append(pApplication);
0980: }
0981: return new ObjectName(sb.toString());
0982: } catch (javax.management.MalformedObjectNameException e) {
0983: // this should never occur
0984: return null;
0985: }
0986: }
0987:
0988: public static ObjectName getResourceAdapterModules(String pDomain,
0989: String pServer) {
0990: try {
0991: StringBuffer sb = new StringBuffer(pDomain);
0992: sb.append(":j2eeType=ResourceAdapterModule");
0993: if ((pServer != null) && (pServer.length() > 0)) {
0994: sb.append(",J2EEServer=");
0995: sb.append(pServer);
0996: }
0997: sb.append(",");
0998: sb.append(ALL);
0999: return new ObjectName(sb.toString());
1000: } catch (javax.management.MalformedObjectNameException e) {
1001: // this should never occur
1002: return null;
1003: }
1004: }
1005:
1006: public static ObjectName getResourceAdapterModules(String pDomain,
1007: String pServer, String pApplication) {
1008: try {
1009: StringBuffer sb = new StringBuffer(pDomain);
1010: sb.append(":j2eeType=ResourceAdapterModule");
1011: if ((pServer != null) && (pServer.length() > 0)) {
1012: sb.append(",J2EEServer=");
1013: sb.append(pServer);
1014: }
1015: if ((pApplication != null) && (pApplication.length() > 0)) {
1016: sb.append(",J2EEApplication=");
1017: sb.append(pApplication);
1018: }
1019: sb.append(",");
1020: sb.append(ALL);
1021: return new ObjectName(sb.toString());
1022: } catch (javax.management.MalformedObjectNameException e) {
1023: // this should never occur
1024: return null;
1025: }
1026: }
1027:
1028: public static ObjectName getResourceAdapter(String pDomain,
1029: String pResourceAdapterModule, String pApplication,
1030: String pServer, String pName) {
1031: try {
1032: StringBuffer sb = new StringBuffer(pDomain);
1033: sb.append(":j2eeType=ResourceAdapter");
1034: sb.append(",name=");
1035: sb.append(pName);
1036: sb.append(",ResourceAdapterModule=");
1037: sb.append(pResourceAdapterModule);
1038: sb.append(",J2EEApplication=");
1039: if ((pApplication == null) || (pApplication.length() == 0)) {
1040: sb.append(NONE);
1041: } else {
1042: sb.append(pApplication);
1043: }
1044: sb.append(",J2EEServer=");
1045: sb.append(pServer);
1046: return new ObjectName(sb.toString());
1047: } catch (javax.management.MalformedObjectNameException e) {
1048: // this should never occur
1049: return null;
1050: }
1051: }
1052:
1053: public static ObjectName getResourceAdapters(String pDomain,
1054: String pServer) {
1055: try {
1056: StringBuffer sb = new StringBuffer(pDomain);
1057: sb.append(":j2eeType=ResourceAdapter");
1058: if ((pServer != null) && (pServer.length() > 0)) {
1059: sb.append(",J2EEServer=");
1060: sb.append(pServer);
1061: }
1062: sb.append(",");
1063: sb.append(ALL);
1064: return new ObjectName(sb.toString());
1065: } catch (javax.management.MalformedObjectNameException e) {
1066: // this should never occur
1067: return null;
1068: }
1069: }
1070:
1071: public static ObjectName getResourceAdapters(String pDomain,
1072: String pApplication, String pServer) {
1073: try {
1074: StringBuffer sb = new StringBuffer(pDomain);
1075: sb.append(":j2eeType=ResourceAdapter");
1076: sb.append(",J2EEApplication=");
1077: if ((pApplication == null) || (pApplication.length() == 0)) {
1078: sb.append(NONE);
1079: } else {
1080: sb.append(pApplication);
1081: }
1082: if ((pServer != null) && (pServer.length() > 0)) {
1083: sb.append(",J2EEServer=");
1084: sb.append(pServer);
1085: }
1086: sb.append(",");
1087: sb.append(ALL);
1088: return new ObjectName(sb.toString());
1089: } catch (javax.management.MalformedObjectNameException e) {
1090: // this should never occur
1091: return null;
1092: }
1093: }
1094:
1095: public static ObjectName getJCAResource(String pDomain,
1096: String pServer, String pResourceAdapter, String pName) {
1097: try {
1098: StringBuffer sb = new StringBuffer(pDomain);
1099: sb.append(":j2eeType=JCAResource");
1100: sb.append(",name=");
1101: sb.append(pName);
1102: sb.append(",J2EEServer=");
1103: sb.append(pServer);
1104: sb.append(",ResourceAdapter=");
1105: sb.append(pResourceAdapter);
1106: return new ObjectName(sb.toString());
1107: } catch (javax.management.MalformedObjectNameException e) {
1108: // this should never occur
1109: return null;
1110: }
1111: }
1112:
1113: public static ObjectName getJCAActivationSpec(String pDomain,
1114: String pJCAResource, String pServer, String pName) {
1115: try {
1116: StringBuffer sb = new StringBuffer(pDomain);
1117: sb.append(":j2eeType=JCAActivationSpec");
1118: sb.append(",name=");
1119: sb.append(pName);
1120: sb.append(",JCAResource=");
1121: sb.append(pJCAResource);
1122: sb.append(",J2EEServer=");
1123: sb.append(pServer);
1124: return new ObjectName(sb.toString());
1125: } catch (javax.management.MalformedObjectNameException e) {
1126: // this should never occur
1127: return null;
1128: }
1129: }
1130:
1131: public static ObjectName getJCAAdminObject(String pDomain,
1132: String pJCAResource, String pServer, String pName) {
1133: try {
1134: StringBuffer sb = new StringBuffer(pDomain);
1135: sb.append(":j2eeType=JCAAdminObject");
1136: sb.append(",name=");
1137: sb.append(pName);
1138: sb.append(",JCAResource=");
1139: sb.append(pJCAResource);
1140: sb.append(",J2EEServer=");
1141: sb.append(pServer);
1142: return new ObjectName(sb.toString());
1143: } catch (javax.management.MalformedObjectNameException e) {
1144: // this should never occur
1145: return null;
1146: }
1147: }
1148:
1149: public static ObjectName getJCAConnectionFactory(String pDomain,
1150: String pJCAResource, String pServer, String pName) {
1151: try {
1152: StringBuffer sb = new StringBuffer(pDomain);
1153: sb.append(":j2eeType=JCAConnectionFactory");
1154: sb.append(",name=");
1155: sb.append(pName);
1156: sb.append(",JCAResource=");
1157: sb.append(pJCAResource);
1158: sb.append(",J2EEServer=");
1159: sb.append(pServer);
1160: return new ObjectName(sb.toString());
1161: } catch (javax.management.MalformedObjectNameException e) {
1162: // this should never occur
1163: return null;
1164: }
1165: }
1166:
1167: public static ObjectName getJCAConnectionFactories(String pDomain,
1168: String pServer) {
1169: try {
1170: StringBuffer sb = new StringBuffer(pDomain);
1171: sb.append(":j2eeType=JCAConnectionFactory");
1172: sb.append(",J2EEServer=");
1173: sb.append(pServer);
1174: sb.append(",");
1175: sb.append(ALL);
1176: return new ObjectName(sb.toString());
1177: } catch (javax.management.MalformedObjectNameException e) {
1178: // this should never occur
1179: return null;
1180: }
1181: }
1182:
1183: public static ObjectName getJCAManagedConnectionFactory(
1184: String pDomain, String pServer, String pName) {
1185: try {
1186: StringBuffer sb = new StringBuffer(pDomain);
1187: sb.append(":j2eeType=JCAManagedConnectionFactory");
1188: sb.append(",name=");
1189: sb.append(pName);
1190: sb.append(",J2EEServer=");
1191: sb.append(pServer);
1192: return new ObjectName(sb.toString());
1193: } catch (javax.management.MalformedObjectNameException e) {
1194: // this should never occur
1195: return null;
1196: }
1197: }
1198:
1199: public static ObjectName ManagementListener(String pDomain,
1200: String pServer) {
1201: try {
1202: StringBuffer sb = new StringBuffer(pDomain);
1203: sb.append(":type=management,name=managementListener");
1204: sb.append(",J2EEServer=");
1205: sb.append(pServer);
1206: return new ObjectName(sb.toString());
1207: } catch (javax.management.MalformedObjectNameException e) {
1208: // this should never occur
1209: return null;
1210: }
1211: }
1212:
1213: public static ObjectName JTAResource(String pDomain,
1214: String pServer, String pName) {
1215: try {
1216: StringBuffer sb = new StringBuffer(pDomain);
1217: sb
1218: .append(":j2eeType=JTAResource,name=JTAResource,J2EEServer=");
1219: sb.append(pServer);
1220: return new ObjectName(sb.toString());
1221: } catch (javax.management.MalformedObjectNameException e) {
1222: // this should never occur
1223: return null;
1224: }
1225: }
1226:
1227: /**
1228: * Create ObjectName for a JDBCResource MBean
1229: * @param pDomain domain name
1230: * @param pServer server name
1231: * @param pName MBean name
1232: * @return ObjectName for a JDBCResource MBean
1233: */
1234: public static ObjectName JDBCResource(String pDomain,
1235: String pServer, String pName) {
1236: try {
1237: StringBuffer sb = new StringBuffer(pDomain);
1238: sb.append(":j2eeType=JDBCResource");
1239: sb.append(",name=");
1240: sb.append(pName);
1241: sb.append(",J2EEServer=");
1242: sb.append(pServer);
1243: return new ObjectName(sb.toString());
1244: } catch (javax.management.MalformedObjectNameException e) {
1245: // this should never occur
1246: return null;
1247: }
1248: }
1249:
1250: /**
1251: * Create ObjectName for a JDBCResource MBean using name="JDBCResource"
1252: * @param pDomain
1253: * @param pServer server name
1254: * @return ObjectName for a JDBCResource MBean
1255: */
1256: public static ObjectName JDBCResource(String pDomain, String pServer) {
1257: try {
1258: StringBuffer sb = new StringBuffer(pDomain);
1259: sb.append(":j2eeType=JDBCResource");
1260: sb.append(",name=");
1261: sb.append("JDBCResource");
1262: sb.append(",J2EEServer=");
1263: sb.append(pServer);
1264: return new ObjectName(sb.toString());
1265: } catch (javax.management.MalformedObjectNameException e) {
1266: // this should never occur
1267: return null;
1268: }
1269: }
1270:
1271: /**
1272: * Create ObjectName for a JDBCDataSource MBeans in a JDBCResource named "JDBCResource"
1273: * @param pDomain domain name
1274: * @param pServer server name
1275: * @param pName JDBCDataSource name
1276: * @return ObjectName for a JDBCDataSource MBean
1277: */
1278: public static ObjectName getJDBCDataSource(String pDomain,
1279: String pServer, String pName) {
1280: try {
1281: StringBuffer sb = new StringBuffer(pDomain);
1282: sb.append(":j2eeType=JDBCDataSource");
1283: sb.append(",name=");
1284: sb.append(pName);
1285: sb.append(",JDBCResource=");
1286: sb.append("JDBCResource");
1287: sb.append(",J2EEServer=");
1288: sb.append(pServer);
1289: return new ObjectName(sb.toString());
1290: } catch (javax.management.MalformedObjectNameException e) {
1291: // this should never occur
1292: return null;
1293: }
1294: }
1295:
1296: /**
1297: * @param pDomain domain name
1298: * @param pServer server name
1299: * @return ObjectName for all JDBCDataSource MBeans in the JDBCResource of a given server
1300: */
1301: public static ObjectName getJDBCDataSources(String pDomain,
1302: String pServer) {
1303: try {
1304: StringBuffer sb = new StringBuffer(pDomain);
1305: sb.append(":j2eeType=JDBCDataSource");
1306: sb.append(",JDBCResource=");
1307: sb.append("JDBCResource");
1308: sb.append(",J2EEServer=");
1309: sb.append(pServer);
1310: sb.append(",");
1311: sb.append(ALL);
1312: return new ObjectName(sb.toString());
1313: } catch (javax.management.MalformedObjectNameException e) {
1314: // this should never occur
1315: return null;
1316: }
1317: }
1318:
1319: /**
1320: * This method is equivalent with the previous as in a server we currently have a
1321: * sole JDBCResource MBean.
1322: * @param pDomain domain name
1323: * @param pServer server name
1324: * @return ObjectName for all JDBCDataSource MBeans in a given server
1325: */
1326: public static ObjectName JDBCDataSources(String pDomain,
1327: String pServer) {
1328: try {
1329: StringBuffer sb = new StringBuffer(pDomain);
1330: sb.append(":j2eeType=JDBCDataSource");
1331: sb.append(",J2EEServer=");
1332: sb.append(pServer);
1333: sb.append(",");
1334: sb.append(ALL);
1335: return new ObjectName(sb.toString());
1336: } catch (javax.management.MalformedObjectNameException e) {
1337: // this should never occur
1338: return null;
1339: }
1340: }
1341:
1342: public static ObjectName JDBCDataSources(String pDomain,
1343: String pJDBCResource, String pServer) {
1344: try {
1345: StringBuffer sb = new StringBuffer(pDomain);
1346: sb.append(":j2eeType=JDBCDataSource");
1347: sb.append(",JDBCResource=");
1348: sb.append(pJDBCResource);
1349: sb.append(",J2EEServer=");
1350: sb.append(pServer);
1351: sb.append(",");
1352: sb.append(ALL);
1353: return new ObjectName(sb.toString());
1354: } catch (javax.management.MalformedObjectNameException e) {
1355: // this should never occur
1356: return null;
1357: }
1358: }
1359:
1360: public static ObjectName getJDBCDriver(String pDomain,
1361: String pServer, String pName) {
1362: try {
1363: StringBuffer sb = new StringBuffer(pDomain);
1364: sb.append(":j2eeType=JDBCDriver");
1365: sb.append(",name=");
1366: sb.append(pName);
1367: sb.append(",J2EEServer=");
1368: sb.append(pServer);
1369: return new ObjectName(sb.toString());
1370: } catch (javax.management.MalformedObjectNameException e) {
1371: // this should never occur
1372: return null;
1373: }
1374: }
1375:
1376: }
|