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    private ExchangePattern pattern;
038
039    public ToDefinition() {
040    }
041
042    public ToDefinition(String uri) {
043        this();
044        setUri(uri);
045    }
046
047    public ToDefinition(Endpoint endpoint) {
048        this();
049        setEndpoint(endpoint);
050    }
051
052    public ToDefinition(EndpointProducerBuilder endpointDefinition) {
053        this();
054        setEndpointProducerBuilder(endpointDefinition);
055    }
056
057    public ToDefinition(String uri, ExchangePattern pattern) {
058        this(uri);
059        this.pattern = pattern;
060    }
061
062    public ToDefinition(Endpoint endpoint, ExchangePattern pattern) {
063        this(endpoint);
064        this.pattern = pattern;
065    }
066
067    public ToDefinition(EndpointProducerBuilder endpoint, ExchangePattern pattern) {
068        this(endpoint);
069        this.pattern = pattern;
070    }
071
072    @Override
073    public String getShortName() {
074        return "to";
075    }
076
077    @Override
078    public String toString() {
079        return "To[" + getLabel() + "]";
080    }
081
082    @Override
083    public ExchangePattern getPattern() {
084        return pattern;
085    }
086
087    /**
088     * Sets the optional {@link ExchangePattern} used to invoke this endpoint
089     */
090    public void setPattern(ExchangePattern pattern) {
091        this.pattern = pattern;
092    }
093
094}