Package net.jsunit

Source Code of net.jsunit.RemoteConfigurationFetcher

package net.jsunit;

import net.jsunit.configuration.RemoteConfiguration;

import java.io.IOException;
import java.net.URL;
import java.util.logging.Logger;

public class RemoteConfigurationFetcher extends Thread implements Comparable<RemoteConfigurationFetcher> {

    private Logger logger = Logger.getLogger("net.jsunit");

    private RemoteServerHitter hitter;
    private URL remoteMachineURL;
    private RemoteConfiguration retrievedRemoteConfiguration;

    public RemoteConfigurationFetcher(RemoteServerHitter hitter, URL remoteMachineURL) {
        this.hitter = hitter;
        this.remoteMachineURL = remoteMachineURL;
    }

    public void run() {
        try {
            fetch();
        } catch (IOException e) {
            logger.severe("Cannot retrieve remote configuration on " + remoteMachineURL.toString() + ": " + e.getMessage());
        }
    }

    public void fetch() throws IOException {
        logger.info("Fetching remote machine configuration from " + remoteMachineURL.toString());
        RemoteConfigurationSource remoteSource = new RemoteConfigurationSource(hitter, remoteMachineURL.toString());
        retrievedRemoteConfiguration = new RemoteConfiguration(remoteMachineURL, remoteSource);
        logger.info("Done fetching remote machine configuration from " + remoteMachineURL.toString());
    }

    public URL getRemoteMachineURL() {
        return remoteMachineURL;
    }

    public RemoteConfiguration getRetrievedRemoteConfiguration() {
        return retrievedRemoteConfiguration;
    }

    public int compareTo(RemoteConfigurationFetcher other) {
        return remoteMachineURL.toString().compareTo(other.getRemoteMachineURL().toString());
    }
}
TOP

Related Classes of net.jsunit.RemoteConfigurationFetcher

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.