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.CamelContext;
026    import org.apache.camel.model.DataFormatDefinition;
027    import org.apache.camel.spi.DataFormat;
028    
029    @XmlRootElement(name = "soapjaxb")
030    @XmlAccessorType(XmlAccessType.FIELD)
031    public class SoapJaxbDataFormat extends DataFormatDefinition {
032        @XmlAttribute(required = true)
033        private String contextPath;
034        @XmlAttribute
035        private String encoding;
036        @XmlAttribute
037        private String elementNameStrategyRef;
038        @XmlTransient
039        private Object elementNameStrategy;
040        @XmlAttribute
041        private String version;
042        @XmlAttribute
043        private String namespacePrefixRef;
044    
045        public SoapJaxbDataFormat() {
046            super("soapjaxb");
047        }
048        
049        public SoapJaxbDataFormat(String contextPath) {
050            this();
051            setContextPath(contextPath);
052        }
053        
054        public SoapJaxbDataFormat(String contextPath, String elementNameStrategyRef) {
055            this();
056            setContextPath(contextPath);
057            setElementNameStrategyRef(elementNameStrategyRef);
058        }
059        
060        public SoapJaxbDataFormat(String contextPath, Object elementNameStrategy) {
061            this();
062            setContextPath(contextPath);
063            setElementNameStrategy(elementNameStrategy);
064        }
065    
066        public void setContextPath(String contextPath) {
067            this.contextPath = contextPath;
068        }
069    
070        public String getContextPath() {
071            return contextPath;
072        }
073    
074        public void setEncoding(String encoding) {
075            this.encoding = encoding;
076        }
077    
078        public String getEncoding() {
079            return encoding;
080        }
081    
082        public void setElementNameStrategyRef(String elementNameStrategyRef) {
083            this.elementNameStrategyRef = elementNameStrategyRef;
084        }
085    
086        public String getElementNameStrategyRef() {
087            return elementNameStrategyRef;
088        }
089    
090        public String getVersion() {
091            return version;
092        }
093    
094        public void setVersion(String version) {
095            this.version = version;
096        }
097    
098        public void setElementNameStrategy(Object elementNameStrategy) {
099            this.elementNameStrategy = elementNameStrategy;
100        }
101    
102        public Object getElementNameStrategy() {
103            return elementNameStrategy;
104        }
105    
106        public String getNamespacePrefixRef() {
107            return namespacePrefixRef;
108        }
109    
110        public void setNamespacePrefixRef(String namespacePrefixRef) {
111            this.namespacePrefixRef = namespacePrefixRef;
112        }
113    
114        @Override
115        protected void configureDataFormat(DataFormat dataFormat, CamelContext camelContext) {
116            if (elementNameStrategy != null) {
117                setProperty(camelContext, dataFormat, "elementNameStrategy", elementNameStrategy);
118            }
119            if (elementNameStrategyRef != null) {
120                setProperty(camelContext, dataFormat, "elementNameStrategyRef", elementNameStrategyRef);
121            }
122            if (encoding != null) {
123                setProperty(camelContext, dataFormat, "encoding", encoding);
124            }
125            if (version != null) {
126                setProperty(camelContext, dataFormat, "version", version);
127            }
128            if (namespacePrefixRef != null) {
129                setProperty(camelContext, dataFormat, "namespacePrefixRef", namespacePrefixRef);
130            }
131            setProperty(camelContext, dataFormat, "contextPath", contextPath);
132        }
133    
134    }