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: * @(#)AdministrationServiceMBeanImpl.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.administration;
0030:
0031: import java.io.Serializable;
0032: import java.util.ArrayList;
0033: import java.util.HashMap;
0034: import java.util.List;
0035: import java.util.Map;
0036: import java.util.Properties;
0037: import java.util.Set;
0038:
0039: import javax.management.MBeanServerConnection;
0040: import javax.management.ObjectName;
0041:
0042: import com.sun.esb.management.api.administration.AdministrationService;
0043: import com.sun.esb.management.base.services.AbstractListStateServiceMBeansImpl;
0044: import com.sun.esb.management.common.ManagementRemoteException;
0045: import com.sun.jbi.ComponentInfo;
0046: import com.sun.jbi.ComponentQuery;
0047: import com.sun.jbi.ComponentType;
0048: import com.sun.jbi.EnvironmentContext;
0049: import com.sun.jbi.ui.common.JBIAdminCommands;
0050: import com.sun.jbi.ui.common.JBIComponentInfo;
0051: import com.sun.jbi.ui.common.JBIDescriptor;
0052: import com.sun.jbi.ui.common.ServiceAssemblyInfo;
0053: import com.sun.jbi.ui.runtime.GenericsSupport;
0054:
0055: /**
0056: * Defines MBean operations for common administration services.
0057: *
0058: * @author graj
0059: */
0060: public class AdministrationServiceMBeanImpl extends
0061: AbstractListStateServiceMBeansImpl implements
0062: AdministrationService, Serializable {
0063:
0064: static final long serialVersionUID = -1L;
0065:
0066: /**
0067: * Constructor - Constructs a new instance of AdministrationServiceMBeanImpl
0068: *
0069: * @param anEnvContext
0070: */
0071: public AdministrationServiceMBeanImpl(
0072: EnvironmentContext anEnvContext) {
0073: super (anEnvContext);
0074: }
0075:
0076: /**
0077: * Returns a map of target names to an array of target instance names.
0078: * In the case cluster targets, the key contains the cluster target name,
0079: * and the the value contains an array of the "target instance" names.
0080: * If it is not a cluster target, the key contains the targetName, and
0081: * the value is null.
0082: *
0083: * @return map of target names to array of target instance names
0084: * @throws ManagementRemoteException
0085: */
0086: public Map<String /*targetName*/, String[] /*targetInstanceNames*/> listTargetNames()
0087: throws ManagementRemoteException {
0088: return super .listTargetNames();
0089: }
0090:
0091: /**
0092: * Retrieve runtime version information
0093: * @return map of targetName to Properties elements detailing version info
0094: * @throws ManagementRemoteException
0095: */
0096: @SuppressWarnings("unchecked")
0097: public Map<String /*targetName*/, Properties /*version information*/> getRuntimeDetails()
0098: throws ManagementRemoteException {
0099: Map<String /*targetName*/, Properties /*version information*/> result = null;
0100: result = new HashMap<String /*targetName*/, Properties /*version information*/>();
0101: Map<String /*targetName*/, String[] /*targetInstanceNames*/> targetNameToInstancesMap = null;
0102: targetNameToInstancesMap = listTargetNames();
0103:
0104: if (targetNameToInstancesMap != null) {
0105: for (String targetName : targetNameToInstancesMap.keySet()) {
0106: ObjectName objectName = null;
0107: String value = null;
0108: Properties properties = new Properties();
0109: if (targetName
0110: .equals(JBIAdminCommands.SERVER_TARGET_KEY) == true) {
0111: objectName = super .getAdminServiceMBeanObjectName();
0112: if (objectName != null) {
0113: value = (String) this .getAttributeValue(
0114: objectName, SYSTEM_INFORMATION_KEY);
0115: if (value != null) {
0116: properties.setProperty(
0117: SYSTEM_INFORMATION_KEY, value);
0118: }
0119: value = (String) this .getAttributeValue(
0120: objectName, BUILD_NUMBER_KEY);
0121: if (value != null) {
0122: properties.setProperty(BUILD_NUMBER_KEY,
0123: value);
0124: }
0125: value = (String) this .getAttributeValue(
0126: objectName, COPYRIGHT_KEY);
0127: if (value != null) {
0128: properties
0129: .setProperty(COPYRIGHT_KEY, value);
0130: }
0131: value = (String) this .getAttributeValue(
0132: objectName, FULL_PRODUCT_NAME_KEY);
0133: if (value != null) {
0134: properties.setProperty(
0135: FULL_PRODUCT_NAME_KEY, value);
0136: }
0137: value = (String) this .getAttributeValue(
0138: objectName, MAJOR_VERSION_KEY);
0139: if (value != null) {
0140: properties.setProperty(MAJOR_VERSION_KEY,
0141: value);
0142: }
0143: value = (String) this .getAttributeValue(
0144: objectName, MINOR_VERSION_KEY);
0145: if (value != null) {
0146: properties.setProperty(MINOR_VERSION_KEY,
0147: value);
0148: }
0149: value = (String) this .getAttributeValue(
0150: objectName, SHORT_PRODUCT_NAME_KEY);
0151: if (value != null) {
0152: properties.setProperty(
0153: SHORT_PRODUCT_NAME_KEY, value);
0154: }
0155: result.put(targetName, properties);
0156: }
0157: } else {
0158: objectName = this
0159: .getAdminServiceMBeanObjectName(targetName);
0160: if (objectName != null) {
0161: value = (String) this .getAttributeValue(
0162: objectName, SYSTEM_INFORMATION_KEY);
0163: if (value != null) {
0164: properties.setProperty(
0165: SYSTEM_INFORMATION_KEY, value);
0166: }
0167: result.put(targetName, properties);
0168: }
0169: }
0170: }
0171: }
0172:
0173: return result;
0174: }
0175:
0176: /**
0177: * Checks to see if the Target (server, cluster) is up or down.
0178: *
0179: * @param targetName
0180: * name of the target (e.g., cluster1, server, etc.)
0181: * @return true if Target is up, false if not
0182: * @throws ManagementRemoteException
0183: * if error or exception occurs.
0184: *
0185: * @see com.sun.esb.management.api.runtime.RuntimeManagementService#isTargetUp(java.lang.String)
0186: */
0187: public boolean isTargetUp(String targetName)
0188: throws ManagementRemoteException {
0189: return super .isTargetUp(targetName);
0190: }
0191:
0192: /**
0193: * Retrieve the Component Installation descriptor for the server target.
0194: *
0195: * The Installation descriptor will never be different for a component name
0196: * in a JBI system because there's only one component allowed with that same
0197: * name. Therefore, this implies a registry lookup for the server target.
0198: *
0199: * @param Component
0200: * name as a string
0201: * @return the Component Installation descriptor as a string
0202: * @throws ManagementRemoteException
0203: * on error
0204: *
0205: * @see com.sun.esb.management.api.administration.AdministrationService#getComponentInstallationDescriptor(java.lang.String)
0206: */
0207: public String getComponentInstallationDescriptor(
0208: String componentName) throws ManagementRemoteException {
0209: // The deployment descriptor will never be different for a
0210: // component name in a JBI system because there's
0211: // only one component allowed with that same name.
0212: // Therefore, this implies a registry lookup for the domain target.
0213: String targetName = JBIAdminCommands.DOMAIN_TARGET_KEY;
0214: // String targetName = JBIAdminCommands.SERVER_TARGET_KEY;
0215: String jbiXml = this .getInstallationDescriptor(componentName,
0216: targetName);
0217: return jbiXml;
0218: }
0219:
0220: /**
0221: * Gets the component state
0222: *
0223: * @param componentName
0224: * @param targetName
0225: * @return the state of the component
0226: * @throws ManagementRemoteException
0227: * on error
0228: *
0229: * @see com.sun.esb.management.api.administration.AdministrationService#getComponentState(java.lang.String,
0230: * java.lang.String)
0231: */
0232: @SuppressWarnings("unchecked")
0233: public String getComponentState(String componentName,
0234: String targetName) throws ManagementRemoteException {
0235: return super .getComponentState(componentName, targetName);
0236: }
0237:
0238: /**
0239: * Gets the component type
0240: *
0241: * @param componentName
0242: * @param targetName
0243: * @return the type of the component (binding-component, service-engine, or
0244: * shared-library)
0245: * @throws ManagementRemoteException
0246: * on error
0247: *
0248: * @see com.sun.esb.management.api.administration.AdministrationService#getComponentType(java.lang.String,
0249: * java.lang.String)
0250: */
0251: @SuppressWarnings("unchecked")
0252: public String getComponentType(String componentName,
0253: String targetName) throws ManagementRemoteException {
0254: String result = null;
0255: String xmlText = null;
0256: List<JBIComponentInfo> infoList = null;
0257: String state = null, sharedLibraryName = null, serviceAssemblyName = null;
0258: try {
0259: xmlText = this .listComponents(ComponentType.BINDING, state,
0260: sharedLibraryName, serviceAssemblyName, targetName);
0261: if ((xmlText != null) && (xmlText.length() > 0)) {
0262: infoList = JBIComponentInfo.readFromXmlText(xmlText);
0263: for (JBIComponentInfo info : infoList) {
0264: if (info.getName().equals(componentName) == true) {
0265: return info.getType();
0266: }
0267: }
0268: }
0269: } catch (ManagementRemoteException e) {
0270: // Ignore exception
0271: }
0272: try {
0273: xmlText = this .listComponents(ComponentType.ENGINE, state,
0274: sharedLibraryName, serviceAssemblyName, targetName);
0275: if ((xmlText != null) && (xmlText.length() > 0)) {
0276: infoList = JBIComponentInfo.readFromXmlText(xmlText);
0277: for (JBIComponentInfo info : infoList) {
0278: if (info.getName().equals(componentName) == true) {
0279: return info.getType();
0280: }
0281: }
0282: }
0283: } catch (ManagementRemoteException e) {
0284: // Ignore exception
0285: }
0286: try {
0287: // ////////////////////////////////////////
0288: // Start Check to make sure target is valid
0289: // ////////////////////////////////////////
0290: ObjectName installerServiceObjectName = this
0291: .getInstallationServiceMBeanObjectName(targetName);
0292: this .checkForValidTarget(installerServiceObjectName,
0293: targetName);
0294: // ////////////////////////////////////////
0295: // End Check to make sure target is valid
0296: // ////////////////////////////////////////
0297:
0298: List frameworkCompInfoList = this
0299: .getFrameworkComponentInfoListForSharedLibraries(
0300: null, targetName);
0301: List uiCompInfoList = new ArrayList();
0302: uiCompInfoList = this .toUiComponentInfoList(
0303: frameworkCompInfoList, targetName);
0304: xmlText = JBIComponentInfo.writeAsXmlText(uiCompInfoList);
0305: if ((xmlText != null) && (xmlText.length() > 0)) {
0306: infoList = JBIComponentInfo.readFromXmlText(xmlText);
0307: for (JBIComponentInfo info : infoList) {
0308: if (info.getName().equals(componentName) == true) {
0309: return info.getType();
0310: }
0311: }
0312: }
0313: } catch (ManagementRemoteException e) {
0314: // Ignore exception
0315: }
0316: return result;
0317: }
0318:
0319: /**
0320: * Get the list of consuming endpoints
0321: *
0322: * @param componentName
0323: * @param targetName
0324: * @return Returns the consumingEndpoints.
0325: * @throws ManagementRemoteException
0326: *
0327: * @see com.sun.esb.management.api.administration.AdministrationService#getConsumingEndpoints(java.lang.String,
0328: * java.lang.String)
0329: */
0330: public String[] getConsumingEndpoints(String componentName,
0331: String targetName) throws ManagementRemoteException {
0332: List<String> endpointsList = new ArrayList<String>();
0333:
0334: Map<String /*instanceName*/, ObjectName[]> targetToObjectNamesMap = null;
0335: targetToObjectNamesMap = findLiveExtensionMBeanObjectNames(
0336: componentName, CUSTOM_STATISTICS_NAME_KEY, targetName);
0337: if (targetToObjectNamesMap != null) {
0338: for (String instanceName : targetToObjectNamesMap.keySet()) {
0339: ObjectName[] objectNames = targetToObjectNamesMap
0340: .get(instanceName);
0341: if (objectNames != null) {
0342: for (ObjectName objectName : objectNames) {
0343: String[] consumingEndpoints = null;
0344: consumingEndpoints = (String[]) getAttributeValue(
0345: targetName, objectName,
0346: "ConsumingEndpoints");
0347: if (consumingEndpoints != null) {
0348: for (String endpoint : consumingEndpoints) {
0349: if (endpointsList.contains(endpoint) == false) {
0350: endpointsList.add(endpoint);
0351: }
0352: }
0353: }
0354: }
0355: }
0356: }
0357: }
0358: return GenericsSupport.toArray(endpointsList, String.class);
0359:
0360: }
0361:
0362: /**
0363: * Get the list of provisioning endpoints
0364: *
0365: * @param componentName
0366: * @param targetName
0367: * @return Returns the provisioningEndpoints.
0368: * @throws ManagementRemoteException
0369: *
0370: * @see com.sun.esb.management.api.administration.AdministrationService#getProvisioningEndpoints(java.lang.String,
0371: * java.lang.String)
0372: */
0373: public String[] getProvisioningEndpoints(String componentName,
0374: String targetName) throws ManagementRemoteException {
0375: List<String> endpointsList = new ArrayList<String>();
0376:
0377: Map<String /*instanceName*/, ObjectName[]> targetToObjectNamesMap = null;
0378: targetToObjectNamesMap = findLiveExtensionMBeanObjectNames(
0379: componentName, CUSTOM_STATISTICS_NAME_KEY, targetName);
0380: if (targetToObjectNamesMap != null) {
0381: for (String instanceName : targetToObjectNamesMap.keySet()) {
0382: ObjectName[] objectNames = targetToObjectNamesMap
0383: .get(instanceName);
0384: if (objectNames != null) {
0385: for (ObjectName objectName : objectNames) {
0386: String[] provisioningEndpoints = null;
0387: provisioningEndpoints = (String[]) getAttributeValue(
0388: targetName, objectName,
0389: "ProvisioningEndpoints");
0390: if (provisioningEndpoints != null) {
0391: for (String endpoint : provisioningEndpoints) {
0392: if (endpointsList.contains(endpoint) == false) {
0393: endpointsList.add(endpoint);
0394: }
0395: }
0396: }
0397: }
0398: }
0399: }
0400: }
0401: return GenericsSupport.toArray(endpointsList, String.class);
0402: }
0403:
0404: /**
0405: * Retrieve the Service Assembly Deployment descriptor for the domain
0406: * target.
0407: *
0408: * The deployment descriptor will never be different for a service assembly
0409: * name in a JBI system because there's only one Service Assembly allowed
0410: * with that same name. Therefore, this implies a registry lookup for the
0411: * domain target.
0412: *
0413: * @param service
0414: * assembly name as a string
0415: * @return the service assembly deployment descriptor as a string
0416: * @throws ManagementRemoteException
0417: * on error
0418: *
0419: * @see com.sun.esb.management.api.administration.AdministrationService#getServiceAssemblyDeploymentDescriptor(java.lang.String)
0420: */
0421: public String getServiceAssemblyDeploymentDescriptor(
0422: String serviceAssemblyName)
0423: throws ManagementRemoteException {
0424: // The deployment descriptor will never be different for a
0425: // service assembly name in a JBI system because there's
0426: // only one Service Assembly allowed with that same name.
0427: // Therefore, this implies a registry lookup for the domain target.
0428: String targetName = JBIAdminCommands.DOMAIN_TARGET_KEY;
0429:
0430: ObjectName deploymentServiceObjectName = this
0431: .getDeploymentServiceMBeanObjectName(targetName);
0432:
0433: logDebug("Calling deploy on DeploymentServiceMBean = "
0434: + deploymentServiceObjectName);
0435:
0436: Object resultObject = this .invokeMBeanOperation(
0437: deploymentServiceObjectName,
0438: "getServiceAssemblyDescriptor", serviceAssemblyName);
0439:
0440: if (resultObject != null) {
0441: return resultObject.toString();
0442: } else {
0443: Exception exception = this .createManagementException(
0444: "ui.mbean.deploy.error", null, null);
0445: throw new ManagementRemoteException(exception);
0446: }
0447: }
0448:
0449: /**
0450: * Gets the Service Assembly state
0451: *
0452: * @param serviceAssemblyName
0453: * @param targetName
0454: * @return the state of the Service Assembly
0455: * @throws ManagementRemoteException
0456: * if error or exception occurs.
0457: *
0458: * @see com.sun.esb.management.api.administration.AdministrationService#getServiceAssemblyState(java.lang.String,
0459: * java.lang.String)
0460: */
0461: @SuppressWarnings("unchecked")
0462: public String getServiceAssemblyState(String serviceAssemblyName,
0463: String targetName) throws ManagementRemoteException {
0464: String result = ServiceAssemblyInfo.UNKNOWN_STATE;
0465: String xmlText = null;
0466: List<ServiceAssemblyInfo> infoList = null;
0467: String state = null, componentName = null;
0468: try {
0469: // ////////////////////////////////////////
0470: // Start Check to make sure target is valid
0471: // ////////////////////////////////////////
0472: ObjectName installerServiceObjectName = this
0473: .getInstallationServiceMBeanObjectName(targetName);
0474: this .checkForValidTarget(installerServiceObjectName,
0475: targetName);
0476: // ////////////////////////////////////////
0477: // End Check to make sure target is valid
0478: // ////////////////////////////////////////
0479:
0480: this .validateUiServiceAssemblyInfoState(state);
0481:
0482: List saInfoList = this .getServiceAssemblyInfoList(
0483: toFrameworkServiceAssemblyState(state),
0484: componentName, targetName);
0485:
0486: xmlText = ServiceAssemblyInfo
0487: .writeAsXmlTextWithProlog(saInfoList);
0488: if ((xmlText != null) && (xmlText.length() > 0)) {
0489: infoList = ServiceAssemblyInfo
0490: .readFromXmlTextWithProlog(xmlText);
0491: for (ServiceAssemblyInfo info : infoList) {
0492: if (info.getName().equals(serviceAssemblyName) == true) {
0493: return info.getState();
0494: }
0495: }
0496: }
0497: } catch (ManagementRemoteException e) {
0498: // Ignore exception
0499: }
0500: return result;
0501: }
0502:
0503: /**
0504: * Returns the jbi.xml Deployment Descriptor for a Service Unit.
0505: *
0506: * @param the
0507: * name of the Service Assembly
0508: * @param the
0509: * name of the Service Unit
0510: * @return the jbi.xml deployment descriptor of the archive
0511: * @throws ManagementRemoteException
0512: * if error or exception occurs.
0513: *
0514: * @see com.sun.esb.management.api.administration.AdministrationService#getServiceUnitDeploymentDescriptor(java.lang.String,
0515: * java.lang.String)
0516: */
0517: public String getServiceUnitDeploymentDescriptor(
0518: String serviceAssemblyName, String serviceUnitName)
0519: throws ManagementRemoteException {
0520: // The deployment descriptor will never be different for a
0521: // service assembly name in a JBI system because there's
0522: // only one Service Assembly allowed with that same name.
0523: // Therefore, this implies a registry lookup for the domain target.
0524: String targetName = JBIAdminCommands.DOMAIN_TARGET_KEY;
0525:
0526: ObjectName deploymentServiceObjectName = this
0527: .getDeploymentServiceMBeanObjectName(targetName);
0528:
0529: logDebug("Calling deploy on DeploymentServiceMBean = "
0530: + deploymentServiceObjectName);
0531:
0532: Object[] params = new Object[2];
0533: params[0] = serviceAssemblyName;
0534: params[1] = serviceUnitName;
0535:
0536: String[] signature = new String[2];
0537: signature[0] = "java.lang.String";
0538: signature[1] = "java.lang.String";
0539:
0540: Object resultObject = invokeMBeanOperation(
0541: deploymentServiceObjectName,
0542: "getServiceUnitDescriptor", params, signature);
0543:
0544: if (resultObject != null) {
0545: return resultObject.toString();
0546: } else {
0547: Exception exception = this .createManagementException(
0548: "ui.mbean.deploy.error", null, null);
0549: throw new ManagementRemoteException(exception);
0550: }
0551: }
0552:
0553: /**
0554: * Retrieve the Shared Library Installation descriptor for the server
0555: * target.
0556: *
0557: * The Installation descriptor will never be different for a Shared Library
0558: * name in a JBI system because there's only one Shared Library allowed with
0559: * that same name. Therefore, this implies a registry lookup for the server
0560: * target.
0561: *
0562: * @param Shared
0563: * Library name as a string
0564: * @return the Shared Library Installation descriptor as a string
0565: * @throws ManagementRemoteException
0566: * on error
0567: *
0568: * @see com.sun.esb.management.api.administration.AdministrationService#getSharedLibraryInstallationDescriptor(java.lang.String)
0569: */
0570: public String getSharedLibraryInstallationDescriptor(
0571: String sharedLibraryName) throws ManagementRemoteException {
0572: // The deployment descriptor will never be different for a
0573: // Shared Library name in a JBI system because there's
0574: // only one Shared Library allowed with that same name.
0575: // Therefore, this implies a registry lookup for the domain target.
0576: String targetName = JBIAdminCommands.DOMAIN_TARGET_KEY;
0577: // String targetName = JBIAdminCommands.SERVER_TARGET_KEY;
0578: String jbiXml = this .getSharedLibraryDescriptor(
0579: sharedLibraryName, targetName);
0580: return jbiXml;
0581: }
0582:
0583: /**
0584: * Retrieves the primary WSDL associated with the specified endpoint.
0585: *
0586: * @param componentName
0587: * @param endpoint
0588: * @param targetName
0589: * @return primary WSDL associated with the endpoint
0590: * @throws ManagementRemoteException
0591: *
0592: * @see com.sun.esb.management.api.administration.AdministrationService#getWSDLDefinition(java.lang.String,
0593: * java.lang.String, java.lang.String)
0594: */
0595: public String getWSDLDefinition(String componentName,
0596: String endpoint, String targetName)
0597: throws ManagementRemoteException {
0598: String wsdlDefinition = "";
0599:
0600: Map<String /*instanceName*/, ObjectName[]> targetToObjectNamesMap = null;
0601: targetToObjectNamesMap = findLiveExtensionMBeanObjectNames(
0602: componentName, CUSTOM_STATISTICS_NAME_KEY, targetName);
0603: if (targetToObjectNamesMap != null) {
0604: for (String instanceName : targetToObjectNamesMap.keySet()) {
0605: ObjectName[] objectNames = targetToObjectNamesMap
0606: .get(instanceName);
0607: if (objectNames != null) {
0608: for (ObjectName objectName : objectNames) {
0609: Object[] params = new Object[1];
0610: params[0] = endpoint;
0611:
0612: String[] signature = new String[1];
0613: signature[0] = "java.lang.String";
0614:
0615: Object resultObject = this
0616: .invokeMBeanOperation(targetName,
0617: objectName,
0618: "getWSDLDefinition", params,
0619: signature);
0620:
0621: if (resultObject != null) {
0622: wsdlDefinition = resultObject.toString();
0623: if ((wsdlDefinition != null)
0624: && (wsdlDefinition.length() > 0)) {
0625: break;
0626: }
0627: }
0628: }
0629: }
0630: if ((wsdlDefinition != null)
0631: && (wsdlDefinition.length() > 0)) {
0632: break;
0633: }
0634: }
0635: }
0636: return wsdlDefinition;
0637:
0638: }
0639:
0640: /**
0641: * Retrieves the WSDL or XSD associated with the specified endpoint and
0642: * targetNamespace
0643: *
0644: * @param componentName
0645: * @param endpoint
0646: * @param targetNamespace
0647: * @param targetName
0648: * @return wsdl or xsd
0649: * @throws ManagementRemoteException
0650: *
0651: * @see com.sun.esb.management.api.administration.AdministrationService#getWSDLImportedResource(java.lang.String,
0652: * java.lang.String, java.lang.String, java.lang.String)
0653: */
0654: public String getWSDLImportedResource(String componentName,
0655: String endpoint, String targetNamespace, String targetName)
0656: throws ManagementRemoteException {
0657: String importedResource = "";
0658:
0659: Map<String /*instanceName*/, ObjectName[]> targetToObjectNamesMap = null;
0660: targetToObjectNamesMap = findLiveExtensionMBeanObjectNames(
0661: componentName, CUSTOM_STATISTICS_NAME_KEY, targetName);
0662: if (targetToObjectNamesMap != null) {
0663: for (String instanceName : targetToObjectNamesMap.keySet()) {
0664: ObjectName[] objectNames = targetToObjectNamesMap
0665: .get(instanceName);
0666: if (objectNames != null) {
0667: for (ObjectName objectName : objectNames) {
0668: Object[] params = new Object[2];
0669: params[0] = endpoint;
0670: params[1] = targetNamespace;
0671:
0672: String[] signature = new String[2];
0673: signature[0] = "java.lang.String";
0674: signature[1] = "java.lang.String";
0675:
0676: Object resultObject = this
0677: .invokeMBeanOperation(targetName,
0678: objectName,
0679: "getWSDLImportedResource",
0680: params, signature);
0681:
0682: if (resultObject != null) {
0683: importedResource = resultObject.toString();
0684: }
0685: if ((importedResource != null)
0686: && (importedResource.length() > 0)) {
0687: break;
0688: }
0689: }
0690: }
0691: if ((importedResource != null)
0692: && (importedResource.length() > 0)) {
0693: break;
0694: }
0695: }
0696: }
0697:
0698: return importedResource;
0699: }
0700:
0701: /**
0702: * check for BindingComponent
0703: *
0704: * @param the
0705: * name of the ServiceEngine or Binding Component
0706: * @return true if it is a Binding Component else false.
0707: * @throws ManagementRemoteException
0708: * if error or exception occurs.
0709: *
0710: * @see com.sun.esb.management.api.administration.AdministrationService#isBindingComponent(java.lang.String)
0711: */
0712: public boolean isBindingComponent(String componentName)
0713: throws ManagementRemoteException {
0714: boolean isBindingComponent = false;
0715: String descriptorString = this
0716: .getComponentInstallationDescriptor(componentName);
0717: try {
0718: JBIDescriptor descriptor = JBIDescriptor
0719: .createJBIDescriptor(descriptorString);
0720: isBindingComponent = descriptor
0721: .isBindingComponentDescriptor();
0722: } catch (Exception e) {
0723: throw new ManagementRemoteException(e);
0724: }
0725: return isBindingComponent;
0726: }
0727:
0728: /**
0729: * Tests is a component/library is installed on a target
0730: *
0731: * @param componentName
0732: * @param targetName
0733: * @return true if installed, false if not
0734: * @throws ManagementRemoteException
0735: * if error or exception occurs.
0736: *
0737: * @see com.sun.esb.management.api.administration.AdministrationService#isJBIComponentInstalled(java.lang.String,
0738: * java.lang.String)
0739: */
0740: @SuppressWarnings("unchecked")
0741: public boolean isJBIComponentInstalled(String componentName,
0742: String targetName) throws ManagementRemoteException {
0743: String xmlText = null;
0744: List<JBIComponentInfo> infoList = null;
0745: String state = null, sharedLibraryName = null, serviceAssemblyName = null;
0746:
0747: try {
0748: xmlText = this .listComponents(ComponentType.BINDING, state,
0749: sharedLibraryName, serviceAssemblyName, targetName);
0750: if ((xmlText != null) && (xmlText.length() > 0)) {
0751: infoList = JBIComponentInfo.readFromXmlText(xmlText);
0752: for (JBIComponentInfo info : infoList) {
0753: if (componentName.equals(info.getName()) == true) {
0754: return true;
0755: }
0756: }
0757: }
0758: } catch (ManagementRemoteException e) {
0759: // Ignore the exception
0760: }
0761: try {
0762: xmlText = this .listComponents(ComponentType.ENGINE, state,
0763: sharedLibraryName, serviceAssemblyName, targetName);
0764: if ((xmlText != null) && (xmlText.length() > 0)) {
0765: infoList = JBIComponentInfo.readFromXmlText(xmlText);
0766: for (JBIComponentInfo info : infoList) {
0767: if (componentName.equals(info.getName()) == true) {
0768: return true;
0769: }
0770: }
0771: }
0772: } catch (ManagementRemoteException e) {
0773: // Ignore the exception
0774: }
0775: try {
0776: // ////////////////////////////////////////
0777: // Start Check to make sure target is valid
0778: // ////////////////////////////////////////
0779: ObjectName installerServiceObjectName = this
0780: .getInstallationServiceMBeanObjectName(targetName);
0781: this .checkForValidTarget(installerServiceObjectName,
0782: targetName);
0783: // ////////////////////////////////////////
0784: // End Check to make sure target is valid
0785: // ////////////////////////////////////////
0786:
0787: List frameworkCompInfoList = this
0788: .getFrameworkComponentInfoListForSharedLibraries(
0789: null, targetName);
0790: List uiCompInfoList = new ArrayList();
0791: uiCompInfoList = this .toUiComponentInfoList(
0792: frameworkCompInfoList, targetName);
0793: xmlText = JBIComponentInfo.writeAsXmlText(uiCompInfoList);
0794: if ((xmlText != null) && (xmlText.length() > 0)) {
0795: infoList = JBIComponentInfo.readFromXmlText(xmlText);
0796: for (JBIComponentInfo info : infoList) {
0797: if (componentName.equals(info.getName()) == true) {
0798: return true;
0799: }
0800: }
0801: }
0802: } catch (ManagementRemoteException e) {
0803: // Ignore the exception
0804: }
0805: return false;
0806: }
0807:
0808: /**
0809: * Checks to see if the JBI Runtime is enabled.
0810: *
0811: * @return true if JBI Runtime Framework is available, false if not
0812: * @throws ManagementRemoteException
0813: * if error or exception occurs.
0814: *
0815: * @see com.sun.esb.management.api.administration.AdministrationService#isJBIRuntimeEnabled()
0816: */
0817: public boolean isJBIRuntimeEnabled()
0818: throws ManagementRemoteException {
0819: return true;
0820: }
0821:
0822: /**
0823: * Tests is a component/library is installed on a target
0824: *
0825: * @param name
0826: * @param targetName
0827: * @return true if installed, false if not
0828: * @throws ManagementRemoteException
0829: * if error or exception occurs.
0830: *
0831: * @see com.sun.esb.management.api.administration.AdministrationService#isServiceAssemblyDeployed(java.lang.String,
0832: * java.lang.String)
0833: */
0834: @SuppressWarnings("unchecked")
0835: public boolean isServiceAssemblyDeployed(
0836: String serviceAssemblyName, String targetName)
0837: throws ManagementRemoteException {
0838: String xmlText = null;
0839: List<ServiceAssemblyInfo> infoList = null;
0840: String state = null, componentName = null;
0841: try {
0842: // ////////////////////////////////////////
0843: // Start Check to make sure target is valid
0844: // ////////////////////////////////////////
0845: ObjectName installerServiceObjectName = this
0846: .getInstallationServiceMBeanObjectName(targetName);
0847: this .checkForValidTarget(installerServiceObjectName,
0848: targetName);
0849: // ////////////////////////////////////////
0850: // End Check to make sure target is valid
0851: // ////////////////////////////////////////
0852:
0853: this .validateUiServiceAssemblyInfoState(state);
0854:
0855: List saInfoList = this .getServiceAssemblyInfoList(
0856: toFrameworkServiceAssemblyState(state),
0857: componentName, targetName);
0858:
0859: xmlText = ServiceAssemblyInfo
0860: .writeAsXmlTextWithProlog(saInfoList);
0861: if ((xmlText != null) && (xmlText.length() > 0)) {
0862: infoList = ServiceAssemblyInfo
0863: .readFromXmlTextWithProlog(xmlText);
0864: for (ServiceAssemblyInfo info : infoList) {
0865: if (serviceAssemblyName.equals(info.getName()) == true) {
0866: return true;
0867: }
0868: }
0869: }
0870: } catch (ManagementRemoteException e) {
0871: // Ignore the exception
0872: }
0873: return false;
0874: }
0875:
0876: /**
0877: * check for ServiceEngine
0878: *
0879: * @param the
0880: * name of the ServiceEngine or Binding Component
0881: * @return true if it is a Service Engine else false.
0882: * @throws ManagementRemoteException
0883: * if error or exception occurs.
0884: *
0885: * @see com.sun.esb.management.api.administration.AdministrationService#isServiceEngine(java.lang.String)
0886: */
0887: public boolean isServiceEngine(String componentName)
0888: throws ManagementRemoteException {
0889: boolean isServiceEngine = false;
0890: String descriptorString = this
0891: .getComponentInstallationDescriptor(componentName);
0892: try {
0893: JBIDescriptor descriptor = JBIDescriptor
0894: .createJBIDescriptor(descriptorString);
0895: isServiceEngine = descriptor.isServiceEngineDescriptor();
0896: } catch (Exception e) {
0897: throw new ManagementRemoteException(e);
0898: }
0899: return isServiceEngine;
0900: }
0901:
0902: /**
0903: * Retrieve the Component Installation descriptor for the server target.
0904: *
0905: * The Installation descriptor will never be different for a component name
0906: * in a JBI system because there's only one component allowed with that same
0907: * name. Therefore, this implies a registry lookup for the server target.
0908: *
0909: * @param Component
0910: * name as a string
0911: * @param targetName
0912: * @return the Component Installation descriptor as a string
0913: * @throws ManagementRemoteException
0914: * on error
0915: */
0916: protected String getInstallationDescriptor(String componentName,
0917: String targetName) {
0918: ComponentQuery componentQuery = null;
0919: ComponentInfo componentInfo = null;
0920: String jbiXml = null;
0921:
0922: componentQuery = this .environmentContext
0923: .getComponentQuery(targetName);
0924: if (componentQuery != null) {
0925: componentInfo = componentQuery
0926: .getComponentInfo(componentName);
0927: if (componentInfo != null) {
0928: jbiXml = componentInfo.getInstallationDescriptor();
0929: }
0930: }
0931: return jbiXml;
0932: }
0933:
0934: /**
0935: * Retrieve the Shared Library Installation descriptor for the server
0936: * target.
0937: *
0938: * The Installation descriptor will never be different for a library name in
0939: * a JBI system because there's only one library allowed with that same
0940: * name. Therefore, this implies a registry lookup for the domain target.
0941: *
0942: * @param libraryName
0943: * name as a string
0944: * @param targetName
0945: * @return the Library Installation descriptor as a string
0946: * @throws ManagementRemoteException
0947: * on error
0948: */
0949: protected String getSharedLibraryDescriptor(String libraryName,
0950: String targetName) {
0951: ComponentQuery componentQuery = null;
0952: ComponentInfo componentInfo = null;
0953: String jbiXml = null;
0954:
0955: componentQuery = this .environmentContext
0956: .getComponentQuery(targetName);
0957: if (componentQuery != null) {
0958: componentInfo = componentQuery
0959: .getSharedLibraryInfo(libraryName);
0960: if (componentInfo != null) {
0961: jbiXml = componentInfo.getInstallationDescriptor();
0962: }
0963: }
0964: return jbiXml;
0965: }
0966:
0967: /**
0968: * Get the instance name of the platform's administration server. If the
0969: * platform does not provide a separate administration server, then this
0970: * method returns the name of the local instance.
0971: * @return instance name of the administration server
0972: * @throws ManagementRemoteException
0973: */
0974: public String getAdminServerName() throws ManagementRemoteException {
0975: return super .getPlatformContextAdminServerName();
0976: }
0977:
0978: /**
0979: * Determine whether this instance is the administration server instance.
0980: * @return <CODE>true</CODE> if this instance is the administration server,
0981: * <CODE>false</CODE> if not.
0982: * @throws ManagementRemoteException
0983: */
0984: public boolean isAdminServer() throws ManagementRemoteException {
0985: return super .isPlatformContextAdminServer();
0986: }
0987:
0988: /**
0989: * Get the name of this instance.
0990: * @return the name of this server instance.
0991: * @throws ManagementRemoteException
0992: */
0993: public String getInstanceName() throws ManagementRemoteException {
0994: return super .getPlatformContextInstanceName();
0995: }
0996:
0997: /**
0998: * Determine if the specified instance is up.
0999: * @return true if the instance is up and running, false otherwise
1000: * @throws ManagementRemoteException
1001: */
1002: public boolean isInstanceUp(String instanceName)
1003: throws ManagementRemoteException {
1004: return super .isPlatformContextInstanceUp(instanceName);
1005: }
1006:
1007: /**
1008: * Determine whether multiple servers are permitted within this AS
1009: * installation.
1010: * @return true if multiple servers are permitted.
1011: * @throws ManagementRemoteException
1012: */
1013: public boolean supportsMultipleServers()
1014: throws ManagementRemoteException {
1015: return super .platformContextSupportsMultipleServers();
1016: }
1017:
1018: /**
1019: * Get the Target Name. If the instance is not a clustered instance then
1020: * the target name is the instance name. If the instance is part of a
1021: * cluster then the target name is the cluster name.
1022: *
1023: * @return the target name.
1024: * @throws ManagementRemoteException
1025: */
1026: public String getTargetName() throws ManagementRemoteException {
1027: return super .getPlatformContextTargetName();
1028: }
1029:
1030: /**
1031: * Get the Target Name for a specified instance. If the instance is not
1032: * clustered the instance name is returned. This operation is invoked by
1033: * the JBI instance MBeans only.
1034: *
1035: * @return the target name.
1036: * @throws ManagementRemoteException
1037: */
1038: public String getTargetName(String instanceName)
1039: throws ManagementRemoteException {
1040: return super .getPlatformContextTargetName(instanceName);
1041: }
1042:
1043: /**
1044: * Get a set of the names of all the standalone servers in the domain.
1045: * @return a set of names of standalone servers in the domain.
1046: * @throws ManagementRemoteException
1047: */
1048: public Set<String> getStandaloneServerNames()
1049: throws ManagementRemoteException {
1050: return super .getPlatformContextStandaloneServerNames();
1051: }
1052:
1053: /**
1054: * Get a set of the names of all the clustered servers in the domain.
1055: * @return a set of names of clustered servers in the domain.
1056: * @throws ManagementRemoteException
1057: */
1058: public Set<String> getClusteredServerNames()
1059: throws ManagementRemoteException {
1060: return super .getPlatformContextClusteredServerNames();
1061: }
1062:
1063: /**
1064: * Get a set of the names of all the clusters in the domain.
1065: * @return a set of names of clusters in the domain.
1066: * @throws ManagementRemoteException
1067: */
1068: public Set<String> getClusterNames()
1069: throws ManagementRemoteException {
1070: return super .getPlatformContextClusterNames();
1071: }
1072:
1073: /**
1074: * Get a set of the names of all the servers in the specified cluster.
1075: * @return a set of names of servers in the cluster.
1076: * @throws ManagementRemoteException
1077: */
1078: public Set<String> getServersInCluster(String clusterName)
1079: throws ManagementRemoteException {
1080: return super .getPlatformContextServersInCluster(clusterName);
1081: }
1082:
1083: /**
1084: * Determine whether a target is a valid server or cluster name.
1085: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a valid
1086: * standalone server name or cluster name, <CODE>false</CODE> if not.
1087: * @throws ManagementRemoteException
1088: */
1089: public boolean isValidTarget(String targetName)
1090: throws ManagementRemoteException {
1091: return super .isPlatformContextValidTarget(targetName);
1092: }
1093:
1094: /**
1095: * Determine whether a target is a cluster.
1096: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a cluster,
1097: * <CODE>false</CODE> if not.
1098: * @throws ManagementRemoteException
1099: */
1100: public boolean isCluster(String targetName)
1101: throws ManagementRemoteException {
1102: return super .isPlatformContextCluster(targetName);
1103: }
1104:
1105: /**
1106: * Determine whether a target is a standalone server.
1107: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a standalone
1108: * server, <CODE>false</CODE> if not.
1109: * @throws ManagementRemoteException
1110: */
1111: public boolean isStandaloneServer(String targetName)
1112: throws ManagementRemoteException {
1113: return super .isPlatformContextStandaloneServer(targetName);
1114: }
1115:
1116: /**
1117: * Determine whether the target is a clustered server.
1118: * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a clustered
1119: * server, <CODE>false</CODE> if not.
1120: * @throws ManagementRemoteException
1121: */
1122: public boolean isClusteredServer(String targetName)
1123: throws ManagementRemoteException {
1124: return super .isPlatformContextClusteredServer(targetName);
1125: }
1126:
1127: /**
1128: * Determine whether or not an instance is clustered.
1129: * @return <CODE>true</CODE> if the instance is clustered,
1130: * <CODE>false</CODE> if not.
1131: * @throws ManagementRemoteException
1132: */
1133: public boolean isInstanceClustered(String instanceName)
1134: throws ManagementRemoteException {
1135: return super .isPlatformContextInstanceClustered(instanceName);
1136: }
1137:
1138: /**
1139: * Get a string representation of the DAS JMX RMI connector port.
1140: * @return the JMX RMI connector port as a (CODE>String</CODE>.
1141: * @throws ManagementRemoteException
1142: */
1143: public String getJmxRmiPort() throws ManagementRemoteException {
1144: return super .getPlatformContextJmxRmiPort();
1145: }
1146:
1147: /**
1148: * Get the full path to the platform's instance root directory.
1149: * @return platform instance root
1150: * @throws ManagementRemoteException
1151: */
1152: public String getInstanceRoot() throws ManagementRemoteException {
1153: return super .getPlatformContextInstanceRoot();
1154: }
1155:
1156: /**
1157: * Get the full path to the platform's instaall root directory.
1158: * @return platform install root
1159: * @throws ManagementRemoteException
1160: */
1161: public String getInstallRoot() throws ManagementRemoteException {
1162: return super .getPlatformContextInstallRoot();
1163: }
1164:
1165: /**
1166: * Get the MBean server connection for a particular instance.
1167: * @return the <CODE>MBeanServerConnection</CODE> for the specified instance.
1168: * @throws ManagementRemoteException
1169: */
1170: public MBeanServerConnection getConnectionForInstance(
1171: String instanceName) throws ManagementRemoteException {
1172: MBeanServerConnection connection = null;
1173: try {
1174: connection = this .getPlatformContext()
1175: .getMBeanServerConnection(instanceName);
1176: } catch (Exception e) {
1177: throw new ManagementRemoteException(e);
1178: }
1179: return connection;
1180: }
1181:
1182: }
|