001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: /*
038: * ServiceUnitBean.java
039: */
040:
041: package com.sun.jbi.jsf.bean;
042:
043: import com.sun.data.provider.TableDataProvider;
044: import com.sun.data.provider.impl.ObjectListDataProvider;
045: import com.sun.jbi.jsf.util.BeanUtilities;
046: import com.sun.jbi.jsf.util.ClusterUtilities;
047: import com.sun.jbi.jsf.util.JBIConstants;
048: import com.sun.jbi.jsf.util.JBILogger;
049: import com.sun.jbi.jsf.util.JSFUtils;
050: import com.sun.jbi.jsf.util.SaStatsUtils;
051: import com.sun.jbi.ui.common.JBIAdminCommands;
052: import com.sun.webui.jsf.component.PropertySheet;
053: import java.util.ArrayList;
054: import java.util.List;
055: import java.util.logging.Logger;
056: import javax.management.openmbean.TabularData;
057:
058: /**
059: * Provides properties used to populate JBI Show Serice Unit
060: * view properties and metadata
061: */
062: public class ServiceUnitBean {
063: /**
064: * default result for queries when no data found
065: */
066: private final static String DEFAULT_RESULT = "";
067:
068: //Get logger to log fine, info level messages in server.log file
069: private Logger sLog = JBILogger.getInstance();
070:
071: /**
072: * Constructs an uninitialized Service Unit Bean.
073: * To complete initialization, call the setServiceUnitName
074: * and setServiceAssemblyName methods.
075: * The description and deployment descriptor are derived.
076: */
077: public ServiceUnitBean() {
078: mJac = BeanUtilities.getClient();
079: }
080:
081: // getters
082:
083: /**
084: * get contents of /META-INF/jbi.xml for this service unit
085: * @return the JBI deployment descriptor in a (validated) XML String
086: */
087: public String getDeploymentDescriptor() {
088: String result = DEFAULT_RESULT;
089: try {
090: if (null != mJac) {
091: sLog
092: .fine("ServiceUnitBean.getDeploymentDescriptor(), mJac="
093: + mJac
094: + ", mServiceUnitName="
095: + mServiceUnitName);
096: result = mJac.getServiceUnitDeploymentDescriptor(
097: mServiceAssemblyName, mServiceUnitName);
098: }
099: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
100: sLog
101: .fine("ServiceUnitBean.querySuDeploymentDescriptor(), caught jrEx="
102: + jrEx);
103: jrEx.printStackTrace();
104: }
105:
106: sLog.fine("ServiceUnitBean.getDeploymentDescriptor(),result="
107: + result);
108: return result;
109: }
110:
111: /**
112: * get the list of service units
113: * @return a List contain the service units
114: */
115: public List getServiceUnitsList() {
116: return mServiceUnitsList;
117: }
118:
119: /**
120: * get the service assembly name
121: * @return a String containing the service assembly name
122: */
123: public String getServiceAssemblyName() {
124: return mServiceAssemblyName;
125: }
126:
127: /**
128: * get the target component name
129: * @return a String containing the target component name
130: */
131: public String getTargetComponent() {
132: return mTargetComponent;
133: }
134:
135: /**
136: * get the component type
137: * @return a String containing component type
138: */
139: public String getComponentType() {
140: return mComponentType;
141: }
142:
143: /**
144: * get the service unit description
145: * @return a String containing component type
146: */
147: public String getDescription() {
148: return mDescription;
149: }
150:
151: /**
152: * get the service unit name
153: * @return a String containing component type
154: */
155: public String getName() {
156: return mServiceUnitName;
157: }
158:
159: /**
160: * get the component type icon
161: * @return a String containing the icon for the component
162: */
163: public String getComponentTypeIcon() {
164: String iconFileName = "";
165: if (mComponentType
166: .equals(JBIConstants.JBI_BINDING_COMPONENT_TYPE)) {
167: iconFileName = "JBIBindingComponent.gif";
168: } else if (mComponentType
169: .equals(JBIConstants.JBI_SERVICE_ENGINE_TYPE)) {
170: iconFileName = "JBIServiceEngine.gif";
171: }
172: return iconFileName;
173: }
174:
175: public PropertySheet getServiceUnitStatsPS() {
176: PropertySheet result = null;
177:
178: String targetName = ClusterUtilities
179: .getInstanceDomainCluster(mSaInstanceName);
180:
181: TabularData saTabularData = SaStatsUtils.getStats(targetName,
182: mServiceAssemblyName);
183:
184: TabularData tbdEndpointTabularData = null; // TBD
185:
186: result = JSFUtils.getSuStatsPS(saTabularData,
187: tbdEndpointTabularData, mSaInstanceName,
188: mServiceAssemblyName, mServiceUnitName);
189: return result;
190: }
191:
192: public TableDataProvider getServiceUnitsTableData() {
193: sLog.fine("ShowBean.getServiceUnitsTableData()");
194: TableDataProvider result = new ObjectListDataProvider(
195: mServiceUnitsList);
196: sLog.fine("ShowBean.getServiceUnitsTableData(): result="
197: + result);
198: return result;
199: }
200:
201: // setters
202:
203: /**
204: * set the service units list
205: * @param aServiceUnitsListt a List of zero or more service units.
206: */
207: public void setServiceUnitsList(List aServiceUnitsList) {
208: sLog.fine("ShowBean.setServiceUnitsList(" + aServiceUnitsList
209: + ")");
210: mServiceUnitsList = aServiceUnitsList;
211: }
212:
213: public void setServiceUnitStatsPS(PropertySheet aPropertySheet) {
214: // no-op
215: }
216:
217: public void setServiceAssemblyName(String aName) {
218: mServiceAssemblyName = aName;
219: }
220:
221: public void setTargetComponent(String aName) {
222: mTargetComponent = aName;
223: }
224:
225: public void setComponentType(String aType) {
226: mComponentType = aType;
227: }
228:
229: public void setDescription(String aDescription) {
230: mDescription = aDescription;
231: }
232:
233: public void setName(String aServiceUnitName) {
234: mServiceUnitName = aServiceUnitName;
235: }
236:
237: public void setSuStatsProps(String anSaName, String anSuName,
238: String anInstanceName) {
239: mServiceAssemblyName = anSaName;
240: mServiceUnitName = anSuName;
241: mSaInstanceName = anInstanceName;
242: }
243:
244: // private methods
245:
246: // member variables
247:
248: /**
249: * cached JBI Admin Commands client
250: */
251: private JBIAdminCommands mJac;
252:
253: /**
254: * List containing the list of SelectableServiceUnitInfo objects
255: */
256: private List mServiceUnitsList = new ArrayList();
257:
258: /**
259: * The Containing Service Assembly Name
260: */
261: private String mServiceAssemblyName = null;
262:
263: /**
264: * The Target Component Name
265: */
266: private String mTargetComponent = null;
267:
268: /**
269: * The Target Component Type
270: */
271: private String mComponentType = null;
272:
273: /**
274: * The Description of the Service Unit
275: */
276: private String mDescription = null;
277:
278: /**
279: * The instance name
280: */
281: private String mSaInstanceName;
282:
283: /**
284: * The Name of the service unit
285: */
286: private String mServiceUnitName = null;
287:
288: }
|