|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| XStreamHandler.java | - | 55.6% | 16.7% | 40% |
|
||||||||||||||
| 1 |
/**
|
|
| 2 |
*
|
|
| 3 |
* Copyright 2004 Protique Ltd
|
|
| 4 |
*
|
|
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 6 |
* you may not use this file except in compliance with the License.
|
|
| 7 |
* You may obtain a copy of the License at
|
|
| 8 |
*
|
|
| 9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 10 |
*
|
|
| 11 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 14 |
* See the License for the specific language governing permissions and
|
|
| 15 |
* limitations under the License.
|
|
| 16 |
*
|
|
| 17 |
**/
|
|
| 18 |
package org.codehaus.activesoap.handler.xstream;
|
|
| 19 |
|
|
| 20 |
import com.thoughtworks.xstream.XStream;
|
|
| 21 |
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
|
| 22 |
import org.codehaus.activesoap.Handler;
|
|
| 23 |
import org.codehaus.activesoap.MessageExchange;
|
|
| 24 |
|
|
| 25 |
import javax.xml.stream.XMLStreamReader;
|
|
| 26 |
import javax.xml.stream.XMLStreamWriter;
|
|
| 27 |
|
|
| 28 |
/**
|
|
| 29 |
* @version $Revision: 1.5 $
|
|
| 30 |
*/
|
|
| 31 |
public class XStreamHandler implements Handler { |
|
| 32 |
private Object object;
|
|
| 33 |
protected StaxDriver driver = new StaxDriver(); |
|
| 34 |
protected XStream xstream = new XStream(driver); |
|
| 35 |
|
|
| 36 | 7 |
public void invoke(MessageExchange exchange) throws Exception { |
| 37 | 7 |
XMLStreamReader in = exchange.getIn(); |
| 38 | 7 |
XMLStreamWriter out = exchange.getOut(); |
| 39 |
|
|
| 40 |
// lets reset first in case we get a fault
|
|
| 41 | 7 |
object = null;
|
| 42 | 7 |
object = xstream.unmarshal(driver.createStaxReader(in)); |
| 43 | 7 |
handleBody(exchange, object, out); |
| 44 |
} |
|
| 45 |
|
|
| 46 |
/**
|
|
| 47 |
* Sends the reply object to the output body
|
|
| 48 |
*/
|
|
| 49 | 0 |
public void reply(MessageExchange exchange, Object reply, XMLStreamWriter out) throws Exception { |
| 50 | 0 |
xstream.marshal(reply, driver.createStaxWriter(out)); |
| 51 |
} |
|
| 52 |
|
|
| 53 |
|
|
| 54 |
// Properties
|
|
| 55 |
//-------------------------------------------------------------------------
|
|
| 56 |
|
|
| 57 |
/**
|
|
| 58 |
* Returns the body of the SOAP request converted to the native POJO
|
|
| 59 |
*/
|
|
| 60 | 0 |
public Object getObject() {
|
| 61 | 0 |
return object;
|
| 62 |
} |
|
| 63 |
|
|
| 64 | 0 |
public StaxDriver getDriver() {
|
| 65 | 0 |
return driver;
|
| 66 |
} |
|
| 67 |
|
|
| 68 | 0 |
public XStream getXstream() {
|
| 69 | 0 |
return xstream;
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
// Implementation methods
|
|
| 73 |
//-------------------------------------------------------------------------
|
|
| 74 | 0 |
protected void handleBody(MessageExchange exchange, Object body, XMLStreamWriter out) throws Exception { |
| 75 |
} |
|
| 76 |
} |
|
| 77 |
|
|
||||||||||