001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2008 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: package com.sun.jbi.jsf.handlers;
038:
039: import com.sun.jbi.jsf.bean.RuntimeStatsBean;
040: import com.sun.jbi.jsf.bean.ServiceUnitBean;
041: import com.sun.jbi.jsf.bean.ShowBean;
042: import com.sun.jbi.jsf.util.BeanUtilities;
043: import com.sun.jbi.jsf.util.CompStatsUtils;
044: import com.sun.jbi.jsf.util.JBILogger;
045: import com.sun.jsftemplating.annotation.Handler;
046: import com.sun.jsftemplating.annotation.HandlerInput;
047: import com.sun.jsftemplating.annotation.HandlerOutput;
048: import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
049: import com.sun.webui.jsf.component.PropertySheet;
050: import java.util.logging.Level;
051: import java.util.logging.Logger;
052:
053: /**
054: * Provides jsftemplating handlers for Statistics/Monitorung use-cases
055: */
056: public class StatsHandlers {
057: private static Logger sLog = JBILogger.getInstance();
058:
059: /**
060: * <p> This method sets the component statistics for the specified component
061: * on the specified instance into the ShowBean.
062: * <p> Input value: "compName" -- Type: <code> java.lang.String</code> Name of the component
063: * <p> Input value: "instanceName" -- Type: <code>java.lang.String</code></p>
064: * @param context The HandlerContext.
065: */
066: @Handler(id="jbiSetCompStatsForInstance",input={@HandlerInput(name="compName",type=String.class,required=true),@HandlerInput(name="instanceName",type=String.class,required=true)})
067: public static void jbiSetCompStatsForInstance(
068: HandlerContext handlerCtx) {
069: String compName = (String) handlerCtx.getInputValue("compName");
070: String instanceName = (String) handlerCtx
071: .getInputValue("instanceName");
072: sLog
073: .fine("StatsHandlers.jbiSetCompStatsForInstance(...), compName="
074: + compName + ", instanceName=" + instanceName);
075:
076: ShowBean showBean = BeanUtilities.getShowBean();
077: showBean.setCompStatsProps(compName, instanceName);
078: }
079:
080: /**
081: * <p> This method sets the runtime monitoring framework statistics
082: * <p> Input value: "instanceName" -- Type: <code>java.lang.String</code></p>
083: * @param context The HandlerContext.
084: */
085: @Handler(id="jbiSetFrameworkStatsForInstance",input={@HandlerInput(name="instanceName",type=String.class,required=true)})
086: public static void jbiSetFrameworkStatsForInstance(
087: HandlerContext handlerCtx) {
088: String instanceName = (String) handlerCtx
089: .getInputValue("instanceName");
090: sLog
091: .fine("StatsHandlers.jbiSetFrameworkStatsForInstance(...), instanceName="
092: + instanceName);
093: RuntimeStatsBean runtimeStatsBean = BeanUtilities
094: .getRuntimeStatsBean();
095:
096: PropertySheet frameworkPS = null;
097: // TBD frameworkPS = JSFUtils.getFrameworkPS(instanceName);
098:
099: runtimeStatsBean.setFrameworkPS(frameworkPS);
100: }
101:
102: /**
103: * <p> This method sets the runtime monitoring NMR statistics
104: * <p> Input value: "instanceName" -- Type: <code>java.lang.String</code></p>
105: * @param context The HandlerContext.
106: */
107: @Handler(id="jbiSetNMRStatsForInstance",input={@HandlerInput(name="instanceName",type=String.class,required=true)})
108: public static void jbiSetNMRStatsForInstance(
109: HandlerContext handlerCtx) {
110: String instanceName = (String) handlerCtx
111: .getInputValue("instanceName");
112: sLog
113: .fine("StatsHandlers.jbiSetNMRStatsForInstance(...), instanceName="
114: + instanceName);
115: RuntimeStatsBean runtimeStatsBean = BeanUtilities
116: .getRuntimeStatsBean();
117: PropertySheet nmrPS = null;
118: // TBD nmrPS = JSFUtils.getNMRPS(instanceName);
119: runtimeStatsBean.setNMRPS(nmrPS);
120: }
121:
122: /**
123: * <p> This method sets the statistics for the specified Service Assembly
124: * on the specified instance into the ShowBean.
125: * <p> Input value: "saName" -- Type: <code> java.lang.String</code> JBI
126: * Service Assembly name
127: * <p> Input value: "instanceName" -- Type: <code>java.lang.String</code></p>
128: * @param context The HandlerContext.
129: */
130: @Handler(id="jbiSetSaStatsForInstance",input={@HandlerInput(name="saName",type=String.class,required=true),@HandlerInput(name="instanceName",type=String.class,required=true)})
131: public static void jbiSetSaStatsForInstance(
132: HandlerContext handlerCtx) {
133: String saName = (String) handlerCtx.getInputValue("saName");
134: String instanceName = (String) handlerCtx
135: .getInputValue("instanceName");
136: sLog
137: .fine("StatsHandlers.jbiSetSaStatsForInstance(...), saName="
138: + saName + ", instanceName=" + instanceName);
139:
140: ShowBean showBean = BeanUtilities.getShowBean();
141: showBean.setSaStatsProps(saName, instanceName);
142: }
143:
144: /**
145: * <p> This method sets the statistics for the specified Service Unit
146: * on the specified instance into the ServiceUnitBean.
147: * <p> Input value: "saName" -- Type: <code> java.lang.String</code> JBI
148: * Service Assembly name
149: * <p> Input value: "suName" -- Type: <code> java.lang.String</code> JBI
150: * Service Unit name
151: * <p> Input value: "instanceName" -- Type: <code>java.lang.String</code></p>
152: * @param context The HandlerContext.
153: */
154: @Handler(id="jbiSetSuStatsForInstance",input={@HandlerInput(name="saName",type=String.class,required=true),@HandlerInput(name="suName",type=String.class,required=true),@HandlerInput(name="instanceName",type=String.class,required=true)})
155: public static void jbiSetSuStatsForInstance(
156: HandlerContext handlerCtx) {
157: String saName = (String) handlerCtx.getInputValue("saName");
158: String suName = (String) handlerCtx.getInputValue("suName");
159: String instanceName = (String) handlerCtx
160: .getInputValue("instanceName");
161: sLog
162: .fine("StatsHandlers.jbiSetSaStatsForInstance(...), saName="
163: + saName
164: + ", suName="
165: + suName
166: + ", instanceName=" + instanceName);
167:
168: ShowBean showBean = BeanUtilities.getShowBean();
169: showBean.setSaStatsProps(saName, instanceName);
170: ServiceUnitBean suBean = BeanUtilities.getServiceUnitBean();
171: suBean.setSuStatsProps(saName, suName, instanceName);
172: }
173:
174: }
|