00001 /* 00002 * SingleAddressProvider.hpp 00003 * 00004 * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_SINGLE_ADDRESS_PROVIDER_HPP 00017 #define COH_SINGLE_ADDRESS_PROVIDER_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/net/AddressProvider.hpp" 00022 00023 COH_OPEN_NAMESPACE2(coherence,net) 00024 00025 /** 00026 * SocketAddressProvider wrapper for a single address dynamically added to 00027 * this provider. 00028 * 00029 * @author Wei Lin 2012.06.21 00030 * 00031 * @since Coherence 12.1.2 00032 */ 00033 class COH_EXPORT SingleAddressProvider 00034 : public class_spec<SingleAddressProvider, 00035 extends<Object>, 00036 implements<AddressProvider> > 00037 { 00038 friend class factory<SingleAddressProvider>; 00039 00040 // ----- constructors --------------------------------------------------- 00041 00042 protected: 00043 /** 00044 * Set the InetSocketAddress for this AddressProvider. 00045 * 00046 * @param address the address which will be returned by this 00047 * InetSocketAddress 00048 */ 00049 SingleAddressProvider(InetSocketAddress::View address); 00050 00051 // ----- AddressProvider interface -------------------------------------- 00052 00053 public: 00054 /** 00055 * {@inheritDoc} 00056 */ 00057 virtual void accept(); 00058 00059 /** 00060 * {@inheritDoc} 00061 */ 00062 virtual InetSocketAddress::View getNextAddress(); 00063 00064 /** 00065 * {@inheritDoc} 00066 */ 00067 virtual void reject(Exception::Holder oheCause); 00068 00069 // ----- Object methods ------------------------------------------------- 00070 00071 public: 00072 /** 00073 * {@inheritDoc} 00074 */ 00075 virtual TypedHandle<const String> toString() const; 00076 00077 // ----- data members --------------------------------------------------- 00078 00079 protected: 00080 /** 00081 * The InetSocketAddress returned by this AddressProvider. 00082 */ 00083 MemberView<InetSocketAddress> m_vAddress; 00084 00085 /** 00086 * Whether the InetSocketAddress has already been returned. 00087 */ 00088 bool m_fAddressGiven; 00089 }; 00090 00091 COH_CLOSE_NAMESPACE2 00092 00093 #endif // COH_SINGLE_ADDRESS_PROVIDER_HPP 00094