Search in sources :

Example 1 with ExtentionFileFilter

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

the class CashedClassLoader method setupDirPropList.

// 
/**
 * Method ディレクトリ指定でクラス名を抽出する.
 * @param item
 */
protected void setupDirPropList(URL item) {
    String dirPath = StringOperator.replaceString(item.getFile(), C_BK_SRASH, C_SRASH);
    if (!item.getFile().endsWith(C_SRASH)) {
        dirPath = dirPath + C_SRASH;
    }
    RecurciveSearchFile file = new RecurciveSearchFile(dirPath);
    ExtentionFileFilter filter = new ExtentionFileFilter(C_CLASS_EXT, true);
    File[] list = file.listAllTreeFiles(filter);
    for (int cnt = 0; cnt < list.length; cnt++) {
        String path = list[cnt].getAbsolutePath();
        // int pos = item.getFile().length();
        // 2003.11.13 Hirokado -1追加
        int pos = item.getFile().length() - 1;
        path = path.substring(pos, path.length() - C_CLASS_EXT.length());
        path = StringOperator.replaceString(path, C_SRASH, C_DOT);
        Class cls = null;
        try {
            cls = this.loadClass(path);
        } catch (ClassNotFoundException e) {
            // $NON-NLS-1$//$NON-NLS-2$
            throw new ServiceException("CASHCLASSLODER003", "ClassNotFoundException clsename = " + path, e);
        }
        mClassHash.put(path, cls);
    }
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) ServiceException(jp.ossc.nimbus.lang.ServiceException) RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) JarFile(java.util.jar.JarFile) File(java.io.File) ExtentionFileFilter(jp.ossc.nimbus.io.ExtentionFileFilter)

Example 2 with ExtentionFileFilter

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

the class ResourceBundlePropertiesFactoryService method setupDirPropList.

// 
/**
 * Method ディレクトリ指定でプロパティファイルを抽出する.
 * @param item
 */
protected void setupDirPropList(String item) {
    String dirPath = StringOperator.replaceString(item, C_BK_SRASH, C_SRASH);
    if (!item.endsWith(C_SRASH)) {
        dirPath = dirPath + C_SRASH;
    }
    File dirPathFile = new File(dirPath);
    int pos = dirPathFile.getAbsolutePath().length();
    RecurciveSearchFile file = new RecurciveSearchFile(dirPath);
    ExtentionFileFilter filter = new ExtentionFileFilter(C_PROP_EXT, true);
    File[] list = file.listAllTreeFiles(filter);
    for (int cnt = 0; cnt < list.length; cnt++) {
        FileInputStream stream;
        try {
            stream = new FileInputStream(list[cnt]);
        } catch (FileNotFoundException e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            throw new ServiceException("PROPFACTORY002", "FileNotFoundException name = " + list[cnt], e);
        }
        ArrayProperties prop = new ArrayProperties(mEncode);
        try {
            prop.load(stream);
        } catch (IOException e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            throw new ServiceException("PROPFACTORY003", "IOException filename = " + list[cnt], e);
        }
        try {
            stream.close();
        } catch (IOException e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            throw new ServiceException("PROPFACTORY004", "IOException filename = " + list[cnt], e);
        }
        String path = list[cnt].getAbsolutePath();
        path = path.substring(pos + 1, path.length() - C_PROP_EXT.length());
        path = StringOperator.replaceString(path, C_BK_SRASH, C_DOT);
        path = StringOperator.replaceString(path, C_SRASH, C_DOT);
        mPropHash.put(path, prop);
    }
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) ServiceException(jp.ossc.nimbus.lang.ServiceException) ArrayProperties(jp.ossc.nimbus.util.ArrayProperties) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) File(java.io.File) RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) ExtentionFileFilter(jp.ossc.nimbus.io.ExtentionFileFilter) FileInputStream(java.io.FileInputStream)

Example 3 with ExtentionFileFilter

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

the class LocalTestResourceManagerService method linkTemplate.

protected void linkTemplate(File dir, boolean isRecurcive) throws Exception {
    File[] linkFiles = null;
    if (isRecurcive) {
        RecurciveSearchFile targetDir = new RecurciveSearchFile(dir);
        linkFiles = targetDir.listAllTreeFiles(new ExtentionFileFilter(templateLinkFileExtention));
    } else {
        linkFiles = dir.listFiles(new ExtentionFileFilter(templateLinkFileExtention));
    }
    if (linkFiles != null) {
        Set deleteDataFiles = new HashSet();
        for (int i = 0; i < linkFiles.length; i++) {
            if (linkFiles[i].isDirectory()) {
                continue;
            }
            createTemplateFile(linkFiles[i], deleteDataFiles);
        }
        Iterator dataFiles = deleteDataFiles.iterator();
        while (dataFiles.hasNext()) {
            ((File) dataFiles.next()).delete();
        }
    }
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) File(java.io.File) RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) ExtentionFileFilter(jp.ossc.nimbus.io.ExtentionFileFilter) HashSet(java.util.HashSet)

Example 4 with ExtentionFileFilter

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

the class MessageRecordFactoryService method setMessageDef.

/**
 * 指定されたディレクトリ配下のメッセージ定義ファイルを読み込んで、このサービスに格納する。<p>
 *
 * @param dirRoot メッセージ定義ファイルが格納されたディレクトリ
 * @exception IOException メッセージ定義ファイルの読み込みに失敗した場合
 * @exception MessageRecordParseException メッセージ定義ファイルのパースに失敗した場合
 */
protected void setMessageDef(File dirRoot) throws IOException, MessageRecordParseException {
    ExtentionFileFilter filter = new ExtentionFileFilter(mExtention);
    File[] defFileList = dirRoot.listFiles(filter);
    if (defFileList != null) {
        for (int rCnt = 0; rCnt < defFileList.length; rCnt++) {
            if (defFileList[rCnt].isFile()) {
                // ファイルOPEN
                FileInputStream stream = null;
                try {
                    stream = new FileInputStream(defFileList[rCnt]);
                } catch (FileNotFoundException e) {
                    continue;
                }
                readStream(stream, null);
            }
        }
    }
}
Also used : ExtentionFileFilter(jp.ossc.nimbus.io.ExtentionFileFilter)

Example 5 with ExtentionFileFilter

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

the class MessageRecordFactoryService method addMessageDef.

/**
 * 指定されたディレクトリ配下のメッセージ定義ファイルを読み込んで、このサービスに格納する。<p>
 *
 * @param dir メッセージ定義ファイルが格納されたディレクトリ
 * @return メッセージ定義ファイルを読み込んだ場合true
 * @exception IOException メッセージ定義ファイルの読み込みに失敗した場合
 * @exception MessageRecordParseException メッセージ定義ファイルのパースに失敗した場合
 */
protected boolean addMessageDef(File dir) throws IOException, MessageRecordParseException {
    ExtentionFileFilter filter = new ExtentionFileFilter(mExtention);
    File[] defFileList = dir.listFiles(filter);
    boolean bret = false;
    if (defFileList != null) {
        for (int rCnt = 0; rCnt < defFileList.length; rCnt++) {
            if (defFileList[rCnt].isDirectory()) {
                continue;
            }
            // ファイルOPEN
            FileInputStream stream = null;
            try {
                stream = new FileInputStream(defFileList[rCnt]);
            } catch (FileNotFoundException e) {
                continue;
            }
            readStream(stream, dir.getName());
        }
        mSerchedPath.put(dir.getAbsolutePath(), C_FOUND_DEF);
        bret = true;
    } else {
        mSerchedPath.put(dir.getAbsolutePath(), C_NOT_FOUND_DEF);
    }
    return bret;
}
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