Coverage Report - org.apache.camel.component.mina.MinaEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
MinaEndpoint
100% 
N/A 
0
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.component.mina;
 18  
 
 19  
 import java.net.SocketAddress;
 20  
 
 21  
 import org.apache.camel.Consumer;
 22  
 import org.apache.camel.Processor;
 23  
 import org.apache.camel.Producer;
 24  
 import org.apache.camel.impl.DefaultEndpoint;
 25  
 import org.apache.mina.common.IoAcceptor;
 26  
 import org.apache.mina.common.IoConnector;
 27  
 import org.apache.mina.common.IoServiceConfig;
 28  
 import org.apache.mina.common.IoSession;
 29  
 
 30  
 /**
 31  
  * @version $Revision: 563665 $
 32  
  */
 33  2
 public class MinaEndpoint extends DefaultEndpoint<MinaExchange> {
 34  
     private final IoAcceptor acceptor;
 35  
     private final SocketAddress address;
 36  
     private final IoConnector connector;
 37  
     private final IoServiceConfig config;
 38  
 
 39  
     public MinaEndpoint(String endpointUri, MinaComponent component, SocketAddress address, IoAcceptor acceptor, IoConnector connector, IoServiceConfig config) {
 40  2
         super(endpointUri, component);
 41  2
         this.config = config;
 42  2
         this.address = address;
 43  2
         this.acceptor = acceptor;
 44  2
         this.connector = connector;
 45  2
     }
 46  
 
 47  
     public Producer<MinaExchange> createProducer() throws Exception {
 48  2
         return new MinaProducer(this);
 49  
     }
 50  
 
 51  
     public Consumer<MinaExchange> createConsumer(Processor processor) throws Exception {
 52  2
         return new MinaConsumer(this, processor);
 53  
     }
 54  
 
 55  
     public MinaExchange createExchange() {
 56  2
         return new MinaExchange(getContext());
 57  
     }
 58  
 
 59  
     public MinaExchange createExchange(IoSession session, Object object) {
 60  2
         MinaExchange exchange = new MinaExchange(getContext());
 61  2
         exchange.getIn().setBody(object);
 62  
         // TODO store session in exchange?
 63  2
         return exchange;
 64  
     }
 65  
 
 66  
     // Properties
 67  
     // -------------------------------------------------------------------------
 68  
     public IoAcceptor getAcceptor() {
 69  2
         return acceptor;
 70  
     }
 71  
 
 72  
     public SocketAddress getAddress() {
 73  4
         return address;
 74  
     }
 75  
 
 76  
     public IoConnector getConnector() {
 77  2
         return connector;
 78  
     }
 79  
 
 80  
     public IoServiceConfig getConfig() {
 81  4
         return config;
 82  
     }
 83  
 
 84  
     public boolean isSingleton() {
 85  2
         return true;
 86  
     }
 87  
 
 88  
 }