01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.binding.xml;
19:
20: import javax.xml.namespace.QName;
21:
22: import org.apache.cxf.binding.AbstractBindingFactory;
23: import org.apache.cxf.binding.Binding;
24: import org.apache.cxf.binding.xml.interceptor.XMLFaultInInterceptor;
25: import org.apache.cxf.binding.xml.interceptor.XMLFaultOutInterceptor;
26: import org.apache.cxf.binding.xml.interceptor.XMLMessageInInterceptor;
27: import org.apache.cxf.binding.xml.interceptor.XMLMessageOutInterceptor;
28: import org.apache.cxf.interceptor.AttachmentInInterceptor;
29: import org.apache.cxf.interceptor.DocLiteralInInterceptor;
30: import org.apache.cxf.interceptor.StaxInInterceptor;
31: import org.apache.cxf.interceptor.StaxOutInterceptor;
32: import org.apache.cxf.interceptor.URIMappingInterceptor;
33: import org.apache.cxf.service.model.BindingInfo;
34: import org.apache.cxf.service.model.BindingOperationInfo;
35: import org.apache.cxf.service.model.OperationInfo;
36: import org.apache.cxf.service.model.ServiceInfo;
37:
38: public class XMLBindingFactory extends AbstractBindingFactory {
39:
40: public Binding createBinding(BindingInfo binding) {
41: XMLBinding xb = new XMLBinding(binding);
42:
43: if (!Boolean.TRUE.equals(binding
44: .getProperty(DATABINDING_DISABLED))) {
45: xb.getInInterceptors().add(new AttachmentInInterceptor());
46: xb.getInInterceptors().add(new StaxInInterceptor());
47: xb.getOutInterceptors().add(new StaxOutInterceptor());
48:
49: xb.getInInterceptors().add(new URIMappingInterceptor());
50: xb.getOutInterceptors().add(new XMLMessageOutInterceptor());
51: xb.getInInterceptors().add(new DocLiteralInInterceptor());
52: xb.getInInterceptors().add(new XMLMessageInInterceptor());
53: }
54:
55: xb.getInFaultInterceptors().add(new XMLFaultInInterceptor());
56: xb.getOutFaultInterceptors().add(new StaxOutInterceptor());
57: xb.getOutFaultInterceptors().add(new XMLFaultOutInterceptor());
58:
59: return xb;
60: }
61:
62: public BindingInfo createBindingInfo(ServiceInfo service,
63: String namespace, Object config) {
64: BindingInfo info = new BindingInfo(service,
65: "http://cxf.apache.org/bindings/xformat");
66: info.setName(new QName(service.getName().getNamespaceURI(),
67: service.getName().getLocalPart() + "XMLBinding"));
68:
69: for (OperationInfo op : service.getInterface().getOperations()) {
70: BindingOperationInfo bop = info
71: .buildOperation(op.getName(), op.getInputName(), op
72: .getOutputName());
73: info.addOperation(bop);
74: }
75:
76: return info;
77: }
78:
79: }
|