001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.model.dataformat;
018    
019    import javax.xml.bind.annotation.XmlAccessType;
020    import javax.xml.bind.annotation.XmlAccessorType;
021    import javax.xml.bind.annotation.XmlAttribute;
022    import javax.xml.bind.annotation.XmlRootElement;
023    import javax.xml.bind.annotation.XmlTransient;
024    
025    import org.apache.camel.model.DataFormatDefinition;
026    import org.apache.camel.spi.DataFormat;
027    
028    @XmlRootElement(name = "soapjaxb")
029    @XmlAccessorType(XmlAccessType.FIELD)
030    public class SoapJaxbDataFormat extends DataFormatDefinition {
031        @XmlAttribute(required = true)
032        private String contextPath;
033        @XmlAttribute
034        private String encoding;
035        @XmlAttribute
036        private String elementNameStrategyRef;
037        @XmlTransient
038        private Object elementNameStrategy;
039        @XmlAttribute
040        private String version;
041    
042        public SoapJaxbDataFormat() {
043            super("soapjaxb");
044        }
045        
046        public SoapJaxbDataFormat(String contextPath) {
047            this();
048            setContextPath(contextPath);
049        }
050        
051        public SoapJaxbDataFormat(String contextPath, String elementNameStrategyRef) {
052            this();
053            setContextPath(contextPath);
054            setElementNameStrategyRef(elementNameStrategyRef);
055        }
056        
057        public SoapJaxbDataFormat(String contextPath, Object elementNameStrategy) {
058            this();
059            setContextPath(contextPath);
060            setElementNameStrategy(elementNameStrategy);
061        }
062    
063        public void setContextPath(String contextPath) {
064            this.contextPath = contextPath;
065        }
066    
067        public String getContextPath() {
068            return contextPath;
069        }
070    
071        public void setEncoding(String encoding) {
072            this.encoding = encoding;
073        }
074    
075        public String getEncoding() {
076            return encoding;
077        }
078    
079        public void setElementNameStrategyRef(String elementNameStrategyRef) {
080            this.elementNameStrategyRef = elementNameStrategyRef;
081        }
082    
083        public String getElementNameStrategyRef() {
084            return elementNameStrategyRef;
085        }
086    
087        public String getVersion() {
088            return version;
089        }
090    
091        public void setVersion(String version) {
092            this.version = version;
093        }
094    
095        public void setElementNameStrategy(Object elementNameStrategy) {
096            this.elementNameStrategy = elementNameStrategy;
097        }
098    
099        public Object getElementNameStrategy() {
100            return elementNameStrategy;
101        }
102    
103        @Override
104        protected void configureDataFormat(DataFormat dataFormat) {
105            if (elementNameStrategy != null) {
106                setProperty(dataFormat, "elementNameStrategy", elementNameStrategy);
107            }
108            if (elementNameStrategyRef != null) {
109                setProperty(dataFormat, "elementNameStrategyRef", elementNameStrategyRef);
110            }
111            if (encoding != null) {
112                setProperty(dataFormat, "encoding", encoding);
113            }
114            if (version != null) {
115                setProperty(dataFormat, "version", version);
116            }
117            setProperty(dataFormat, "contextPath", contextPath);
118        }
119    
120    }