Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.apache.aries.jmx;

This class MBeanServiceTracker represents org.osgi.util.tracker.ServiceTracker for javax.management.MBeanServer's registered as services. Tracking all registered MBeanServers in ServiceRegistry.

Version:
$Rev: 896239 $ $Date: 2010-01-05 17:02:23 -0500 (Tue, 05 Jan 2010) $
See also:
org.osgi.util.tracker.ServiceTracker
public class MBeanServiceTracker extends ServiceTracker {
    private JMXAgentContext agentContext;

    
Constructs new MBeanServiceTracker.

Parameters:
agentContext agent context.
    public MBeanServiceTracker(JMXAgentContext agentContext) {
        super(agentContext.getBundleContext(), MBeanServer.class.getName(), null);
        this. = agentContext;
    }

    
    public Object addingService(final ServiceReference reference) {
        final MBeanServer mbeanServer = (MBeanServer.getService(reference);
        Logger logger = .getLogger();
        logger.log(."Discovered MBean server " + mbeanServer);
        ExecutorService executor = .getRegistrationExecutor();
        executor.submit(new Runnable() {
            public void run() {
                .registerMBeans(mbeanServer);
            }
        });
        return super.addingService(reference);
    }

    
    public void removedService(final ServiceReference referenceObject service) {
        final MBeanServer mbeanServer = (MBeanServer.getService(reference);
        Logger logger = .getLogger();
        logger.log(."MBean server " + mbeanServer" is unregistered from SeviceRegistry");
        ExecutorService executor = .getRegistrationExecutor();
        executor.submit(new Runnable() {
            public void run() {
                .unregisterMBeans(mbeanServer);
            }
        });
        super.removedService(referenceservice);
    }
    
New to GrepCode? Check out our FAQ X