Search in sources :

Example 6 with ExtentionFileFilter

use of jp.ossc.nimbus.io.ExtentionFileFilter in project nimbus by nimbus-org.

the class CodeMasterService method load.

public void load() throws IOException, ClassNotFoundException {
    if (persistDir == null) {
        throw new IOException("PersistDir is null.");
    }
    if (master == null) {
        throw new IOException("Master is not initializing.");
    }
    File dir = new File(persistDir);
    if (!dir.exists()) {
        return;
    } else if (!dir.isDirectory()) {
        throw new IOException("PersistDir is not directory. path=" + persistDir);
    }
    synchronized (master) {
        File[] files = dir.listFiles(new ExtentionFileFilter(".mst"));
        for (int i = 0; i < files.length; i++) {
            String key = files[i].getName().substring(0, files[i].getName().lastIndexOf('.'));
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream(files[i]));
            try {
                master.put(key, ois.readObject());
            } finally {
                ois.close();
            }
        }
    }
}
Also used : ExtentionFileFilter(jp.ossc.nimbus.io.ExtentionFileFilter)

Aggregations

ExtentionFileFilter (jp.ossc.nimbus.io.ExtentionFileFilter)6 File (java.io.File)3 RecurciveSearchFile (jp.ossc.nimbus.io.RecurciveSearchFile)3 JarFile (java.util.jar.JarFile)2 ServiceException (jp.ossc.nimbus.lang.ServiceException)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 ArrayProperties (jp.ossc.nimbus.util.ArrayProperties)1