use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker in project nimbus by nimbus-org.
the class HtmlBeanFlowCoverageRepoterService method getResourceData.
private Map getResourceData() {
final Map resourceMap = new TreeMap();
final Iterator flowNames = beanFlowInvokerFactory.getBeanFlowKeySet().iterator();
while (flowNames.hasNext()) {
BeanFlowInvoker invoker = beanFlowInvokerFactory.createFlow((String) flowNames.next());
Map coverageMap = (Map) resourceMap.get(invoker.getResourcePath());
if (coverageMap == null) {
coverageMap = new TreeMap();
resourceMap.put(invoker.getResourcePath(), coverageMap);
}
coverageMap.put(invoker.getFlowName(), invoker.getBeanFlowCoverage());
invoker.end();
}
return resourceMap;
}
use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker in project nimbus by nimbus-org.
the class WeakReferenceCodeMasterService method codeMasterRefresh.
/**
* マスター更新
* Message は MapMessageとし、<br>
* nameとvalueの組み合わせは、<br>
* "key" (String) | [マスター名] (String)<br>
* "date" (String) | [データ有効日時](long)<br>
* で設定すること<br>
* 指定した日付以降の日付が既に設定されていれば、該当するマスタデータを無効にする
* @see javax.jms.MessageListener#onMessage(javax.jms.Message)
*/
private void codeMasterRefresh(String[] flowNames, Date date) {
for (int i = 0; i < flowNames.length; i++) {
String bfname = flowNames[i];
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(null);
} 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();
// マスタを登録(内部でキャッシュ参照に変換される)
newTm.addMaster(date, outMaster);
// 現在時刻で不要なマスタを削除
newTm.clear();
synchronized (this.mMaster) {
this.mMaster.put(bfname, newTm);
}
}
}
use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker in project nimbus by nimbus-org.
the class DefaultBeanFlowInvokerFactoryServiceTest method testCreateFlow.
/**
* DefaultBeanFlowInvokerFactoryService#createFlow()を検査する。
*/
public void testCreateFlow() {
try {
ServiceManagerFactory.loadManager(SERVICE_DEFINITION_FILE_PATH);
BeanFlowInvokerFactory beanFlowInvokerFactory = (BeanFlowInvokerFactory) ServiceManagerFactory.getServiceObject(SERVICE_MANAGER_NAME, SERVICE_NAME);
BeanFlowInvoker beanFlowInvoker = beanFlowInvokerFactory.createFlow(BEANFLOW_NAME);
assertEquals(beanFlowInvoker.invokeFlow(null), new Integer(1));
} catch (Exception e) {
e.printStackTrace();
fail();
} finally {
ServiceManagerFactory.unloadManager(SERVICE_DEFINITION_FILE_PATH);
}
}
use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker in project nimbus by nimbus-org.
the class BeanFlowRestServerService method processExecute.
protected boolean processExecute(RestRequest request, RestResponse response, List paths, ResourceMetaData resource, String methodPostfix) throws Exception {
final String flowName = resource.resourcePath.path + methodPostfix;
if (!beanFlowInvokerFactory.containsFlow(flowName)) {
getLogger().write("BFRS_00021", new Object[] { resource.resourcePath.path, flowName });
response.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return false;
}
if (journal != null) {
journal.addInfo(JOURNAL_KEY_FLOW, flowName);
}
BeanFlowInvoker flow = null;
try {
flow = beanFlowInvokerFactory.createFlow(flowName);
} catch (Exception e) {
getLogger().write("BFRS_00022", new Object[] { resource.resourcePath.path, flowName }, e);
if (journal != null) {
journal.addInfo(JOURNAL_KEY_EXCEPTION, e);
}
response.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return false;
}
try {
flow.invokeFlow(new RestContext(request, response));
return true;
} catch (Throwable th) {
getLogger().write("BFRS_00023", new Object[] { resource.resourcePath.path, flowName }, th);
if (journal != null) {
journal.addInfo(JOURNAL_KEY_EXCEPTION, th);
}
response.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return false;
}
}
use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker in project nimbus by nimbus-org.
the class BeanFlowRestServerService method processValidateRequestObject.
protected boolean processValidateRequestObject(RestRequest request, RestResponse response, List paths, ResourceMetaData resource) throws Exception {
if (journal != null) {
journal.addInfo(JOURNAL_KEY_REQUEST_OBJECT, request.getRequestObject());
}
final String flowName = validateFlowPrefix + resource.resourcePath.path;
if (!beanFlowInvokerFactory.containsFlow(flowName)) {
return true;
}
if (journal != null) {
journal.addInfo(JOURNAL_KEY_VALIDATE_FLOW, flowName);
}
BeanFlowInvoker flow = null;
try {
flow = beanFlowInvokerFactory.createFlow(flowName);
} catch (Exception e) {
getLogger().write("BFRS_00019", new Object[] { resource.resourcePath.path, flowName }, e);
if (journal != null) {
journal.addInfo(JOURNAL_KEY_EXCEPTION, e);
}
response.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return false;
}
try {
final Object ret = flow.invokeFlow(new RestContext(request, response));
boolean result = false;
if (ret != null && ret instanceof Boolean) {
result = ((Boolean) ret).booleanValue();
}
if (!result) {
response.setResult(HttpServletResponse.SC_BAD_REQUEST);
}
return result;
} catch (Throwable th) {
getLogger().write("BFRS_00020", new Object[] { resource.resourcePath.path, flowName }, th);
if (journal != null) {
journal.addInfo(JOURNAL_KEY_EXCEPTION, th);
}
response.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return false;
}
}
Aggregations