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.javaspace;
018    
019    import java.util.Map;
020    
021    import org.apache.camel.Consumer;
022    import org.apache.camel.Processor;
023    import org.apache.camel.Producer;
024    import org.apache.camel.impl.DefaultEndpoint;
025    import org.apache.camel.impl.DefaultExchange;
026    
027    /**
028     * @version $Revision: 15488 $
029     */
030    public class JavaSpaceEndpoint extends DefaultEndpoint {
031    
032        private final String remaining;
033        private final Map<?, ?> parameters;
034    
035        private int concurrentConsumers = 1;
036        private String spaceName;
037        private boolean transactional;
038        private long transactionTimeout = Long.MAX_VALUE;
039        private String verb = "take";
040        private String templateId;
041    
042        public JavaSpaceEndpoint(String endpointUri, String remaining, Map<?, ?> parameters, JavaSpaceComponent component) {
043            super(endpointUri, component);
044            this.remaining = remaining;
045            this.parameters = parameters;
046        }
047        
048        public boolean isTransactional() {
049            return transactional;
050        }
051    
052        public String getVerb() {
053            return verb;
054        }
055    
056        public void setVerb(String verb) {
057            this.verb = verb;
058        }
059    
060        public void setTransactional(boolean transactional) {
061            this.transactional = transactional;
062        }
063    
064        public Producer createProducer() throws Exception {
065            return new JavaSpaceProducer(this);
066        }
067    
068        @Override
069        public DefaultExchange createExchange() {
070            return new DefaultExchange(getCamelContext(), getExchangePattern());
071        }
072    
073        public boolean isSingleton() {
074            return true;
075        }
076    
077        public String getRemaining() {
078            return remaining;
079        }
080    
081        public Map<?, ?> getParameters() {
082            return parameters;
083        }
084    
085        public Consumer createConsumer(Processor processor) throws Exception {
086            return new JavaSpaceConsumer(this, processor);
087        }
088    
089        public void setConcurrentConsumers(int concurrentConsumers) {
090            this.concurrentConsumers = concurrentConsumers;
091        }
092    
093        public int getConcurrentConsumers() {
094            return concurrentConsumers;
095        }
096    
097        public String getSpaceName() {
098            return spaceName;
099        }
100    
101        public void setSpaceName(String spaceName) {
102            this.spaceName = spaceName;
103        }
104    
105        public String getTemplateId() {
106            return templateId;
107        }
108    
109        public void setTemplateId(String templateId) {
110            this.templateId = templateId;
111        }
112    
113        public long getTransactionTimeout() {
114            return transactionTimeout;
115        }
116    
117        public void setTransactionTimeout(long transactionTimeout) {
118            this.transactionTimeout = transactionTimeout;
119        }
120    
121    }