1 /* 2 * #%L 3 * ConnectionInfo.java - mongodb-async-driver - Allanbank Consulting, Inc. 4 * %% 5 * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc. 6 * %% 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * #L% 19 */ 20 21 package com.allanbank.mongodb.client.connection.proxy; 22 23 import com.allanbank.mongodb.client.connection.Connection; 24 25 /** 26 * ConnectionInfo provides a container for the information on a discovered 27 * server. 28 * 29 * @param <K> 30 * The type of key used to identify the server. 31 * 32 * @api.no This class is <b>NOT</b> part of the drivers API. This class may be 33 * mutated in incompatible ways between any two releases of the driver. 34 * @copyright 2013, Allanbank Consulting, Inc., All Rights Reserved 35 */ 36 public class ConnectionInfo<K> { 37 38 /** The connection to the primary server. */ 39 private final Connection myConnection; 40 41 /** The primary server. */ 42 private final K myConnectionKey; 43 44 /** 45 * Creates a new ConnectionInfo. 46 * 47 * @param connection 48 * The connection to the primary server. 49 * @param connectionKey 50 * The primary server. 51 */ 52 public ConnectionInfo(final Connection connection, final K connectionKey) { 53 super(); 54 this.myConnection = connection; 55 this.myConnectionKey = connectionKey; 56 } 57 58 /** 59 * Returns the connection to the primary server. 60 * 61 * @return The connection to the primary server. 62 */ 63 public Connection getConnection() { 64 return myConnection; 65 } 66 67 /** 68 * Returns the primary server. 69 * 70 * @return The primary server. 71 */ 72 public K getConnectionKey() { 73 return myConnectionKey; 74 } 75 }