Coverage Report - org.mule.management.agents.FixedHostRmiClientSocketFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
FixedHostRmiClientSocketFactory
0%
0/10
N/A
1
 
 1  
 /*
 2  
  * $Id: FixedHostRmiClientSocketFactory.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.management.agents;
 12  
 
 13  
 import org.mule.util.StringUtils;
 14  
 
 15  
 import java.io.IOException;
 16  
 import java.io.Serializable;
 17  
 import java.net.Socket;
 18  
 import java.rmi.server.RMIClientSocketFactory;
 19  
 
 20  
 /**
 21  
  * This implementation will enforce specific overrideHost/ip for RMI calls on multi-NIC servers.
 22  
  * TODO MULE-1440 this should probably be moved into the RMI transport.
 23  
  */
 24  
 public class FixedHostRmiClientSocketFactory implements RMIClientSocketFactory, Serializable
 25  
 {
 26  
     /**
 27  
      * Host to use instead of the default one.
 28  
      */
 29  
     private String overrideHost;
 30  
 
 31  
     /**
 32  
      * Default constructor.
 33  
      */
 34  
     public FixedHostRmiClientSocketFactory ()
 35  0
     {
 36  0
     }
 37  
 
 38  
     /**
 39  
      * Create a new instance.
 40  
      * @param overrideHost host/ip to enforce
 41  
      */
 42  
     public FixedHostRmiClientSocketFactory (final String overrideHost)
 43  0
     {
 44  0
         this.overrideHost = overrideHost;
 45  0
     }
 46  
 
 47  
     /**
 48  
      * Create a client socket connected to the specified overrideHost and port.
 49  
      *
 50  
      * @param host the host name IGNORED if an override configured
 51  
      * @param port the port number
 52  
      * @return a socket connected to the specified overrideHost and port.
 53  
      * @throws java.io.IOException if an I/O error occurs during socket creation
 54  
      */
 55  
     public Socket createSocket (String host, int port) throws IOException
 56  
     {
 57  0
         final String hostToUse = StringUtils.defaultString(overrideHost, host);
 58  0
         return new Socket(hostToUse, port);
 59  
     }
 60  
 
 61  
     /**
 62  
      * Getter for property 'overrideHost'.
 63  
      *
 64  
      * @return Value for property 'overrideHost'.
 65  
      */
 66  
     public String getOverrideHost ()
 67  
     {
 68  0
         return overrideHost;
 69  
     }
 70  
 
 71  
     /**
 72  
      * Setter for property 'overrideHost'.
 73  
      *
 74  
      * @param overrideHost Value to set for property 'overrideHost'.
 75  
      */
 76  
     public void setOverrideHost (final String overrideHost)
 77  
     {
 78  0
         this.overrideHost = overrideHost;
 79  0
     }
 80  
 }