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.component.dataset;
018    
019    import org.apache.camel.Processor;
020    
021    /**
022     * A simple DataSet that allows a static payload to be used to create each message exchange
023     * along with using a pluggable transformer to randomize the message.
024     *
025     * @version $Revision: 37863 $
026     */
027    public class SimpleDataSet extends DataSetSupport {
028        private Object defaultBody = "<hello>world!</hello>";
029        private Processor inputTransformer;
030    
031        public SimpleDataSet() {
032        }
033    
034        public SimpleDataSet(int size) {
035            super(size);
036        }
037    
038        // Properties
039        //-------------------------------------------------------------------------
040    
041        public Object getDefaultBody() {
042            return defaultBody;
043        }
044    
045        public void setDefaultBody(Object defaultBody) {
046            this.defaultBody = defaultBody;
047        }
048    
049        public Processor getInputTransformer() {
050            return inputTransformer;
051        }
052    
053        public void setInputTransformer(Processor inputTransformer) {
054            this.inputTransformer = inputTransformer;
055        }
056    
057        // Implementation methods
058        //-------------------------------------------------------------------------
059    
060        /**
061         * Creates the message body for a given message
062         */
063        protected Object createMessageBody(long messageIndex) {
064            return getDefaultBody();
065        }
066    }