001: /**
002: * $Id: LogTag.java,v 1.4 2005/09/21 10:53:29 dg154973 Exp $
003: * Copyright 2002 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.wireless.taglibs.util;
014:
015: import com.sun.portal.log.common.PortalLogger;
016: import com.sun.portal.wireless.taglibs.base.BeanSupport;
017:
018: import java.beans.*;
019: import java.util.logging.Logger;
020: import java.util.logging.Level;
021: import javax.servlet.jsp.*;
022: import javax.servlet.jsp.tagext.*;
023:
024: /**
025: * BeanGetTag - get a bean property
026: *
027: * This class reads the specified bean property
028: * and either writes the value as a string to the
029: * page output or saves the value into the page context
030: * using the "id" attribute.
031: *
032: * Attributes:
033: *
034: * property
035: * name of the bean property to get
036: * name
037: * name to use to retrieve the bean from the page context
038: * id
039: * name to use to store the property onto the page context
040: * eval
041: * attribute to evaluate and write to the page output
042: *
043: * @author Robert O'Brien
044: * @version 1.0
045: * @see com.sun.portal.wireless.taglibs.base.BeanSetTag
046: * @see com.sun.portal.wireless.taglibs.base.BeanSupport
047: */
048: public class LogTag extends BeanSupport {
049:
050: // Create a logger for this class
051: private static Logger logger = PortalLogger.getLogger(LogTag.class);
052:
053: /**
054: * Log at specified level to the Portal logger.
055: *
056: * @return SKIP_BODY
057: * @exception javax.servlet.jsp.JspException
058: */
059: public int doStartTag() throws JspException {
060:
061: String s = "";
062: if (msg1 != null)
063: s = s + msg1;
064: if (msg2 != null)
065: s = s + " " + msg2;
066: if (msg3 != null)
067: s = s + " " + msg3;
068: if (msg4 != null)
069: s = s + " " + msg4;
070: if (msg5 != null)
071: s = s + " " + msg5;
072: if (msg6 != null)
073: s = s + " " + msg6;
074: if (msg7 != null)
075: s = s + " " + msg7;
076: if (msg8 != null)
077: s = s + " " + msg8;
078:
079: logger.log(level, s);
080:
081: return SKIP_BODY;
082: }
083:
084: String levelStr = "FINEST";
085: Level level = Level.FINEST;
086:
087: public String getLevel() {
088: return levelStr;
089: }
090:
091: public void setLevel(String level) {
092: this .levelStr = level;
093: this .level = Level.parse(levelStr);
094: }
095:
096: /**
097: * msg attributes
098: */
099: String msg1 = null;
100: String msg2 = null;
101: String msg3 = null;
102: String msg4 = null;
103: String msg5 = null;
104: String msg6 = null;
105: String msg7 = null;
106: String msg8 = null;
107:
108: /**
109: * Set the msg attributes
110: */
111: public void setMsg1(String msg) {
112: this .msg1 = evalAttribute(msg);
113: }
114:
115: public void setMsg2(String msg) {
116: this .msg2 = evalAttribute(msg);
117: }
118:
119: public void setMsg3(String msg) {
120: this .msg3 = evalAttribute(msg);
121: }
122:
123: public void setMsg4(String msg) {
124: this .msg4 = evalAttribute(msg);
125: }
126:
127: public void setMsg5(String msg) {
128: this .msg5 = evalAttribute(msg);
129: }
130:
131: public void setMsg6(String msg) {
132: this .msg6 = evalAttribute(msg);
133: }
134:
135: public void setMsg7(String msg) {
136: this .msg7 = evalAttribute(msg);
137: }
138:
139: public void setMsg8(String msg) {
140: this .msg8 = evalAttribute(msg);
141: }
142:
143: /**
144: * Cleanup
145: */
146: public void release() {
147: super.release();
148: msg1 = null;
149: msg2 = null;
150: msg3 = null;
151: msg4 = null;
152: msg5 = null;
153: msg6 = null;
154: msg7 = null;
155: msg8 = null;
156: level = null;
157: levelStr = null;
158: }
159:
160: }
|