0001: /*
0002: * BEGIN_HEADER - DO NOT EDIT
0003: *
0004: * The contents of this file are subject to the terms
0005: * of the Common Development and Distribution License
0006: * (the "License"). You may not use this file except
0007: * in compliance with the License.
0008: *
0009: * You can obtain a copy of the license at
0010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0011: * See the License for the specific language governing
0012: * permissions and limitations under the License.
0013: *
0014: * When distributing Covered Code, include this CDDL
0015: * HEADER in each file and include the License file at
0016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0017: * If applicable add the following below this CDDL HEADER,
0018: * with the fields enclosed by brackets "[]" replaced with
0019: * your own identifying information: Portions Copyright
0020: * [year] [name of copyright owner]
0021: */
0022:
0023: /*
0024: * @(#)RuntimeManagementServiceMBeanImpl.java
0025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026: *
0027: * END_HEADER - DO NOT EDIT
0028: */
0029: package com.sun.esb.management.impl.runtime;
0030:
0031: import java.io.Serializable;
0032: import java.util.ArrayList;
0033: import java.util.Collection;
0034: import java.util.HashMap;
0035: import java.util.Iterator;
0036: import java.util.List;
0037: import java.util.Map;
0038: import java.util.Set;
0039: import java.util.concurrent.ConcurrentHashMap;
0040:
0041: import javax.management.ObjectName;
0042:
0043: import com.sun.esb.management.api.runtime.RuntimeManagementService;
0044: import com.sun.esb.management.base.services.AbstractListStateServiceMBeansImpl;
0045: import com.sun.esb.management.common.ManagementRemoteException;
0046: import com.sun.jbi.ComponentInfo;
0047: import com.sun.jbi.ComponentQuery;
0048: import com.sun.jbi.ComponentState;
0049: import com.sun.jbi.ComponentType;
0050: import com.sun.jbi.EnvironmentContext;
0051: import com.sun.jbi.ui.common.JBIComponentInfo;
0052: import com.sun.jbi.ui.common.ServiceAssemblyInfo;
0053: import com.sun.jbi.ui.runtime.GenericsSupport;
0054:
0055: /**
0056: * Defines operations for common runtime management services. Common runtime
0057: * management operations include listing component containers available in the
0058: * runtime, composite applications deployed, controlling lifecycle across the
0059: * runtime and composite applications, getting state of each container and
0060: * composite application, etc.
0061: *
0062: * @author graj
0063: */
0064: public class RuntimeManagementServiceMBeanImpl extends
0065: AbstractListStateServiceMBeansImpl implements
0066: RuntimeManagementService, Serializable {
0067:
0068: static final long serialVersionUID = -1L;
0069:
0070: /**
0071: * Constructor - Constructs a new instance of RuntimeManagementServiceMBeanImpl
0072: *
0073: * @param anEnvContext
0074: */
0075: public RuntimeManagementServiceMBeanImpl(
0076: EnvironmentContext anEnvContext) {
0077: super (anEnvContext);
0078: }
0079:
0080: /**
0081: * return component info xml text that has only binding component infos.
0082: *
0083: * @param targetName
0084: * @return the component info xml text.
0085: * @throws ManagementRemoteException
0086: * on error
0087: *
0088: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listBindingComponents(java.lang.String)
0089: */
0090: public String listBindingComponents(String targetName)
0091: throws ManagementRemoteException {
0092: return listBindingComponents(null, null, null, targetName);
0093: }
0094:
0095: /**
0096: * return component info xml text that has only binding component infos
0097: * which satisfies the options passed to the method.
0098: *
0099: * @param state
0100: * return all the binding components that are in the specified
0101: * state. valid states are JBIComponentInfo.STARTED, STOPPED,
0102: * INSTALLED or null for ANY state
0103: * @param sharedLibraryName
0104: * return all the binding components that have a dependency on
0105: * the specified shared library. null value to ignore this
0106: * option.
0107: * @param serviceAssemblyName
0108: * return all the binding components that have the specified
0109: * service assembly deployed on them. null value to ignore this
0110: * option.
0111: * @param targetName
0112: * @return xml text contain the list of binding component infos
0113: * @throws ManagementRemoteException
0114: * if error or exception occurs.
0115: *
0116: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listBindingComponents(java.lang.String,
0117: * java.lang.String, java.lang.String, java.lang.String)
0118: */
0119: public String listBindingComponents(String state,
0120: String sharedLibraryName, String serviceAssemblyName,
0121: String targetName) throws ManagementRemoteException {
0122: return this .listComponents(ComponentType.BINDING, state,
0123: sharedLibraryName, serviceAssemblyName, targetName);
0124: }
0125:
0126: /**
0127: * returns a list of Service Assembly Infos in a xml format.
0128: *
0129: * @param targetName
0130: * @return xml text containing the Service Assembly infos
0131: * @throws ManagementRemoteException
0132: * on error
0133: *
0134: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listServiceAssemblies(java.lang.String)
0135: */
0136: public String listServiceAssemblies(String targetName)
0137: throws ManagementRemoteException {
0138: return listServiceAssemblies(null, targetName);
0139: }
0140:
0141: /**
0142: * returns the list of service asssembly infos in a xml format that have the
0143: * service unit deployed on the specified component.
0144: *
0145: * @param componentName
0146: * to list all the service assemblies that have some deployments
0147: * on this component.
0148: * @param targetName
0149: * @return xml string contain the list of service assembly infos
0150: * @throws ManagementRemoteException
0151: * if error or exception occurs.
0152: *
0153: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listServiceAssemblies(java.lang.String,
0154: * java.lang.String)
0155: */
0156: public String listServiceAssemblies(String componentName,
0157: String targetName) throws ManagementRemoteException {
0158: return listServiceAssemblies(null, componentName, targetName);
0159: }
0160:
0161: /**
0162: * returns the list of service asssembly infos in a xml format that have the
0163: * service unit deployed on the specified component.
0164: *
0165: * @param state
0166: * to return all the service assemblies that are in the specified
0167: * state. JBIServiceAssemblyInfo.STARTED, STOPPED, SHUTDOWN or
0168: * null for ANY state
0169: * @param componentName
0170: * to list all the service assemblies that have some deployments
0171: * on this component.
0172: * @param targetName
0173: * @return xml string contain the list of service assembly infos
0174: * @throws ManagementRemoteException
0175: * if error or exception occurs.
0176: *
0177: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listServiceAssemblies(java.lang.String,
0178: * java.lang.String, java.lang.String)
0179: */
0180: @SuppressWarnings("unchecked")
0181: public String listServiceAssemblies(String state,
0182: String componentName, String targetName)
0183: throws ManagementRemoteException {
0184: // ////////////////////////////////////////
0185: // Start Check to make sure target is valid
0186: // ////////////////////////////////////////
0187: ObjectName installerServiceObjectName = this
0188: .getInstallationServiceMBeanObjectName(targetName);
0189: this
0190: .checkForValidTarget(installerServiceObjectName,
0191: targetName);
0192: // ////////////////////////////////////////
0193: // End Check to make sure target is valid
0194: // ////////////////////////////////////////
0195:
0196: this .validateUiServiceAssemblyInfoState(state);
0197:
0198: List saInfoList = this .getServiceAssemblyInfoList(
0199: toFrameworkServiceAssemblyState(state), componentName,
0200: targetName);
0201:
0202: return ServiceAssemblyInfo.writeAsXmlTextWithProlog(saInfoList);
0203: }
0204:
0205: /**
0206: * return component info xml text that has only service engine infos.
0207: *
0208: * @param targetName
0209: * @return the component info xml text.
0210: * @throws ManagementRemoteException
0211: * on error
0212: *
0213: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listServiceEngines(java.lang.String)
0214: */
0215: public String listServiceEngines(String targetName)
0216: throws ManagementRemoteException {
0217: return this .listServiceEngines(null, null, null, targetName);
0218: }
0219:
0220: /**
0221: * return component info xml text that has only service engine infos which
0222: * satisfies the options passed to the method.
0223: *
0224: * @param state
0225: * return all the service engines that are in the specified
0226: * state. valid states are JBIComponentInfo.STARTED, STOPPED,
0227: * INSTALLED or null for ANY state
0228: * @param sharedLibraryName
0229: * return all the service engines that have a dependency on the
0230: * specified shared library. null value to ignore this option.
0231: * @param serviceAssemblyName
0232: * return all the service engines that have the specified service
0233: * assembly deployed on them. null value to ignore this option.
0234: * @param targetName
0235: * @return xml text contain the list of service engine component infos
0236: * @throws ManagementRemoteException
0237: * if error or exception occurs.
0238: *
0239: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listServiceEngines(java.lang.String,
0240: * java.lang.String, java.lang.String, java.lang.String)
0241: */
0242: public String listServiceEngines(String state,
0243: String sharedLibraryName, String serviceAssemblyName,
0244: String targetName) throws ManagementRemoteException {
0245: return listComponents(ComponentType.ENGINE, state,
0246: sharedLibraryName, serviceAssemblyName, targetName);
0247: }
0248:
0249: /**
0250: * return component info xml text that has only shared library infos.
0251: *
0252: * @param targetName
0253: * @return the component info xml text.
0254: * @throws ManagementRemoteException
0255: * on error
0256: *
0257: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listSharedLibraries(java.lang.String)
0258: */
0259: public String listSharedLibraries(String targetName)
0260: throws ManagementRemoteException {
0261: return listSharedLibraries(null, targetName);
0262: }
0263:
0264: /**
0265: * returns the list of Shared Library infos in the in a xml format
0266: *
0267: * @param componentName
0268: * to return only the shared libraries that are this component
0269: * dependents. null for listing all the shared libraries in the
0270: * system.
0271: * @param targetName
0272: * @return xml string contain the list of componentinfos for shared
0273: * libraries.
0274: * @throws ManagementRemoteException
0275: * if error or exception occurs.
0276: *
0277: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listSharedLibraries(java.lang.String,
0278: * java.lang.String)
0279: */
0280: @SuppressWarnings("unchecked")
0281: public String listSharedLibraries(String componentName,
0282: String targetName) throws ManagementRemoteException {
0283: // ////////////////////////////////////////
0284: // Start Check to make sure target is valid
0285: // ////////////////////////////////////////
0286: ObjectName installerServiceObjectName = this
0287: .getInstallationServiceMBeanObjectName(targetName);
0288: this
0289: .checkForValidTarget(installerServiceObjectName,
0290: targetName);
0291: // ////////////////////////////////////////
0292: // End Check to make sure target is valid
0293: // ////////////////////////////////////////
0294:
0295: List frameworkCompInfoList = this
0296: .getFrameworkComponentInfoListForSharedLibraries(
0297: componentName, targetName);
0298: List uiCompInfoList = new ArrayList();
0299: uiCompInfoList = this .toUiComponentInfoList(
0300: frameworkCompInfoList, targetName);
0301: return JBIComponentInfo.writeAsXmlText(uiCompInfoList);
0302: }
0303:
0304: /**
0305: * returns a list of Binding Component and Service Engine infos in xml
0306: * format, that are dependent upon a specified Shared Library
0307: *
0308: * @param sharedLibraryName
0309: * the shared library name
0310: * @param targetName
0311: * @return xml string containing the list of componentInfos
0312: * @throws ManagementRemoteException
0313: * on error
0314: *
0315: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#listSharedLibraryDependents(java.lang.String,
0316: * java.lang.String)
0317: */
0318: @SuppressWarnings("unchecked")
0319: public String listSharedLibraryDependents(String sharedLibraryName,
0320: String targetName) throws ManagementRemoteException {
0321: // ////////////////////////////////////////
0322: // Start Check to make sure target is valid
0323: // ////////////////////////////////////////
0324: ObjectName installerServiceObjectName = this
0325: .getInstallationServiceMBeanObjectName(targetName);
0326: this
0327: .checkForValidTarget(installerServiceObjectName,
0328: targetName);
0329: // ////////////////////////////////////////
0330: // End Check to make sure target is valid
0331: // ////////////////////////////////////////
0332:
0333: Collection compNames = this
0334: .getComponentNamesDependentOnSharedLibrary(
0335: sharedLibraryName, targetName);
0336: return JBIComponentInfo.writeAsXmlText(this
0337: .toUiComponentInfoList(getFrameworkComponentInfoList(
0338: compNames, targetName), targetName));
0339: }
0340:
0341: /**
0342: * return component info xml text for the specified binding component if
0343: * exists. If no binding component with that name exists, it returns the xml
0344: * with empty list.
0345: *
0346: * @param name
0347: * name of the binding component to lookup
0348: * @param state
0349: * return the binding component that is in the specified state.
0350: * valid states are JBIComponentInfo.STARTED, STOPPED, INSTALLED
0351: * or null for ANY state
0352: * @param sharedLibraryName
0353: * return the binding component that has a dependency on the
0354: * specified shared library. null value to ignore this option.
0355: * @param serviceAssemblyName
0356: * return the binding component that has the specified service
0357: * assembly deployed on it. null value to ignore this option.
0358: * @param targetName
0359: * @return xml text contain the binding component info that confirms to the
0360: * component info list xml grammer.
0361: * @throws ManagementRemoteException
0362: * if error or exception occurs.
0363: *
0364: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#showBindingComponent(java.lang.String,
0365: * java.lang.String, java.lang.String, java.lang.String,
0366: * java.lang.String)
0367: */
0368: public String showBindingComponent(String name, String state,
0369: String sharedLibraryName, String serviceAssemblyName,
0370: String targetName) throws ManagementRemoteException {
0371: return this .showComponent(name, ComponentType.BINDING, state,
0372: sharedLibraryName, serviceAssemblyName, targetName);
0373: }
0374:
0375: /**
0376: * return service assembly info xml text for the specified service assembly
0377: * if exists. If no service assembly with that name exists, it returns the
0378: * xml with empty list.
0379: *
0380: * @param name
0381: * name of the service assembly to lookup
0382: * @param state
0383: * return the service assembly that is in the specified state.
0384: * JBIServiceAssemblyInfo.STARTED, STOPPED, SHUTDOWN or null for
0385: * ANY state
0386: * @param componentName
0387: * return the service assembly that has service units on this
0388: * component.
0389: * @param targetName
0390: * @return xml string contain service assembly info that confirms to the
0391: * service assembly list xml grammer.
0392: * @throws ManagementRemoteException
0393: * if error or exception occurs.
0394: *
0395: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#showServiceAssembly(java.lang.String,
0396: * java.lang.String, java.lang.String, java.lang.String)
0397: */
0398: @SuppressWarnings("unchecked")
0399: public String showServiceAssembly(String name, String state,
0400: String componentName, String targetName)
0401: throws ManagementRemoteException {
0402: logDebug("show ServiceAssembly info for : " + name);
0403:
0404: // ////////////////////////////////////////
0405: // Start Check to make sure target is valid
0406: // ////////////////////////////////////////
0407: ObjectName installerServiceObjectName = this
0408: .getInstallationServiceMBeanObjectName(targetName);
0409: this
0410: .checkForValidTarget(installerServiceObjectName,
0411: targetName);
0412: // ////////////////////////////////////////
0413: // End Check to make sure target is valid
0414: // ////////////////////////////////////////
0415:
0416: validateUiServiceAssemblyInfoState(state);
0417:
0418: String saName = null;
0419: if (null != name && name.trim().length() > 0) {
0420: saName = name.trim();
0421: }
0422:
0423: List uiInfoList = new ArrayList();
0424:
0425: if (saName == null) {
0426: // return empty list
0427: return ServiceAssemblyInfo
0428: .writeAsXmlTextWithProlog(uiInfoList);
0429: }
0430:
0431: // get the service infos with the state and component dependency
0432: List saInfoList = getServiceAssemblyInfoList(
0433: toFrameworkServiceAssemblyState(state), componentName,
0434: targetName);
0435:
0436: // now check that this saName is there in saInfoList
0437: for (Iterator itr = saInfoList.iterator(); itr.hasNext();) {
0438: ServiceAssemblyInfo saInfo = (ServiceAssemblyInfo) itr
0439: .next();
0440: if (saInfo.getName().equals(saName)) {
0441: uiInfoList.add(saInfo);
0442: break;
0443: }
0444: }
0445:
0446: return ServiceAssemblyInfo.writeAsXmlTextWithProlog(uiInfoList);
0447: }
0448:
0449: /**
0450: * return component info xml text for the specified service engine if
0451: * exists. If no service engine with that name exists, it returns the xml
0452: * with empty list.
0453: *
0454: * @param name
0455: * name of the service engine to lookup
0456: * @param state
0457: * return service engine that is in the specified state. valid
0458: * states are JBIComponentInfo.STARTED, STOPPED, INSTALLED or
0459: * null for ANY state
0460: * @param sharedLibraryName
0461: * return service engine that has a dependency on the specified
0462: * shared library. null value to ignore this option.
0463: * @param serviceAssemblyName
0464: * return the service engine that has the specified service
0465: * assembly deployed on it. null value to ignore this option.
0466: * @param targetName
0467: * @return xml text contain the service engine component info that confirms
0468: * to the component info list xml grammer.
0469: * @throws ManagementRemoteException
0470: * if error or exception occurs.
0471: *
0472: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#showServiceEngine(java.lang.String,
0473: * java.lang.String, java.lang.String, java.lang.String,
0474: * java.lang.String)
0475: */
0476: public String showServiceEngine(String name, String state,
0477: String sharedLibraryName, String serviceAssemblyName,
0478: String targetName) throws ManagementRemoteException {
0479: return this .showComponent(name, ComponentType.ENGINE, state,
0480: sharedLibraryName, serviceAssemblyName, targetName);
0481: }
0482:
0483: /**
0484: * return component info xml text for the specified shared library if
0485: * exists. If no shared library with that name exists, it returns the xml
0486: * with empty list.
0487: *
0488: * @param name
0489: * name of the shared library to lookup
0490: * @param componentName
0491: * return the shared library that is this component dependents.
0492: * null to ignore this option.
0493: * @param targetName
0494: * @return xml string contain shared library component info that confirms to
0495: * the component info list xml grammer.
0496: * @throws ManagementRemoteException
0497: * if error or exception occurs.
0498: *
0499: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#showSharedLibrary(java.lang.String,
0500: * java.lang.String, java.lang.String)
0501: */
0502: @SuppressWarnings("unchecked")
0503: public String showSharedLibrary(String name, String componentName,
0504: String targetName) throws ManagementRemoteException {
0505: // ////////////////////////////////////////
0506: // Start Check to make sure target is valid
0507: // ////////////////////////////////////////
0508: ObjectName installerServiceObjectName = this
0509: .getInstallationServiceMBeanObjectName(targetName);
0510: this
0511: .checkForValidTarget(installerServiceObjectName,
0512: targetName);
0513: // ////////////////////////////////////////
0514: // End Check to make sure target is valid
0515: // ////////////////////////////////////////
0516:
0517: ArrayList uiCompInfoList = new ArrayList();
0518:
0519: ComponentQuery componentQuery = this
0520: .getFrameworkComponentQuery(targetName);
0521: ComponentInfo componentInformation = null;
0522: if (componentQuery != null) {
0523: componentInformation = componentQuery
0524: .getSharedLibraryInfo(name);
0525: if ((componentInformation != null)
0526: && (ComponentType.SHARED_LIBRARY == componentInformation
0527: .getComponentType())) {
0528: uiCompInfoList.add(this .toUiComponentInfo(
0529: componentInformation, targetName));
0530: }
0531: }
0532:
0533: return JBIComponentInfo.writeAsXmlText(uiCompInfoList);
0534: }
0535:
0536: /**
0537: * shuts down component ( service engine, binding component)
0538: *
0539: * @return name of the component
0540: * @param force
0541: * true to force shutdown
0542: * @param componentName
0543: * name of the component
0544: * @param targetName
0545: * @throws ManagementRemoteException
0546: * on error
0547: *
0548: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#shutdownComponent(java.lang.String,
0549: * boolean, java.lang.String)
0550: */
0551: public String shutdownComponent(String componentName,
0552: boolean force, String targetName)
0553: throws ManagementRemoteException {
0554: logDebug("shutting down Component " + componentName);
0555:
0556: ObjectName lifecycleObjectName = this
0557: .getComponentLifeCycleMBeanObjectName(componentName,
0558: targetName);
0559:
0560: // ////////////////////////////////////////
0561: // Start Check to make sure target is valid
0562: // ////////////////////////////////////////
0563: this .checkForValidTarget(lifecycleObjectName, targetName);
0564: // ////////////////////////////////////////
0565: // End Check to make sure target is valid
0566: // ////////////////////////////////////////
0567:
0568: Object result = null;
0569: logDebug("Calling shutDown on Component LifecycleMBean "
0570: + lifecycleObjectName);
0571: if (force == true) {
0572: Object[] params = new Object[1];
0573: params[0] = Boolean.valueOf(force);
0574:
0575: String[] signature = new String[1];
0576: signature[0] = "boolean";
0577: result = this .invokeMBeanOperation(lifecycleObjectName,
0578: "shutDown", params, signature);
0579: } else {
0580: result = this .invokeMBeanOperation(lifecycleObjectName,
0581: "shutDown");
0582: }
0583:
0584: return componentName;
0585: }
0586:
0587: /**
0588: * shuts down component ( service engine, binding component)
0589: *
0590: * @return name of the component
0591: * @param componentName
0592: * name of the component
0593: * @param targetName
0594: * @throws ManagementRemoteException
0595: * on error
0596: *
0597: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#shutdownComponent(java.lang.String,
0598: * java.lang.String)
0599: */
0600: public String shutdownComponent(String componentName,
0601: String targetName) throws ManagementRemoteException {
0602: boolean force = false;
0603: return this .shutdownComponent(componentName, force, targetName);
0604: }
0605:
0606: /**
0607: * shuts down service assembly
0608: *
0609: * @param serviceAssemblyName
0610: * name of the service assembly
0611: * @param forceShutdown
0612: * @param targetName
0613: * name of the target for this operation
0614: * @return Map of targetName and result as a management message xml text
0615: * strings.
0616: * @throws ManagementRemoteException
0617: * on error
0618: *
0619: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#shutdownServiceAssembly(java.lang.String,
0620: * boolean, java.lang.String)
0621: */
0622: public String shutdownServiceAssembly(String serviceAssemblyName,
0623: boolean forceShutdown, String targetName)
0624: throws ManagementRemoteException {
0625: return this .shutdownServiceAssemblyInternal(
0626: serviceAssemblyName, forceShutdown, targetName);
0627: }
0628:
0629: /**
0630: * shuts down service assembly
0631: *
0632: * @param serviceAssemblyName
0633: * name of the service assembly
0634: * @param targetName
0635: * @return result as a management message xml text
0636: * @throws ManagementRemoteException
0637: * on error
0638: *
0639: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#shutdownServiceAssembly(java.lang.String,
0640: * java.lang.String)
0641: */
0642: public String shutdownServiceAssembly(String serviceAssemblyName,
0643: String targetName) throws ManagementRemoteException {
0644: boolean force = false;
0645: return this .shutdownServiceAssemblyInternal(
0646: serviceAssemblyName, force, targetName);
0647: }
0648:
0649: /**
0650: * starts component ( service engine, binding component)
0651: *
0652: * @param componentName
0653: * name of the component
0654: * @param targetName
0655: * @throws ManagementRemoteException
0656: * on error
0657: * @return name of the component
0658: *
0659: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#startComponent(java.lang.String,
0660: * java.lang.String)
0661: */
0662: public String startComponent(String componentName, String targetName)
0663: throws ManagementRemoteException {
0664: logDebug("starting Component " + componentName);
0665:
0666: ObjectName lifecycleObjectName = this
0667: .getComponentLifeCycleMBeanObjectName(componentName,
0668: targetName);
0669: // ////////////////////////////////////////
0670: // Start Check to make sure target is valid
0671: // ////////////////////////////////////////
0672: this .checkForValidTarget(lifecycleObjectName, targetName);
0673: // ////////////////////////////////////////
0674: // End Check to make sure target is valid
0675: // ////////////////////////////////////////
0676:
0677: Object result = null;
0678: logDebug("Calling start on Component LifecycleMBean "
0679: + lifecycleObjectName);
0680: result = invokeMBeanOperation(lifecycleObjectName, "start");
0681:
0682: return componentName;
0683: }
0684:
0685: /**
0686: * starts service assembly
0687: *
0688: * @param serviceAssemblyName
0689: * name of the service assembly
0690: * @param targetName
0691: * @return result as a management message xml text
0692: * @throws ManagementRemoteException
0693: * on error
0694: *
0695: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#startServiceAssembly(java.lang.String,
0696: * java.lang.String)
0697: */
0698: public String startServiceAssembly(String serviceAssemblyName,
0699: String targetName) throws ManagementRemoteException {
0700: logDebug("Starting Service Assembly " + serviceAssemblyName);
0701:
0702: ObjectName deploymentServiceObjectName = this
0703: .getDeploymentServiceMBeanObjectName(targetName);
0704:
0705: // ////////////////////////////////////////
0706: // Start Check to make sure target is valid
0707: // ////////////////////////////////////////
0708: this .checkForValidTarget(deploymentServiceObjectName,
0709: targetName);
0710: // ////////////////////////////////////////
0711: // End Check to make sure target is valid
0712: // ////////////////////////////////////////
0713:
0714: logDebug("Calling start on DeploymentServiceMBean = "
0715: + deploymentServiceObjectName);
0716:
0717: Object resultObject = this .invokeMBeanOperation(
0718: deploymentServiceObjectName, "start",
0719: serviceAssemblyName);
0720:
0721: String result = null;
0722: if (resultObject != null) {
0723: result = resultObject.toString();
0724: if ((serviceAssemblyName == null)
0725: || (result.contains("FAILED") == true)
0726: || (result.contains("WARNING") == true)) {
0727: result = resultObject.toString();
0728: } else {
0729: result = serviceAssemblyName;
0730: }
0731: return result;
0732: } else {
0733: Exception exception = this .createManagementException(
0734: "ui.mbean.sasm.start.error", null, null);
0735: throw new ManagementRemoteException(exception);
0736:
0737: }
0738: }
0739:
0740: /**
0741: * stops component ( service engine, binding component)
0742: *
0743: * @param componentName
0744: * name of the component
0745: * @param targetName
0746: * @return name of the component
0747: * @throws ManagementRemoteException
0748: * on error
0749: *
0750: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#stopComponent(java.lang.String,
0751: * java.lang.String)
0752: */
0753: public String stopComponent(String componentName, String targetName)
0754: throws ManagementRemoteException {
0755: logDebug("stopping Component " + componentName);
0756:
0757: ObjectName lifecycleObjectName = this
0758: .getComponentLifeCycleMBeanObjectName(componentName,
0759: targetName);
0760: // ////////////////////////////////////////
0761: // Start Check to make sure target is valid
0762: // ////////////////////////////////////////
0763: this .checkForValidTarget(lifecycleObjectName, targetName);
0764: // ////////////////////////////////////////
0765: // End Check to make sure target is valid
0766: // ////////////////////////////////////////
0767:
0768: Object result = null;
0769: logDebug("Calling stop on Component LifecycleMBean "
0770: + lifecycleObjectName);
0771: result = this .invokeMBeanOperation(lifecycleObjectName, "stop");
0772:
0773: return componentName;
0774: }
0775:
0776: /**
0777: * stops service assembly
0778: *
0779: * @param serviceAssemblyName
0780: * name of the service assembly
0781: * @param targetName
0782: * @return result as a management message xml text
0783: * @throws ManagementRemoteException
0784: * on error
0785: *
0786: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#stopServiceAssembly(java.lang.String,
0787: * java.lang.String)
0788: */
0789: public String stopServiceAssembly(String serviceAssemblyName,
0790: String targetName) throws ManagementRemoteException {
0791: logDebug("Stopping Service Assembly " + serviceAssemblyName);
0792:
0793: ObjectName deploymentServiceObjectName = this
0794: .getDeploymentServiceMBeanObjectName(targetName);
0795: // ////////////////////////////////////////
0796: // Start Check to make sure target is valid
0797: // ////////////////////////////////////////
0798: this .checkForValidTarget(deploymentServiceObjectName,
0799: targetName);
0800: // ////////////////////////////////////////
0801: // End Check to make sure target is valid
0802: // ////////////////////////////////////////
0803:
0804: logDebug("Calling stop on Deployment Service MBean = "
0805: + deploymentServiceObjectName);
0806:
0807: Object resultObject = this .invokeMBeanOperation(
0808: deploymentServiceObjectName, "stop",
0809: serviceAssemblyName);
0810:
0811: String result = null;
0812: if (resultObject != null) {
0813: result = resultObject.toString();
0814: if ((serviceAssemblyName == null)
0815: || (result.contains("FAILED") == true)
0816: || (result.contains("WARNING") == true)) {
0817: result = resultObject.toString();
0818: } else {
0819: result = serviceAssemblyName;
0820: }
0821: return result;
0822: } else {
0823: Exception exception = this .createManagementException(
0824: "ui.mbean.sasm.stop.error", null, null);
0825: throw new ManagementRemoteException(exception);
0826: }
0827: }
0828:
0829: /////////////////////////////////////////////
0830: // Start of Cumulative Operation Definitions
0831: /////////////////////////////////////////////
0832:
0833: /**
0834: * return component info xml text that has only binding component infos.
0835: *
0836: * @param targetNames
0837: * @return the component info xml text as a Map of [targetName, xmlString].
0838: * @throws ManagementRemoteException
0839: * on error
0840: *
0841: */
0842: public Map<String, String> listBindingComponents(
0843: String[] targetNames) throws ManagementRemoteException {
0844:
0845: String xmlString = null;
0846: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0847: for (int index = 0; index < targetNames.length; index++) {
0848: try {
0849: xmlString = this
0850: .listBindingComponents(targetNames[index]);
0851: if (xmlString != null) {
0852: result.putIfAbsent(targetNames[index], xmlString);
0853: }
0854: } catch (ManagementRemoteException exception) {
0855: xmlString = this .getStackTrace(exception);
0856: result.putIfAbsent(targetNames[index], xmlString);
0857: }
0858: }
0859: return (Map<String, String>) result;
0860:
0861: }
0862:
0863: /**
0864: * return component info xml text that has only binding component infos
0865: * which satisfies the options passed to the method.
0866: *
0867: * @param state
0868: * return all the binding components that are in the specified
0869: * state. valid states are JBIComponentInfo.STARTED, STOPPED,
0870: * INSTALLED or null for ANY state
0871: * @param sharedLibraryName
0872: * return all the binding components that have a dependency on
0873: * the specified shared library. null value to ignore this
0874: * option.
0875: * @param serviceAssemblyName
0876: * return all the binding components that have the specified
0877: * service assembly deployed on them. null value to ignore this
0878: * option.
0879: * @param targetName
0880: * @return xml text contain the list of binding component infos as map of
0881: * [targetName, xmlString]
0882: * @throws ManagementRemoteException
0883: * if error or exception occurs.
0884: *
0885: */
0886: public Map<String, String> listBindingComponents(String state,
0887: String sharedLibraryName, String serviceAssemblyName,
0888: String[] targetNames) throws ManagementRemoteException {
0889:
0890: String xmlString = null;
0891: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0892: for (int index = 0; index < targetNames.length; index++) {
0893: try {
0894: xmlString = this .listBindingComponents(state,
0895: sharedLibraryName, serviceAssemblyName,
0896: targetNames[index]);
0897: if (xmlString != null) {
0898: result.putIfAbsent(targetNames[index], xmlString);
0899: }
0900: } catch (ManagementRemoteException exception) {
0901: xmlString = this .getStackTrace(exception);
0902: result.putIfAbsent(targetNames[index], xmlString);
0903: }
0904: }
0905: return (Map<String, String>) result;
0906:
0907: }
0908:
0909: /**
0910: * returns a list of Service Assembly Infos in a xml format.
0911: *
0912: * @param targetNames
0913: * @return xml text containing the Service Assembly infos as map of
0914: * [targetName, xmlString]
0915: * @throws ManagementRemoteException
0916: * on error
0917: *
0918: */
0919: public Map<String, String> listServiceAssemblies(
0920: String[] targetNames) throws ManagementRemoteException {
0921:
0922: String xmlString = null;
0923: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0924: for (int index = 0; index < targetNames.length; index++) {
0925: try {
0926: xmlString = this
0927: .listServiceAssemblies(targetNames[index]);
0928: if (xmlString != null) {
0929: result.putIfAbsent(targetNames[index], xmlString);
0930: }
0931: } catch (ManagementRemoteException exception) {
0932: xmlString = this .getStackTrace(exception);
0933: result.putIfAbsent(targetNames[index], xmlString);
0934: }
0935: }
0936: return (Map<String, String>) result;
0937:
0938: }
0939:
0940: /**
0941: * returns the list of service assembly infos in a xml format that have the
0942: * service unit deployed on the specified component.
0943: *
0944: * @param componentName
0945: * to list all the service assemblies that have some deployments
0946: * on this component.
0947: * @param targetNames
0948: * @return xml string contain the list of service assembly infos as map of
0949: * [targetName, xmlString]
0950: * @throws ManagementRemoteException
0951: * if error or exception occurs.
0952: *
0953: */
0954: public Map<String, String> listServiceAssemblies(
0955: String componentName, String[] targetNames)
0956: throws ManagementRemoteException {
0957:
0958: String xmlString = null;
0959: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0960: for (int index = 0; index < targetNames.length; index++) {
0961: try {
0962: xmlString = this .listServiceAssemblies(componentName,
0963: targetNames[index]);
0964: if (xmlString != null) {
0965: result.putIfAbsent(targetNames[index], xmlString);
0966: }
0967: } catch (ManagementRemoteException exception) {
0968: xmlString = this .getStackTrace(exception);
0969: result.putIfAbsent(targetNames[index], xmlString);
0970: }
0971: }
0972: return (Map<String, String>) result;
0973:
0974: }
0975:
0976: /**
0977: * returns the list of service asssembly infos in a xml format that have the
0978: * service unit deployed on the specified component.
0979: *
0980: * @param state
0981: * to return all the service assemblies that are in the specified
0982: * state. JBIServiceAssemblyInfo.STARTED, STOPPED, SHUTDOWN or
0983: * null for ANY state
0984: * @param componentName
0985: * to list all the service assemblies that have some deployments
0986: * on this component.
0987: * @param targetNames
0988: * @return xml string contain the list of service assembly infos as map of
0989: * [targetName, xmlString]
0990: * @throws ManagementRemoteException
0991: * if error or exception occurs.
0992: *
0993: */
0994: public Map<String, String> listServiceAssemblies(String state,
0995: String componentName, String[] targetNames)
0996: throws ManagementRemoteException {
0997:
0998: String xmlString = null;
0999: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1000: for (int index = 0; index < targetNames.length; index++) {
1001: try {
1002: xmlString = this .listServiceAssemblies(state,
1003: componentName, targetNames[index]);
1004: if (xmlString != null) {
1005: result.putIfAbsent(targetNames[index], xmlString);
1006: }
1007: } catch (ManagementRemoteException exception) {
1008: xmlString = this .getStackTrace(exception);
1009: result.putIfAbsent(targetNames[index], xmlString);
1010: }
1011: }
1012: return (Map<String, String>) result;
1013:
1014: }
1015:
1016: /**
1017: * return component info xml text that has only service engine infos.
1018: *
1019: * @param targetName
1020: * @return the component info xml text as map of [targetName,xmlString].
1021: * @throws ManagementRemoteException
1022: * on error
1023: *
1024: */
1025: public Map<String, String> listServiceEngines(String[] targetNames)
1026: throws ManagementRemoteException {
1027:
1028: String xmlString = null;
1029: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1030: for (int index = 0; index < targetNames.length; index++) {
1031: try {
1032: xmlString = this .listServiceEngines(targetNames[index]);
1033: if (xmlString != null) {
1034: result.putIfAbsent(targetNames[index], xmlString);
1035: }
1036: } catch (ManagementRemoteException exception) {
1037: xmlString = this .getStackTrace(exception);
1038: result.putIfAbsent(targetNames[index], xmlString);
1039: }
1040: }
1041: return (Map<String, String>) result;
1042:
1043: }
1044:
1045: /**
1046: * return component info xml text that has only service engine infos which
1047: * satisfies the options passed to the method.
1048: *
1049: * @param state
1050: * return all the service engines that are in the specified
1051: * state. valid states are JBIComponentInfo.STARTED, STOPPED,
1052: * INSTALLED or null for ANY state
1053: * @param sharedLibraryName
1054: * return all the service engines that have a dependency on the
1055: * specified shared library. null value to ignore this option.
1056: * @param serviceAssemblyName
1057: * return all the service engines that have the specified service
1058: * assembly deployed on them. null value to ignore this option.
1059: * @param targetName
1060: * @return xml text contain the map of service engine component infos as
1061: * [targetName, xmlString]
1062: * @throws ManagementRemoteException
1063: * if error or exception occurs.
1064: *
1065: */
1066: public Map<String, String> listServiceEngines(String state,
1067: String sharedLibraryName, String serviceAssemblyName,
1068: String[] targetNames) throws ManagementRemoteException {
1069:
1070: String xmlString = null;
1071: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1072: for (int index = 0; index < targetNames.length; index++) {
1073: try {
1074: xmlString = this .listServiceEngines(state,
1075: sharedLibraryName, serviceAssemblyName,
1076: targetNames[index]);
1077: if (xmlString != null) {
1078: result.putIfAbsent(targetNames[index], xmlString);
1079: }
1080: } catch (ManagementRemoteException exception) {
1081: xmlString = this .getStackTrace(exception);
1082: result.putIfAbsent(targetNames[index], xmlString);
1083: }
1084:
1085: }
1086: return (Map<String, String>) result;
1087:
1088: }
1089:
1090: /**
1091: * return component info xml text that has only shared library infos.
1092: *
1093: * @param targetName
1094: * @return the component info xml text as a map of [targetName, xmlString].
1095: * @throws ManagementRemoteException
1096: * on error
1097: *
1098: */
1099: public Map<String, String> listSharedLibraries(String[] targetNames)
1100: throws ManagementRemoteException {
1101:
1102: String xmlString = null;
1103: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1104: for (int index = 0; index < targetNames.length; index++) {
1105: try {
1106: xmlString = this
1107: .listSharedLibraries(targetNames[index]);
1108: if (xmlString != null) {
1109: result.putIfAbsent(targetNames[index], xmlString);
1110: }
1111: } catch (ManagementRemoteException exception) {
1112: xmlString = this .getStackTrace(exception);
1113: result.putIfAbsent(targetNames[index], xmlString);
1114: }
1115: }
1116: return (Map<String, String>) result;
1117:
1118: }
1119:
1120: /**
1121: * returns the list of Shared Library infos in the in a xml format
1122: *
1123: * @param componentName
1124: * to return only the shared libraries that are this component
1125: * dependents. null for listing all the shared libraries in the
1126: * system.
1127: * @param targetName
1128: * @return xml string contains the map of componentinfos for shared
1129: * libraries as [targetName, xmlString].
1130: * @throws ManagementRemoteException
1131: * if error or exception occurs.
1132: *
1133: */
1134: public Map<String, String> listSharedLibraries(
1135: String componentName, String[] targetNames)
1136: throws ManagementRemoteException {
1137:
1138: String xmlString = null;
1139: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1140: for (int index = 0; index < targetNames.length; index++) {
1141: try {
1142: xmlString = this .listSharedLibraries(componentName,
1143: targetNames[index]);
1144: if (xmlString != null) {
1145: result.putIfAbsent(targetNames[index], xmlString);
1146: }
1147: } catch (ManagementRemoteException exception) {
1148: xmlString = this .getStackTrace(exception);
1149: result.putIfAbsent(targetNames[index], xmlString);
1150: }
1151: }
1152: return (Map<String, String>) result;
1153:
1154: }
1155:
1156: /**
1157: * returns a list of Binding Component and Service Engine infos in xml
1158: * format, that are dependent upon a specified Shared Library
1159: *
1160: * @param sharedLibraryName
1161: * the shared library name
1162: * @param targetName
1163: * @return xml string containing the map of componentInfos as [targetName,
1164: * xmlString]
1165: * @throws ManagementRemoteException
1166: * on error
1167: *
1168: */
1169: public Map<String, String> listSharedLibraryDependents(
1170: String sharedLibraryName, String[] targetNames)
1171: throws ManagementRemoteException {
1172:
1173: String xmlString = null;
1174: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1175: for (int index = 0; index < targetNames.length; index++) {
1176: try {
1177: xmlString = this .listSharedLibraryDependents(
1178: sharedLibraryName, targetNames[index]);
1179: if (xmlString != null) {
1180: result.putIfAbsent(targetNames[index], xmlString);
1181: }
1182: } catch (ManagementRemoteException exception) {
1183: xmlString = this .getStackTrace(exception);
1184: result.putIfAbsent(targetNames[index], xmlString);
1185: }
1186: }
1187: return (Map<String, String>) result;
1188:
1189: }
1190:
1191: /**
1192: * return component info xml text for the specified binding component if
1193: * exists. If no binding component with that name exists, it returns the xml
1194: * with empty list.
1195: *
1196: * @param name
1197: * name of the binding component to lookup
1198: * @param state
1199: * return the binding component that is in the specified state.
1200: * valid states are JBIComponentInfo.STARTED, STOPPED, INSTALLED
1201: * or null for ANY state
1202: * @param sharedLibraryName
1203: * return the binding component that has a dependency on the
1204: * specified shared library. null value to ignore this option.
1205: * @param serviceAssemblyName
1206: * return the binding component that has the specified service
1207: * assembly deployed on it. null value to ignore this option.
1208: * @param targetName
1209: * @return xml text contain the binding component info that confirms to the
1210: * component info list xml grammer as a map of [targetName,
1211: * xmlString].
1212: * @throws ManagementRemoteException
1213: * if error or exception occurs.
1214: *
1215: */
1216: public Map<String, String> showBindingComponent(String name,
1217: String state, String sharedLibraryName,
1218: String serviceAssemblyName, String[] targetNames)
1219: throws ManagementRemoteException {
1220:
1221: String xmlString = null;
1222: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1223: for (int index = 0; index < targetNames.length; index++) {
1224: try {
1225: xmlString = this .showBindingComponent(name, state,
1226: sharedLibraryName, serviceAssemblyName,
1227: targetNames[index]);
1228: if (xmlString != null) {
1229: result.putIfAbsent(targetNames[index], xmlString);
1230: }
1231: } catch (ManagementRemoteException exception) {
1232: xmlString = this .getStackTrace(exception);
1233: result.putIfAbsent(targetNames[index], xmlString);
1234: }
1235: }
1236: return (Map<String, String>) result;
1237:
1238: }
1239:
1240: /**
1241: * return service assembly info xml text for the specified service assembly
1242: * if exists. If no service assembly with that name exists, it returns the
1243: * xml with empty list.
1244: *
1245: * @param name
1246: * name of the service assembly to lookup
1247: * @param state
1248: * return the service assembly that is in the specified state.
1249: * JBIServiceAssemblyInfo.STARTED, STOPPED, SHUTDOWN or null for
1250: * ANY state
1251: * @param componentName
1252: * return the service assembly that has service units on this
1253: * component.
1254: * @param targetNames
1255: * @return xml string contain service assembly info that confirms to the
1256: * service assembly list xml grammer as [targetName, xmlString] map.
1257: * @throws ManagementRemoteException
1258: * if error or exception occurs.
1259: *
1260: */
1261: public Map<String, String> showServiceAssembly(String name,
1262: String state, String componentName, String[] targetNames)
1263: throws ManagementRemoteException {
1264:
1265: String xmlString = null;
1266: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1267: for (int index = 0; index < targetNames.length; index++) {
1268: try {
1269: xmlString = this .showServiceAssembly(name, state,
1270: componentName, targetNames[index]);
1271: if (xmlString != null) {
1272: result.putIfAbsent(targetNames[index], xmlString);
1273: }
1274: } catch (ManagementRemoteException exception) {
1275: xmlString = this .getStackTrace(exception);
1276: result.putIfAbsent(targetNames[index], xmlString);
1277: }
1278: }
1279: return (Map<String, String>) result;
1280:
1281: }
1282:
1283: /**
1284: * return component info xml text for the specified service engine if
1285: * exists. If no service engine with that name exists, it returns the xml
1286: * with empty list.
1287: *
1288: * @param name
1289: * name of the service engine to lookup
1290: * @param state
1291: * return service engine that is in the specified state. valid
1292: * states are JBIComponentInfo.STARTED, STOPPED, INSTALLED or
1293: * null for ANY state
1294: * @param sharedLibraryName
1295: * return service engine that has a dependency on the specified
1296: * shared library. null value to ignore this option.
1297: * @param serviceAssemblyName
1298: * return the service engine that has the specified service
1299: * assembly deployed on it. null value to ignore this option.
1300: * @param targetName
1301: * @return xml text contain the service engine component info that confirms
1302: * to the component info list xml grammer as a map of [targetName,
1303: * xmlString].
1304: * @throws ManagementRemoteException
1305: * if error or exception occurs.
1306: *
1307: */
1308: public Map<String, String> showServiceEngine(String name,
1309: String state, String sharedLibraryName,
1310: String serviceAssemblyName, String[] targetNames)
1311: throws ManagementRemoteException {
1312:
1313: String xmlString = null;
1314: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1315: for (int index = 0; index < targetNames.length; index++) {
1316: try {
1317: xmlString = this .showServiceEngine(name, state,
1318: sharedLibraryName, serviceAssemblyName,
1319: targetNames[index]);
1320: if (xmlString != null) {
1321: result.putIfAbsent(targetNames[index], xmlString);
1322: }
1323: } catch (ManagementRemoteException exception) {
1324: xmlString = this .getStackTrace(exception);
1325: result.putIfAbsent(targetNames[index], xmlString);
1326: }
1327: }
1328: return (Map<String, String>) result;
1329:
1330: }
1331:
1332: /**
1333: * return component info xml text for the specified shared library if
1334: * exists. If no shared library with that name exists, it returns the xml
1335: * with empty list.
1336: *
1337: * @param name
1338: * name of the shared library to lookup
1339: * @param componentName
1340: * return the shared library that is this component dependents.
1341: * null to ignore this option.
1342: * @param targetName
1343: * @return xml string contain shared library component info that confirms to
1344: * the component info list xml grammer as a map of [targetName,
1345: * xmlString].
1346: * @throws ManagementRemoteException
1347: * if error or exception occurs.
1348: *
1349: */
1350: public Map<String, String> showSharedLibrary(String name,
1351: String componentName, String[] targetNames)
1352: throws ManagementRemoteException {
1353:
1354: String xmlString = null;
1355: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1356: for (int index = 0; index < targetNames.length; index++) {
1357: try {
1358: xmlString = this .showSharedLibrary(name, componentName,
1359: targetNames[index]);
1360: if (xmlString != null) {
1361: result.putIfAbsent(targetNames[index], xmlString);
1362: }
1363: } catch (ManagementRemoteException exception) {
1364: xmlString = this .getStackTrace(exception);
1365: result.putIfAbsent(targetNames[index], xmlString);
1366: }
1367: }
1368:
1369: return (Map<String, String>) result;
1370:
1371: }
1372:
1373: /**
1374: * shuts down component (service engine, binding component)
1375: *
1376: * @param componentName
1377: * name of the component
1378: * @param targetNames
1379: * @return name of the component as [targetName, string] map
1380: * @throws ManagementRemoteException
1381: * on error
1382: *
1383: */
1384: public Map<String, String> shutdownComponent(String componentName,
1385: String[] targetNames) throws ManagementRemoteException {
1386:
1387: String xmlString = null;
1388: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1389: for (int index = 0; index < targetNames.length; index++) {
1390: try {
1391: xmlString = this .shutdownComponent(componentName,
1392: targetNames[index]);
1393: if (xmlString != null) {
1394: result.putIfAbsent(targetNames[index], xmlString);
1395: }
1396: } catch (ManagementRemoteException exception) {
1397: xmlString = this .getStackTrace(exception);
1398: result.putIfAbsent(targetNames[index], xmlString);
1399: }
1400: }
1401: return (Map<String, String>) result;
1402:
1403: }
1404:
1405: /**
1406: * shuts down component (service engine, binding component)
1407: *
1408: * @param componentName
1409: * name of the component
1410: * @param force
1411: * true to force shutdown
1412: * @param targetNames
1413: * @return name of the component as [targetName, string] map
1414: * @throws ManagementRemoteException
1415: * on error
1416: *
1417: */
1418: public Map<String, String> shutdownComponent(String componentName,
1419: boolean force, String[] targetNames)
1420: throws ManagementRemoteException {
1421:
1422: String xmlString = null;
1423: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1424: for (int index = 0; index < targetNames.length; index++) {
1425: try {
1426: xmlString = this .shutdownComponent(componentName,
1427: force, targetNames[index]);
1428: if (xmlString != null) {
1429: result.putIfAbsent(targetNames[index], xmlString);
1430: }
1431: } catch (ManagementRemoteException exception) {
1432: xmlString = this .getStackTrace(exception);
1433: result.putIfAbsent(targetNames[index], xmlString);
1434: }
1435: }
1436: return (Map<String, String>) result;
1437:
1438: }
1439:
1440: /**
1441: * shuts down service assembly
1442: *
1443: * @param serviceAssemblyName
1444: * name of the service assembly
1445: * @param targetNames
1446: * @throws ManagementRemoteException
1447: * on error
1448: * @return result as a management message xml text as [targetName, string]
1449: * map
1450: *
1451: */
1452: public Map<String, String> shutdownServiceAssembly(
1453: String serviceAssemblyName, String[] targetNames)
1454: throws ManagementRemoteException {
1455:
1456: String xmlString = null;
1457: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1458: for (int index = 0; index < targetNames.length; index++) {
1459: try {
1460: xmlString = this .shutdownServiceAssembly(
1461: serviceAssemblyName, targetNames[index]);
1462: if (xmlString != null) {
1463: result.putIfAbsent(targetNames[index], xmlString);
1464: }
1465: } catch (ManagementRemoteException exception) {
1466: xmlString = this .getStackTrace(exception);
1467: result.putIfAbsent(targetNames[index], xmlString);
1468: }
1469:
1470: }
1471: return (Map<String, String>) result;
1472:
1473: }
1474:
1475: /**
1476: * shuts down service assembly
1477: *
1478: * @param serviceAssemblyName
1479: * name of the service assembly
1480: * @param forceShutdown
1481: * @param targetName
1482: * name of the target for this operation
1483: * @return Map of targetName and result as a management message xml text
1484: * strings.
1485: * @throws ManagementRemoteException
1486: * on error
1487: */
1488: public Map<String /* targetName */, String /* targetResult */> shutdownServiceAssembly(
1489: String serviceAssemblyName, boolean forceShutdown,
1490: String[] targetNames) throws ManagementRemoteException {
1491:
1492: String xmlString = null;
1493: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1494: for (int index = 0; index < targetNames.length; index++) {
1495: try {
1496: xmlString = this .shutdownServiceAssembly(
1497: serviceAssemblyName, forceShutdown,
1498: targetNames[index]);
1499: if (xmlString != null) {
1500: result.putIfAbsent(targetNames[index], xmlString);
1501: }
1502: } catch (ManagementRemoteException exception) {
1503: xmlString = this .getStackTrace(exception);
1504: result.putIfAbsent(targetNames[index], xmlString);
1505: }
1506:
1507: }
1508: return (Map<String, String>) result;
1509: }
1510:
1511: /**
1512: * starts component ( service engine, binding component)
1513: *
1514: * @param componentName
1515: * name of the component
1516: * @param targetNames
1517: * @throws ManagementRemoteException
1518: * on error
1519: * @return name of the component as [targetName, string] map
1520: *
1521: */
1522: public Map<String, String> startComponent(String componentName,
1523: String[] targetNames) throws ManagementRemoteException {
1524:
1525: String xmlString = null;
1526: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1527: for (int index = 0; index < targetNames.length; index++) {
1528: try {
1529: xmlString = this .startComponent(componentName,
1530: targetNames[index]);
1531: if (xmlString != null) {
1532: result.putIfAbsent(targetNames[index], xmlString);
1533: }
1534: } catch (ManagementRemoteException exception) {
1535: xmlString = this .getStackTrace(exception);
1536: result.putIfAbsent(targetNames[index], xmlString);
1537: }
1538:
1539: }
1540: return (Map<String, String>) result;
1541:
1542: }
1543:
1544: /**
1545: * starts service assembly
1546: *
1547: * @param serviceAssemblyName
1548: * name of the service assembly
1549: * @param targetNames
1550: * @throws ManagementRemoteException
1551: * on error
1552: * @return result as a management message xml text as [targetName, string]
1553: * map
1554: *
1555: */
1556: public Map<String, String> startServiceAssembly(
1557: String serviceAssemblyName, String[] targetNames)
1558: throws ManagementRemoteException {
1559:
1560: String xmlString = null;
1561: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1562: for (int index = 0; index < targetNames.length; index++) {
1563: try {
1564: xmlString = this .startServiceAssembly(
1565: serviceAssemblyName, targetNames[index]);
1566: if (xmlString != null) {
1567: result.putIfAbsent(targetNames[index], xmlString);
1568: }
1569: } catch (ManagementRemoteException exception) {
1570: xmlString = this .getStackTrace(exception);
1571: result.putIfAbsent(targetNames[index], xmlString);
1572: }
1573:
1574: }
1575: return (Map<String, String>) result;
1576:
1577: }
1578:
1579: /**
1580: * stops component ( service engine, binding component)
1581: *
1582: * @param componentName
1583: * name of the component
1584: * @param targetNames
1585: * @return name of the component as [targetName, string] map
1586: * @throws ManagementRemoteException
1587: * on error
1588: *
1589: */
1590: public Map<String, String> stopComponent(String componentName,
1591: String[] targetNames) throws ManagementRemoteException {
1592:
1593: String xmlString = null;
1594: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1595: for (int index = 0; index < targetNames.length; index++) {
1596: try {
1597: xmlString = this .stopComponent(componentName,
1598: targetNames[index]);
1599: if (xmlString != null) {
1600: result.putIfAbsent(targetNames[index], xmlString);
1601: }
1602: } catch (ManagementRemoteException exception) {
1603: xmlString = this .getStackTrace(exception);
1604: result.putIfAbsent(targetNames[index], xmlString);
1605: }
1606: }
1607: return (Map<String, String>) result;
1608:
1609: }
1610:
1611: /**
1612: * stops service assembly
1613: *
1614: * @param serviceAssemblyName
1615: * name of the service assembly
1616: * @param targetNames
1617: * @return result as a management message xml text as [targetName, string]
1618: * map
1619: * @throws ManagementRemoteException
1620: * on error
1621: *
1622: */
1623: public Map<String, String> stopServiceAssembly(
1624: String serviceAssemblyName, String[] targetNames)
1625: throws ManagementRemoteException {
1626:
1627: String xmlString = null;
1628: ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1629: for (int index = 0; index < targetNames.length; index++) {
1630: try {
1631: xmlString = this .stopServiceAssembly(
1632: serviceAssemblyName, targetNames[index]);
1633: if (xmlString != null) {
1634: result.putIfAbsent(targetNames[index], xmlString);
1635: }
1636: } catch (ManagementRemoteException exception) {
1637: xmlString = this .getStackTrace(exception);
1638: result.putIfAbsent(targetNames[index], xmlString);
1639: }
1640:
1641: }
1642: return (Map<String, String>) result;
1643:
1644: }
1645:
1646: /////////////////////////////////////////////
1647: // End of Cumulative Operation Definitions
1648: /////////////////////////////////////////////
1649:
1650: /**
1651: * return component info xml text for the specified service engine if
1652: * exists. If no service engine with that name exists, it returns the xml
1653: * with empty list.
1654: *
1655: * @param name
1656: * name of the service engine to lookup
1657: * @param type
1658: * ENGINE or BINDING
1659: * @param state
1660: * to return all the service engines that are in the specified
1661: * state. JBIComponentInfo.STARTED, STOPPED, INSTALLED or null
1662: * for ANY state
1663: * @param sharedLibraryName
1664: * to return all the service engines that have a dependency on
1665: * the specified shared library. Could be null for not filtering
1666: * the service engines for this dependency.
1667: * @param serviceAssemblyName
1668: * to return all the service engines that have the specified
1669: * service assembly deployed on them. Could be null for not
1670: * filtering the service engines for this dependency.
1671: * @param targetName
1672: * @return xml string contain service engine component info
1673: * @throws ManagementRemoteException
1674: * if error or exception occurs.
1675: */
1676: protected String showComponent(String name, ComponentType type,
1677: String state, String sharedLibraryName,
1678: String serviceAssemblyName, String targetName)
1679: throws ManagementRemoteException {
1680:
1681: // ////////////////////////////////////////
1682: // Start Check to make sure target is valid
1683: // ////////////////////////////////////////
1684: ObjectName installerServiceObjectName = this
1685: .getInstallationServiceMBeanObjectName(targetName);
1686: this
1687: .checkForValidTarget(installerServiceObjectName,
1688: targetName);
1689: // ////////////////////////////////////////
1690: // End Check to make sure target is valid
1691: // ////////////////////////////////////////
1692:
1693: validateUiJBIComponentInfoState(state);
1694:
1695: ArrayList uiCompInfoList = new ArrayList();
1696:
1697: if (name == null || name.trim().length() <= 0) {
1698: // return empty list
1699: return JBIComponentInfo.writeAsXmlText(uiCompInfoList);
1700: }
1701:
1702: ComponentQuery componentQuery = this
1703: .getFrameworkComponentQuery(targetName);
1704: ComponentInfo componentInformation = null;
1705: if (componentQuery != null) {
1706: componentInformation = componentQuery
1707: .getComponentInfo(name);
1708: }
1709:
1710: if (componentInformation == null) {
1711: // component does not exits
1712: // return empty list
1713: return JBIComponentInfo.writeAsXmlText(uiCompInfoList);
1714: }
1715:
1716: ComponentType frameworkCompType = ComponentType.BINDINGS_AND_ENGINES;
1717: ComponentState frameworkCompState = ComponentState.UNKNOWN;
1718:
1719: if (type != ComponentType.ENGINE
1720: && type != ComponentType.BINDING) {
1721: frameworkCompType = ComponentType.BINDINGS_AND_ENGINES;
1722: } else {
1723: frameworkCompType = type;
1724: }
1725:
1726: if (state != null) {
1727: frameworkCompState = toFrameworkComponentInfoState(state);
1728: }
1729:
1730: List compInfoList = this
1731: .getFrameworkComponentInfoListForEnginesAndBindings(
1732: frameworkCompType, frameworkCompState,
1733: sharedLibraryName, serviceAssemblyName,
1734: targetName);
1735:
1736: if (compInfoList == null || compInfoList.size() <= 0) {
1737: // no components found for the rest of the query
1738: // return empty list
1739: return JBIComponentInfo.writeAsXmlText(uiCompInfoList);
1740: }
1741:
1742: // find if the component is in the filtered list or not.
1743: for (Iterator itr = compInfoList.iterator(); itr.hasNext();) {
1744: String compName = ((ComponentInfo) itr.next()).getName();
1745: if (compName.equals(componentInformation.getName())) {
1746: uiCompInfoList.add(this .toUiComponentInfo(
1747: componentInformation, targetName));
1748: break;
1749: }
1750: }
1751:
1752: return JBIComponentInfo.writeAsXmlText(uiCompInfoList);
1753: }
1754:
1755: /**
1756: * shuts down service assembly
1757: *
1758: * @param serviceAssemblyName
1759: * name of the service assembly
1760: * @param force
1761: * @param targetName
1762: * @return result as a management message xml text
1763: * @throws ManagementRemoteException
1764: * on error
1765: */
1766: protected String shutdownServiceAssemblyInternal(
1767: String serviceAssemblyName, boolean force, String targetName)
1768: throws ManagementRemoteException {
1769: logDebug("Shutting down Service Assembly "
1770: + serviceAssemblyName);
1771:
1772: ObjectName deploymentServiceObjectName = this
1773: .getDeploymentServiceMBeanObjectName(targetName);
1774:
1775: // ////////////////////////////////////////
1776: // Start Check to make sure target is valid
1777: // ////////////////////////////////////////
1778: this .checkForValidTarget(deploymentServiceObjectName,
1779: targetName);
1780: // ////////////////////////////////////////
1781: // End Check to make sure target is valid
1782: // ////////////////////////////////////////
1783:
1784: logDebug("Calling shutdown on Deployment Service MBean = "
1785: + deploymentServiceObjectName.toString());
1786:
1787: Object resultObject = null;
1788:
1789: if (force == false) {
1790: resultObject = invokeMBeanOperation(
1791: deploymentServiceObjectName, "shutDown",
1792: serviceAssemblyName);
1793: } else {
1794: Object[] params = new Object[2];
1795: params[0] = serviceAssemblyName;
1796: params[1] = Boolean.valueOf(force);
1797:
1798: String[] signature = new String[2];
1799: signature[0] = "java.lang.String";
1800: signature[1] = "boolean";
1801:
1802: resultObject = invokeMBeanOperation(
1803: deploymentServiceObjectName, "shutDown", params,
1804: signature);
1805: }
1806:
1807: String result = null;
1808: if (resultObject != null) {
1809: result = resultObject.toString();
1810: if ((serviceAssemblyName == null)
1811: || (result.contains("FAILED") == true)
1812: || (result.contains("WARNING") == true)) {
1813: result = resultObject.toString();
1814: } else {
1815: result = serviceAssemblyName;
1816: }
1817: return result;
1818: } else {
1819: Exception exception = this .createManagementException(
1820: "ui.mbean.sasm.shutdown.error", null, null);
1821: throw new ManagementRemoteException(exception);
1822: }
1823: }
1824:
1825: }
|