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.servicemix.bean.support;
018    
019    import java.lang.reflect.Method;
020    import java.util.HashMap;
021    import java.util.HashSet;
022    import java.util.Map;
023    import java.util.Set;
024    
025    import javax.jbi.messaging.MessageExchange;
026    
027    public class Request {
028        private Object bean;
029        private MessageExchange exchange;
030        private Set<String> sentExchanges;
031        // Keep track of callbacks already called, so that the same callback
032        // can not be called twice
033        private Map<Method, Boolean> callbacks;
034        
035        public Request() {
036        }
037        
038        public Request(Object bean, MessageExchange exchange) {
039            this.bean = bean;
040            this.exchange = exchange;
041        }
042        
043        /**
044         * @return the bean
045         */
046        public Object getBean() {
047            return bean;
048        }
049    
050        /**
051         * @param bean the bean to set
052         */
053        public void setBean(Object bean) {
054            this.bean = bean;
055        }
056        /**
057         * @return the exchange
058         */
059        public MessageExchange getExchange() {
060            return exchange;
061        }
062        /**
063         * @param exchange the exchange to set
064         */
065        public void setExchange(MessageExchange exchange) {
066            this.exchange = exchange;
067        }
068        /**
069         * @param id the id of the exchange sent 
070         */
071        public void addSentExchange(String id) {
072            if (sentExchanges == null) {
073                sentExchanges = new HashSet<String>();
074            }
075            sentExchanges.add(id);
076        }
077    
078        /**
079         * @return the callbacks
080         */
081        public Map<Method, Boolean> getCallbacks() {
082            if (callbacks == null) {
083                callbacks = new HashMap<Method, Boolean>();
084            }
085            return callbacks;
086        }
087    
088    }