Search in sources :

Example 1 with ConsoleLogger

use of org.kie.workbench.common.services.shared.kmodule.ConsoleLogger in project kie-wb-common by kiegroup.

the class KSessionConverter method marshal.

public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    KSessionModel kSession = (KSessionModel) value;
    writer.addAttribute("name", kSession.getName());
    writer.addAttribute("type", kSession.getType());
    writer.addAttribute("default", Boolean.toString(kSession.isDefault()));
    if (kSession.getClockType() != null) {
        writer.addAttribute("clockType", kSession.getClockType().getClockTypeAsString());
    }
    if (kSession.getScope() != null) {
        writer.addAttribute("scope", kSession.getScope().toString());
    }
    writeObjectList(writer, context, "workItemHandlers", "workItemHandler", kSession.getWorkItemHandelerModels());
    if (kSession.getLogger() instanceof ConsoleLogger) {
        writeObject(writer, context, "consoleLogger", kSession.getLogger());
    } else if (kSession.getLogger() instanceof FileLogger) {
        writeObject(writer, context, "fileLogger", kSession.getLogger());
    }
    if (!kSession.getListeners().isEmpty()) {
        writer.startNode("listeners");
        for (ListenerModel listener : kSession.getListeners()) {
            writeObject(writer, context, listener.getKind().toString(), listener);
        }
        writer.endNode();
    }
}
Also used : ListenerModel(org.kie.workbench.common.services.shared.kmodule.ListenerModel) ConsoleLogger(org.kie.workbench.common.services.shared.kmodule.ConsoleLogger) KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) FileLogger(org.kie.workbench.common.services.shared.kmodule.FileLogger)

Example 2 with ConsoleLogger

use of org.kie.workbench.common.services.shared.kmodule.ConsoleLogger in project kie-wb-common by kiegroup.

the class KModuleContentHandlerTest method testConsoleLogger.

@Test
public void testConsoleLogger() throws Exception {
    final KModuleContentHandler kModuleContentHandler = new KModuleContentHandler();
    final KModuleModel model = kModuleContentHandler.toModel(readResource("consoleLoggerKModule.xml"));
    assertNotNull(model);
    assertEquals(1, model.getKBases().size());
    final KBaseModel kBaseModel = model.getKBases().get("org.kie.example2");
    assertNotNull(kBaseModel);
    assertEquals(1, kBaseModel.getKSessions().size());
    final KSessionModel kSessionModel = kBaseModel.getKSessions().get(0);
    assertEquals("ksession2", kSessionModel.getName());
    assertEquals("stateless", kSessionModel.getType());
    assertFalse(kSessionModel.isDefault());
    assertEquals(ClockTypeOption.PSEUDO, kSessionModel.getClockType());
    assertTrue(kSessionModel.getLogger() instanceof ConsoleLogger);
    final String xml = kModuleContentHandler.toString(model);
    assertTrue(xml.contains("<kbase name=\"org.kie.example2\" default=\"false\" eventProcessingMode=\"stream\" equalsBehavior=\"identity\">"));
    assertTrue(xml.contains("<ksession name=\"ksession2\" type=\"stateless\" default=\"false\" clockType=\"pseudo\">"));
    assertTrue(xml.contains("<consoleLogger/>"));
}
Also used : ConsoleLogger(org.kie.workbench.common.services.shared.kmodule.ConsoleLogger) KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Aggregations

ConsoleLogger (org.kie.workbench.common.services.shared.kmodule.ConsoleLogger)2 KSessionModel (org.kie.workbench.common.services.shared.kmodule.KSessionModel)2 Test (org.junit.Test)1 FileLogger (org.kie.workbench.common.services.shared.kmodule.FileLogger)1 KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)1 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)1 ListenerModel (org.kie.workbench.common.services.shared.kmodule.ListenerModel)1