1 package org
.argeo
.slc
.lib
.detached
;
3 import java
.io
.IOException
;
5 import javax
.xml
.transform
.Result
;
6 import javax
.xml
.transform
.Source
;
8 import org
.argeo
.slc
.core
.SlcException
;
9 import org
.argeo
.slc
.detached
.DetachedAnswer
;
10 import org
.argeo
.slc
.detached
.DetachedCommunication
;
11 import org
.argeo
.slc
.detached
.DetachedException
;
12 import org
.argeo
.slc
.detached
.DetachedRequest
;
13 import org
.argeo
.slc
.detached
.DetachedXmlConverter
;
14 import org
.springframework
.oxm
.Marshaller
;
15 import org
.springframework
.oxm
.Unmarshaller
;
16 import org
.springframework
.oxm
.XmlMappingException
;
17 import org
.springframework
.xml
.validation
.XmlValidator
;
18 import org
.xml
.sax
.InputSource
;
20 public class DetachedXmlConverterSpring
implements DetachedXmlConverter
{
21 private Marshaller marshaller
;
22 private Unmarshaller unmarshaller
;
24 public void marshallCommunication(DetachedCommunication detCom
,
26 if (detCom
instanceof DetachedRequest
) {
27 marshallRequest((DetachedRequest
) detCom
, result
);
28 } else if (detCom
instanceof DetachedAnswer
) {
29 marshallAnswer((DetachedAnswer
) detCom
, result
);
31 throw new DetachedException("Unkown communication type "
36 public DetachedCommunication
unmarshallCommunication(Source source
) {
38 return (DetachedCommunication
) unmarshaller
.unmarshal(source
);
39 } catch (Exception e
) {
40 throw new SlcException("Could not unmarshall", e
);
44 public void marshallRequest(DetachedRequest request
, Result result
) {
46 marshaller
.marshal(request
, result
);
47 } catch (Exception e
) {
48 throw new SlcException("Could not marshall", e
);
52 public void marshallAnswer(DetachedAnswer answer
, Result result
) {
54 marshaller
.marshal(answer
, result
);
55 } catch (Exception e
) {
56 throw new SlcException("Could not marshall", e
);
60 public void setMarshaller(Marshaller marshaller
) {
61 this.marshaller
= marshaller
;
64 public void setUnmarshaller(Unmarshaller unmarshaller
) {
65 this.unmarshaller
= unmarshaller
;