summaryrefslogtreecommitdiff
path: root/dotnet/Qpid.Client/Client
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-01-29 11:05:20 +0000
committerRobert Greig <rgreig@apache.org>2007-01-29 11:05:20 +0000
commit509d48d3a12c3477c893456549e0d052d9e5e9f9 (patch)
treedb601f414a0f65e79bd74a3957fc8a78f918df12 /dotnet/Qpid.Client/Client
parenta6808589c1ce06773f599bc28fe90938e2dcd60f (diff)
downloadqpid-python-509d48d3a12c3477c893456549e0d052d9e5e9f9.tar.gz
(Patch supplied by Tomas Restrepo) QPID-312.diff applied. This converts Javadoc copied accross from the orignal Java code to .Net format. Renames some files/classes/methods to use .Net conventions.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@501006 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Client/Client')
-rw-r--r--dotnet/Qpid.Client/Client/AMQConnection.cs30
-rw-r--r--dotnet/Qpid.Client/Client/AmqBrokerInfo.cs118
-rw-r--r--dotnet/Qpid.Client/Client/QpidConnectionInfo.cs92
3 files changed, 105 insertions, 135 deletions
diff --git a/dotnet/Qpid.Client/Client/AMQConnection.cs b/dotnet/Qpid.Client/Client/AMQConnection.cs
index 3192b0018d..1a342f0b15 100644
--- a/dotnet/Qpid.Client/Client/AMQConnection.cs
+++ b/dotnet/Qpid.Client/Client/AMQConnection.cs
@@ -26,7 +26,7 @@ using System.Threading;
using log4net;
using Qpid.Client.Failover;
using Qpid.Client.Protocol;
-using Qpid.Client.qms;
+using Qpid.Client.Qms;
using Qpid.Client.State;
using Qpid.Client.Transport;
using Qpid.Client.Transport.Socket.Blocking;
@@ -40,7 +40,7 @@ namespace Qpid.Client
{
private static readonly ILog _log = LogManager.GetLogger(typeof(AMQConnection));
- ConnectionInfo _connectionInfo;
+ IConnectionInfo _connectionInfo;
private int _nextChannelId = 0;
// _Connected should be refactored with a suitable wait object.
@@ -121,7 +121,7 @@ namespace Qpid.Client
get { return _protocolWriter; }
}
- public AMQConnection(ConnectionInfo connectionInfo)
+ public AMQConnection(IConnectionInfo connectionInfo)
{
if (connectionInfo == null)
{
@@ -129,7 +129,7 @@ namespace Qpid.Client
}
_log.Info("ConnectionInfo: " + connectionInfo);
_connectionInfo = connectionInfo;
- _log.Info("password = " + _connectionInfo.GetPassword());
+ _log.Info("password = " + _connectionInfo.Password);
_failoverPolicy = new FailoverPolicy(connectionInfo);
// We are not currently connected.
@@ -140,7 +140,7 @@ namespace Qpid.Client
{
try
{
- BrokerInfo brokerInfo = _failoverPolicy.GetNextBrokerInfo();
+ IBrokerInfo brokerInfo = _failoverPolicy.GetNextBrokerInfo();
_log.Info("Connecting to " + brokerInfo);
MakeBrokerConnection(brokerInfo);
break;
@@ -220,12 +220,12 @@ namespace Qpid.Client
get
{
CheckNotClosed();
- return _connectionInfo.GetClientName();
+ return _connectionInfo.ClientName;
}
set
{
CheckNotClosed();
- _connectionInfo.SetClientName(value);
+ _connectionInfo.ClientName = value;
}
}
@@ -505,7 +505,7 @@ namespace Qpid.Client
{
get
{
- return _failoverPolicy.GetCurrentBrokerInfo().getHost();
+ return _failoverPolicy.GetCurrentBrokerInfo().Host;
}
}
@@ -513,7 +513,7 @@ namespace Qpid.Client
{
get
{
- return _failoverPolicy.GetCurrentBrokerInfo().getPort();
+ return _failoverPolicy.GetCurrentBrokerInfo().Port;
}
}
@@ -521,7 +521,7 @@ namespace Qpid.Client
{
get
{
- return _connectionInfo.GetUsername();
+ return _connectionInfo.Username;
}
}
@@ -529,7 +529,7 @@ namespace Qpid.Client
{
get
{
- return _connectionInfo.GetPassword();
+ return _connectionInfo.Password;
}
}
@@ -537,7 +537,7 @@ namespace Qpid.Client
{
get
{
- return _connectionInfo.GetVirtualHost();
+ return _connectionInfo.VirtualHost;
}
}
@@ -674,7 +674,7 @@ namespace Qpid.Client
public bool AttemptReconnection(String host, int port, bool useSSL)
{
- BrokerInfo bd = new AmqBrokerInfo("amqp", host, port, useSSL);
+ IBrokerInfo bd = new AmqBrokerInfo("amqp", host, port, useSSL);
_failoverPolicy.setBroker(bd);
@@ -691,7 +691,7 @@ namespace Qpid.Client
return false;
}
- private void MakeBrokerConnection(BrokerInfo brokerDetail)
+ private void MakeBrokerConnection(IBrokerInfo brokerDetail)
{
try
{
@@ -708,7 +708,7 @@ namespace Qpid.Client
_transport = LoadTransportFromAssembly(brokerDetail.getHost(), brokerDetail.getPort(), assemblyName, transportType);
*/
- _transport = new BlockingSocketTransport(brokerDetail.getHost(), brokerDetail.getPort(), this);
+ _transport = new BlockingSocketTransport(brokerDetail.Host, brokerDetail.Port, this);
// Connect.
_transport.Open();
diff --git a/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs b/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs
index 81a5f10647..f26756ccad 100644
--- a/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs
+++ b/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs
@@ -21,11 +21,11 @@
using System;
using System.Collections;
using System.Text;
-using Qpid.Client.qms;
+using Qpid.Client.Qms;
namespace Qpid.Client
{
- public class AmqBrokerInfo : BrokerInfo
+ public class AmqBrokerInfo : IBrokerInfo
{
public readonly string URL_FORMAT_EXAMPLE =
"<transport>://<hostname>[:<port Default=\""+BrokerInfoConstants.DEFAULT_PORT+"\">][?<option>='<value>'[,<option>='<value>']]";
@@ -90,10 +90,10 @@ namespace Qpid.Client
" In broker URL:'" + url + "' Format: " + URL_FORMAT_EXAMPLE, "");
}
- setTransport(transport);
+ Transport = transport;
String host = connection.Host;
- if (!host.Equals("default")) setHost(host);
+ if (!host.Equals("default")) Host = host;
int port = connection.Port;
@@ -130,7 +130,7 @@ namespace Qpid.Client
}
if (found)
{
- setPort(int.Parse(auth.Substring(start, end-start+1)));
+ Port = int.Parse(auth.Substring(start, end-start+1));
}
else
{
@@ -140,12 +140,12 @@ namespace Qpid.Client
}
else
{
- setPort(BrokerInfoConstants.DEFAULT_PORT);
+ Port = BrokerInfoConstants.DEFAULT_PORT;
}
}
else
{
- setPort(port);
+ Port = port;
}
String queryString = connection.Query;
@@ -178,70 +178,58 @@ namespace Qpid.Client
if (useSSL)
{
- setOption(BrokerInfoConstants.OPTIONS_SSL, "true");
+ SetOption(BrokerInfoConstants.OPTIONS_SSL, "true");
}
}
- public string getHost()
+ public string Host
{
- return _host;
+ get { return _host; }
+ set { _host = value; }
}
- public void setHost(string _host)
+ public int Port
{
- this._host = _host;
+ get { return _port; }
+ set { _port = value; }
}
- public int getPort()
+ public string Transport
{
- return _port;
+ get { return _transport; }
+ set { _transport = value; }
}
- public void setPort(int _port)
- {
- this._port = _port;
- }
-
- public string getTransport()
- {
- return _transport;
- }
-
- public void setTransport(string _transport)
- {
- this._transport = _transport;
- }
-
- public string getOption(string key)
+ public string GetOption(string key)
{
return (string)_options[key];
}
- public void setOption(string key, string value)
+ public void SetOption(string key, string value)
{
_options[key] = value;
}
- public long getTimeout()
+ public long Timeout
{
- if (_options.ContainsKey(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT))
+ get
{
- try
- {
- return long.Parse((string)_options[BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT]);
- }
- catch (FormatException)
+ if ( _options.ContainsKey(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT) )
{
- //Do nothing as we will use the default below.
+ try
+ {
+ return long.Parse(GetOption(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT));
+ } catch ( FormatException )
+ {
+ //Do nothing as we will use the default below.
+ }
}
+ return BrokerInfoConstants.DEFAULT_CONNECT_TIMEOUT;
+ }
+ set
+ {
+ SetOption(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT, value.ToString());
}
-
- return BrokerInfoConstants.DEFAULT_CONNECT_TIMEOUT;
- }
-
- public void setTimeout(long timeout)
- {
- setOption(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT, timeout.ToString());
}
public override string ToString()
@@ -267,15 +255,15 @@ namespace Qpid.Client
public override bool Equals(object obj)
{
- if (!(obj is BrokerInfo))
+ if (!(obj is IBrokerInfo))
{
return false;
}
- BrokerInfo bd = (BrokerInfo) obj;
- return StringEqualsIgnoreCase(_host, bd.getHost()) &&
- _port == bd.getPort() &&
- _transport == bd.getTransport();
+ IBrokerInfo bd = (IBrokerInfo) obj;
+ return StringEqualsIgnoreCase(_host, bd.Host) &&
+ _port == bd.Port &&
+ _transport == bd.Transport;
}
public override int GetHashCode()
@@ -318,23 +306,25 @@ namespace Qpid.Client
// return optionsURL.tostring();
// }
- public bool useSSL()
+ public bool UseSSL
{
- // To be friendly to users we should be case insensitive.
- // or simply force users to conform to OPTIONS_SSL
- // todo make case insensitive by trying ssl Ssl sSl ssL SSl SsL sSL SSL
-
- if (_options.ContainsKey(BrokerInfoConstants.OPTIONS_SSL))
+ get
{
- return StringEqualsIgnoreCase((string)_options[BrokerInfoConstants.OPTIONS_SSL], "true");
- }
+ // To be friendly to users we should be case insensitive.
+ // or simply force users to conform to OPTIONS_SSL
+ // todo make case insensitive by trying ssl Ssl sSl ssL SSl SsL sSL SSL
- return false;
- }
+ if ( _options.ContainsKey(BrokerInfoConstants.OPTIONS_SSL) )
+ {
+ return StringEqualsIgnoreCase(GetOption(BrokerInfoConstants.OPTIONS_SSL), "true");
+ }
- public void useSSL(bool ssl)
- {
- setOption(BrokerInfoConstants.OPTIONS_SSL, ssl.ToString());
+ return false;
+ }
+ set
+ {
+ SetOption(BrokerInfoConstants.OPTIONS_SSL, value.ToString());
+ }
}
}
}
diff --git a/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs b/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
index 7207253603..66bb549779 100644
--- a/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
+++ b/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
@@ -24,7 +24,7 @@ using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using log4net;
-using Qpid.Client.qms;
+using Qpid.Client.Qms;
namespace Qpid.Client
{
@@ -192,10 +192,10 @@ namespace Qpid.Client
public class QpidConnectionUrl
{
- internal static ConnectionInfo FromUrl(string fullURL)
+ internal static IConnectionInfo FromUrl(string fullURL)
{
//_url = fullURL;
- ConnectionInfo connectionInfo = new QpidConnectionInfo();
+ IConnectionInfo connectionInfo = new QpidConnectionInfo();
// _options = new HashMap<String, String>();
@@ -216,7 +216,7 @@ namespace Qpid.Client
if (connection.Host != null && connection.Host.Length > 0 && !connection.Host.Equals("default"))
{
- connectionInfo.SetClientName(connection.Host);
+ connectionInfo.ClientName = connection.Host;
}
String userInfo = connection.UserInfo;
@@ -231,9 +231,9 @@ namespace Qpid.Client
}
String virtualHost = connection.AbsolutePath; // XXX: is AbsolutePath corrrect?
- if (virtualHost != null && (!virtualHost.Equals("")))
+ if (virtualHost != null && virtualHost.Length > 0)
{
- connectionInfo.SetVirtualHost(virtualHost);
+ connectionInfo.VirtualHost = virtualHost;
}
else
{
@@ -290,7 +290,7 @@ namespace Qpid.Client
}
}
- private static void parseUserInfo(String userinfo, string fullUrl, ConnectionInfo connectionInfo)
+ private static void parseUserInfo(String userinfo, string fullUrl, IConnectionInfo connectionInfo)
{
//user info = user:pass
@@ -303,12 +303,12 @@ namespace Qpid.Client
}
else
{
- connectionInfo.setUsername(userinfo.Substring(0, colonIndex));
- connectionInfo.SetPassword(userinfo.Substring(colonIndex + 1));
+ connectionInfo.Username = userinfo.Substring(0, colonIndex);
+ connectionInfo.Password = userinfo.Substring(colonIndex + 1);
}
}
- private static void processOptions(ConnectionInfo connectionInfo)
+ private static void processOptions(IConnectionInfo connectionInfo)
{
string brokerlist = connectionInfo.GetOption(ConnectionUrlConstants.OPTIONS_BROKERLIST);
if (brokerlist != null)
@@ -334,14 +334,14 @@ namespace Qpid.Client
if (methodIndex > -1)
{
- connectionInfo.SetFailoverMethod(failover.Substring(0, methodIndex));
+ connectionInfo.FailoverMethod = failover.Substring(0, methodIndex);
QpidConnectionInfo qpidConnectionInfo = (QpidConnectionInfo)connectionInfo;
URLHelper.parseOptions(qpidConnectionInfo.GetFailoverOptions(),
failover.Substring(methodIndex + 1));
}
else
{
- connectionInfo.SetFailoverMethod(failover);
+ connectionInfo.FailoverMethod = failover;
}
connectionInfo.SetOption(ConnectionUrlConstants.OPTIONS_FAILOVER, null);
@@ -349,14 +349,14 @@ namespace Qpid.Client
}
}
- internal static ConnectionInfo FromUri(Uri uri)
+ internal static IConnectionInfo FromUri(Uri uri)
{
return null; // FIXME
}
}
- public class QpidConnectionInfo : ConnectionInfo
+ public class QpidConnectionInfo : IConnectionInfo
{
string _username = "guest";
string _password = "guest";
@@ -378,7 +378,7 @@ namespace Qpid.Client
return _options;
}
- public static ConnectionInfo FromUrl(String url)
+ public static IConnectionInfo FromUrl(String url)
{
return QpidConnectionUrl.FromUrl(url);
}
@@ -386,7 +386,7 @@ namespace Qpid.Client
public string AsUrl()
{
string result = "amqp://";
- foreach (BrokerInfo info in _brokerInfos)
+ foreach (IBrokerInfo info in _brokerInfos)
{
result += info.ToString();
}
@@ -394,14 +394,10 @@ namespace Qpid.Client
}
- public string GetFailoverMethod()
+ public string FailoverMethod
{
- return _failoverMethod;
- }
-
- public void SetFailoverMethod(string failoverMethod)
- {
- _failoverMethod = failoverMethod;
+ get { return _failoverMethod; }
+ set { _failoverMethod = value; }
}
public string GetFailoverOption(string key)
@@ -409,17 +405,17 @@ namespace Qpid.Client
return (string)_failoverOptions[key];
}
- public int GetBrokerCount()
+ public int BrokerCount
{
- return _brokerInfos.Count;
+ get { return _brokerInfos.Count; }
}
- public BrokerInfo GetBrokerInfo(int index)
+ public IBrokerInfo GetBrokerInfo(int index)
{
- return (BrokerInfo)_brokerInfos[index];
+ return (IBrokerInfo)_brokerInfos[index];
}
- public void AddBrokerInfo(BrokerInfo brokerInfo)
+ public void AddBrokerInfo(IBrokerInfo brokerInfo)
{
if (!_brokerInfos.Contains(brokerInfo))
{
@@ -432,44 +428,28 @@ namespace Qpid.Client
return _brokerInfos;
}
- public string GetClientName()
- {
- return _clientName;
- }
-
- public void SetClientName(string clientName)
- {
- _clientName = clientName;
- }
-
- public string GetUsername()
- {
- return _username;
- }
-
- public void setUsername(string username)
- {
- _username = username;
- }
-
- public string GetPassword()
+ public string ClientName
{
- return _password;
+ get { return _clientName; }
+ set { _clientName = value; }
}
- public void SetPassword(string password)
+ public string Username
{
- _password = password;
+ get { return _username; }
+ set { _username = value; }
}
- public string GetVirtualHost()
+ public string Password
{
- return _virtualHost;
+ get { return _password; }
+ set { _password = value; }
}
- public void SetVirtualHost(string virtualHost)
+ public string VirtualHost
{
- _virtualHost = virtualHost;
+ get { return _virtualHost; }
+ set { _virtualHost = value; }
}
public string GetOption(string key)