00001 /* 00002 * ConfigurableAddressProviderFactory.hpp 00003 * 00004 * Copyright (c) 2000, 2013, 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_CONFIGURABLE_ADDRESS_PROVIDER_FACTORY_HPP 00017 #define COH_CONFIGURABLE_ADDRESS_PROVIDER_FACTORY_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/net/AddressProvider.hpp" 00022 #include "coherence/net/AddressProviderFactory.hpp" 00023 #include "coherence/run/xml/XmlConfigurable.hpp" 00024 #include "coherence/run/xml/XmlElement.hpp" 00025 00026 COH_OPEN_NAMESPACE2(coherence,net) 00027 00028 using coherence::run::xml::XmlConfigurable; 00029 using coherence::run::xml::XmlElement; 00030 00031 00032 /** 00033 * An AddressProviderFactory implementation that creates instances of a 00034 * AddressProvider class configured using an XmlElement of the following structure: 00035 * <pre> 00036 * <!ELEMENT ... (socket-address+ | address-provider)> 00037 * <!ELEMENT address-provider 00038 * (class-name | (class-factory-name, method-name), init-params?> 00039 * <!ELEMENT socket-address (address, port)> 00040 * </pre> 00041 * 00042 * @author wl 2012.04.04 00043 * @since Coherence 12.1.2 00044 */ 00045 class COH_EXPORT ConfigurableAddressProviderFactory 00046 : public class_spec<ConfigurableAddressProviderFactory, 00047 extends<Object>, 00048 implements<AddressProviderFactory, XmlConfigurable> > 00049 { 00050 friend class factory<ConfigurableAddressProviderFactory>; 00051 00052 // ----- constructors --------------------------------------------------- 00053 00054 protected: 00055 /** 00056 * Create a new ConfigurableAddressProviderFactory instance. 00057 */ 00058 ConfigurableAddressProviderFactory(); 00059 00060 00061 // ----- ConfigurableAddressProviderFactory interface ------------------- 00062 00063 public: 00064 /** 00065 * Instantiate an AddressProvider configured according to the specified XML. 00066 * The passed XML has to conform to the following format: 00067 * <pre> 00068 * <!ELEMENT ... (socket-address+ | address-provider)> 00069 * <!ELEMENT address-provider 00070 * (class-name | (class-factory-name, method-name), init-params?> 00071 * <!ELEMENT socket-address (address, port)> 00072 * </pre> 00073 * 00074 * @param vLoader the optional ClassLoader with which to configure the 00075 * new AddressProvider. 00076 * 00077 * @return an instance of the corresponding AddressProvider 00078 * implementation. 00079 */ 00080 virtual AddressProvider::Handle createAddressProvider(ClassLoader::View vLoader = NULL); 00081 00082 00083 // ----- XmlConfigurable interface--------------------------------------- 00084 00085 public: 00086 /** 00087 * {@inheritDoc} 00088 */ 00089 virtual void setConfig(XmlElement::View xml); 00090 00091 /** 00092 * {@inheritDoc} 00093 */ 00094 virtual XmlElement::View getConfig() const; 00095 00096 00097 // ----- Object interface ----------------------------------------------- 00098 00099 public: 00100 /** 00101 * {@inheritDoc} 00102 */ 00103 virtual void toStream(std::ostream& out) const; 00104 00105 00106 // ---- data members ---------------------------------------------------- 00107 00108 protected: 00109 /** 00110 * XML configuration for this ConfigurableAddressProviderFactory. 00111 */ 00112 FinalView<XmlElement> f_vXmlConfig; 00113 }; 00114 00115 COH_CLOSE_NAMESPACE2 00116 00117 #endif // COH_CONFIGURABLE_ADDRESS_PROVIDER_FACTORY_HPP