1 10 11 package org.mule.providers.stream; 12 13 import java.io.InputStream ; 14 import java.io.OutputStream ; 15 16 import org.mule.umo.UMOComponent; 17 import org.mule.umo.UMOException; 18 import org.mule.umo.endpoint.UMOEndpoint; 19 import org.mule.umo.provider.UMOConnector; 20 import org.mule.umo.provider.UMOMessageReceiver; 21 22 26 public class SystemStreamConnector extends StreamConnector 27 { 28 29 private String promptMessage; 30 private String outputMessage; 31 private long messageDelayTime = 3000; 32 private boolean firstTime = true; 33 34 public SystemStreamConnector() 35 { 36 super(); 37 inputStream = System.in; 38 outputStream = System.out; 39 } 40 41 46 public InputStream getInputStream() 47 { 48 return inputStream; 49 } 50 51 56 public void doStart() 57 { 58 firstTime = false; 59 } 60 61 66 public OutputStream getOutputStream() 67 { 68 return outputStream; 69 } 70 71 74 public String getPromptMessage() 75 { 76 return promptMessage; 77 } 78 79 82 public void setPromptMessage(String promptMessage) 83 { 84 this.promptMessage = promptMessage; 85 } 86 87 90 public String getOutputMessage() 91 { 92 return outputMessage; 93 } 94 95 98 public void setOutputMessage(String outputMessage) 99 { 100 this.outputMessage = outputMessage; 101 } 102 103 108 public UMOConnector getConnector() 109 { 110 return this; 111 } 112 113 118 public Object getDelegateSession() throws UMOException 119 { 120 return null; 121 } 122 123 public UMOMessageReceiver registerListener(UMOComponent component, UMOEndpoint endpoint) throws Exception 124 { 125 if (receivers.size() > 0) 126 { 127 throw new UnsupportedOperationException ( 128 "You can only register one listener per system stream connector"); 129 } 130 UMOMessageReceiver receiver = super.registerListener(component, endpoint); 131 return receiver; 132 } 133 134 public long getMessageDelayTime() 135 { 136 if (firstTime) 137 { 138 return messageDelayTime + 4000; 139 } 140 else 141 { 142 return messageDelayTime; 143 } 144 } 145 146 public void setMessageDelayTime(long messageDelayTime) 147 { 148 this.messageDelayTime = messageDelayTime; 149 } 150 151 protected void doDispose() 152 { 153 159 167 } 170 } 171 | Popular Tags |