use of org.kie.workbench.common.services.shared.kmodule.FileLogger in project kie-wb-common by kiegroup.
the class FileLoggerConverter method marshal.
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
FileLogger logger = (FileLogger) value;
writer.addAttribute("name", logger.getName());
writer.addAttribute("file", logger.getFile());
writer.addAttribute("threaded", Boolean.toString(logger.isThreaded()));
writer.addAttribute("interval", Integer.toString(logger.getInterval()));
}
use of org.kie.workbench.common.services.shared.kmodule.FileLogger in project kie-wb-common by kiegroup.
the class FileLoggerConverter method unmarshal.
public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) {
final FileLogger logger = new FileLogger();
logger.setName(reader.getAttribute("name"));
logger.setFile(reader.getAttribute("file"));
logger.setThreaded(Boolean.parseBoolean(reader.getAttribute("threaded")));
logger.setInterval(Integer.parseInt(reader.getAttribute("interval")));
return logger;
}
use of org.kie.workbench.common.services.shared.kmodule.FileLogger in project kie-wb-common by kiegroup.
the class KSessionConverter method unmarshal.
public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) {
final KSessionModel kSession = new KSessionModel();
kSession.setName(reader.getAttribute("name"));
kSession.setDefault("true".equals(reader.getAttribute("default")));
String kSessionType = reader.getAttribute("type");
kSession.setType(kSessionType != null ? kSessionType : "stateful");
String clockType = reader.getAttribute("clockType");
if (clockType != null) {
kSession.setClockType(ClockTypeOption.get(clockType));
}
String scope = reader.getAttribute("scope");
if (scope != null) {
kSession.setScope(scope);
}
readNodes(reader, new AbstractXStreamConverter.NodeReader() {
public void onNode(HierarchicalStreamReader reader, String name, String value) {
if ("listeners".equals(name)) {
while (reader.hasMoreChildren()) {
reader.moveDown();
kSession.getListeners().add(readObject(reader, context, ListenerModel.class));
reader.moveUp();
}
} else if ("workItemHandlers".equals(name)) {
kSession.getWorkItemHandelerModels().addAll(readObjectList(reader, context, WorkItemHandlerModel.class));
} else if ("consoleLogger".equals(name)) {
kSession.setLogger(readObject(reader, context, ConsoleLogger.class));
} else if ("fileLogger".equals(name)) {
kSession.setLogger(readObject(reader, context, FileLogger.class));
}
}
});
return kSession;
}
use of org.kie.workbench.common.services.shared.kmodule.FileLogger 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();
}
}
use of org.kie.workbench.common.services.shared.kmodule.FileLogger in project kie-wb-common by kiegroup.
the class KModuleContentHandlerTest method testBasic.
@Test
public void testBasic() throws Exception {
final KModuleContentHandler kModuleContentHandler = new KModuleContentHandler();
final KModuleModel model = kModuleContentHandler.toModel(readResource("simpleKModule.xml"));
assertNotNull(model);
assertEquals(1, model.getKBases().size());
final KBaseModel kBaseModel = model.getKBases().get("org.kie.example1");
assertNotNull(kBaseModel);
assertEquals(1, kBaseModel.getKSessions().size());
final KSessionModel kSessionModel = kBaseModel.getKSessions().get(0);
assertEquals("ksession1", kSessionModel.getName());
assertEquals("stateful", kSessionModel.getType());
assertTrue(kSessionModel.isDefault());
assertEquals(ClockTypeOption.REALTIME, kSessionModel.getClockType());
assertTrue(kSessionModel.getLogger() instanceof FileLogger);
final FileLogger logger = (FileLogger) kSessionModel.getLogger();
assertEquals("response-builder_filelogger", logger.getName());
assertEquals("/tmp/response-builder_filelogger.log", logger.getFile());
assertTrue(logger.isThreaded());
assertEquals(1500, logger.getInterval());
final String xml = kModuleContentHandler.toString(model);
assertTrue(xml.contains("<kbase name=\"org.kie.example1\" default=\"false\" eventProcessingMode=\"stream\" equalsBehavior=\"identity\">"));
assertTrue(xml.contains("<ksession name=\"ksession1\" type=\"stateful\" default=\"true\" clockType=\"realtime\">"));
assertTrue(xml.contains("<fileLogger name=\"response-builder_filelogger\" file=\"/tmp/response-builder_filelogger.log\" threaded=\"true\" interval=\"1500\"/>"));
}
Aggregations