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 */ 017package org.apache.camel.model; 018 019import javax.xml.bind.annotation.XmlAccessType; 020import javax.xml.bind.annotation.XmlAccessorType; 021import javax.xml.bind.annotation.XmlAttribute; 022import javax.xml.bind.annotation.XmlRootElement; 023 024import org.apache.camel.Endpoint; 025import org.apache.camel.ExchangePattern; 026import org.apache.camel.builder.EndpointProducerBuilder; 027import org.apache.camel.spi.Metadata; 028 029/** 030 * Sends the message to a static endpoint 031 */ 032@Metadata(label = "eip,endpoint,routing") 033@XmlRootElement(name = "to") 034@XmlAccessorType(XmlAccessType.FIELD) 035public class ToDefinition extends SendDefinition<ToDefinition> { 036 @XmlAttribute 037 @Metadata(javaType = "org.apache.camel.ExchangePattern", enums = "InOnly,InOut,InOptionalOut") 038 private String pattern; 039 040 public ToDefinition() { 041 } 042 043 public ToDefinition(String uri) { 044 this(); 045 setUri(uri); 046 } 047 048 public ToDefinition(Endpoint endpoint) { 049 this(); 050 setEndpoint(endpoint); 051 } 052 053 public ToDefinition(EndpointProducerBuilder endpointDefinition) { 054 this(); 055 setEndpointProducerBuilder(endpointDefinition); 056 } 057 058 public ToDefinition(String uri, ExchangePattern pattern) { 059 this(uri); 060 this.pattern = pattern.name(); 061 } 062 063 public ToDefinition(Endpoint endpoint, ExchangePattern pattern) { 064 this(endpoint); 065 this.pattern = pattern.name(); 066 } 067 068 public ToDefinition(EndpointProducerBuilder endpoint, ExchangePattern pattern) { 069 this(endpoint); 070 this.pattern = pattern.name(); 071 } 072 073 @Override 074 public String getShortName() { 075 return "to"; 076 } 077 078 @Override 079 public String toString() { 080 return "To[" + getLabel() + "]"; 081 } 082 083 @Override 084 public String getPattern() { 085 return pattern; 086 } 087 088 /** 089 * Sets the optional {@link ExchangePattern} used to invoke this endpoint 090 */ 091 public void setPattern(String pattern) { 092 this.pattern = pattern; 093 } 094 095}