PageRenderTime 40ms CodeModel.GetById 25ms app.highlight 14ms RepoModel.GetById 0ms 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*/
22package org.jboss.as.jsr77.subsystem;
23
24import org.jboss.as.controller.ModelController;
25import org.jboss.as.server.jmx.PluggableMBeanServer;
26import org.jboss.msc.service.Service;
27import org.jboss.msc.service.ServiceName;
28import org.jboss.msc.service.StartContext;
29import org.jboss.msc.service.StartException;
30import org.jboss.msc.service.StopContext;
31import org.jboss.msc.value.InjectedValue;
32
33/**
34 *
35 * @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
36 */
37class RegisterMBeanServerDelegateService implements Service<Void>{
38
39    static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append(ServiceName.of(JSR77ManagementExtension.SUBSYSTEM_NAME, "mbeanwrapper"));
40
41    final InjectedValue<PluggableMBeanServer> injectedMbeanServer = new InjectedValue<PluggableMBeanServer>();
42    final InjectedValue<ModelController> injectedController = new InjectedValue<ModelController>();
43
44    volatile JSR77ManagementMBeanServer server;
45
46    @Override
47    public Void getValue() throws IllegalStateException, IllegalArgumentException {
48        return null;
49    }
50
51    @Override
52    public void start(StartContext context) throws StartException {
53        server = new JSR77ManagementMBeanServer(injectedController.getValue());
54        injectedMbeanServer.getValue().addPlugin(server);
55    }
56
57    @Override
58    public void stop(StopContext context) {
59        injectedMbeanServer.getValue().removePlugin(server);
60        server = null;
61    }
62
63}