View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
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  package org.openehealth.ipf.commons.ihe.ws.cxf.databinding.plainxml;
17  
18  import javax.xml.stream.XMLStreamReader;
19  import javax.xml.stream.XMLStreamWriter;
20  
21  import org.apache.cxf.databinding.AbstractDataBinding;
22  import org.apache.cxf.databinding.DataReader;
23  import org.apache.cxf.databinding.DataWriter;
24  import org.apache.cxf.service.Service;
25  
26  /**
27   * Special CXF data binding for plain XML transactions (e.g. HL7 v3). 
28   * @author Dmytro Rud
29   */
30  public class PlainXmlDataBinding extends AbstractDataBinding {
31  
32      @SuppressWarnings("unchecked")
33      @Override
34      public <T> DataReader<T> createReader(Class<T> cls) {
35          return (DataReader<T>) new PlainXmlReader();
36      }
37  
38      @SuppressWarnings("unchecked")
39      @Override
40      public <T> DataWriter<T> createWriter(Class<T> cls) {
41          return (DataWriter<T>) new PlainXmlWriter();
42      }
43  
44      @Override
45      public Class<?>[] getSupportedReaderFormats() {
46          return new Class[] {XMLStreamReader.class};
47      }
48  
49      @Override
50      public Class<?>[] getSupportedWriterFormats() {
51          return new Class[] {XMLStreamWriter.class};
52      }
53  
54      @Override
55      public void initialize(Service service) {
56          // nop
57      }
58  }