Permalink
Browse files

[AS7-4403] Allow access to the platform MBeanServer within the HostCo…

…ntroller process.
  • Loading branch information...
1 parent 89252f3 commit dc59010ded2e5698bb0e4a6738b169336d6b6d0b @darranl darranl committed with bstansberry Apr 4, 2012
View
1 build/src/main/resources/modules/org/jboss/as/host-controller/main/module.xml
@@ -56,6 +56,7 @@
<module name="org.jboss.modules"/>
<module name="org.jboss.msc"/>
<module name="org.jboss.remoting3"/>
+ <module name="org.jboss.remoting3.remoting-jmx"/>
<module name="org.jboss.sasl"/>
<module name="org.jboss.stdio"/>
<module name="org.jboss.threads"/>
View
2 build/src/main/resources/modules/org/jboss/remoting3/remoting-jmx/main/module.xml
@@ -2,7 +2,7 @@
<!--
~ JBoss, Home of Professional Open Source.
- ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ Copyright 2012, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
View
4 host-controller/pom.xml
@@ -109,6 +109,10 @@
<artifactId>jboss-marshalling</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.remotingjmx</groupId>
+ <artifactId>remoting-jmx</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling-river</artifactId>
<scope>test</scope>
View
93 host-controller/src/main/java/org/jboss/as/host/controller/jmx/RemotingConnectorService.java
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.host.controller.jmx;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+
+import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.remoting.management.ManagementRemotingServices;
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.ServiceBuilder;
+import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.service.ServiceTarget;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
+import org.jboss.msc.value.InjectedValue;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remotingjmx.RemotingConnectorServer;
+
+/**
+ * The remote connector services
+ *
+ * Copied from the JMX subsystem to avoid bringing in a new dependency.
+ *
+ * @author Stuart Douglas
+ */
+public class RemotingConnectorService implements Service<RemotingConnectorServer> {
+
+ public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("jmx", "remoting-connector-ref");
+
+ private RemotingConnectorServer server;
+
+ private final InjectedValue<Endpoint> endpoint = new InjectedValue<Endpoint>();
+
+ @Override
+ public synchronized void start(final StartContext context) throws StartException {
+ server = new RemotingConnectorServer(ManagementFactory.getPlatformMBeanServer(), endpoint.getValue());
+ try {
+ server.start();
+ } catch (IOException e) {
+ throw new StartException(e);
+ }
+ }
+
+ @Override
+ public synchronized void stop(final StopContext context) {
+ try {
+ server.stop();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public synchronized RemotingConnectorServer getValue() throws IllegalStateException, IllegalArgumentException {
+ return server;
+ }
+
+ public static ServiceController<?> addService(final ServiceTarget target,
+ final ServiceVerificationHandler verificationHandler) {
+ final RemotingConnectorService service = new RemotingConnectorService();
+ final ServiceBuilder<RemotingConnectorServer> builder = target.addService(SERVICE_NAME, service);
+
+ builder.addDependency(ManagementRemotingServices.MANAGEMENT_ENDPOINT, Endpoint.class, service.endpoint);
+
+ if (verificationHandler != null) {
+ builder.addListener(verificationHandler);
+ }
+ return builder.install();
+ }
+
+}
View
2 ...ler/src/main/java/org/jboss/as/host/controller/operations/NativeManagementAddHandler.java
@@ -34,6 +34,7 @@
import org.jboss.as.domain.controller.LocalHostControllerInfo;
import org.jboss.as.domain.management.security.SecurityRealmService;
import org.jboss.as.host.controller.DomainModelControllerService;
+import org.jboss.as.host.controller.jmx.RemotingConnectorService;
import org.jboss.as.host.controller.mgmt.ServerToHostOperationHandlerFactoryService;
import org.jboss.as.host.controller.resources.NativeManagementResourceDefinition;
import org.jboss.as.remoting.EndpointService;
@@ -120,6 +121,7 @@ public static void installNativeManagementServices(final ServiceTarget serviceTa
new ModelControllerClientOperationHandlerFactoryService(),
DomainModelControllerService.SERVICE_NAME, ManagementRemotingServices.MANAGEMENT_CHANNEL, verificationHandler, newControllers);
+ RemotingConnectorService.addService(serviceTarget, verificationHandler);
}
}
View
21 jmx/src/main/java/org/jboss/as/jmx/RemotingConnectorService.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.as.jmx;
import java.io.IOException;

0 comments on commit dc59010

Please sign in to comment.