/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software License
 * version 1.1, a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 */
package org.apache.avalon.phoenix.components.manager;

/**
 * @author sshort
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */

import java.io.File;
import java.util.ArrayList;
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;

/**
 * This component is responsible for managing phoenix instance.
 *
 * @author <a href="mail@leosimons.com">Leo Simons</a>
 * @author <a href="mailto:peter at apache.org">Peter Donald</a>
 * @author <a href="mailto:Huw@mmlive.com">Huw Roberts</a>
 */
public class JBossHostedSystemManager
    extends AbstractJMXManager
    implements Contextualizable, Configurable
{
    public void contextualize( Context context )
        throws ContextException
    {
    }

    public void configure( final Configuration configuration )
        throws ConfigurationException
    {
    }

    public void initialize()
        throws Exception
    {
        super.initialize();

        final MBeanServer mBeanServer = createMBeanServer();

    }

    protected MBeanServer createMBeanServer()
        throws Exception
    {
    	ArrayList serverList = MBeanServerFactory.findMBeanServer(null);
    	
    	if (serverList.size() == 0) {
			getLogger().debug("JBossHostedSystemManager createMBeanServer no MBeanServer could be found");
    		return null;
    	}

		MBeanServer ms = (MBeanServer)serverList.get(0);
		getLogger().debug("JBossHostedSystemManager createMBeanServer \""+ms+"\"");
        return ms;
    }
}
