PageRenderTime 377ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/jboss-as-7.1.1.Final/jsr77/src/main/java/org/jboss/as/jsr77/subsystem/RegisterMBeanServerDelegateService.java

#
Java | 63 lines | 29 code | 9 blank | 25 comment | 0 complexity | 648976d0f69d93790848db5a6db264a6 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2011, Red Hat Middleware LLC, and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.jsr77.subsystem;
  23. import org.jboss.as.controller.ModelController;
  24. import org.jboss.as.server.jmx.PluggableMBeanServer;
  25. import org.jboss.msc.service.Service;
  26. import org.jboss.msc.service.ServiceName;
  27. import org.jboss.msc.service.StartContext;
  28. import org.jboss.msc.service.StartException;
  29. import org.jboss.msc.service.StopContext;
  30. import org.jboss.msc.value.InjectedValue;
  31. /**
  32. *
  33. * @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
  34. */
  35. class RegisterMBeanServerDelegateService implements Service<Void>{
  36. static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append(ServiceName.of(JSR77ManagementExtension.SUBSYSTEM_NAME, "mbeanwrapper"));
  37. final InjectedValue<PluggableMBeanServer> injectedMbeanServer = new InjectedValue<PluggableMBeanServer>();
  38. final InjectedValue<ModelController> injectedController = new InjectedValue<ModelController>();
  39. volatile JSR77ManagementMBeanServer server;
  40. @Override
  41. public Void getValue() throws IllegalStateException, IllegalArgumentException {
  42. return null;
  43. }
  44. @Override
  45. public void start(StartContext context) throws StartException {
  46. server = new JSR77ManagementMBeanServer(injectedController.getValue());
  47. injectedMbeanServer.getValue().addPlugin(server);
  48. }
  49. @Override
  50. public void stop(StopContext context) {
  51. injectedMbeanServer.getValue().removePlugin(server);
  52. server = null;
  53. }
  54. }