KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > community > taglib > LogTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.applications.community.taglib;
11
12 import javax.servlet.jsp.JspTagException JavaDoc;
13
14 import org.mmbase.bridge.Node;
15 import org.mmbase.bridge.Module;
16
17 import org.mmbase.bridge.jsp.taglib.NodeTag;
18
19 /**
20  * As NodeTag, but logging will be started on the node (which should be a channel)
21  * at the start of the body tag.
22  *
23  * @author Pierre van Rooden
24  * @version $Id: LogTag.java,v 1.4 2003/06/18 20:03:57 michiel Exp $
25  */

26  
27 public class LogTag extends NodeTag {
28
29     public final static String JavaDoc STOP = "STOP";
30     public final static String JavaDoc FILE = "FILE";
31
32     String JavaDoc action=FILE;
33     String JavaDoc file="chat.log";
34
35     public void setChannel(String JavaDoc c) throws JspTagException JavaDoc {
36         setNumber(c);
37     }
38
39     public void setFile(String JavaDoc f) throws JspTagException JavaDoc {
40         file=getAttributeValue(f);
41     }
42
43     public void setAction(String JavaDoc a) throws JspTagException JavaDoc {
44         action=getAttributeValue(a).toUpperCase();
45         if (!action.equals(STOP) &&
46             !action.equals(FILE)) {
47             throw new JspTagException JavaDoc("Action need be one of STOP or FILE.");
48         }
49     }
50
51     public int doStartTag() throws JspTagException JavaDoc {
52         super.doStartTag() ;
53         Module community=getCloudContext().getModule("communityprc");
54         Node node=getNodeVar();
55         if (action.equals(FILE)) {
56             community.getInfo("CHANNEL-"+node.getNumber()+"-RECORD-FILE-"+file,pageContext.getRequest(),pageContext.getResponse());
57         } else {
58             community.getInfo("CHANNEL-"+node.getNumber()+"-RECORD-STOP",pageContext.getRequest(),pageContext.getResponse());
59         }
60         return EVAL_BODY_BUFFERED;
61     }
62 }
63
Popular Tags