18 package org.turro.scheduler.entities;
21 import java.io.IOException;
22 import java.io.OutputStreamWriter;
23 import java.util.HashSet;
24 import java.util.List;
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.impl.util.FileUtil;
43 public static final String
47 Document doc =
new Document(
new Element(
"elephant-entities"));
48 saveXML(doc.getRootElement(),
set);
52 Format fm = Format.getPrettyFormat();
54 XMLOutputter xo =
new XMLOutputter(fm);
57 }
catch (IOException ex) {
63 SAXBuilder builder =
new SAXBuilder();
67 if(confFile.exists()) {
68 doc = builder.build(confFile);
69 readXML(doc.getRootElement(),
set);
71 }
catch (IOException ex) {
73 }
catch (JDOMException ex) {
78 private static void readXML(Element rootElement, Set
set) {
79 for(Element el : (List<Element>) rootElement.getChildren(
"scheduled-entity")) {
86 private static void saveXML(Element rootElement, Set
set) {
87 for(Object st :
set) {
88 ((ScheduledEntity) st).writeXML(rootElement);
95 ses.doAddEntity(scheduledEntity);
102 ses.remove(scheduledEntity);
110 if(se.getEntityPath().equals(path)) {
118 remove(scheduledEntity);
119 add(scheduledEntity);
static String getRealPath(String path)
static String logMsg(String msg)
static String getEncoding()
static OutputStreamWriter getFileWriter(String folder, String file)
static void addEntity(ScheduledEntity scheduledEntity)
static final String SCHEDULER_FILE
static ScheduledEntity getScheduledEntity(String path)
static void saveSet(Set set)
static void loadSet(Set set)
static void removeEntity(ScheduledEntity scheduledEntity)