KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > stream > StreamConnector


1 /*
2  * $Id: StreamConnector.java 3937 2006-11-20 16:04:25Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.stream;
12
13 import java.io.InputStream JavaDoc;
14 import java.io.OutputStream JavaDoc;
15
16 import org.apache.commons.io.IOUtils;
17 import org.mule.providers.AbstractServiceEnabledConnector;
18 import org.mule.umo.UMOComponent;
19 import org.mule.umo.endpoint.UMOEndpoint;
20 import org.mule.umo.provider.UMOMessageReceiver;
21
22 /**
23  * <code>StreamConnector</code> can send and receive Mule events over IO streams.
24  */

25
26 public abstract class StreamConnector extends AbstractServiceEnabledConnector
27 {
28     public static final String JavaDoc STREAM_SYSTEM_IN = "system.in";
29     public static final String JavaDoc STREAM_SYSTEM_OUT = "system.out";
30     public static final String JavaDoc STREAM_SYSTEM_ERR = "system.err";
31
32     protected OutputStream JavaDoc outputStream;
33     protected InputStream JavaDoc inputStream;
34
35     /*
36      * (non-Javadoc)
37      *
38      * @see org.mule.umo.provider.UMOConnector#registerListener(org.mule.umo.UMOSession,
39      * org.mule.umo.endpoint.UMOEndpoint)
40      */

41     public UMOMessageReceiver createReceiver(UMOComponent component, UMOEndpoint endpoint) throws Exception JavaDoc
42     {
43         return serviceDescriptor.createMessageReceiver(this, component, endpoint,
44             new Object JavaDoc[]{new Long JavaDoc(1000)});
45     }
46
47     /*
48      * (non-Javadoc)
49      *
50      * @see org.mule.providers.AbstractConnector#doStop()
51      */

52     public void doStop()
53     {
54         // template method
55
}
56
57     protected void doDispose()
58     {
59         IOUtils.closeQuietly(inputStream);
60         IOUtils.closeQuietly(outputStream);
61     }
62
63     /*
64      * (non-Javadoc)
65      *
66      * @see org.mule.providers.AbstractConnector#doStart()
67      */

68     public void doStart()
69     {
70         // template method
71
}
72
73     /*
74      * (non-Javadoc)
75      *
76      * @see org.mule.umo.provider.UMOConnector#getProtocol()
77      */

78
79     public String JavaDoc getProtocol()
80     {
81         return "stream";
82     }
83
84     public InputStream JavaDoc getInputStream()
85     {
86         return inputStream;
87     }
88
89     public void setInputStream(InputStream JavaDoc inputStream)
90     {
91         this.inputStream = inputStream;
92     }
93
94     public OutputStream JavaDoc getOutputStream()
95     {
96         return outputStream;
97     }
98
99     public void setOutputStream(OutputStream JavaDoc outputStream)
100     {
101         this.outputStream = outputStream;
102     }
103
104 }
105
Popular Tags