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.example.server;
018    
019    import org.apache.camel.builder.RouteBuilder;
020    
021    /**
022     * This class defines the routes on the Server. The class extends a base class in Camel {@link RouteBuilder}
023     * that can be used to easily setup the routes in the configure() method.
024     */
025    // START SNIPPET: e1
026    public class ServerRoutes extends RouteBuilder {
027    
028        @Override
029        public void configure() throws Exception {
030            // route from the numbers queue to our business that is a spring bean registered with the id=multiplier
031            // Camel will introspect the multiplier bean and find the best candidate of the method to invoke.
032            // You can add annotations etc to help Camel find the method to invoke.
033            // As our multiplier bean only have one method its easy for Camel to find the method to use.
034            from("jms:queue:numbers").to("multiplier");
035    
036            // Camel has several ways to configure the same routing, we have defined some of them here below
037    
038            // as above but with the bean: prefix
039            //from("jms:queue:numbers").to("bean:multiplier");
040    
041            // beanRef is using explicity bean bindings to lookup the multiplier bean and invoke the multiply method
042            //from("jms:queue:numbers").beanRef("multiplier", "multiply");
043    
044            // the same as above but expressed as a URI configuration
045            //from("activemq:queue:numbers").to("bean:multiplier?methodName=multiply");
046        }
047    
048    }
049    // END SNIPPET: e1