use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvokerFactory 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.BeanFlowInvokerFactory in project nimbus by nimbus-org.
the class DatabaseTimerScheduleFactoryService method createScheduleTask.
protected ScheduleTask createScheduleTask(String scheduleName, ResultSet rs) throws Exception {
final ServiceNameEditor serviceNameEditor = new ServiceNameEditor();
if (scheduleBeanFlowNamesQueryIndex > 0) {
final String beanFlowNames = rs.getString(scheduleBeanFlowNamesQueryIndex);
if (beanFlowNames != null && beanFlowNames.length() != 0) {
final StringArrayEditor stringArrayEditor = new StringArrayEditor();
stringArrayEditor.setAsText(beanFlowNames);
final String[] beanFlowNameArray = (String[]) stringArrayEditor.getValue();
FacadeCaller facadeCaller = null;
if (scheduleFacadeCallerServiceNameQueryIndex > 0) {
final String serviceNameStr = rs.getString(scheduleFacadeCallerServiceNameQueryIndex);
if (serviceNameStr != null) {
serviceNameEditor.setAsText(serviceNameStr);
facadeCaller = (FacadeCaller) ServiceManagerFactory.getServiceObject((ServiceName) serviceNameEditor.getValue());
}
}
if (facadeCaller == null) {
facadeCaller = scheduleFacadeCaller;
}
if (facadeCaller == null) {
throw new IllegalArgumentException("FacadeCaller is null : " + scheduleName);
}
String iocCallType = null;
if (scheduleIOCCallTypeQueryIndex > 0) {
iocCallType = rs.getString(scheduleIOCCallTypeQueryIndex);
}
final IOCCallScheduleTaskService iocCallTask = new IOCCallScheduleTaskService();
iocCallTask.setBeanFlowNames(beanFlowNameArray);
iocCallTask.setFacadeCaller(facadeCaller);
if (iocCallType != null) {
iocCallTask.setIOCCallType(iocCallType);
}
iocCallTask.create();
iocCallTask.start();
return iocCallTask;
}
}
if (scheduleBeanFlowNameQueryIndex > 0) {
final String beanFlowName = rs.getString(scheduleBeanFlowNameQueryIndex);
if (beanFlowName != null && beanFlowName.length() != 0) {
BeanFlowInvokerFactory beanFlowInvokerFactory = null;
if (scheduleBeanFlowInvokerFactoryServiceNameQueryIndex > 0) {
final String serviceNameStr = rs.getString(scheduleBeanFlowInvokerFactoryServiceNameQueryIndex);
if (serviceNameStr != null) {
serviceNameEditor.setAsText(serviceNameStr);
beanFlowInvokerFactory = (BeanFlowInvokerFactory) ServiceManagerFactory.getServiceObject((ServiceName) serviceNameEditor.getValue());
}
}
if (beanFlowInvokerFactory == null) {
beanFlowInvokerFactory = scheduleBeanFlowInvokerFactory;
}
if (beanFlowInvokerFactory == null) {
throw new IllegalArgumentException("BeanFlowInvokerFactory is null : " + scheduleName);
}
final BeanFlowCallScheduleTaskService beanFlowTask = new BeanFlowCallScheduleTaskService();
beanFlowTask.setBeanFlowName(beanFlowName);
beanFlowTask.setBeanFlowInvokerFactory(beanFlowInvokerFactory);
beanFlowTask.create();
beanFlowTask.start();
return beanFlowTask;
}
}
if (scheduleTaskServiceNameQueryIndex > 0) {
final String scheduleTaskServiceNameStr = rs.getString(scheduleTaskServiceNameQueryIndex);
if (scheduleTaskServiceNameStr != null) {
serviceNameEditor.setAsText(scheduleTaskServiceNameStr);
return (ScheduleTask) ServiceManagerFactory.getServiceObject((ServiceName) serviceNameEditor.getValue());
}
}
throw new IllegalArgumentException("Task is null : " + scheduleName);
}
use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvokerFactory in project nimbus by nimbus-org.
the class DefaultBeanFlowInvokerFactoryServiceTest method testCreateFlow_DI.
/**
* DefaultBeanFlowInvokerFactoryService#createFlow()を検査する。
* DI形式によるサービス定義を読み込む。
*/
public void testCreateFlow_DI() {
try {
ServiceManagerFactory.loadManager(SERVICE_DEFINITION_FILE_PATH);
BeanFlowInvokerFactory beanFlowInvokerFactory = (BeanFlowInvokerFactory) ServiceManagerFactory.getServiceObject(SERVICE_MANAGER_NAME, SERVICE_NAME_DI);
BeanFlowInvoker beanFlowInvoker = beanFlowInvokerFactory.createFlow(BEANFLOW_NAME);
beanFlowInvoker.invokeFlow(null);
} catch (Exception e) {
e.printStackTrace();
fail();
} finally {
ServiceManagerFactory.unloadManager(SERVICE_DEFINITION_FILE_PATH);
}
}
use of jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvokerFactory in project nimbus by nimbus-org.
the class BeanFlowServlet method doService.
/**
* 検証BeanFlow及びアクションBeanFlowの呼び出しを制御する。<p>
*
* @param req HTTPリクエスト
* @param resp HTTPレスポンス
* @exception ServletException
* @exception IOException
*/
protected void doService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String flowName = processSelectBeanFlow(req, resp);
if (flowName == null || flowName.length() == 0) {
handleNotFound(req, resp, flowName);
return;
}
final BeanFlowInvokerFactory beanFlowInvokerFactory = (BeanFlowInvokerFactory) ServiceManagerFactory.getServiceObject(beanFlowInvokerFactoryServiceName);
if (!beanFlowInvokerFactory.containsFlow(flowName)) {
handleNotFound(req, resp, flowName);
return;
}
Journal journal = null;
EditorFinder editorFinder = null;
EditorFinder validateEditorFinder = null;
EditorFinder actionEditorFinder = null;
String requestId = null;
if (journalServiceName != null) {
journal = (Journal) ServiceManagerFactory.getServiceObject(journalServiceName);
if (editorFinderServiceName != null) {
editorFinder = (EditorFinder) ServiceManagerFactory.getServiceObject(editorFinderServiceName);
}
if (validateEditorFinderServiceName != null) {
validateEditorFinder = (EditorFinder) ServiceManagerFactory.getServiceObject(validateEditorFinderServiceName);
}
if (actionEditorFinderServiceName != null) {
actionEditorFinder = (EditorFinder) ServiceManagerFactory.getServiceObject(actionEditorFinderServiceName);
}
if (contextServiceName != null) {
Context context = (Context) ServiceManagerFactory.getServiceObject(contextServiceName);
requestId = (String) context.get(ThreadContextKey.REQUEST_ID);
}
}
try {
if (journal != null) {
journal.startJournal(JOURNAL_KEY_PROCESS, editorFinder);
if (requestId != null) {
journal.setRequestId(requestId);
}
}
final BeanFlowServletContext context = new BeanFlowServletContext(req, resp, req.getAttribute(inputAttributeName));
if (validateFlowPrefix != null && isValidate) {
final String validateFlowName = validateFlowPrefix + flowName;
if (beanFlowInvokerFactory.containsFlow(validateFlowName)) {
final BeanFlowInvoker validateFlow = beanFlowInvokerFactory.createFlow(validateFlowName);
try {
if (journal != null) {
journal.addStartStep(JOURNAL_KEY_VALIDATE, validateEditorFinder);
journal.addInfo(JOURNAL_KEY_FLOW_NAME, validateFlowName);
}
if (!processValidate(req, resp, context, validateFlow, journal)) {
if (!handleValidateError(req, resp, context, journal)) {
return;
}
}
} finally {
if (journal != null) {
journal.addEndStep();
}
}
}
}
final BeanFlowInvoker flow = beanFlowInvokerFactory.createFlow(flowName);
try {
if (journal != null) {
journal.addStartStep(JOURNAL_KEY_ACTION, actionEditorFinder);
journal.addInfo(JOURNAL_KEY_FLOW_NAME, flowName);
}
processAction(req, resp, context, flow, journal);
} finally {
if (journal != null) {
journal.addEndStep();
}
}
} finally {
if (journal != null) {
journal.endJournal();
}
}
}
Aggregations