Beispiel #1
0
    public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
      KieSessionModelImpl kSession = (KieSessionModelImpl) value;
      writer.addAttribute("name", kSession.getName());
      writer.addAttribute("type", kSession.getType().toString().toLowerCase());
      writer.addAttribute("default", Boolean.toString(kSession.isDefault()));
      if (kSession.getClockType() != null) {
        writer.addAttribute("clockType", kSession.getClockType().getClockType());
      }
      if (kSession.getBeliefSystem() != null) {
        writer.addAttribute(
            "beliefSystem", kSession.getBeliefSystem().getBeliefSystemType().toLowerCase());
      }
      if (kSession.getScope() != null) {
        writer.addAttribute("scope", kSession.getScope());
      }
      if (kSession.getConsoleLogger() != null) {
        writer.startNode("consoleLogger");
        if (kSession.getConsoleLogger().length() > 0) {
          writer.addAttribute("name", kSession.getConsoleLogger());
        }
        writer.endNode();
      }
      if (kSession.getFileLogger() != null) {
        writer.startNode("fileLogger");
        writer.addAttribute("file", kSession.getFileLogger().getFile());
        writer.addAttribute("threaded", "" + kSession.getFileLogger().isThreaded());
        writer.addAttribute("interval", "" + kSession.getFileLogger().getInterval());
        writer.endNode();
      }

      writeObjectList(
          writer,
          context,
          "workItemHandlers",
          "workItemHandler",
          kSession.getWorkItemHandlerModels());

      if (!kSession.getListenerModels().isEmpty()) {
        writer.startNode("listeners");
        for (ListenerModel listener :
            kSession.getListenerModels(ListenerModel.Kind.RULE_RUNTIME_EVENT_LISTENER)) {
          writeObject(writer, context, listener.getKind().toString(), listener);
        }
        for (ListenerModel listener :
            kSession.getListenerModels(ListenerModel.Kind.AGENDA_EVENT_LISTENER)) {
          writeObject(writer, context, listener.getKind().toString(), listener);
        }
        for (ListenerModel listener :
            kSession.getListenerModels(ListenerModel.Kind.PROCESS_EVENT_LISTENER)) {
          writeObject(writer, context, listener.getKind().toString(), listener);
        }
        writer.endNode();
      }
    }
 private KieSessionConfiguration getKnowledgeSessionConfiguration(
     KieSessionModelImpl kSessionModel) {
   KieSessionConfiguration ksConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
   ksConf.setOption(kSessionModel.getClockType());
   ksConf.setOption(kSessionModel.getBeliefSystem());
   return ksConf;
 }