

package org.wso2.analytics.http.internal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.wso2.analytics.http.udf.GeoLocationResolverUDF;
import org.wso2.analytics.http.udf.UserAgentResolverUDF;
import org.wso2.carbon.analytics.spark.core.udf.CarbonUDF;

public class AnalyticsHTTPBundleActivator implements BundleActivator {

    private static final Log log = LogFactory.getLog(AnalyticsHTTPBundleActivator.class);

    @Override
    public void start(BundleContext bundleContext) throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("Starting analytics http Bundle");
        }

        try {
            bundleContext.registerService(CarbonUDF.class, new UserAgentResolverUDF(), null);
            bundleContext.registerService(CarbonUDF.class, new GeoLocationResolverUDF(), null);
        } catch (Throwable e) {
            log.error("Error in starting analytics http bundle: " + e.getMessage(), e);
        }
    }

    @Override
    public void stop(BundleContext bundleContext) throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("Stopping analytics http component");
        }
    }
}
