1 28 29 30 package org.objectweb.corba.logservice; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class LogServerImpl 38 extends org.omg.CORBA.LocalObject 39 implements Servant, LogServerOperations 40 { 41 static private String _class_name = "LogServerImpl"; 43 44 static final private String _type_id = LogServerHelper.id(); 46 47 private javax.swing.JFrame _frame; 49 private javax.swing.JTextArea _text_error; 50 private javax.swing.JTextArea _text_warn; 51 private javax.swing.JTextArea _text_info; 52 private javax.swing.JTextArea _text_debug; 53 54 protected 56 LogServerImpl() 57 { 58 _frame = null; 60 _text_error = null; 61 _text_warn = null; 62 _text_info = null; 63 _text_debug = null; 64 } 65 66 70 static public Servant 71 create_servant() 72 { 73 return new LogServerImpl(); 74 } 75 76 80 private void 81 initializeGUI() 82 { 83 _text_error = new javax.swing.JTextArea (20, 25); 85 _text_error.setEditable(false); 86 javax.swing.JScrollPane scroll_err = new javax.swing.JScrollPane (_text_error); 87 javax.swing.JLabel label_err = new javax.swing.JLabel ("ERRORS"); 88 89 _text_warn = new javax.swing.JTextArea (20, 25); 90 _text_warn.setEditable(false); 91 javax.swing.JScrollPane scroll_warn = new javax.swing.JScrollPane (_text_warn); 92 javax.swing.JLabel label_warn = new javax.swing.JLabel ("WARNINGS"); 93 94 _text_info = new javax.swing.JTextArea (20, 25); 95 _text_info.setEditable(false); 96 javax.swing.JScrollPane scroll_info = new javax.swing.JScrollPane (_text_info); 97 javax.swing.JLabel label_info = new javax.swing.JLabel ("INFOS"); 98 99 _text_debug = new javax.swing.JTextArea (20, 25); 100 _text_debug.setEditable(false); 101 javax.swing.JScrollPane scroll_debug = new javax.swing.JScrollPane (_text_debug); 102 javax.swing.JLabel label_debug = new javax.swing.JLabel ("DEBUG"); 103 104 javax.swing.Box mbox = javax.swing.Box.createHorizontalBox(); 106 javax.swing.Box lbox = javax.swing.Box.createVerticalBox(); 107 javax.swing.Box rbox = javax.swing.Box.createVerticalBox(); 109 mbox.add(lbox); 111 mbox.add(rbox); 112 lbox.add(label_err); 113 lbox.add(scroll_err); 114 lbox.add(label_warn); 115 lbox.add(scroll_warn); 116 rbox.add(label_info); 117 rbox.add(scroll_info); 118 rbox.add(label_debug); 119 rbox.add(scroll_debug); 120 121 _frame = new javax.swing.JFrame ("LogServer GUI"); 123 _frame.getContentPane().add(mbox); 124 _frame.pack(); 125 _frame.show(); 126 } 127 128 132 final public void 133 system_configuration_complete(SystemConfiguration cfg) 134 { 135 initializeGUI(); 137 } 138 139 final public void 140 destroy() 141 { 142 } 144 145 149 final public String 150 type_id() 151 { 152 return _type_id; 153 } 154 155 final public org.omg.PortableServer.Servant 156 as_native_servant() 157 { 158 return new LogServerPOATie(this); 159 } 160 161 165 final public void 166 log_event(LogEvent evt) 167 { 168 javax.swing.JTextArea area = null; 169 if (evt.level==org.objectweb.corba.logservice.ERROR_LEVEL.value) { 170 area = _text_error; 171 } else if (evt.level==org.objectweb.corba.logservice.WARN_LEVEL.value) { 172 area = _text_warn; 173 } else if (evt.level==org.objectweb.corba.logservice.INFO_LEVEL.value) { 174 area = _text_info; 175 } else if (evt.level==org.objectweb.corba.logservice.DEBUG_LEVEL.value) { 176 area = _text_debug; 177 } 178 179 181 area.append("[new message] \n"); 182 if (evt.message.interception_point.length()!=0) { 183 area.append(" IP: "+evt.message.interception_point+"\n"); 184 } 185 area.append(" timesptamp: "+evt.message.timestamp+"\n"); 186 area.append(" operation: "+evt.message.operation_name+"\n"); 187 if (evt.message.sender_id.length()!=0) { 188 area.append(" sender: "+evt.message.sender_id+"\n"); 189 } 190 if (evt.message.receiver_id.length()!=0) { 191 area.append(" receiver: "+evt.message.receiver_id+"\n"); 192 } 193 if (evt.message.data.length()!=0) { 194 area.append(" data: "+evt.message.data+"\n"); 195 } 196 } 197 198 final public void 199 log_events(LogEvent[] evts) 200 { 201 for (int i=0;i<evts.length;i++) { 202 log_event(evts[i]); 203 } 204 } 205 } 206 | Popular Tags |