1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.stdio; |
12 | |
|
13 | |
import org.mule.api.endpoint.InboundEndpoint; |
14 | |
import org.mule.api.service.Service; |
15 | |
import org.mule.api.transport.MessageReceiver; |
16 | |
import org.mule.transport.AbstractConnector; |
17 | |
import org.mule.transport.AbstractPollingMessageReceiver; |
18 | |
|
19 | |
import java.io.InputStream; |
20 | |
import java.io.OutputStream; |
21 | |
|
22 | |
import org.apache.commons.io.IOUtils; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | 36 | public abstract class StdioConnector extends AbstractConnector |
29 | |
{ |
30 | |
|
31 | |
public static final String STDIO = "stdio"; |
32 | |
public static final String STREAM_SYSTEM_IN = "system.in"; |
33 | |
public static final String STREAM_SYSTEM_OUT = "system.out"; |
34 | |
public static final String STREAM_SYSTEM_ERR = "system.err"; |
35 | |
|
36 | |
protected OutputStream outputStream; |
37 | |
protected InputStream inputStream; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
public MessageReceiver createReceiver(Service service, InboundEndpoint endpoint) throws Exception |
46 | |
{ |
47 | 8 | return serviceDescriptor.createMessageReceiver(this, service, endpoint, |
48 | |
new Object[]{new Long(AbstractPollingMessageReceiver.DEFAULT_POLL_FREQUENCY)}); |
49 | |
} |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
public void doStop() |
57 | |
{ |
58 | |
|
59 | 32 | } |
60 | |
|
61 | |
protected void doDispose() |
62 | |
{ |
63 | 0 | IOUtils.closeQuietly(inputStream); |
64 | 0 | IOUtils.closeQuietly(outputStream); |
65 | 0 | } |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public void doStart() |
73 | |
{ |
74 | |
|
75 | 0 | } |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public String getProtocol() |
84 | |
{ |
85 | 88 | return STDIO; |
86 | |
} |
87 | |
|
88 | |
public InputStream getInputStream() |
89 | |
{ |
90 | 0 | return inputStream; |
91 | |
} |
92 | |
|
93 | |
public void setInputStream(InputStream inputStream) |
94 | |
{ |
95 | 0 | this.inputStream = inputStream; |
96 | 0 | } |
97 | |
|
98 | |
public OutputStream getOutputStream() |
99 | |
{ |
100 | 0 | return outputStream; |
101 | |
} |
102 | |
|
103 | |
public void setOutputStream(OutputStream outputStream) |
104 | |
{ |
105 | 0 | this.outputStream = outputStream; |
106 | 0 | } |
107 | |
|
108 | |
} |