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);
}
}
}
}
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);
}
}
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);
}
}
}
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);
}
}
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$
}
}
Aggregations