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

org.osgl.storage.spring.FileSystemServiceConfigurer Maven / Gradle / Ivy

Go to download

A simple storage service supports plugin varieties of implementations including Amazon S3

There is a newer version: 1.11.1
Show newest version
package org.osgl.storage.spring;

import org.osgl.storage.IStorageService;
import org.osgl.storage.impl.FileSystemService;
import org.osgl.util.C;
import org.osgl.util.E;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

import static org.osgl.storage.IStorageService.CONF_KEY_GEN;

/**
 * Created by luog on 3/01/14.
 */
@Component
public class FileSystemServiceConfigurer extends StorageServiceConfigurerBase implements StorageServiceConfigurer {

    private String homeDir;
    private String homeUrl;

    public void setHomeDir(Resource homeDir) throws IOException {
        E.NPE(homeDir);
        this.homeDir = homeDir.getFile().getAbsolutePath();
    }

    public void setHomeUrl(String homeUrl) {
        E.NPE(homeUrl);
        this.homeUrl = homeUrl;
    }

    @Override
    public IStorageService getStorageService() {
        Map conf = C.map(
                FileSystemService.CONF_HOME_DIR, homeDir,
                FileSystemService.CONF_HOME_URL, homeUrl,
                CONF_KEY_GEN, getKeyGenerator().name());
        return new FileSystemService(conf);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy