package com.qmth.boot.core.fss.service.impl;

import com.qmth.boot.core.fss.service.FileService;
import com.qmth.boot.core.fss.store.FileStore;

import javax.annotation.PreDestroy;
import javax.validation.constraints.NotNull;

public class SingletonFileService implements FileService {

    private FileStore fileStore;

    public SingletonFileService(@NotNull FileStore fileStore) {
        this.fileStore = fileStore;
    }

    public void close() {
        this.fileStore.close();
    }

    @Override
    public FileStore getFileStore(String name) {
        return this.fileStore;
    }

    @PreDestroy
    public void shutdown() {
        fileStore.close();
    }
}
