18 package org.turro.scheduler.motor;
21 import java.io.IOException;
22 import java.io.OutputStreamWriter;
23 import java.util.List;
25 import java.util.TreeSet;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import org.jdom.Document;
29 import org.jdom.Element;
30 import org.jdom.JDOMException;
31 import org.jdom.input.SAXBuilder;
32 import org.jdom.output.Format;
33 import org.jdom.output.XMLOutputter;
34 import org.turro.elephant.context.ElephantContext;
35 import org.turro.elephant.context.IConstructor;
36 import org.turro.elephant.impl.context.ContextFactory;
37 import org.turro.elephant.impl.util.FileUtil;
38 import org.turro.reflection.Reflections;
47 public static final String
55 Document doc =
new Document(
new Element(
"elephant-scheduler"));
56 saveXML(doc.getRootElement(),
set);
60 Format fm = Format.getPrettyFormat();
62 XMLOutputter xo =
new XMLOutputter(fm);
65 }
catch (IOException ex) {
71 SAXBuilder builder =
new SAXBuilder();
75 if(confFile.exists()) {
76 doc = builder.build(confFile);
77 readXML(constructor, doc.getRootElement(),
set);
79 }
catch (IOException ex) {
81 }
catch (JDOMException ex) {
86 private static void readXML(
IConstructor constructor, Element rootElement, Set
set) {
87 for(Element el : (List<Element>) rootElement.getChildren(
"scheduled-task")) {
90 st = (
ScheduledTask) Reflections.of(el.getAttributeValue(
"implementation")).instance();
99 private static void saveXML(Element rootElement, Set
set) {
100 for(Object st :
set) {
101 ((ScheduledTask) st).writeXML(rootElement);
static String getRealPath(String path)
static String logMsg(String msg)
static String getEncoding()
static Object getImplementation(IElement iel, String name)
static OutputStreamWriter getFileWriter(String folder, String file)
static void saveSet(IConstructor constructor, Set set)
static final String SCHEDULER_FILE
static void loadSet(IConstructor constructor, Set set)