1 package net.sf.panoptes.module.log4j;
2
3 import java.util.Collection;
4
5 import net.sf.panoptes.model.component.Component;
6 import net.sf.panoptes.model.node.Node;
7 import net.sf.panoptes.model.node.NodeDescriptor;
8
9 import org.eclipse.swt.graphics.Image;
10 import org.jboss.util.property.Configurable;
11
12 /***
13 * Wraps a logger location.
14 *
15 * @author Dag Liodden
16 * @version 0.1
17 */
18 public class LoggerComponent extends Component {
19
20 private LoggerRepository repository = null;
21 private LogFilter filter;
22
23 /***
24 * Constructor for LoggerComponent.
25 */
26 public LoggerComponent() {
27 }
28
29 public void setLogFilter(LogFilter filter) {
30 this.filter = filter;
31 }
32
33 public void setLoggerRepository(LoggerRepository repository) {
34 this.repository = repository;
35 }
36
37 public void init() {
38 repository.addLoggerCompnent(this);
39 }
40
41 public Configurable[] listChildren() {
42 return new Configurable[0];
43 }
44
45 public LoggingEventInfo[] listEvents() {
46 return repository.listEvents(filter);
47 }
48
49 public LoggingEventInfo[] listEvents(int maxCount) {
50 return repository.listEvents(filter, maxCount);
51 }
52
53 /***
54 * @see com.glt.troodon.console.Node#getConfigDescriptor()
55 */
56 public NodeDescriptor getConfigDescriptor() {
57 return super.getConfigDescriptor();
58 /*
59 String displayPrefix = filter.getPrefix() + "*";
60 String hostString = filter.getHost().length() == 0 ? "any host" : filter.getHost();
61 return new NodeDescriptor(
62 filter.getHost() + ":" + displayPrefix,
63 "Log events from " + hostString + " and classes " + displayPrefix);
64 */
65
66 }
67
68 /***
69 * @see com.glt.troodon.console.Node#getIconName()
70 */
71 public Image getIcon() {
72 return Node.ICON_LOG;
73 }
74
75 /* (non-Javadoc)
76 * @see net.sf.panoptes.model.node.Node#getConfiguratorScripts()
77 */
78 public String[] getConfiguratorScripts() {
79 // TODO Auto-generated method stub
80 return null;
81 }
82
83 /***
84 * @return
85 */
86 public LogFilter getFilter() {
87 return filter;
88 }
89
90 /***
91 * @param filter
92 */
93 public void setFilter(LogFilter filter) {
94 this.filter = filter;
95 }
96
97 /* (non-Javadoc)
98 * @see net.sf.panoptes.model.node.log4j.RepositoryListener#repositoryUpdated()
99 */
100 public void repositoryUpdated(Collection newEvents) {
101 notifyListeners(new LogComponentUpdateEvent(this, newEvents));
102 }
103
104 }
This page was automatically generated by Maven