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