0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common Development
0008: * and Distribution License("CDDL") (collectively, the "License"). You
0009: * may not use this file except in compliance with the License. You can obtain
0010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
0011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
0012: * language governing permissions and limitations under the License.
0013: *
0014: * When distributing the software, include this License Header Notice in each
0015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
0016: * Sun designates this particular file as subject to the "Classpath" exception
0017: * as provided by Sun in the GPL Version 2 section of the License file that
0018: * accompanied this code. If applicable, add the following below the License
0019: * Header, with the fields enclosed by brackets [] replaced by your own
0020: * identifying information: "Portions Copyrighted [year]
0021: * [name of copyright owner]"
0022: *
0023: * Contributor(s):
0024: *
0025: * If you wish your version of this file to be governed by only the CDDL or
0026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
0027: * elects to include this software in this distribution under the [CDDL or GPL
0028: * Version 2] license." If you don't indicate a single choice of license, a
0029: * recipient has the option to distribute your version of this file under
0030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
0031: * its licensees as provided above. However, if you add GPL Version 2 code
0032: * and therefore, elected the GPL Version 2 license, then the option applies
0033: * only if the new code is made subject to such option by the copyright
0034: * holder.
0035: */
0036: /*
0037: * ShowBean.java
0038: */
0039: package com.sun.jbi.jsf.bean;
0040:
0041: import java.util.ArrayList;
0042: import java.util.Arrays;
0043: import java.util.List;
0044: import java.util.Properties;
0045: import java.util.logging.Level;
0046: import java.util.logging.Logger;
0047: import javax.management.openmbean.TabularData;
0048: import com.sun.data.provider.TableDataProvider;
0049: import com.sun.data.provider.impl.ObjectListDataProvider;
0050: import com.sun.jbi.jsf.util.AppConfigUtils;
0051: import com.sun.jbi.jsf.util.BeanUtilities;
0052: import com.sun.jbi.jsf.util.ClusterUtilities;
0053: import com.sun.jbi.jsf.util.CompStatsUtils;
0054: import com.sun.jbi.jsf.util.CompositeDataUtils;
0055: import com.sun.jbi.jsf.util.I18nUtilities;
0056: import com.sun.jbi.jsf.util.JBIConstants;
0057: import com.sun.jbi.jsf.util.JBILogger;
0058: import com.sun.jbi.jsf.util.JSFUtils;
0059: import com.sun.jbi.jsf.util.RuntimeMonitoringUtils;
0060: import com.sun.jbi.jsf.util.SaStatsUtils;
0061: import com.sun.jbi.jsf.util.SharedConstants;
0062: import com.sun.jbi.ui.common.JBIAdminCommands;
0063: import com.sun.jbi.ui.common.JBIComponentInfo;
0064: import com.sun.jbi.ui.common.JBIManagementMessage;
0065: import com.sun.jbi.ui.common.ServiceAssemblyInfo;
0066: import com.sun.webui.jsf.component.DropDown;
0067: import com.sun.webui.jsf.component.Label;
0068: import com.sun.webui.jsf.component.Property;
0069: import com.sun.webui.jsf.component.PropertySheet;
0070: import com.sun.webui.jsf.component.PropertySheetSection;
0071: import com.sun.webui.jsf.component.TextField;
0072: import com.sun.webui.jsf.model.Option;
0073:
0074: /**
0075: * Provides properties used to populate JBI Show view properties and metadata
0076: *
0077: * @author Sun Microsystems Inc.
0078: */
0079: public class ShowBean {
0080:
0081: /**
0082: * Constructor for the ShowBean object
0083: */
0084: public ShowBean() {
0085: mJac = BeanUtilities.getClient();
0086: }
0087:
0088: /**
0089: * Gets the CompStartedOnInstance attribute of the ShowBean object
0090: *
0091: * @param aCompName Description of Parameter
0092: * @param aCompType Description of Parameter
0093: * @param anInstanceName Description of Parameter
0094: * @param aStatus Description of Parameter
0095: * @return The CompStartedOnInstance value
0096: */
0097: public boolean isCompStartedOnInstance(String aCompName,
0098: String aCompType, String anInstanceName, Properties aStatus) {
0099: boolean result = false;
0100: sLog.fine("ShowBean.isCompStartedOnInstance(" + aCompName
0101: + ", " + aCompType + ", " + anInstanceName + ")");
0102:
0103: String target = ClusterUtilities
0104: .getInstanceDomainCluster(anInstanceName);
0105:
0106: String queryResult = null;
0107:
0108: try {
0109: if (JBIConstants.JBI_BINDING_COMPONENT_TYPE
0110: .equals(aCompType)) {
0111: queryResult = mJac.showBindingComponent(aCompName,
0112: null, /* no state check */
0113: null, /* no library check */
0114: null, /* no deployment check */
0115: target);
0116: } else if (JBIConstants.JBI_SERVICE_ENGINE_TYPE
0117: .equals(aCompType)) {
0118: queryResult = mJac.showServiceEngine(aCompName, null, /* no state check */
0119: null, /* no library check */
0120: null, /* no deployment check */
0121: target);
0122:
0123: }
0124:
0125: List list = new ArrayList();
0126:
0127: if (null != queryResult) {
0128: list = JBIComponentInfo.readFromXmlText(queryResult);
0129: }
0130:
0131: if (1 == list.size()) {
0132: JBIComponentInfo compInfo = (JBIComponentInfo) list
0133: .get(0);
0134:
0135: String state = compInfo.getState();
0136:
0137: if (JBIComponentInfo.STARTED_STATE.equals(state)) {
0138: result = true;
0139: String diagnostic = "(diagnostic) '" + aCompName
0140: + "' started on '" + target + "'";
0141:
0142: // TBD check for MBean, too?
0143: aStatus.put("success-result", diagnostic);
0144: } else {
0145: aStatus.put("alert-summary",
0146: "Information not available");
0147: aStatus.put("alert-details",
0148: "Component not started");
0149: }
0150: } else {
0151: aStatus.put("alert-summary",
0152: "Information not available");
0153: aStatus
0154: .put(
0155: "alert-details",
0156: "The specified target is not available "
0157: + " or the component is not installed on the target");
0158: }
0159: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
0160: sLog
0161: .log(
0162: Level.FINE,
0163: ("ShowBean.isCompStartedOnInstance(...) caught jrEx=" + jrEx),
0164: jrEx);
0165:
0166: aStatus.put("alert-summary", "Information not available");
0167:
0168: JBIManagementMessage mgmtMsg = BeanUtilities
0169: .extractJBIManagementMessage(jrEx);
0170:
0171: if (null != mgmtMsg) {
0172: aStatus.put("alert-details", mgmtMsg.getMessage());
0173: } else {
0174: String internalErrorMsg = I18nUtilities
0175: .getResourceString("jbi.internal.error.invalid.remote.exception");
0176: aStatus.put("alert-details", internalErrorMsg);
0177: }
0178:
0179: aStatus.put("alert-details", jrEx.toString());
0180: }
0181:
0182: sLog.fine("ShowBean.isCompStartedOnInstance(" + aCompName
0183: + ", " + aCompType + ", " + anInstanceName + ", "
0184: + aStatus + "), result=" + result);
0185:
0186: return result;
0187: }
0188:
0189: // getters
0190:
0191: /**
0192: * get contents of /META-INF/jbi.xml for this "component"
0193: *
0194: * @return the JBI deployment descriptor in a (validated) XML String
0195: */
0196: public String getDeploymentOrInstallationDescriptor() {
0197: String result = queryDeploymentOrInstallationDescriptor();
0198:
0199: sLog
0200: .fine("ShowBean.getDeploymentOrInstallationDescriptor(),result="
0201: + result);
0202: return result;
0203: }
0204:
0205: /**
0206: * get the "component" description
0207: *
0208: * @return the JBI "component" description
0209: */
0210: public String getDescription() {
0211: String result = queryDescription();
0212:
0213: sLog.fine("ShowBean.getDescription(), result=" + result);
0214: return result;
0215: }
0216:
0217: /**
0218: * get the "component" name
0219: *
0220: * @return the JBI "component" name
0221: */
0222: public String getName() {
0223: sLog.fine("ShowBean.getName(), mName=" + mName);
0224: return mName;
0225: }
0226:
0227: /**
0228: * Gets the SharedTargetsTableData attribute of the ShowBean object
0229: *
0230: * @return The SharedTargetsTableData value
0231: */
0232: public TableDataProvider getSharedTargetsTableData() {
0233: sLog.fine("ShowBean.getSharedTargetsTableData()");
0234: TableDataProvider result = new ObjectListDataProvider(
0235: mTargetsList);
0236:
0237: sLog.fine("ShowBean.getSharedTargetsTableData(): result="
0238: + result);
0239: return result;
0240: }
0241:
0242: /**
0243: * Gets the CompAppConfigSupported attribute of the ShowBean object
0244: *
0245: * @return The CompAppConfigSupported value
0246: */
0247: public boolean isCompAppConfigSupported() {
0248: boolean result = mIsCompAppConfigSupported;
0249: sLog.fine("ShowBean.isCompAppConfigSupported(), result="
0250: + result);
0251: return result;
0252: }
0253:
0254: /**
0255: * provides table data with list of application configuration names for
0256: * the current component.
0257: *
0258: * @return TableDataProvider with selectable row beans
0259: */
0260: public TableDataProvider getCompAppConfigNamesTableData() {
0261: sLog
0262: .fine("ShowBean.getCompAppConfigNamesTableData(), mCompAppConfigNames="
0263: + mCompAppConfigNames);
0264:
0265: TableDataProvider result = null;
0266:
0267: if (null != mCompAppConfigNames) {
0268: SelectableAppConfigList appConfigList = new SelectableAppConfigList(
0269: mCompAppConfigNames);
0270:
0271: result = appConfigList.getListAppConfigsTableData();
0272:
0273: }
0274:
0275: sLog.fine("ShowBean.getCompAppConfigNamesTableData(), result="
0276: + result);
0277: return result;
0278: }
0279:
0280: /**
0281: * get the targets list
0282: *
0283: * @return a List of zero or more targets for this component/deployment.
0284: * An empty list implies installed/deployed to 'domain' only.
0285: */
0286: public List getTargetsList() {
0287: sLog.fine("ShowBean.getTargetsList(), mTargetsList="
0288: + mTargetsList);
0289: return mTargetsList;
0290: }
0291:
0292: /**
0293: * get the "component" type
0294: *
0295: * @return the JBI "component" type (one of: <code>binding-component,
0296: *service-assembly, service-engine, shared-library</code>)
0297: */
0298: public String getType() {
0299: sLog.fine("ShowBean.getType(), mType=" + mType);
0300: return mType;
0301: }
0302:
0303: /**
0304: * get the target names
0305: *
0306: * @return an Array of zero or more target names for this
0307: * component/deployment.
0308: */
0309: public String[] getTargetNames() {
0310: return mTargetNames;
0311: }
0312:
0313: /**
0314: * get the target names
0315: *
0316: * @return a Array of zero or more target names for this
0317: * component/deployment.
0318: */
0319: public String[] getOriginalTargetNames() {
0320: return mOriginalTargetNames;
0321: }
0322:
0323: /**
0324: * Gets the FilterTargetComponentState attribute of the ShowBean object
0325: *
0326: * @return The FilterTargetComponentState value
0327: */
0328: public String getFilterTargetComponentState() {
0329: return mFilterTargetComponentState;
0330: }
0331:
0332: /**
0333: * Gets the FilterTargetComponentStates attribute of the ShowBean object
0334: *
0335: * @return The FilterTargetComponentStates value
0336: */
0337: public ArrayList getFilterTargetComponentStates() {
0338: return mFilterTargetComponentStates;
0339: }
0340:
0341: /**
0342: * Gets the FilterTargetAssemblyState attribute of the ShowBean object
0343: *
0344: * @return The FilterTargetAssemblyState value
0345: */
0346: public String getFilterTargetAssemblyState() {
0347: return mFilterTargetAssemblyState;
0348: }
0349:
0350: /**
0351: * Gets the FilterTargetAssemblyStates attribute of the ShowBean object
0352: *
0353: * @return The FilterTargetAssemblyStates value
0354: */
0355: public ArrayList getFilterTargetAssemblyStates() {
0356: return mFilterTargetAssemblyStates;
0357: }
0358:
0359: // public void setRenderAlertOff() {
0360: // renderAlertMessage = false;
0361: //}
0362:
0363: /**
0364: * Gets the CreateCompAppConfigPropertySheet attribute of the ShowBean
0365: * object
0366: *
0367: * @return The CreateCompAppConfigPropertySheet value
0368: */
0369: public PropertySheet getCreateCompAppConfigPropertySheet() {
0370: sLog.fine("ShowBean.getCreateCompAppConfigPropertySheet()");
0371: List<AppConfigField> fields = AppConfigUtils
0372: .getAppConfigFields(mName, mInstanceName,
0373: mCompAppConfigName);
0374: return JSFUtils.getCompAppConfigPropertySheet(
0375: JSFUtils.PS_CREATE, fields);
0376: }
0377:
0378: /**
0379: * Gets the CompStatsPropertySheet attribute of the ShowBean object
0380: *
0381: * @return The CompStatsPropertySheet value
0382: */
0383: public PropertySheet getCompStatsPropertySheet() {
0384: sLog.fine("ShowBean.getCompStatsPropertySheet()");
0385:
0386: String clusterNameOrSaInstanceName = ClusterUtilities
0387: .getInstanceDomainCluster(mInstanceName);
0388:
0389: TabularData componentTabularData = CompStatsUtils.getStats(
0390: mName, clusterNameOrSaInstanceName);
0391:
0392: Properties statusProps = new Properties();
0393:
0394: TabularData nmrTabularData = RuntimeMonitoringUtils
0395: .getNMRStats(clusterNameOrSaInstanceName, statusProps);
0396:
0397: List endpointsList = CompositeDataUtils.findComponentEndpoints(
0398: nmrTabularData, clusterNameOrSaInstanceName, mName);
0399: sLog.fine("ShowBean.getCompStatsPropertySheet, endpointsList="
0400: + endpointsList);
0401:
0402: return JSFUtils.getCompStatsPS(componentTabularData,
0403: endpointsList, mName, mInstanceName);
0404: }
0405:
0406: /**
0407: * Gets the ServiceAssemblyStatsPS attribute of the ShowBean object
0408: *
0409: * @return The ServiceAssemblyStatsPS value
0410: */
0411: public PropertySheet getServiceAssemblyStatsPS() {
0412: PropertySheet result = null;
0413:
0414: String targetName = ClusterUtilities
0415: .getInstanceDomainCluster(mInstanceName);
0416:
0417: TabularData saTabularData = SaStatsUtils.getStats(targetName,
0418: mName);
0419:
0420: // TBD TabularData tbdEndpointTabularData = null;
0421:
0422: result = JSFUtils.getSaStatsPS(saTabularData, null, /* tbdEndpointTabularData, */
0423: mInstanceName, mName);
0424: return result;
0425: }
0426:
0427: /**
0428: * Gets the EditCompAppConfigPropertySheet attribute of the ShowBean
0429: * object
0430: *
0431: * @return The EditCompAppConfigPropertySheet value
0432: */
0433: public PropertySheet getEditCompAppConfigPropertySheet() {
0434: sLog.fine("ShowBean.getEditCompAppConfigPropertySheet()");
0435: List<AppConfigField> fields = AppConfigUtils
0436: .getAppConfigFields(mName, mInstanceName,
0437: mCompAppConfigName);
0438: return JSFUtils.getCompAppConfigPropertySheet(JSFUtils.PS_EDIT,
0439: fields);
0440: }
0441:
0442: /**
0443: * Gets the CreateCompAppVarsPropertySheet attribute of the ShowBean
0444: * object
0445: *
0446: * @return The CreateCompAppVarsPropertySheet value
0447: */
0448: public PropertySheet getCreateCompAppVarsPropertySheet() {
0449: sLog.fine("ShowBean.getCreateCompAppVarsPropertySheet()");
0450: return getCompAppVarsPropertySheet("create");
0451: }
0452:
0453: /**
0454: * Gets the EditCompAppVarsPropertySheet attribute of the ShowBean object
0455: *
0456: * @return The EditCompAppVarsPropertySheet value
0457: */
0458: public PropertySheet getEditCompAppVarsPropertySheet() {
0459: sLog.fine("ShowBean.getEditCompAppVarsPropertySheet()");
0460: return getCompAppVarsPropertySheet("edit");
0461: }
0462:
0463: /**
0464: * Sets the CompAppConfigNamesTableData attribute of the ShowBean object
0465: *
0466: * @param aCompName The new CompAppConfigNamesTableData value
0467: * @param aCompType The new CompAppConfigNamesTableData value
0468: * @param anInstanceName The new CompAppConfigNamesTableData value
0469: */
0470: public void setCompAppConfigNamesTableData(String aCompName,
0471: String aCompType, String anInstanceName) {
0472: sLog.fine("ShowBean.setCompAppConfigNamesTableData("
0473: + aCompName + ", " + aCompType + ", " + anInstanceName);
0474:
0475: mName = aCompName;
0476: mType = aCompType;
0477: mInstanceName = anInstanceName;
0478: mCompAppConfigNames = null;
0479: mIsCompAppConfigSupported = false;
0480:
0481: try {
0482: mCompAppConfigNames = mJac
0483: .listApplicationConfigurationNames(aCompName,
0484: anInstanceName);
0485: mIsCompAppConfigSupported = true;
0486: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
0487: sLog
0488: .log(
0489: Level.FINE,
0490: ("ShowBean.setCompAppConfigNamesTableData() caught jrEx=" + jrEx),
0491: jrEx);
0492: }
0493: sLog
0494: .fine("ShowBean.setCompAppConfigNamesTableData(...), mCompAppConfigNames="
0495: + mCompAppConfigNames);
0496:
0497: }
0498:
0499: /**
0500: * Creates an empty set of Application Configuration properties for the
0501: * specified component
0502: *
0503: * @param aCompName String with the component name
0504: * @param anInstanceName String with the instance name
0505: */
0506: public void setNewCompAppConfigProps(String aCompName,
0507: String anInstanceName) {
0508: sLog.fine("ShowBean.setNewCompAppConfigProps(" + aCompName
0509: + ", " + anInstanceName);
0510:
0511: mInstanceName = anInstanceName;
0512: mCompAppConfigName = null;
0513: }
0514:
0515: /**
0516: * Sets the Application Configuration properties for the specified
0517: * component
0518: *
0519: * @param aCompName String with the component name
0520: * @param anInstanceName String with the instance name
0521: * @param anAppConfigName String with the Application Configuration name
0522: */
0523: public void setCompAppConfigProps(String aCompName,
0524: String anInstanceName, String anAppConfigName) {
0525: sLog.fine("ShowBean.setCompAppConfigProps(" + aCompName + ", "
0526: + anInstanceName + ", " + anAppConfigName + ")");
0527:
0528: mName = aCompName;
0529: mInstanceName = anInstanceName;
0530: mCompAppConfigName = anAppConfigName;
0531: }
0532:
0533: /**
0534: * Sets the Component Statistics properties for the specified component
0535: *
0536: * @param aCompName String with the component name
0537: * @param anInstanceName String with the instance name
0538: */
0539: public void setCompStatsProps(String aCompName,
0540: String anInstanceName) {
0541: sLog.fine("ShowBean.setCompStatsProps(" + aCompName + ", "
0542: + anInstanceName + ")");
0543:
0544: mName = aCompName;
0545: mInstanceName = anInstanceName;
0546: }
0547:
0548: /**
0549: * Sets the Service Assembly Statistics properties for the specified
0550: * component
0551: *
0552: * @param anSaName String with the Service Assembly name
0553: * @param anInstanceName String with the instance name
0554: */
0555: public void setSaStatsProps(String anSaName, String anInstanceName) {
0556: sLog.fine("ShowBean.setSaStatsProps(" + anSaName + ", "
0557: + anInstanceName + ")");
0558:
0559: mName = anSaName;
0560: mInstanceName = anInstanceName;
0561: }
0562:
0563: // setters
0564:
0565: /**
0566: * @param ignored The new DeploymentOrInstallationDescriptor value
0567: */
0568: public void setDeploymentOrInstallationDescriptor(String ignored) {
0569: // required for introspection, but never should be called
0570: throw new RuntimeException(
0571: "ShowBean.setDeploymentOrInstallationDescriptor(String)"
0572: + " not supported (read-only property)");
0573: }
0574:
0575: /**
0576: * set the "component" description
0577: *
0578: * @param ignored The new Description value
0579: */
0580: public void setDescription(String ignored) {
0581: throw new RuntimeException(
0582: "ShowBean.setDescription(String) not supported (read-only property)");
0583: }
0584:
0585: /**
0586: * set the "component" name
0587: *
0588: * @param aName a JBI "component" name
0589: */
0590: public void setName(String aName) {
0591: mName = aName;
0592: }
0593:
0594: /**
0595: * set the targets list
0596: *
0597: * @param aTargetsList a List of zero or more targets for this
0598: * component/deployment. An empty list implies installed/deployed to
0599: * 'domain' only.
0600: */
0601: public void setTargetsList(List aTargetsList) {
0602: sLog.fine("ShowBean.setTargetsList(" + aTargetsList + ")");
0603: mTargetsList = aTargetsList;
0604: }
0605:
0606: /**
0607: * set the "component" type
0608: *
0609: * @param aType a "component" type (one of: binding-component,
0610: * service-assembly, service-engine, shared-library)
0611: */
0612: public void setType(String aType) {
0613: mType = aType;
0614: }
0615:
0616: /**
0617: * Sets the TargetNames attribute of the ShowBean object
0618: *
0619: * @param aTargetNames The new TargetNames value
0620: */
0621: public void setTargetNames(String[] aTargetNames) {
0622: mTargetNames = aTargetNames;
0623: }
0624:
0625: /**
0626: * Sets the FilterTargetComponentState attribute of the ShowBean object
0627: *
0628: * @param filterState The new FilterTargetComponentState value
0629: */
0630: public void setFilterTargetComponentState(String filterState) {
0631: mFilterTargetComponentState = filterState;
0632: }
0633:
0634: /**
0635: * Sets the FilterTargetComponentState attribute of the ShowBean object
0636: *
0637: * @param filterState The new FilterTargetComponentState value
0638: * @param filterStates The new FilterTargetComponentState value
0639: */
0640: public void setFilterTargetComponentState(String filterState,
0641: String filterStates) {
0642: mFilterTargetComponentState = filterState;
0643: filterStates = filterStates.replace('[', ' ');
0644: filterStates = filterStates.replace(']', ' ');
0645: String[] states = filterStates.split("\\,");
0646: for (int i = 0; i < states.length; i++) {
0647: states[i] = states[i].trim();
0648: }
0649: mFilterTargetComponentStates = new ArrayList(Arrays
0650: .asList(states));
0651: }
0652:
0653: /**
0654: * Sets the FilterTargetAssemblyState attribute of the ShowBean object
0655: *
0656: * @param filterState The new FilterTargetAssemblyState value
0657: */
0658: public void setFilterTargetAssemblyState(String filterState) {
0659: mFilterTargetAssemblyState = filterState;
0660: }
0661:
0662: /**
0663: * Sets the FilterTargetAssemblyState attribute of the ShowBean object
0664: *
0665: * @param filterState The new FilterTargetAssemblyState value
0666: * @param filterStates The new FilterTargetAssemblyState value
0667: */
0668: public void setFilterTargetAssemblyState(String filterState,
0669: String filterStates) {
0670: mFilterTargetAssemblyState = filterState;
0671: filterStates = filterStates.replace('[', ' ');
0672: filterStates = filterStates.replace(']', ' ');
0673: String[] states = filterStates.split("\\,");
0674: for (int i = 0; i < states.length; i++) {
0675: states[i] = states[i].trim();
0676: }
0677: mFilterTargetAssemblyStates = new ArrayList(Arrays
0678: .asList(states));
0679: }
0680:
0681: /**
0682: * Sets the ServiceAssemblyStatsPS attribute of the ShowBean object
0683: *
0684: * @param aPropertySheet The new ServiceAssemblyStatsPS value
0685: */
0686: public void setServiceAssemblyStatsPS(PropertySheet aPropertySheet) {
0687: // no-op
0688: }
0689:
0690: /**
0691: * Required but not used setter for read only property sheet.
0692: *
0693: * @param anIgnoredArg not used
0694: */
0695: public void setCompStatsPropertySheet(PropertySheet anIgnoredArg) {
0696: sLog.fine("ShowBean.setCompStatsPropertySheet(" + anIgnoredArg
0697: + ")");
0698: }
0699:
0700: /**
0701: * required, but not used
0702: *
0703: * @param aPropertySheet The new CreateCompAppConfigPropertySheet value
0704: */
0705: public void setCreateCompAppConfigPropertySheet(
0706: PropertySheet aPropertySheet) {
0707: sLog.fine("ShowBean.setCreateCompAppConfigPropertySheet("
0708: + aPropertySheet + ")");
0709: // TBD
0710: }
0711:
0712: /**
0713: * required, but not used
0714: *
0715: * @param aPropertySheet The new EditCompAppConfigPropertySheet value
0716: */
0717: public void setEditCompAppConfigPropertySheet(
0718: PropertySheet aPropertySheet) {
0719: sLog.fine("ShowBean.setEditCompAppConfigPropertySheet("
0720: + aPropertySheet + ")");
0721: // TBD
0722: }
0723:
0724: /**
0725: * required, but not used
0726: *
0727: * @param aPropertySheet The new CreateCompAppVarsPropertySheet value
0728: */
0729: public void setCreateCompAppVarsPropertySheet(
0730: PropertySheet aPropertySheet) {
0731: sLog.fine("ShowBean.setCreateCompAppVarsPropertySheet("
0732: + aPropertySheet + ")");
0733: // TBD
0734: }
0735:
0736: /**
0737: * required, but not used
0738: *
0739: * @param aPropertySheet The new EditCompAppVarsPropertySheet value
0740: */
0741: public void setEditCompAppVarsPropertySheet(
0742: PropertySheet aPropertySheet) {
0743: sLog.fine("ShowBean.setEditCompAppVarsPropertySheet("
0744: + aPropertySheet + ")");
0745: // TBD
0746: }
0747:
0748: /**
0749: * @param aTarget Description of Parameter
0750: * @return String - status (or null if not installed/deployed)
0751: */
0752: public String check(String aTarget) {
0753: sLog.fine("ShowBean.check(" + aTarget + ")");
0754:
0755: String result = null;
0756: // "not found"
0757:
0758: String queryResult = null;
0759:
0760: boolean isServiceAssembly = false;
0761: boolean isSharedLibrary = false;
0762:
0763: if (null != mJac) {
0764: try {
0765:
0766: if (JBIConstants.JBI_BINDING_COMPONENT_TYPE
0767: .equals(mType)) {
0768: queryResult = mJac.showBindingComponent(mName,
0769: null, /* no state check */
0770: null, /* no library check */
0771: null, /* no deployment check */
0772: aTarget);
0773: } else if (JBIConstants.JBI_SERVICE_ENGINE_TYPE
0774: .equals(mType)) {
0775: queryResult = mJac.showServiceEngine(mName, null, /* no state check */
0776: null, /* no library check */
0777: null, /* no deployment check */
0778: aTarget);
0779:
0780: } else if (JBIConstants.JBI_SERVICE_ASSEMBLY_TYPE
0781: .equals(mType)) {
0782: queryResult = mJac.showServiceAssembly(mName, null, /* no state check */
0783: null, /* no component check */
0784: aTarget);
0785: isServiceAssembly = true;
0786: } else if (JBIConstants.JBI_SHARED_LIBRARY_TYPE
0787: .equals(mType)) {
0788: queryResult = mJac.showSharedLibrary(mName, null, /* no component check */
0789: aTarget);
0790: isSharedLibrary = true;
0791: } else {
0792: sLog.fine("ShowBean.check--unrecognized mType="
0793: + mType);
0794: }
0795:
0796: if (null != queryResult) {
0797: sLog.fine("ShowBean.check(" + aTarget
0798: + "), queryResult=" + queryResult);
0799: List list;
0800: if (isServiceAssembly) {
0801: list = ServiceAssemblyInfo
0802: .readFromXmlTextWithProlog(queryResult);
0803: if (1 == list.size()) {
0804: ServiceAssemblyInfo saInfo = (ServiceAssemblyInfo) list
0805: .get(0);
0806: String state = saInfo.getState();
0807:
0808: if (JBIComponentInfo.STARTED_STATE
0809: .equals(state)) {
0810: result = I18nUtilities
0811: .getResourceString("jbi.operations.comp.started");
0812: } else {
0813: result = "Disabled(" + state + ")";
0814: }
0815: }
0816: } else {
0817: list = JBIComponentInfo
0818: .readFromXmlText(queryResult);
0819:
0820: if (1 == list.size()) {
0821: JBIComponentInfo compInfo = (JBIComponentInfo) list
0822: .get(0);
0823:
0824: if (isSharedLibrary) {
0825: // has no lifecycle state
0826:
0827: result = I18nUtilities
0828: .getResourceString("jbi.operations.start.enabled");
0829: } else {
0830: // BC or SE (has lifecycle state)
0831:
0832: String state = compInfo.getState();
0833:
0834: if (JBIComponentInfo.STARTED_STATE
0835: .equals(state)) {
0836: result = I18nUtilities
0837: .getResourceString("jbi.operations.comp.started");
0838: } else if (JBIComponentInfo.STOPPED_STATE
0839: .equals(state)) {
0840: result = I18nUtilities
0841: .getResourceString("jbi.operations.comp.stopped");
0842: } else if (JBIComponentInfo.SHUTDOWN_STATE
0843: .equals(state)) {
0844: result = I18nUtilities
0845: .getResourceString("jbi.operations.comp.shutdown");
0846: } else {
0847: result = I18nUtilities
0848: .getResourceString("jbi.operations.comp.state.unknown");
0849: }
0850: }
0851: }
0852: }
0853: }
0854: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
0855: sLog.log(Level.FINE,
0856: ("ShowBean.check() caught jrEx=" + jrEx), jrEx);
0857: }
0858: }
0859: sLog.fine("ShowBean.check(" + aTarget + "), mName=" + mName
0860: + ", mType=" + mType + ", queryResult=" + queryResult
0861: + ", result = " + result);
0862: return result;
0863: }
0864:
0865: /**
0866: * Saves the Application Configuration properties for the specified
0867: * component
0868: *
0869: * @param anAction Description of Parameter
0870: * @param aCompName String with the component name
0871: * @param anInstanceName String with the instance name
0872: * @param anAppConfigName String with the Application Configuration name
0873: * @param aToBeSaved Properties with edited values to be saved
0874: * @param aStatus Properties where results for alert processing
0875: * are returned
0876: */
0877: public void saveCompAppConfigProps(String anAction,
0878: String aCompName, String anInstanceName,
0879: String anAppConfigName, Properties aToBeSaved,
0880: Properties aStatus) {
0881: sLog.fine("ShowBean.saveCompAppConfigProps(" + anAction + ", "
0882: + aCompName + ", " + anInstanceName + ", "
0883: + anAppConfigName + ", " + aToBeSaved + ", " + aStatus
0884: + ")");
0885:
0886: try {
0887: Properties updatedProps = (Properties) aToBeSaved.clone();
0888:
0889: updatedProps.put("configurationName", anAppConfigName);
0890:
0891: String result = null;
0892:
0893: if ("edit".equals(anAction)) {
0894: result = mJac.setApplicationConfiguration(aCompName,
0895: anInstanceName, anAppConfigName, updatedProps);
0896: } else {
0897: result = mJac.addApplicationConfiguration(aCompName,
0898: anInstanceName, anAppConfigName, updatedProps);
0899: }
0900:
0901: sLog.fine("ShowBean.saveCompAppConfigProps(), result="
0902: + result);
0903: aStatus.put("success-result", result);
0904: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
0905: sLog
0906: .log(
0907: Level.FINE,
0908: ("ShowBean.saveCompAppConfigProps() caught jrEx=" + jrEx),
0909: jrEx);
0910: aStatus.put("failure-result", jrEx.toString());
0911: // TBD ManagementMessage
0912: }
0913:
0914: sLog.fine("ShowBean.saveCompAppConfigProps(...), aStatus="
0915: + aStatus);
0916: }
0917:
0918: /**
0919: * initialize the member varible target name list, which is dynamic and
0920: * also initialize the original target name list, which is static.
0921: */
0922: public void initTargetNames() {
0923: List targets = getTargetsList();
0924: mTargetNames = new String[targets.size()];
0925: mOriginalTargetNames = new String[targets.size()];
0926: for (int i = 0; i < targets.size(); i++) {
0927: SelectableTargetInfo tgtInfo = (SelectableTargetInfo) targets
0928: .get(i);
0929: mTargetNames[i] = tgtInfo.getName();
0930: mOriginalTargetNames[i] = tgtInfo.getName();
0931: }
0932: }
0933:
0934: private static final boolean IS_CLUSTER_PROFILE = ClusterUtilities
0935: .isClusterProfile();
0936:
0937: /**
0938: * default result for queries when no data found
0939: */
0940: private static final String DEFAULT_RESULT = "";
0941:
0942: /**
0943: * Gets the CompAppVarsPropertySheet attribute of the ShowBean object
0944: *
0945: * @param anAction Description of Parameter
0946: * @return The CompAppVarsPropertySheet value
0947: */
0948: private PropertySheet getCompAppVarsPropertySheet(String anAction) {
0949: sLog.fine("ShowBean.getEditCompAppVarsPropertySheet("
0950: + anAction + ")");
0951:
0952: PropertySheet propertySheet = new PropertySheet();
0953: propertySheet.setId("editCompAppVarsPropertySheet");
0954:
0955: // Property sheet section for selection of instance/component/configuration
0956: List propertySectionList = propertySheet.getChildren();
0957:
0958: PropertySheetSection propertySheetSection1 = new PropertySheetSection();
0959: propertySheetSection1.setId("editCompAppVarsPss1");
0960: String propsPss1Label = I18nUtilities
0961: .getResourceString("jbi.edit.comp.app.config.props.pss.selection.label");
0962: propertySheetSection1.setLabel(propsPss1Label);
0963:
0964: propertySectionList.add(propertySheetSection1);
0965:
0966: List propertyList1 = propertySheetSection1.getChildren();
0967:
0968: //
0969: if (IS_CLUSTER_PROFILE) {
0970: Property instanceNameProperty = JSFUtils
0971: .createTextProperty("instanceName",
0972: "jbi.edit.comp.app.config.instance.label",
0973: "#{jbiSelectedInstanceValue}", false);
0974: propertyList1.add(instanceNameProperty);
0975: }
0976:
0977: //
0978: Property componentNameProperty = JSFUtils.createTextProperty(
0979: "compName", "jbi.edit.comp.app.config.component.label",
0980: "#{sharedShowName}", false);
0981: propertyList1.add(componentNameProperty);
0982:
0983: //
0984: //boolean isEditable =
0985: // "create".equals(anAction);
0986: // TBD if isEditable add new field with Type dropDown
0987:
0988: //
0989: // property sheet section for creating/editing properties
0990: //
0991: PropertySheetSection propertySheetSection2 = new PropertySheetSection();
0992: propertySheetSection2.setId("editCompAppVarsPss2");
0993: String propsPss2Label = I18nUtilities
0994: .getResourceString("jbi.edit.comp.app.vars.pss.new.var.label");
0995: propertySheetSection2.setLabel(propsPss2Label);
0996:
0997: propertySectionList.add(propertySheetSection2);
0998:
0999: List propertyList2 = propertySheetSection2.getChildren();
1000:
1001: // TBD AppVarUtils.getVars...
1002: if (null != mJac) {
1003: Properties appVars = null;
1004: try {
1005: appVars = mJac.getApplicationVariables(mName,
1006: mInstanceName);
1007: sLog.fine("ShowBean.getEditCompAppVarsPropertySheet("
1008: + anAction + "), mName=" + mName
1009: + ", mInstanceName=" + mInstanceName
1010: + ", appVars=" + appVars);
1011:
1012: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
1013: sLog.log(Level.FINE,
1014: ("ShowBean.getEditCompAppVarsPropertySheet("
1015: + anAction + ") caught jrEx=" + jrEx),
1016: jrEx);
1017: }
1018: }
1019:
1020: // Name
1021: Property nameProperty = new Property();
1022: nameProperty.setId("NameProperty");
1023: List namePropSubElts = nameProperty.getChildren();
1024:
1025: Label nameLabel = new Label();
1026: nameLabel.setId("nameLabel");
1027: String nameLabelStr = I18nUtilities
1028: .getResourceString("jbi.edit.comp.app.vars.new.var.name.label");
1029: nameLabel.setText(nameLabelStr);
1030: namePropSubElts.add(nameLabel);
1031:
1032: TextField nameValue = new TextField();
1033: nameValue.setId("nameValue");
1034: nameValue.setText("");
1035: namePropSubElts.add(nameValue);
1036:
1037: propertyList2.add(nameProperty);
1038:
1039: // Type
1040: Property typeProperty = new Property();
1041: typeProperty.setId("TypeProperty");
1042: List typePropSubElts = typeProperty.getChildren();
1043:
1044: Label typeLabel = new Label();
1045: typeLabel.setId("typeLabel");
1046: String typeLabelStr = I18nUtilities
1047: .getResourceString("jbi.edit.comp.app.vars.new.var.type.label");
1048: typeLabel.setText(typeLabelStr);
1049: typePropSubElts.add(typeLabel);
1050:
1051: String booleanLabel = I18nUtilities
1052: .getResourceString("jbi.show.comp.app.vars.typeIsBoolean");
1053: Option booleanOption = new Option(
1054: SharedConstants.APP_VAR_TYPE_BOOLEAN, booleanLabel);
1055: String numberLabel = I18nUtilities
1056: .getResourceString("jbi.show.comp.app.vars.typeIsNumber");
1057: Option numberOption = new Option(
1058: SharedConstants.APP_VAR_TYPE_NUMBER, numberLabel);
1059: String passwordLabel = I18nUtilities
1060: .getResourceString("jbi.show.comp.app.vars.typeIsPassword");
1061: Option passwordOption = new Option(
1062: SharedConstants.APP_VAR_TYPE_PASSWORD, passwordLabel);
1063: String stringLabel = I18nUtilities
1064: .getResourceString("jbi.show.comp.app.vars.typeIsString");
1065: Option stringOption = new Option(
1066: SharedConstants.APP_VAR_TYPE_STRING, stringLabel);
1067:
1068: Option[] options = { booleanOption, numberOption,
1069: passwordOption, stringOption };
1070:
1071: DropDown typeValue = new DropDown();
1072: typeValue.setId("typeValue");
1073:
1074: typeValue.setItems(options);
1075:
1076: // TBD delete this experimental code
1077: //import javax.el.ValueExpression;
1078: //import javax.faces.context.FacesContext;
1079: //if (false)
1080: //{
1081: // String vExprStr =
1082: // "#{sessionScope.jbiNewAppVarType}";
1083: // FacesContext facesContext =
1084: // FacesContext.getCurrentInstance();
1085: // ValueExpression ve =
1086: // facesContext.getApplication().getExpressionFactory()
1087: // .createValueExpression(
1088: // facesContext.getELContext(), vExprStr, Object.class);
1089: // //typeValue.setValueExpression(facesContext.getELContext(), stringOption);
1090: //}
1091:
1092: typeValue.setSelected(SharedConstants.APP_VAR_TYPE_STRING);
1093: typeValue.setSubmitForm(true);
1094:
1095: typePropSubElts.add(typeValue);
1096:
1097: propertyList2.add(typeProperty);
1098:
1099: // Value
1100: Property valueProperty = new Property();
1101: valueProperty.setId("ValueProperty");
1102: List valuePropSubElts = valueProperty.getChildren();
1103:
1104: Label valueLabel = new Label();
1105: valueLabel.setId("valueLabel");
1106: String valueLabelStr = I18nUtilities
1107: .getResourceString("jbi.edit.comp.app.vars.new.var.value.label");
1108: valueLabel.setText(valueLabelStr);
1109: valuePropSubElts.add(valueLabel);
1110:
1111: TextField valueValue = new TextField();
1112: valueValue.setId("valueValue");
1113: valueValue.setText("");
1114: valuePropSubElts.add(valueValue);
1115:
1116: propertyList2.add(valueProperty);
1117:
1118: sLog.fine("ShowBean.getEditCompAppVarsPropertySheet("
1119: + anAction + "), propertySheet=" + propertySheet);
1120:
1121: return propertySheet;
1122: }
1123:
1124: // private methods
1125:
1126: /**
1127: * helper to initialize the "component" deployment/installation metadata
1128: *
1129: * @return the contents of the /META-INF/jbi.xml in a validated XML
1130: * String
1131: */
1132: private String queryDeploymentOrInstallationDescriptor() {
1133: String result = DEFAULT_RESULT;
1134: String descriptor = DEFAULT_RESULT;
1135: try {
1136:
1137: JBIAdminCommands client = BeanUtilities.getClient();
1138:
1139: if (null != client) {
1140:
1141: sLog
1142: .fine("ShowBean.queryDeploymentOrInstallationDescriptor(), client="
1143: + client
1144: + ", mType="
1145: + mType
1146: + ", mName=" + mName);
1147: if (JBIConstants.JBI_BINDING_COMPONENT_TYPE
1148: .equals(mType)
1149: || JBIConstants.JBI_SERVICE_ENGINE_TYPE
1150: .equals(mType)) {
1151: descriptor = client
1152: .getComponentInstallationDescriptor(mName);
1153: } else if (JBIConstants.JBI_SHARED_LIBRARY_TYPE
1154: .equals(mType)) {
1155: descriptor = client
1156: .getSharedLibraryInstallationDescriptor(mName);
1157: } else if (JBIConstants.JBI_SERVICE_ASSEMBLY_TYPE
1158: .equals(mType)) {
1159: descriptor = client
1160: .getServiceAssemblyDeploymentDescriptor(mName);
1161: }
1162: result = descriptor;
1163: }
1164: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
1165: sLog
1166: .log(
1167: Level.FINE,
1168: ("ShowBeanqueryDeploymentOrInstallationDescriptor(), caught jrEx=" + jrEx),
1169: jrEx);
1170: }
1171: sLog
1172: .fine("ShowBean.queryDeploymentOrInstallationDescriptor(), result="
1173: + result);
1174: return result;
1175: }
1176:
1177: /**
1178: * initializes the "component" description
1179: *
1180: * @return the description (or an empty string if not found)
1181: */
1182: private String queryDescription() {
1183: String result = DEFAULT_RESULT;
1184:
1185: ListBean listBean = BeanUtilities.getListBean();
1186:
1187: sLog
1188: .fine("ShowBean.queryDeploymentOrInstallationDescriptor(), mType="
1189: + mType);
1190:
1191: if (JBIConstants.JBI_BINDING_COMPONENT_TYPE.equals(mType)) {
1192: List<SelectableJBIComponentInfo> bindings = listBean
1193: .getBindingComponentsInfoList(
1194: mFilterTargetComponentState,
1195: mFilterTargetComponentStates);
1196: result = listBean.findDescription(mName, bindings);
1197: } else if (JBIConstants.JBI_SERVICE_ASSEMBLY_TYPE.equals(mType)) {
1198: List<SelectableJBIServiceAssemblyInfo> deployments = listBean
1199: .getServiceAssembliesInfoList(
1200: mFilterTargetAssemblyState,
1201: mFilterTargetAssemblyStates);
1202: result = listBean.findDescription(mName, deployments);
1203: } else if (JBIConstants.JBI_SERVICE_ENGINE_TYPE.equals(mType)) {
1204: List<SelectableJBIComponentInfo> engines = listBean
1205: .getServiceEnginesInfoList(
1206: mFilterTargetComponentState,
1207: mFilterTargetComponentStates);
1208: result = listBean.findDescription(mName, engines);
1209: } else if (JBIConstants.JBI_SHARED_LIBRARY_TYPE.equals(mType)) {
1210: List<SelectableJBIComponentInfo> libraries = listBean
1211: .getSharedLibrariesInfoList();
1212: result = listBean.findDescription(mName, libraries);
1213: }
1214:
1215: sLog.fine("ShowBean.queryDescription(), result=" + result);
1216: return result;
1217: }
1218:
1219: //Get logger to log fine, info level messages in server.log file
1220: private Logger sLog = JBILogger.getInstance();
1221:
1222: // member variables
1223:
1224: /**
1225: * cached JBI Admin Commands client
1226: */
1227: private JBIAdminCommands mJac;
1228:
1229: /**
1230: * JBI "component" name
1231: */
1232: private String mName;
1233:
1234: /**
1235: * JBI "component" type (one of: binding-component, service-assembly,
1236: * service-engine, shared-library)
1237: */
1238: private String mType;
1239:
1240: /**
1241: * targets for this component (zero or more cluster name Strings and zero
1242: * or more Stand-Alone Instance name Strings.
1243: */
1244: private List mTargetsList = new ArrayList();
1245:
1246: /**
1247: * Holds the filter type for the components table
1248: */
1249: private String mFilterTargetComponentState = SharedConstants.DROP_DOWN_TYPE_SHOW_ALL;
1250: private ArrayList mFilterTargetComponentStates = null;
1251:
1252: /**
1253: * Holds the filter type for the components table
1254: */
1255: private String mFilterTargetAssemblyState = SharedConstants.DROP_DOWN_TYPE_SHOW_ALL;
1256: private ArrayList mFilterTargetAssemblyStates = null;
1257:
1258: private String[] mTargetNames = null;
1259: private String[] mOriginalTargetNames = null;
1260:
1261: private String mCompAppConfigName;
1262: private String[] mCompAppConfigNames;
1263: private String mInstanceName;
1264: private boolean mIsCompAppConfigSupported;
1265: }
|