/*-
 * ~~~~~~licensing~~~~~~
 * adapters-core
 * ==========
 * Copyright (C) 2020 - 2021 EmDev LLC
 * ==========
 * Licensed 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.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.esb.platform.runtime.base.connecting.adapter.core.tracker;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

import javax.management.DynamicMBean;
import javax.management.MBeanRegistration;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ru.entaxy.esb.platform.runtime.base.connecting.adapter.core.management.AdaptersMBean;
import ru.entaxy.esb.platform.runtime.base.connecting.adapter.core.management.AdaptersMBeanImpl;

public class AdapterTrackerActivator implements BundleActivator {

	protected static final Logger log = LoggerFactory.getLogger(AdapterTrackerActivator.class);
	
	protected AdapterTracker tracker;
	
	@Override
	public void start(BundleContext context) throws Exception {
		tracker = new AdapterTracker(context);
		tracker.open();
		/* AdaptersMBeanImpl mbean = new AdaptersMBeanImpl();
		Hashtable props = new Hashtable();
        props.put("jmx.objectname", "ru.entaxy.esb:type=bundle,name=adapters");
        List<String> list = new ArrayList<>();
        list.add(AdaptersMBean.class.getName());
        list.add(DynamicMBean.class.getName());
        list.add(MBeanRegistration.class.getName());
        String[] clazzes = list.toArray(new String[] {});
        context.registerService(
        		clazzes
        	, mbean
        	, props);*/		
	}

	@Override
	public void stop(BundleContext context) throws Exception {
		tracker.close();
	}

}
