KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > transport > local > LocalTransportSender


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * Runtime state of the engine
17  */

18 package org.apache.axis2.transport.local;
19
20 import org.apache.axis2.addressing.EndpointReference;
21 import org.apache.axis2.context.MessageContext;
22 import org.apache.axis2.engine.AxisFault;
23 import org.apache.axis2.transport.AbstractTransportSender;
24
25 import java.io.*;
26
27
28 public class LocalTransportSender extends AbstractTransportSender {
29     private ByteArrayOutputStream out;
30     public LocalTransportSender() {
31
32     }
33
34     public OutputStream startSendWithToAddress(MessageContext msgContext, OutputStream out) throws AxisFault {
35         return out;
36     }
37
38     public void finalizeSendWithToAddress(MessageContext msgContext,OutputStream out)
39         throws AxisFault {
40         try {
41             InputStream in = new ByteArrayInputStream(this.out.toByteArray());
42             LocalTransportReceiver localTransportReceiver = new LocalTransportReceiver();
43             localTransportReceiver.processMessage(in, msgContext.getTo());
44             in.close();
45             out.close();
46         } catch (IOException e) {
47             throw new AxisFault(e);
48         }
49     }
50
51     /* (non-Javadoc)
52      * @see org.apache.axis2.transport.AbstractTransportSender#openTheConnection(org.apache.axis2.addressing.EndpointReference)
53      */

54     protected OutputStream openTheConnection(EndpointReference epr,MessageContext msgContext) throws AxisFault {
55         //out = new PipedOutputStream();
56
out = new ByteArrayOutputStream();
57         return out;
58     }
59
60     /* (non-Javadoc)
61      * @see org.apache.axis2.transport.AbstractTransportSender#startSendWithOutputStreamFromIncomingConnection(org.apache.axis2.context.MessageContext, java.io.Writer)
62      */

63     public OutputStream startSendWithOutputStreamFromIncomingConnection(
64         MessageContext msgContext,
65     OutputStream out)
66         throws AxisFault {
67         throw new UnsupportedOperationException JavaDoc();
68
69     }
70
71     public void finalizeSendWithOutputStreamFromIncomingConnection(
72         MessageContext msgContext,OutputStream out)
73         throws AxisFault {
74         throw new UnsupportedOperationException JavaDoc();
75
76     }
77
78     public void cleanUp(MessageContext msgContext) throws AxisFault {
79     }
80
81 }
82
Popular Tags