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