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.processor.RoutingSlip; 029 import org.apache.camel.spi.RouteContext; 030 031 /** 032 * Represents an XML <routingSlip/> element 033 */ 034 @XmlRootElement(name = "routingSlip") 035 @XmlAccessorType(XmlAccessType.FIELD) 036 public class RoutingSlipType extends ProcessorType<ProcessorType> { 037 public static final String ROUTING_SLIP_HEADER = "routingSlipHeader"; 038 public static final String DEFAULT_DELIMITER = ","; 039 040 @XmlAttribute 041 private String headerName; 042 @XmlAttribute 043 private String uriDelimiter; 044 045 public RoutingSlipType() { 046 this(ROUTING_SLIP_HEADER, DEFAULT_DELIMITER); 047 } 048 049 public RoutingSlipType(String headerName) { 050 this(headerName, DEFAULT_DELIMITER); 051 } 052 053 public RoutingSlipType(String headerName, String uriDelimiter) { 054 setHeaderName(headerName); 055 setUriDelimiter(uriDelimiter); 056 } 057 058 @Override 059 public String toString() { 060 return "RoutingSlip[ headerName=" + getHeaderName() + " uriDelimiter=" + getUriDelimiter() + "]"; 061 } 062 063 @Override 064 public String getShortName() { 065 return "routingSlip"; 066 } 067 068 @Override 069 public Processor createProcessor(RouteContext routeContext) throws Exception { 070 return new RoutingSlip(getHeaderName(), getUriDelimiter()); 071 } 072 073 @Override 074 public List<ProcessorType<?>> getOutputs() { 075 return Collections.EMPTY_LIST; 076 } 077 078 public void setHeaderName(String headerName) { 079 this.headerName = headerName; 080 } 081 082 public String getHeaderName() { 083 return this.headerName; 084 } 085 086 public void setUriDelimiter(String uriDelimiter) { 087 this.uriDelimiter = uriDelimiter; 088 } 089 090 public String getUriDelimiter() { 091 return uriDelimiter; 092 } 093 }