00001 #ifndef ISPN_HOTROD_CONFIGURATION_CONFIGURATIONBUILDER_H
00002 #define ISPN_HOTROD_CONFIGURATION_CONFIGURATIONBUILDER_H
00003
00004 #include <string>
00005 #include <vector>
00006
00007 #include "infinispan/hotrod/defs.h"
00008 #include "infinispan/hotrod/ImportExport.h"
00009 #include "Builder.h"
00010 #include "Configuration.h"
00011 #include "ConnectionPoolConfigurationBuilder.h"
00012 #include "ServerConfigurationBuilder.h"
00013 #include "SslConfigurationBuilder.h"
00014
00015 namespace infinispan {
00016 namespace hotrod {
00017
00023 class HR_EXTERN ConfigurationBuilder
00024 : public Builder<Configuration>
00025 {
00026 public:
00027 ConfigurationBuilder():
00028 m_connectionTimeout(60000),
00029 m_forceReturnValue(false),
00030 m_keySizeEstimate(64),
00031 m_pingOnStartup(true),
00032 m_protocolVersion(PROTOCOL_VERSION_12),
00033 m_socketTimeout(60000),
00034 m_tcpNoDelay(true),
00035 m_valueSizeEstimate(512),
00036 connectionPoolConfigurationBuilder(*this),
00037 sslConfigurationBuilder(*this)
00038 { };
00039
00046 ServerConfigurationBuilder& addServer();
00047
00054 ConfigurationBuilder& addServers(std::string servers);
00055
00061 ConnectionPoolConfigurationBuilder& connectionPool();
00062
00068 ConfigurationBuilder& connectionTimeout(int connectionTimeout_);
00069
00076 ConfigurationBuilder& forceReturnValues(bool forceReturnValues_);
00077
00083 ConfigurationBuilder& keySizeEstimate(int keySizeEstimate_);
00084
00091 ConfigurationBuilder& pingOnStartup(bool pingOnStartup_);
00092
00100 ConfigurationBuilder& protocolVersion(std::string protocolVersion_);
00101
00108 ConfigurationBuilder& socketTimeout(int socketTimeout_);
00109
00115 SslConfigurationBuilder& ssl();
00116
00122 ConfigurationBuilder& tcpNoDelay(bool tcpNoDelay_);
00123
00129 ConfigurationBuilder& valueSizeEstimate(int valueSizeEstimate_);
00130
00137 Configuration build();
00138
00145 virtual Configuration create();
00146
00153 virtual ConfigurationBuilder& read(Configuration& bean);
00154
00158 static const char* PROTOCOL_VERSION_12;
00159
00160
00161 private:
00162 int m_connectionTimeout;
00163 bool m_forceReturnValue;
00164 int m_keySizeEstimate;
00165 bool m_pingOnStartup;
00166 std::string m_protocolVersion;
00167 std::vector<HR_SHARED_PTR<ServerConfigurationBuilder> > m_servers;
00168 int m_socketTimeout;
00169 bool m_tcpNoDelay;
00170 int m_valueSizeEstimate;
00171
00172 ConnectionPoolConfigurationBuilder connectionPoolConfigurationBuilder;
00173 SslConfigurationBuilder sslConfigurationBuilder;
00174 };
00175
00176 }}
00177
00178 #endif // ISPN_HOTROD_CONFIGURATION_CONFIGURATIONBUILDER_H