From 794acb667c18436d3c0ffc2a1f48442804a5d47a Mon Sep 17 00:00:00 2001 From: James Strachan Date: Tue, 1 Aug 2006 09:50:46 +0000 Subject: [PATCH] a minor refactor to make it easier to extend ConnectionInfo/ConnectionContext without having to change code in the AbstractConnection in the future - such as to support new certificate or security token mechanisms. For background see thread: http://www.nabble.com/Certificate-login-tf2029724.html#a5583011 git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@427507 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/broker/AbstractConnection.java | 8 ++------ .../org/apache/activemq/broker/ConnectionContext.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java b/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java index 39a44c8170..cafb9f9c1e 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java @@ -541,19 +541,15 @@ public abstract class AbstractConnection implements Service, Connection, Task, C public Response processAddConnection(ConnectionInfo info) throws Exception { // Setup the context. - String clientId = info.getClientId(); - ConnectionContext context = new ConnectionContext(); + ConnectionContext context = new ConnectionContext(info); context.setConnection(this); context.setBroker(broker); context.setConnector(connector); context.setTransactions(new ConcurrentHashMap()); - context.setClientId(clientId); - context.setUserName(info.getUserName()); - context.setConnectionId(info.getConnectionId()); context.setWireFormatInfo(wireFormatInfo); this.manageable = info.isManageable(); connectionStates.put(info.getConnectionId(), new ConnectionState(info, context)); - + broker.addConnection(context, info); if (info.isManageable() && broker.isFaultTolerantConfiguration()){ diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java b/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java index 939d37d05b..cff5c1441a 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java @@ -21,6 +21,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.broker.region.MessageReference; import org.apache.activemq.command.ConnectionId; +import org.apache.activemq.command.ConnectionInfo; import org.apache.activemq.command.WireFormatInfo; import org.apache.activemq.filter.MessageEvaluationContext; import org.apache.activemq.security.MessageAuthorizationPolicy; @@ -54,6 +55,15 @@ public class ConnectionContext { private final MessageEvaluationContext messageEvaluationContext = new MessageEvaluationContext(); + public ConnectionContext() { + } + + public ConnectionContext(ConnectionInfo info) { + setClientId(info.getClientId()); + setUserName(info.getUserName()); + setConnectionId(info.getConnectionId()); + } + public SecurityContext getSecurityContext() { return securityContext; }