Search in sources :

Example 6 with ServiceException

use of jp.ossc.nimbus.lang.ServiceException in project nimbus by nimbus-org.

the class ResourceBundlePropertiesFactoryService method setupJarPropList.

/**
 * Jarファイルからプロパティの抽出を行う.
 * @param item
 */
protected void setupJarPropList(String item) {
    String dirPath = StringOperator.replaceString(item, C_BK_SRASH, C_SRASH);
    JarFile jar;
    try {
        jar = new JarFile(dirPath);
    } catch (IOException e) {
        // $NON-NLS-1$ //$NON-NLS-2$
        throw new ServiceException("PROPFACTORY005", "IOException filename = " + dirPath, e);
    }
    for (Enumeration iterator = jar.entries(); iterator.hasMoreElements(); ) {
        ZipEntry entry = (ZipEntry) iterator.nextElement();
        String name = entry.getName();
        if (!entry.isDirectory() && name.endsWith(C_PROP_EXT)) {
            InputStream is = null;
            try {
                is = jar.getInputStream(entry);
            } catch (IOException e) {
                // $NON-NLS-1$//$NON-NLS-2$
                throw new ServiceException("PROPFACTORY006", "IOException filename = " + dirPath, e);
            }
            ArrayProperties prop = new ArrayProperties(mEncode);
            try {
                prop.load(is);
            } catch (IOException e) {
                // $NON-NLS-1$//$NON-NLS-2$
                throw new ServiceException("PROPFACTORY007", "IOException filename = " + dirPath, e);
            }
            name = StringOperator.replaceString(name, C_SRASH, C_DOT);
            name = name.substring(0, name.length() - C_PROP_EXT.length());
            mPropHash.put(name, prop);
            try {
                is.close();
            } catch (IOException e) {
                // $NON-NLS-1$ //$NON-NLS-2$
                throw new ServiceException("PROPFACTORY008", "IOException filename = " + dirPath, e);
            }
        }
    }
}
Also used : Enumeration(java.util.Enumeration) ServiceException(jp.ossc.nimbus.lang.ServiceException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayProperties(jp.ossc.nimbus.util.ArrayProperties) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) JarFile(java.util.jar.JarFile)

Example 7 with ServiceException

use of jp.ossc.nimbus.lang.ServiceException in project nimbus by nimbus-org.

the class ResourceBundlePropertiesFactoryService method refresh.

// 
/**
 * 即時にキャッシュを入れ替える.
 */
protected void refresh() {
    SimpleDateFormat ft = new SimpleDateFormat(TIME_FORMAT);
    mPropHash.clear();
    for (ListIterator iterator = mRootDir.listIterator(); iterator.hasNext(); ) {
        String item = (String) iterator.next();
        String upper = item.toUpperCase();
        if (upper.endsWith(C_JAR_EXT)) {
            // JARファイル内検索
            setupJarPropList(item);
        } else {
            // ディレクトリ内検索
            setupDirPropList(item);
        }
    }
    try {
        mRefreshedTime = ft.parse(ft.format(new Date()));
    } catch (ParseException e) {
        // $NON-NLS-1$//$NON-NLS-2$
        throw new ServiceException("PROPFACTORY021", "ParseException", e);
    }
}
Also used : ServiceException(jp.ossc.nimbus.lang.ServiceException) ParseException(java.text.ParseException) ListIterator(java.util.ListIterator) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 8 with ServiceException

use of jp.ossc.nimbus.lang.ServiceException in project nimbus by nimbus-org.

the class WeakReferenceCodeMasterService method initMasterHash.

/**
 * マスタ管理テーブルを初期化する
 * @throws ServiceException
 */
private void initMasterHash() throws ServiceException {
    for (int cnt = 0; cnt < mMasterNames.length; cnt++) {
        final String bfname = mMasterNames[cnt];
        final BeanFlowInvoker invoker = mBFInvokerFactory.createFlow(bfname);
        if (invoker == null) {
            // BeanFlowInvokerFactoryは無効キーでNULLを返します
            throw new ServiceException("WeakReferenceCodeMasterService001", "Cannot specify Invoker with key ->" + bfname);
        }
        // 時系列管理マスタテーブルを作成
        TimeManageMaster tmgr = new TimeManageMaster();
        tmgr.setMasterName(bfname);
        // マスタに登録
        this.mMaster.put(bfname, tmgr);
        Object outMaster = null;
        try {
            // BeanFlowを実行する
            outMaster = invoker.invokeFlow(null);
        } catch (Exception e) {
            throw new ServiceException("WeakReferenceCodeMasterService002", "Exception occured in Invoker with key ->" + bfname, e);
        }
        if (outMaster != null) {
            // コードマスタを登録する(内部で弱参照に変換される)
            tmgr.addMaster(new Date(), outMaster);
        }
    }
}
Also used : ServiceException(jp.ossc.nimbus.lang.ServiceException) BeanFlowInvoker(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker) ServiceException(jp.ossc.nimbus.lang.ServiceException) Date(java.util.Date)

Example 9 with ServiceException

use of jp.ossc.nimbus.lang.ServiceException in project nimbus by nimbus-org.

the class WeakReferenceCodeMasterService method updateCodeMaster.

public void updateCodeMaster(String key, Object input, Date updateTime) {
    String bfname = key;
    Date date = updateTime;
    final BeanFlowInvoker invoker = mBFInvokerFactory.createFlow(bfname);
    if (invoker == null) {
        // BeanFlowInvokerFactoryは無効キーでNULLを返す
        throw new ServiceException("WeakReferenceCodeMasterService004", "Cannot specify Invoker with key ->" + bfname);
    }
    TimeManageMaster tmgr = (TimeManageMaster) this.mMaster.get(bfname);
    // 無かった場合新しく登録を行う
    if (tmgr == null) {
        // 時系列管理マスタテーブルを作成
        tmgr = new TimeManageMaster();
        tmgr.setMasterName(bfname);
        // マスタに登録
        synchronized (mMaster) {
            this.mMaster.put(bfname, tmgr);
        }
    }
    Object outMaster = null;
    try {
        // BeanFlowを実行する
        outMaster = invoker.invokeFlow(input);
    } catch (Exception e) {
        throw new ServiceException("WeakReferenceCodeMasterService005", "Exception occured in Invoker with key ->" + bfname, e);
    }
    if (outMaster == null) {
        throw new ServiceException("WeakReferenceCodeMasterService006", "Return codemaster is null : key ->" + bfname);
    }
    final TimeManageMaster newTm = tmgr.cloneOwn();
    if (date == null) {
        date = new Date();
    }
    // マスタを登録(内部でキャッシュ参照に変換される)
    newTm.addMaster(date, outMaster);
    // 現在時刻で不要なマスタを削除
    newTm.clear();
    synchronized (this.mMaster) {
        this.mMaster.put(bfname, newTm);
    }
}
Also used : ServiceException(jp.ossc.nimbus.lang.ServiceException) BeanFlowInvoker(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker) Date(java.util.Date) ServiceException(jp.ossc.nimbus.lang.ServiceException)

Example 10 with ServiceException

use of jp.ossc.nimbus.lang.ServiceException in project nimbus by nimbus-org.

the class DefaultSemaphoreFactoryService method createSemaphore.

// SemaphoreFactoryのJavaDoc
public Semaphore createSemaphore(int capa) throws ServiceException {
    try {
        Semaphore ret = null;
        synchronized (mImplClassName) {
            ret = (Semaphore) mClassObj.newInstance();
        }
        ret.setResourceCapacity(capa);
        return ret;
    } catch (Exception e) {
        throw new ServiceException(C_EXCPT + "002", "CLASS_NOT_INSTANCE", e);
    // $NON-NLS-1$ //$NON-NLS-2$
    }
}
Also used : ServiceException(jp.ossc.nimbus.lang.ServiceException) ServiceException(jp.ossc.nimbus.lang.ServiceException)

Aggregations

ServiceException (jp.ossc.nimbus.lang.ServiceException)11 JarFile (java.util.jar.JarFile)4 IOException (java.io.IOException)3 Date (java.util.Date)3 BeanFlowInvoker (jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 Enumeration (java.util.Enumeration)2 ZipEntry (java.util.zip.ZipEntry)2 ExtentionFileFilter (jp.ossc.nimbus.io.ExtentionFileFilter)2 RecurciveSearchFile (jp.ossc.nimbus.io.RecurciveSearchFile)2 ArrayProperties (jp.ossc.nimbus.util.ArrayProperties)2 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ListIterator (java.util.ListIterator)1 CsvArrayList (jp.ossc.nimbus.util.CsvArrayList)1