1 2 3 package Jt; 4 import java.util.*; 5 import java.lang.reflect.*; 6 import java.beans.*; 7 import java.io.*; 8 9 14 15 public class JtCommand extends JtThread { 16 private JtList messageLog = new JtList (); 17 private boolean synchronous = true; 18 19 20 public JtCommand() { 21 } 22 23 24 28 29 public boolean getSynchronous () { 30 return (synchronous); 31 } 32 33 36 37 public void setSynchronous (boolean synchronous) { 38 this.synchronous = synchronous; 39 } 40 41 45 public JtList getMessageLog () { 46 return (messageLog); 47 } 48 49 50 53 54 public void setMessageLog (JtList messageLog) { 55 56 this.messageLog = messageLog; 57 } 58 59 64 65 synchronized public Object enqueueMessage (Object msg) { 67 68 if (synchronous) 69 return (processMessage (msg)); 70 else 71 return (super.enqueueMessage (msg)); 72 73 } 74 75 76 79 80 protected void logMessage (Object msg) 81 { 82 JtMessage m = new JtMessage ("JtADD"); 83 84 85 if (msg == null) 86 return; 87 88 m.setMsgContent (msg); 89 messageLog.processMessage (m); 90 91 } 92 93 97 98 public Object processMessage (Object event) { 99 100 String msgid = null; 101 JtMessage e = (JtMessage) event; 102 Object content; 103 Object data; 104 105 106 if (e == null) 107 return null; 108 109 msgid = (String ) e.getMsgId (); 110 111 if (msgid == null) 112 return null; 113 114 content = e.getMsgContent(); 115 117 118 if (msgid.equals ("JtREMOVE") || 119 msgid.equals ("JtSTART") || msgid.equals ("JtSTOP")) { 120 return (super.processMessage (event)); 121 } 122 123 124 handleError ("JtCommand.processMessage: invalid message id:" + msgid); 125 return (null); 126 127 } 128 129 130 133 134 public static void main(String [] args) { 135 136 JtObject main = new JtObject (); 137 JtMessage msg, msg1; 138 Integer count; 139 JtCommand command; 140 141 142 143 145 command = (JtCommand) main.createObject ("Jt.JtCommand", "command"); 146 147 148 main.sendMessage (command, new JtMessage ("JtSTART")); 149 150 151 main.removeObject ("command"); 152 153 154 } 155 156 } 157 158 159
| Popular Tags
|