KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > monitor > model > ExplorerModel


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.monitor.model;
5
6 import org.oddjob.OJConstants;
7 import org.oddjob.arooa.ArooaContext;
8 import org.oddjob.arooa.Lifecycle;
9 import org.oddjob.logging.ConsoleArchiver;
10 import org.oddjob.logging.LocalConsoleArchiver;
11 import org.oddjob.logging.Log4jArchiver;
12 import org.oddjob.logging.LogArchiver;
13 import org.oddjob.util.ThreadManager;
14
15 /**
16  * Data model for an explorer session.
17  *
18  * @author Rob Gordon
19  */

20 public class ExplorerModel {
21 // private static final Logger logger = Logger.getLogger(ExplorerModel.class);
22

23     /** The root node of the model. */
24     private Object JavaDoc root;
25     
26     /** The ArooaContext */
27     private ArooaContext arooaContext;
28     
29     /** Log Format */
30     private String JavaDoc logFormat;
31     
32     /** Thread manager actions should use. */
33     private ThreadManager threadManager;
34     
35     /** The logArchiver */
36     private LogArchiver logArchiver;
37     
38     /** The console archiver. */
39     private ConsoleArchiver consoleArchiver;
40     
41
42     /**
43      * Set the model root node. This must be done before the model
44      * is used.
45      *
46      * @param rootNode The root node.
47      */

48     public void setRoot(Object JavaDoc rootNode) {
49         this.root = rootNode;
50         logArchiver = new Log4jArchiver(rootNode,
51                 logFormat == null ? OJConstants.DEFAULT_LOG_FORMAT : logFormat);
52         consoleArchiver = new LocalConsoleArchiver(rootNode);
53     }
54
55     /**
56      * Get the root node for this model.
57      *
58      * @return The root node.
59      */

60     public Object JavaDoc getRoot() {
61         return root;
62     }
63     
64     /**
65      * Set the ThreadManager child actions should use.
66      *
67      * @param threadManager The ThreadManager.
68      */

69     public void setThreadManager(ThreadManager threadManager) {
70         this.threadManager = threadManager;
71     }
72     
73     /**
74      * Get an available ThreadManager.
75      *
76      * @return A ThreadManager.
77      */

78     public ThreadManager getThreadManager() {
79         return threadManager;
80     }
81     
82     /**
83      * Set the ArooaContext. This is required by
84      * some child actions (SetPropertyAction).
85      *
86      * @param arooaContext The ArooaContext.
87      */

88     public void setArooaContext(ArooaContext arooaContext) {
89         this.arooaContext = arooaContext;
90     }
91     
92     /**
93      * Get the original ArooaContext that was used to create
94      * OddjobExplorer. Used in some actions.
95      *
96      * @return The ArooaContext.
97      */

98     public ArooaContext getArooaContext() {
99         return arooaContext;
100     }
101     
102     /**
103      * Destroy this model.
104      *
105      */

106     public void destroy() {
107         Lifecycle.destroy(logArchiver);
108         Lifecycle.destroy(consoleArchiver);
109     }
110     
111     /**
112      * Getter for log format.
113      *
114      * @return The log format.
115      */

116     public String JavaDoc getLogFormat() {
117         return logFormat;
118     }
119     
120     /**
121      * The log format.
122      *
123      * @param logFormat The log format.
124      */

125     public void setLogFormat(String JavaDoc logFormat) {
126         this.logFormat = logFormat;
127     }
128     
129     /**
130      * Get the log archiver. This archiver is the top level archiver
131      * created for the root node.
132      * <p>
133      * For the archiver for a particular node use the {@link ExplorerContext}
134      * archiver.
135      *
136      * @return A LogArchiver.
137      */

138     public LogArchiver getLogArchiver() {
139         return logArchiver;
140     }
141     
142     /**
143      * Get the console archiver. This archiver is the top level archiver
144      * created for the root node.
145      * <p>
146      * For the archiver for a particular node use the {@link ExplorerContext}
147      * archiver.
148      *
149      * @return A ConsoelArchiver.
150      */

151     public ConsoleArchiver getConsoleArchiver() {
152         return consoleArchiver;
153     }
154 }
155
Popular Tags