PageRenderTime 99ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Java | 114 lines | 71 code | 16 blank | 27 comment | 0 complexity | 52a29c18f2ff9c4f2b3301b7a24732e9 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 static org.jboss.as.jsr77.subsystem.Constants.APP_NAME;
  24. import static org.jboss.as.jsr77.subsystem.Constants.DISTINCT_NAME;
  25. import static org.jboss.as.jsr77.subsystem.Constants.EJB_NAME;
  26. import static org.jboss.as.jsr77.subsystem.Constants.JNDI_NAME;
  27. import static org.jboss.as.jsr77.subsystem.Constants.MODULE_NAME;
  28. import java.util.List;
  29. import javax.management.MBeanServer;
  30. import javax.management.j2ee.ManagementHome;
  31. import org.jboss.as.controller.AbstractAddStepHandler;
  32. import org.jboss.as.controller.ModelController;
  33. import org.jboss.as.controller.OperationContext;
  34. import org.jboss.as.controller.OperationContext.Stage;
  35. import org.jboss.as.controller.OperationFailedException;
  36. import org.jboss.as.controller.OperationStepHandler;
  37. import org.jboss.as.controller.ServiceVerificationHandler;
  38. import org.jboss.as.ejb3.deployment.DeploymentRepository;
  39. import org.jboss.as.ejb3.remote.DefaultEjbClientContextService;
  40. import org.jboss.as.ejb3.remote.RemoteViewManagedReferenceFactory;
  41. import org.jboss.as.ejb3.remote.TCCLEJBClientContextSelectorService;
  42. import org.jboss.as.jmx.MBeanServerService;
  43. import org.jboss.as.naming.ServiceBasedNamingStore;
  44. import org.jboss.as.naming.deployment.ContextNames;
  45. import org.jboss.as.naming.service.BinderService;
  46. import org.jboss.as.server.Services;
  47. import org.jboss.as.server.jmx.PluggableMBeanServer;
  48. import org.jboss.dmr.ModelNode;
  49. import org.jboss.ejb.client.EJBClientContext;
  50. import org.jboss.msc.service.ServiceController;
  51. import org.jboss.msc.service.ServiceController.Mode;
  52. /**
  53. *
  54. * @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
  55. */
  56. class JSR77ManagementSubsystemAdd extends AbstractAddStepHandler {
  57. static JSR77ManagementSubsystemAdd INSTANCE = new JSR77ManagementSubsystemAdd();
  58. private JSR77ManagementSubsystemAdd() {
  59. }
  60. @Override
  61. protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
  62. model.setEmptyObject();
  63. }
  64. @Override
  65. protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model,
  66. ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers)
  67. throws OperationFailedException {
  68. context.addStep(new OperationStepHandler() {
  69. @Override
  70. public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
  71. RegisterMBeanServerDelegateService mbeanServerService = new RegisterMBeanServerDelegateService();
  72. context.getServiceTarget().addService(RegisterMBeanServerDelegateService.SERVICE_NAME, mbeanServerService)
  73. .addDependency(MBeanServerService.SERVICE_NAME, PluggableMBeanServer.class, mbeanServerService.injectedMbeanServer)
  74. .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, mbeanServerService.injectedController)
  75. .setInitialMode(Mode.ACTIVE)
  76. .install();
  77. RegisterManagementEJBService managementEjbService = new RegisterManagementEJBService();
  78. context.getServiceTarget().addService(RegisterManagementEJBService.SERVICE_NAME, managementEjbService)
  79. .addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, managementEjbService.deploymentRepositoryValue)
  80. .addDependency(MBeanServerService.SERVICE_NAME, MBeanServer.class, managementEjbService.mbeanServerValue)
  81. //TODO I think these are needed here since we don't go through EjbClientContextSetupProcessor
  82. .addDependency(DefaultEjbClientContextService.DEFAULT_SERVICE_NAME, EJBClientContext.class, managementEjbService.ejbClientContextValue)
  83. .addDependency(TCCLEJBClientContextSelectorService.TCCL_BASED_EJB_CLIENT_CONTEXT_SELECTOR_SERVICE_NAME, TCCLEJBClientContextSelectorService.class, managementEjbService.ejbClientContextSelectorValue)
  84. .setInitialMode(Mode.ACTIVE)
  85. .install();
  86. //TODO null for source ok?
  87. final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(JNDI_NAME);
  88. final BinderService binderService = new BinderService(bindInfo.getBindName(), null);
  89. context.getServiceTarget().addService(bindInfo.getBinderServiceName(), binderService)
  90. .addInjection(binderService.getManagedObjectInjector(), new RemoteViewManagedReferenceFactory(APP_NAME, MODULE_NAME, DISTINCT_NAME, EJB_NAME, ManagementHome.class.getName(), false))
  91. .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
  92. .setInitialMode(Mode.ACTIVE)
  93. .install();
  94. context.completeStep();
  95. }
  96. }, Stage.RUNTIME);
  97. }
  98. }