KickJava   Java API By Example, From Geeks To Geeks.

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


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.Constants;
21 import org.apache.axis2.addressing.EndpointReference;
22 import org.apache.axis2.context.ConfigurationContext;
23 import org.apache.axis2.context.MessageContext;
24 import org.apache.axis2.description.TransportInDescription;
25 import org.apache.axis2.description.TransportOutDescription;
26 import org.apache.axis2.engine.AxisEngine;
27 import org.apache.axis2.engine.AxisFault;
28 import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
29 import org.apache.axis2.soap.SOAPEnvelope;
30 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
31
32 import javax.xml.namespace.QName JavaDoc;
33 import javax.xml.stream.FactoryConfigurationError;
34 import javax.xml.stream.XMLInputFactory;
35 import javax.xml.stream.XMLStreamException;
36 import javax.xml.stream.XMLStreamReader;
37 import java.io.BufferedReader JavaDoc;
38 import java.io.InputStream JavaDoc;
39 import java.io.InputStreamReader JavaDoc;
40
41 public class LocalTransportReceiver {
42     public static ConfigurationContext CONFIG_CONTEXT;
43
44     private ConfigurationContext confContext;
45     public LocalTransportReceiver(ConfigurationContext configContext) {
46         confContext = configContext;
47     }
48
49     public LocalTransportReceiver() {
50         this(CONFIG_CONTEXT);
51     }
52
53     public void processMessage(InputStream JavaDoc in, EndpointReference to) throws AxisFault {
54         try {
55             TransportInDescription tIn =
56                 confContext.getAxisConfiguration().getTransportIn(
57                     new QName JavaDoc(Constants.TRANSPORT_LOCAL));
58             TransportOutDescription tOut =
59                 confContext.getAxisConfiguration().getTransportOut(
60                     new QName JavaDoc(Constants.TRANSPORT_LOCAL));
61             MessageContext msgCtx = new MessageContext(confContext, tIn, tOut);
62             msgCtx.setTo(to);
63             msgCtx.setServerSide(true);
64
65             XMLStreamReader reader =
66                 XMLInputFactory.newInstance().createXMLStreamReader(
67                     new BufferedReader JavaDoc(new InputStreamReader JavaDoc(in)));
68
69             StAXBuilder builder = new StAXSOAPModelBuilder(reader);
70             msgCtx.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
71             AxisEngine engine = new AxisEngine(confContext);
72             engine.receive(msgCtx);
73         } catch (XMLStreamException e) {
74             throw new AxisFault(e);
75         } catch (FactoryConfigurationError e) {
76             throw new AxisFault(e);
77         }
78     }
79
80 }
81
Popular Tags