-
Notifications
You must be signed in to change notification settings - Fork 912
/
ManagementControlHelper.java
113 lines (90 loc) · 6.95 KB
/
ManagementControlHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* 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.
*/
package org.apache.activemq.artemis.tests.integration.management;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.AcceptorControl;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.api.core.management.AddressControl;
import org.apache.activemq.artemis.api.core.management.BridgeControl;
import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl;
import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl;
import org.apache.activemq.artemis.api.core.management.ConnectionRouterControl;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.management.DivertControl;
import org.apache.activemq.artemis.api.core.management.JGroupsChannelBroadcastGroupControl;
import org.apache.activemq.artemis.api.core.management.JGroupsFileBroadcastGroupControl;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.core.management.QueueControl;
public class ManagementControlHelper {
public static AcceptorControl createAcceptorControl(final String name,
final MBeanServer mbeanServer) throws Exception {
return (AcceptorControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getAcceptorObjectName(name), AcceptorControl.class, mbeanServer);
}
public static BroadcastGroupControl createBroadcastGroupControl(final String name,
final MBeanServer mbeanServer) throws Exception {
return (BroadcastGroupControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getBroadcastGroupObjectName(name), BroadcastGroupControl.class, mbeanServer);
}
public static JGroupsFileBroadcastGroupControl createJgroupsFileBroadcastGroupControl(final String name,
final MBeanServer mbeanServer) throws Exception {
return (JGroupsFileBroadcastGroupControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getBroadcastGroupObjectName(name), JGroupsFileBroadcastGroupControl.class, mbeanServer);
}
public static JGroupsChannelBroadcastGroupControl createJgroupsChannelBroadcastGroupControl(final String name,
final MBeanServer mbeanServer) throws Exception {
return (JGroupsChannelBroadcastGroupControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getBroadcastGroupObjectName(name), JGroupsChannelBroadcastGroupControl.class, mbeanServer);
}
public static BridgeControl createBridgeControl(final String name, final MBeanServer mbeanServer) throws Exception {
return (BridgeControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getBridgeObjectName(name), BridgeControl.class, mbeanServer);
}
public static DivertControl createDivertControl(final String name, String address, final MBeanServer mbeanServer) throws Exception {
return (DivertControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getDivertObjectName(name, address), DivertControl.class, mbeanServer);
}
public static ClusterConnectionControl createClusterConnectionControl(final String name,
final MBeanServer mbeanServer) throws Exception {
return (ClusterConnectionControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getClusterConnectionObjectName(name), ClusterConnectionControl.class, mbeanServer);
}
public static ActiveMQServerControl createActiveMQServerControl(final MBeanServer mbeanServer) throws Exception {
return (ActiveMQServerControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getActiveMQServerObjectName(), ActiveMQServerControl.class, mbeanServer);
}
public static QueueControl createQueueControl(final SimpleString address,
final SimpleString name,
final MBeanServer mbeanServer) throws Exception {
return (QueueControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, ActiveMQDefaultConfiguration.getDefaultRoutingType()), QueueControl.class, mbeanServer);
}
public static QueueControl createQueueControl(final SimpleString address,
final SimpleString name,
final RoutingType routingType,
final MBeanServer mbeanServer) throws Exception {
return (QueueControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, routingType), QueueControl.class, mbeanServer);
}
public static AddressControl createAddressControl(final SimpleString address,
final MBeanServer mbeanServer) throws Exception {
return (AddressControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getAddressObjectName(address), AddressControl.class, mbeanServer);
}
public static ConnectionRouterControl createConnectionRouterControl(final String name,
final MBeanServer mbeanServer) throws Exception {
return (ConnectionRouterControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getConnectionRouterObjectName(name), ConnectionRouterControl.class, mbeanServer);
}
public static Object createProxy(final ObjectName objectName,
final Class mbeanInterface,
final MBeanServer mbeanServer) {
return MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, mbeanInterface, false);
}
}