insure unique JMX names across multiple connectors and connections

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@392003 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-04-06 15:53:32 +00:00
parent 5982b208d4
commit 2f7ab76817
1 changed files with 7 additions and 7 deletions

View File

@ -36,9 +36,10 @@ import java.net.URISyntaxException;
*/ */
public class ManagedTransportConnector extends TransportConnector { public class ManagedTransportConnector extends TransportConnector {
static long nextConnectionId = 1;
private final MBeanServer mbeanServer; private final MBeanServer mbeanServer;
private final ObjectName connectorName; private final ObjectName connectorName;
long nextConnectionId = 1;
public ManagedTransportConnector(MBeanServer mbeanServer, ObjectName connectorName, Broker next, TransportServer server) { public ManagedTransportConnector(MBeanServer mbeanServer, ObjectName connectorName, Broker next, TransportServer server) {
super(next, server); super(next, server);
@ -51,13 +52,12 @@ public class ManagedTransportConnector extends TransportConnector {
} }
protected Connection createConnection(Transport transport) throws IOException { protected Connection createConnection(Transport transport) throws IOException {
String connectionId = "" + getNextConnectionId();
final String connectionId;
synchronized (this) {
connectionId = "" + (nextConnectionId++);
}
return new ManagedTransportConnection(this, transport, getBroker(), getTaskRunnerFactory(), mbeanServer, connectorName, connectionId); return new ManagedTransportConnection(this, transport, getBroker(), getTaskRunnerFactory(), mbeanServer, connectorName, connectionId);
} }
protected static synchronized long getNextConnectionId() {
return nextConnectionId;
}
} }