From 523ea5f4e736b84d6376bf00f8e94a887a1e7732 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Fri, 17 Feb 2006 22:30:59 +0000 Subject: [PATCH] http://jira.activemq.org/jira//browse/AMQ-568 git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@378642 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/broker/BrokerService.java | 10 ++-- .../activemq/broker/TransportConnector.java | 8 ++- .../xbean/ConnectorXBeanConfigTest.java | 59 +++++++++++++++++++ .../apache/activemq/xbean/connector-test.xml | 31 ++++++++++ 4 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 activemq-core/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java create mode 100644 activemq-core/src/test/resources/org/apache/activemq/xbean/connector-test.xml diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java index e1fdcfe0fb..4d8e450bc7 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -151,14 +151,14 @@ public class BrokerService implements Service { */ public TransportConnector addConnector(TransportConnector connector) throws Exception { - if (isUseJmx()) { - connector = connector.asManagedConnector(getManagementContext().getMBeanServer(), getBrokerObjectName()); - registerConnectorMBean(connector); - } - connector.setBroker(getBroker()); connector.setBrokerName(getBrokerName()); connector.setTaskRunnerFactory(getTaskRunnerFactory()); + + if (isUseJmx()) { + connector = connector.asManagedConnector(getManagementContext().getMBeanServer(), getBrokerObjectName()); + registerConnectorMBean(connector); + } transportConnectors.add(connector); return connector; diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java index 2a9f5a2678..569bb0b03c 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java @@ -83,7 +83,13 @@ public class TransportConnector implements Connector { * Factory method to create a JMX managed version of this transport connector */ public ManagedTransportConnector asManagedConnector(MBeanServer mbeanServer, ObjectName connectorName) throws IOException, URISyntaxException { - return new ManagedTransportConnector(mbeanServer,connectorName, getBroker(), getServer()); + ManagedTransportConnector rc = new ManagedTransportConnector(mbeanServer,connectorName, getBroker(), getServer()); + rc.setTaskRunnerFactory(getTaskRunnerFactory()); + rc.setUri(uri); + rc.setConnectUri(connectUri); + rc.setDiscoveryAgent(discoveryAgent); + rc.setDiscoveryUri(discoveryUri); + return rc; } public BrokerInfo getBrokerInfo() { diff --git a/activemq-core/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java b/activemq-core/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java new file mode 100644 index 0000000000..29b14e7137 --- /dev/null +++ b/activemq-core/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java @@ -0,0 +1,59 @@ +/** + * + * Copyright 2005-2006 The Apache Software Foundation + * + * Licensed 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. + */ +package org.apache.activemq.xbean; + +import java.net.URI; + +import junit.framework.TestCase; + +import org.apache.activemq.broker.BrokerFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; + +/** + * + * @version $Revision: 1.1 $ + */ +public class ConnectorXBeanConfigTest extends TestCase { + + protected BrokerService brokerService; + + public void testConnectorConfiguredCorrectly() throws Throwable { + + TransportConnector connector = (TransportConnector) brokerService.getTransportConnectors().get(0); + + assertEquals( new URI("tcp://localhost:61636"), connector.getUri() ); + assertTrue( connector.getTaskRunnerFactory() == brokerService.getTaskRunnerFactory() ); + } + + protected void setUp() throws Exception { + brokerService = createBroker(); + brokerService.start(); + } + + protected void tearDown() throws Exception { + if (brokerService != null) { + brokerService.stop(); + } + } + + protected BrokerService createBroker() throws Exception { + String uri = "org/apache/activemq/xbean/connector-test.xml"; + return BrokerFactory.createBroker(new URI("xbean:"+uri)); + } + +} diff --git a/activemq-core/src/test/resources/org/apache/activemq/xbean/connector-test.xml b/activemq-core/src/test/resources/org/apache/activemq/xbean/connector-test.xml new file mode 100644 index 0000000000..cf73bf1aac --- /dev/null +++ b/activemq-core/src/test/resources/org/apache/activemq/xbean/connector-test.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + +