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;
018    
019    import java.util.Collections;
020    import java.util.List;
021    
022    import javax.xml.bind.annotation.XmlAccessType;
023    import javax.xml.bind.annotation.XmlAccessorType;
024    import javax.xml.bind.annotation.XmlAttribute;
025    import javax.xml.bind.annotation.XmlRootElement;
026    
027    import org.apache.camel.Processor;
028    import org.apache.camel.impl.RouteContext;
029    import org.apache.camel.processor.RoutingSlip;
030    
031    @XmlRootElement(name = "routingSlip")
032    @XmlAccessorType(XmlAccessType.FIELD)
033    public class RoutingSlipType extends ProcessorType<ProcessorType> {
034        public static final String ROUTING_SLIP_HEADER = "routingSlipHeader";
035        public static final String DEFAULT_DELIMITER = ",";
036    
037        @XmlAttribute
038        private String headerName;
039        @XmlAttribute
040        private String uriDelimiter;
041    
042        public RoutingSlipType() {
043            this(ROUTING_SLIP_HEADER, DEFAULT_DELIMITER);
044        }
045    
046        public RoutingSlipType(String headerName) {
047            this(headerName, DEFAULT_DELIMITER);
048        }
049    
050        public RoutingSlipType(String headerName, String uriDelimiter) {
051            setHeaderName(headerName);
052            setUriDelimiter(uriDelimiter);
053        }
054    
055        @Override
056        public String toString() {
057            return "RoutingSlip[ headerName=" + getHeaderName() + " uriDelimiter=" + getUriDelimiter() + "]";
058        }
059    
060        @Override
061        public Processor createProcessor(RouteContext routeContext) throws Exception {
062            return new RoutingSlip(getHeaderName(), getUriDelimiter());
063        }
064    
065        @Override
066        public List<ProcessorType<?>> getOutputs() {
067            return Collections.EMPTY_LIST;
068        }
069    
070        public void setHeaderName(String headerName) {
071            this.headerName = headerName;
072        }
073    
074        public String getHeaderName() {
075            return this.headerName;
076        }
077    
078        public void setUriDelimiter(String uriDelimiter) {
079            this.uriDelimiter = uriDelimiter;
080        }
081    
082        public String getUriDelimiter() {
083            return uriDelimiter;
084        }
085    }