Activator.java 1.74 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.osgi.framework.Bundle
 *  org.osgi.framework.BundleActivator
 *  org.osgi.framework.BundleContext
 *  org.osgi.framework.ServiceRegistration
 *  org.osgi.service.cm.ManagedService
 */
package com.day.commons.httpclient.impl;

import com.day.commons.httpclient.impl.ProxyWrapper;
import java.util.Dictionary;
import java.util.Hashtable;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.auth.AuthPolicy;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ManagedService;

public class Activator
extends ProxyWrapper
implements BundleActivator,
ManagedService {
    private ServiceRegistration configurator;

    public void start(BundleContext context) throws Exception {
        AuthPolicy.unregisterAuthScheme("NTLM");
        Hashtable<String, Object> props = new Hashtable<String, Object>();
        props.put("service.pid", "com.day.commons.httpclient");
        props.put("service.vendor", context.getBundle().getHeaders("Bundle-Vendor"));
        props.put("service.description", "Day Commons HTTP Client Configurator");
        this.configurator = context.registerService(ManagedService.class.getName(), (Object)this, props);
    }

    public void stop(BundleContext context) throws Exception {
        if (this.configurator != null) {
            this.configurator.unregister();
        }
        MultiThreadedHttpConnectionManager.shutdownAll();
        this.setupProxies(null);
    }

    public void updated(Dictionary properties) {
        this.setupProxies(properties);
    }
}