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

net.sourceforge.tink.model.TinkPublisher Maven / Gradle / Ivy

/**
 * Copyright 2008,2009 Ivan SZKIBA
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * under the License.
 */

package net.sourceforge.tink.model;

import java.io.File;

import java.net.URI;

import java.util.ServiceLoader;

public abstract class TinkPublisher
{
    private Config config;
    private Output output;

    public abstract void execute() throws TinkException;

    public static TinkPublisher newInstance()
    {
        return ServiceLoader.load(TinkPublisher.class, TinkPublisher.class.getClassLoader()).iterator().next();
    }

    public static TinkPublisher newInstance(Output output)
    {
        return newInstance(output, null);
    }

    public static TinkPublisher newInstance(Output output, Config config)
    {
        TinkPublisher instance = newInstance();

        instance.setOutput(output);
        if (config != null)
        {
            instance.setConfig(config);
        }

        return instance;
    }

    public Config getConfig()
    {
        return config;
    }

    public void setConfig(Config value)
    {
        this.config = value;
    }

    public Output getOutput()
    {
        return output;
    }

    public void setOutput(Output value)
    {
        output = value;
    }

    public static interface Config
    {
        File getLocal();

        String getPassword();

        URI getRemote();

        String getUser();
    }

    public static class SimpleConfig implements Config
    {
        private File local;
        private String password;
        private URI remote;
        private String user;

        @Override public File getLocal()
        {
            return local;
        }

        public void setLocal(File value)
        {
            this.local = value;
        }

        @Override public String getPassword()
        {
            return password;
        }

        public void setPassword(String value)
        {
            password = value;
        }

        @Override public URI getRemote()
        {
            return remote;
        }

        public void setRemote(URI value)
        {
            this.remote = value;
        }

        @Override public String getUser()
        {
            return user;
        }

        public void setUser(String value)
        {
            user = value;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy