1 package org
.argeo
.slc
.lib
.detached
;
3 import javax
.xml
.transform
.Result
;
4 import javax
.xml
.transform
.Source
;
6 import org
.argeo
.slc
.SlcException
;
7 import org
.argeo
.slc
.detached
.DetachedAnswer
;
8 import org
.argeo
.slc
.detached
.DetachedCommunication
;
9 import org
.argeo
.slc
.detached
.DetachedException
;
10 import org
.argeo
.slc
.detached
.DetachedRequest
;
11 import org
.argeo
.slc
.detached
.DetachedXmlConverter
;
12 import org
.springframework
.oxm
.Marshaller
;
13 import org
.springframework
.oxm
.Unmarshaller
;
15 public class DetachedXmlConverterSpring
implements DetachedXmlConverter
{
16 private Marshaller marshaller
;
17 private Unmarshaller unmarshaller
;
19 public void marshallCommunication(DetachedCommunication detCom
,
21 if (detCom
instanceof DetachedRequest
) {
22 marshallRequest((DetachedRequest
) detCom
, result
);
23 } else if (detCom
instanceof DetachedAnswer
) {
24 marshallAnswer((DetachedAnswer
) detCom
, result
);
26 throw new DetachedException("Unkown communication type "
31 public DetachedCommunication
unmarshallCommunication(Source source
) {
33 return (DetachedCommunication
) unmarshaller
.unmarshal(source
);
34 } catch (Exception e
) {
35 throw new SlcException("Could not unmarshall", e
);
39 public void marshallRequest(DetachedRequest request
, Result result
) {
41 marshaller
.marshal(request
, result
);
42 } catch (Exception e
) {
43 throw new SlcException("Could not marshall", e
);
47 public void marshallAnswer(DetachedAnswer answer
, Result result
) {
49 marshaller
.marshal(answer
, result
);
50 } catch (Exception e
) {
51 throw new SlcException("Could not marshall", e
);
55 public void setMarshaller(Marshaller marshaller
) {
56 this.marshaller
= marshaller
;
59 public void setUnmarshaller(Unmarshaller unmarshaller
) {
60 this.unmarshaller
= unmarshaller
;