/** * Gets the wrapped KieSession identifier. * @return the id */ public Long getSessionIdentifier() { return Long.valueOf(getKieSession().getIdentifier()); }
/** * {@inheritDoc} */ @Override public void disposeRuntimeEngine(RuntimeEngine runtime) { if (runtime instanceof KnowledgeRuntimeEngine) { runtime = ((KnowledgeRuntimeEngine)runtime).getWrapped(); } _runtimeManager.disposeRuntimeEngine(runtime); }
/** * Gets the global variables from the knowledge runtime engine. * @param runtimeEngine the knowledge runtime engine * @return the global variables */ protected Map<String, Object> getGlobalVariables(KnowledgeRuntimeEngine runtimeEngine) { Map<String, Object> globalVariables = new HashMap<String, Object>(); if (runtimeEngine != null) { Globals globals = runtimeEngine.getSessionGlobals(); if (globals != null) { for (String key : globals.getGlobalKeys()) { Object value = globals.get(key); globalVariables.put(key, value); } } } return globalVariables; }
/** * Gets the wrapped globals. * @return the globals */ public Globals getSessionGlobals() { return isRemote() ? null : getKieSession().getGlobals(); }
KieSession session = runtime.getKieSession(); if (_fireUntilHaltThread == null && runtime.getWrapped() instanceof Disposable) { ClassLoader fireUntilHaltLoader = Classes.getTCCL(); if (fireUntilHaltLoader == null) { ((Disposable) runtime.getWrapped()) .addDisposeListener(fireUntilHalt); _fireUntilHaltThread = fireUntilHalt.startThread();
private static Object filterRemoteDefaultInputContent(Object content, KnowledgeRuntimeEngine runtime) { if (runtime.isRemote() && content != null && content.getClass().getAnnotation(XmlType.class) == null) { content = null; } return content; }
/** * {@inheritDoc} */ @Override public RuntimeEngine getRuntimeEngine(Context<?> context) { KnowledgeRuntimeEngine runtimeEngine; if (context == null || _type != KnowledgeRuntimeManagerType.PER_PROCESS_INSTANCE) { context = EmptyContext.get(); } final ClassLoader origTCCL = Classes.setTCCL(_classLoader); try { RuntimeEngine wrapped = _runtimeManager.getRuntimeEngine(context); initRuntimeEngine(wrapped); runtimeEngine = new KnowledgeRuntimeEngine(wrapped, _persistent); } finally { Classes.setTCCL(origTCCL); } return runtimeEngine; }
/** * Gets the wrapped globals. * @return the globals */ public Globals getSessionGlobals() { return isRemote() ? null : getKieSession().getGlobals(); }
private static Object filterRemoteDefaultInputContent(Object content, KnowledgeRuntimeEngine runtime) { if (runtime.isRemote() && content != null && content.getClass().getAnnotation(XmlType.class) == null) { content = null; } return content; }
/** * {@inheritDoc} */ @Override public RuntimeEngine getRuntimeEngine(Context<?> context) { KnowledgeRuntimeEngine runtimeEngine; if (context == null || _type != KnowledgeRuntimeManagerType.PER_PROCESS_INSTANCE) { context = EmptyContext.get(); } final ClassLoader origTCCL = Classes.setTCCL(_classLoader); try { RuntimeEngine wrapped = _runtimeManager.getRuntimeEngine(context); initRuntimeEngine(wrapped); runtimeEngine = new KnowledgeRuntimeEngine(wrapped, _persistent); } finally { Classes.setTCCL(origTCCL); } return runtimeEngine; }
/** * Gets the wrapped KieSession identifier. * @return the id */ public Long getSessionIdentifier() { return Long.valueOf(getKieSession().getIdentifier()); }
/** * {@inheritDoc} */ @Override public void disposeRuntimeEngine(RuntimeEngine runtime) { if (runtime instanceof KnowledgeRuntimeEngine) { runtime = ((KnowledgeRuntimeEngine)runtime).getWrapped(); } _runtimeManager.disposeRuntimeEngine(runtime); }
/** * Gets the global variables from the knowledge runtime engine. * @param runtimeEngine the knowledge runtime engine * @return the global variables */ protected Map<String, Object> getGlobalVariables(KnowledgeRuntimeEngine runtimeEngine) { Map<String, Object> globalVariables = new HashMap<String, Object>(); if (runtimeEngine != null) { Globals globals = runtimeEngine.getSessionGlobals(); if (globals != null) { for (String key : globals.getGlobalKeys()) { Object value = globals.get(key); globalVariables.put(key, value); } } } return globalVariables; }
private Long getProcessInstanceId(CorrelationKey correlationKey, KnowledgeRuntimeEngine session) { if (correlationKey != null) { ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)session.getKieSession()).getProcessInstance(correlationKey); if (processInstance != null) { return Long.valueOf(processInstance.getId()); } } return null; }
/** * Sets the globals. * @param message the message * @param operation the operation * @param runtime the runtime engine * @param singleton singleton */ public static void setGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime, boolean singleton) { Globals globals = runtime.getSessionGlobals(); if (globals != null) { Map<String, Object> globalsMap = new HashMap<String, Object>(); globalsMap.put(GLOBALS, new ConcurrentHashMap<String, Object>()); Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null); if (expressionMap != null) { globalsMap.putAll(expressionMap); } for (Entry<String, Object> globalsEntry : globalsMap.entrySet()) { if (!singleton) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } else { if (globals.get(globalsEntry.getKey()) == null || (globalsEntry.getValue() != null && (globalsEntry .getValue() instanceof Map && !((Map) globalsEntry .getValue()).isEmpty()))) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } } } } }
private Long getProcessInstanceId(CorrelationKey correlationKey, KnowledgeRuntimeEngine session) { if (correlationKey != null) { ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)session.getKieSession()).getProcessInstance(correlationKey); if (processInstance != null) { return Long.valueOf(processInstance.getId()); } } return null; }
/** * Sets the globals. * @param message the message * @param operation the operation * @param runtime the runtime engine * @param singleton singleton */ public static void setGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime, boolean singleton) { Globals globals = runtime.getSessionGlobals(); if (globals != null) { Map<String, Object> globalsMap = new HashMap<String, Object>(); globalsMap.put(GLOBALS, new ConcurrentHashMap<String, Object>()); Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null); if (expressionMap != null) { globalsMap.putAll(expressionMap); } for (Entry<String, Object> globalsEntry : globalsMap.entrySet()) { if (!singleton) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } else { if (globals.get(globalsEntry.getKey()) == null || (globalsEntry.getValue() != null && (globalsEntry .getValue() instanceof Map && !((Map) globalsEntry .getValue()).isEmpty()))) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } } } } }
private Long getProcessInstanceId(CorrelationKey correlationKey, KnowledgeRuntimeEngine session) { if (correlationKey != null) { ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)session.getKieSession()).getProcessInstance(correlationKey); if (processInstance != null) { return Long.valueOf(processInstance.getId()); } } return null; }
@Override public void run() { ClassLoader originalLoader = Classes.setTCCL(_loader); try { _runtime.getKieSession().fireUntilHalt(); } finally { try { _handler.disposeSingletonRuntimeEngine(); } finally { Classes.setTCCL(originalLoader); } } }
private int fireAllRules(Message inputMessage, KnowledgeOperation operation) { KnowledgeRuntimeEngine runtime = getSingletonRuntimeEngine(); RulesOperationType operationType = (RulesOperationType) operation .getType(); // sessionIdentifier = runtime.getSessionIdentifier(); setGlobals(inputMessage, operation, runtime, true); KieSession session = runtime.getKieSession(); List<Object> facts = getInputList(inputMessage, operation, runtime); for (Object fact : facts) { session.insert(fact); } if (RulesOperationType.FIRE_ALL_RULES.equals(operationType)) { return session.fireAllRules(); } return 0; }