Author: jstrachan
Date: Wed Aug 2 21:08:06 2006
New Revision: 428225
URL: http://svn.apache.org/viewvc?rev=428225&view=rev
Log:
disabled logging by default but allow it to be specified via a URI query
argument of tcp://localhost:port?logging=true
Modified:
incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransportFactory.cs
Modified:
incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransportFactory.cs
URL:
http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransportFactory.cs?rev=428225&r1=428224&r2=428225&view=diff
==============================================================================
---
incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransportFactory.cs
(original)
+++
incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransportFactory.cs
Wed Aug 2 21:08:06 2006
@@ -1,62 +1,67 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
using System;
using System.Net;
using System.Net.Sockets;
using ActiveMQ.Transport;
-namespace ActiveMQ.Transport.Tcp
-{
- public class TcpTransportFactory : ITransportFactory
- {
- public ITransport CreateTransport(Uri location) {
-
- // Console.WriteLine("Opening socket to: " + host + "
on port: " + port);
- Socket socket = Connect(location.Host, location.Port);
- ITransport rc = new TcpTransport(socket);
- // TODO: use URI query string to enable the
LoggingTransport
- rc = new LoggingTransport(rc);
- rc = new ResponseCorrelator(rc);
- rc = new MutexTransport(rc);
- return rc;
-
- }
-
- protected Socket Connect(string host, int port)
- {
+namespace ActiveMQ.Transport.Tcp {
+ public class TcpTransportFactory : ITransportFactory {
+ private bool useLogging = false;
+
+ public bool UseLogging {
+ get { return useLogging; }
+ set { useLogging = value; }
+ }
+
+ public ITransport CreateTransport(Uri location) {
+
+ // Console.WriteLine("Opening socket to: " + host + " on port: " +
port);
+ Socket socket = Connect(location.Host, location.Port);
+ ITransport rc = new TcpTransport(socket);
+
+ // TODO use URI query string to configure properties on this object
+
+ // TODO - dirty hack - replace with better URI query parsing later
+ if (location.Query.IndexOf("logging=true") >= 0) {
+ UseLogging = true;
+ }
+
+ if (UseLogging) {
+ rc = new LoggingTransport(rc);
+ }
+ rc = new ResponseCorrelator(rc);
+ rc = new MutexTransport(rc);
+ return rc;
+ }
+
+ protected Socket Connect(string host, int port) {
// Looping through the AddressList allows different type of
connections to be tried
// (IPv4, IPv6 and whatever else may be available).
IPHostEntry hostEntry = Dns.Resolve(host);
- foreach (IPAddress address in hostEntry.AddressList)
- {
- Socket socket = new Socket(
- address.AddressFamily,
- SocketType.Stream,
- ProtocolType.Tcp);
+ foreach (IPAddress address in hostEntry.AddressList) {
+ Socket socket = new Socket(address.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
socket.Connect(new IPEndPoint(address, port));
- if (socket.Connected)
- {
+ if (socket.Connected) {
return socket;
}
}
throw new SocketException();
}
-
- }
-
+ }
}