1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.stream; |
12 | |
|
13 | |
import org.mule.providers.AbstractConnector; |
14 | |
import org.mule.providers.AbstractPollingMessageReceiver; |
15 | |
import org.mule.umo.UMOComponent; |
16 | |
import org.mule.umo.endpoint.UMOEndpoint; |
17 | |
import org.mule.umo.provider.UMOMessageReceiver; |
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 | 0 | public abstract class StreamConnector extends AbstractConnector |
29 | |
{ |
30 | |
public static final String STREAM_SYSTEM_IN = "system.in"; |
31 | |
public static final String STREAM_SYSTEM_OUT = "system.out"; |
32 | |
public static final String STREAM_SYSTEM_ERR = "system.err"; |
33 | |
|
34 | |
protected OutputStream outputStream; |
35 | |
protected InputStream inputStream; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
public UMOMessageReceiver createReceiver(UMOComponent component, UMOEndpoint endpoint) throws Exception |
44 | |
{ |
45 | 0 | return serviceDescriptor.createMessageReceiver(this, component, endpoint, |
46 | |
new Object[]{new Long(AbstractPollingMessageReceiver.DEFAULT_POLL_FREQUENCY)}); |
47 | |
} |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
public void doStop() |
55 | |
{ |
56 | |
|
57 | 0 | } |
58 | |
|
59 | |
protected void doDispose() |
60 | |
{ |
61 | 0 | IOUtils.closeQuietly(inputStream); |
62 | 0 | IOUtils.closeQuietly(outputStream); |
63 | 0 | } |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
public void doStart() |
71 | |
{ |
72 | |
|
73 | 0 | } |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public String getProtocol() |
82 | |
{ |
83 | 0 | return "stream"; |
84 | |
} |
85 | |
|
86 | |
public InputStream getInputStream() |
87 | |
{ |
88 | 0 | return inputStream; |
89 | |
} |
90 | |
|
91 | |
public void setInputStream(InputStream inputStream) |
92 | |
{ |
93 | 0 | this.inputStream = inputStream; |
94 | 0 | } |
95 | |
|
96 | |
public OutputStream getOutputStream() |
97 | |
{ |
98 | 0 | return outputStream; |
99 | |
} |
100 | |
|
101 | |
public void setOutputStream(OutputStream outputStream) |
102 | |
{ |
103 | 0 | this.outputStream = outputStream; |
104 | 0 | } |
105 | |
|
106 | |
} |