Search in sources :

Example 1 with BeanFlowInvoker

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;
}
Also used : BeanFlowInvoker(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker)

Example 2 with BeanFlowInvoker

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);
        }
    }
}
Also used : ServiceException(jp.ossc.nimbus.lang.ServiceException) BeanFlowInvoker(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker) ServiceException(jp.ossc.nimbus.lang.ServiceException)

Example 3 with BeanFlowInvoker

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);
    }
}
Also used : BeanFlowInvokerFactory(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvokerFactory) BeanFlowInvoker(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker)

Example 4 with BeanFlowInvoker

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;
    }
}
Also used : BeanFlowInvoker(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker) InvocationTargetException(java.lang.reflect.InvocationTargetException) DeploymentException(jp.ossc.nimbus.core.DeploymentException) ConvertException(jp.ossc.nimbus.util.converter.ConvertException) SAXException(org.xml.sax.SAXException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) NoSuchPropertyException(jp.ossc.nimbus.beans.NoSuchPropertyException)

Example 5 with BeanFlowInvoker

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;
    }
}
Also used : BeanFlowInvoker(jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker) InvocationTargetException(java.lang.reflect.InvocationTargetException) DeploymentException(jp.ossc.nimbus.core.DeploymentException) ConvertException(jp.ossc.nimbus.util.converter.ConvertException) SAXException(org.xml.sax.SAXException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) NoSuchPropertyException(jp.ossc.nimbus.beans.NoSuchPropertyException)

Aggregations

BeanFlowInvoker (jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvoker)13 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 NoSuchPropertyException (jp.ossc.nimbus.beans.NoSuchPropertyException)3 ServiceException (jp.ossc.nimbus.lang.ServiceException)3 BeanFlowInvokerFactory (jp.ossc.nimbus.service.beancontrol.interfaces.BeanFlowInvokerFactory)3 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 Date (java.util.Date)2 DeploymentException (jp.ossc.nimbus.core.DeploymentException)2 ConvertException (jp.ossc.nimbus.util.converter.ConvertException)2 SAXException (org.xml.sax.SAXException)2 SAXParseException (org.xml.sax.SAXParseException)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ServletRequest (javax.servlet.ServletRequest)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1