All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.uniroma2.art.coda.standalone.impl.CODAOSGiManger Maven / Gradle / Ivy

There is a newer version: 1.8.1
Show newest version
package it.uniroma2.art.coda.standalone.impl;

import it.uniroma2.art.coda.exception.FelixInitializationException;
import it.uniroma2.art.coda.standalone.CODAStandaloneFactory;

import java.io.File;
import java.util.Properties;

import org.apache.felix.framework.Felix;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Andrea Turbati
 */

public class CODAOSGiManger extends ARTOSGiManager {

	private static CODAOSGiManger manager = null;
	protected static Logger logger = LoggerFactory
			.getLogger(CODAOSGiManger.class);

	private static String globalFilePropertyName = "osgi.properties";
	//private static String propertyName = "art.coda.osgi.packages";

	protected CODAOSGiManger(File felixDir, Properties userConfigProp) throws FelixInitializationException {
		super(felixDir, globalFilePropertyName, CODAStandaloneFactory.CODA_EXPORT_PACKAGES_PROPERTY_NAME, 
				userConfigProp);
	}

	/**
	 * Method to inialize the OSGi framwork using felix implementation
	 * 
	 * @param oSGiDir
	 *            the directory where the bundle will be stored
	 * @param userConfigProp 
	 * @return the CODAOSGiManger
	 * @throws FelixInitializationException
	 */
	public static CODAOSGiManger initialize(File oSGiDir, Properties userConfigProp)
			throws FelixInitializationException {
		manager = new CODAOSGiManger(oSGiDir, userConfigProp);
		return manager;
	}

	/**
	 * Get the CODAOSGiManger
	 * 
	 * @return the CODAOSGiManger
	 */
	public static CODAOSGiManger getManager() {
		return manager;
	}

	/**
	 * Stop Felix
	 */
	public void stop() {
		stopFelix();
	}

	/**
	 * Finds and installs all bundles below rootDir The parameter
	 * layout specifies where to look for bundles (directly in the
	 * rootDir, or within sub-directories, ...)
	 * 
	 * @param bundlesRootDir
	 *            the directory to start the search of bundles from
	 */
	public void loadComponents(File bundlesRootDir) {
		// A flat directory
		bundleToBeStarted.clear();
		findAndInstallPlugin(bundlesRootDir);
		startAllBundle();
	}

	public Felix getFramework() {
		return m_felix;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy