Coverage Report - org.apache.camel.component.rmi.RmiProducer
 
Classes in this File Line Coverage Branch Coverage Complexity
RmiProducer
100% 
100% 
1.333
 
 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.rmi;
 19  
 
 20  
 import java.rmi.AccessException;
 21  
 import java.rmi.NotBoundException;
 22  
 import java.rmi.Remote;
 23  
 import java.rmi.RemoteException;
 24  
 import java.rmi.registry.Registry;
 25  
 
 26  
 import org.apache.camel.component.pojo.PojoEndpoint;
 27  
 import org.apache.camel.component.pojo.PojoExchange;
 28  
 import org.apache.camel.impl.DefaultProducer;
 29  
 import org.apache.camel.Exchange;
 30  
 
 31  
 /**
 32  
  * @version $Revision: 533076 $
 33  
  */
 34  
 public class RmiProducer extends DefaultProducer {
 35  
 
 36  
         private final RmiEndpoint endpoint;
 37  
         private Remote remote;
 38  
 
 39  
         public RmiProducer(RmiEndpoint endpoint) throws AccessException, RemoteException, NotBoundException {
 40  1
                 super(endpoint);
 41  1
                 this.endpoint = endpoint;
 42  1
         }
 43  
 
 44  
         public void process(Exchange exchange) throws AccessException, RemoteException, NotBoundException {
 45  1
         PojoExchange pojoExchange = endpoint.toExchangeType(exchange);
 46  1
         PojoEndpoint.invoke(getRemote(), pojoExchange);
 47  1
         exchange.copyFrom(pojoExchange);
 48  1
     }
 49  
 
 50  
         public Remote getRemote() throws AccessException, RemoteException, NotBoundException {
 51  1
                 if( remote == null ) {
 52  1
                         Registry registry = endpoint.getRegistry();                                
 53  1
                         remote = registry.lookup(endpoint.getName());                        
 54  
                 }
 55  1
                 return remote;
 56  
         }
 57  
         
 58  
 }