mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@378642 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
236a1ac422
commit
523ea5f4e7
|
@ -151,14 +151,14 @@ public class BrokerService implements Service {
|
||||||
*/
|
*/
|
||||||
public TransportConnector addConnector(TransportConnector connector) throws Exception {
|
public TransportConnector addConnector(TransportConnector connector) throws Exception {
|
||||||
|
|
||||||
if (isUseJmx()) {
|
|
||||||
connector = connector.asManagedConnector(getManagementContext().getMBeanServer(), getBrokerObjectName());
|
|
||||||
registerConnectorMBean(connector);
|
|
||||||
}
|
|
||||||
|
|
||||||
connector.setBroker(getBroker());
|
connector.setBroker(getBroker());
|
||||||
connector.setBrokerName(getBrokerName());
|
connector.setBrokerName(getBrokerName());
|
||||||
connector.setTaskRunnerFactory(getTaskRunnerFactory());
|
connector.setTaskRunnerFactory(getTaskRunnerFactory());
|
||||||
|
|
||||||
|
if (isUseJmx()) {
|
||||||
|
connector = connector.asManagedConnector(getManagementContext().getMBeanServer(), getBrokerObjectName());
|
||||||
|
registerConnectorMBean(connector);
|
||||||
|
}
|
||||||
transportConnectors.add(connector);
|
transportConnectors.add(connector);
|
||||||
|
|
||||||
return connector;
|
return connector;
|
||||||
|
|
|
@ -83,7 +83,13 @@ public class TransportConnector implements Connector {
|
||||||
* Factory method to create a JMX managed version of this transport connector
|
* Factory method to create a JMX managed version of this transport connector
|
||||||
*/
|
*/
|
||||||
public ManagedTransportConnector asManagedConnector(MBeanServer mbeanServer, ObjectName connectorName) throws IOException, URISyntaxException {
|
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() {
|
public BrokerInfo getBrokerInfo() {
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- this file can only be parsed using the xbean-spring library -->
|
||||||
|
<!-- START SNIPPET: xbean -->
|
||||||
|
<beans xmlns="http://activemq.org/config/1.0">
|
||||||
|
|
||||||
|
<broker useJmx="true">
|
||||||
|
|
||||||
|
<transportConnectors>
|
||||||
|
<transportConnector uri="tcp://localhost:61636" />
|
||||||
|
</transportConnectors>
|
||||||
|
|
||||||
|
</broker>
|
||||||
|
|
||||||
|
</beans>
|
||||||
|
<!-- END SNIPPET: xbean -->
|
Loading…
Reference in New Issue