1 13 package org.ejbca.core.model.services; 14 15 import java.io.Serializable ; 16 import java.util.Date ; 17 import java.util.HashMap ; 18 import java.util.Iterator ; 19 import java.util.Properties ; 20 21 import org.ejbca.core.model.UpgradeableDataHashMap; 22 23 31 public class ServiceConfiguration extends UpgradeableDataHashMap implements Serializable , Cloneable { 32 33 private static final float LATEST_VERSION = 1; 34 35 private static final String INTERVALCLASSPATH = "INTERVALCLASSPATH"; 36 private static final String INTERVALPROPERTIES = "INTERVALPROPERTIES"; 37 private static final String WORKERCLASSPATH = "WORKERCLASSPATH"; 38 private static final String WORKERPROPERTIES = "WORKERPROPERTIES"; 39 private static final String ACTIONCLASSPATH = "ACTIONCLASSPATH"; 40 private static final String ACTIONPROPERTIES = "ACTIONPROPERTIES"; 41 private static final String DESCRIPTION = "DESCRIPTION"; 42 private static final String ACTIVE = "ACTIVE"; 43 private static final String NEXTRUNTIMESTAMP = "NEXTRUNTIMESTAMP"; 44 45 48 public ServiceConfiguration(){ 49 setActive(false); 50 setDescription(""); 51 setActionClassPath(""); 52 setActionProperties(new Properties ()); 53 setWorkerClassPath(""); 54 setWorkerProperties(new Properties ()); 55 setIntervalClassPath(""); 56 setIntervalProperties(new Properties ()); 57 setNextRunTimestamp(new Date (0)); 58 } 59 60 61 64 public String getActionClassPath() { 65 return (String ) data.get(ACTIONCLASSPATH); 66 } 67 68 71 public void setActionClassPath(String actionClassPath) { 72 data.put(ACTIONCLASSPATH,actionClassPath); 73 } 74 75 78 public Properties getActionProperties() { 79 return (Properties ) data.get(ACTIONPROPERTIES); 80 } 81 82 85 public void setActionProperties(Properties actionProperties) { 86 data.put(ACTIONPROPERTIES, actionProperties); 87 } 88 89 92 public boolean isActive() { 93 return ((Boolean ) data.get(ACTIVE)).booleanValue(); 94 } 95 96 99 public void setActive(boolean active) { 100 data.put(ACTIVE, new Boolean (active)); 101 } 102 103 109 public Date getNextRunTimestamp() { 110 if(data.get(NEXTRUNTIMESTAMP) == null){ 111 return new Date (0); 112 } 113 114 return new Date (((Long ) data.get(NEXTRUNTIMESTAMP)).longValue()); 115 } 116 117 120 public void setNextRunTimestamp(Date nextRunTimeStamp) { 121 data.put(NEXTRUNTIMESTAMP, new Long (nextRunTimeStamp.getTime())); 122 } 123 124 127 public String getDescription() { 128 return (String ) data.get(DESCRIPTION); 129 } 130 131 134 public void setDescription(String description) { 135 data.put(DESCRIPTION, description); 136 } 137 138 141 public String getIntervalClassPath() { 142 return (String ) data.get(INTERVALCLASSPATH); 143 } 144 145 148 public void setIntervalClassPath(String intervalClassPath) { 149 data.put(INTERVALCLASSPATH,intervalClassPath); 150 } 151 152 155 public Properties getIntervalProperties() { 156 return (Properties ) data.get(INTERVALPROPERTIES); 157 } 158 159 162 public void setIntervalProperties(Properties intervalProperties) { 163 data.put(INTERVALPROPERTIES, intervalProperties); 164 } 165 166 169 public String getWorkerClassPath() { 170 return (String ) data.get(WORKERCLASSPATH); 171 } 172 173 176 public void setWorkerClassPath(String workerClassPath) { 177 data.put(WORKERCLASSPATH,workerClassPath); 178 } 179 180 183 public Properties getWorkerProperties() { 184 return (Properties ) data.get(WORKERPROPERTIES); 185 } 186 187 190 public void setWorkerProperties(Properties workerProperties) { 191 data.put(WORKERPROPERTIES, workerProperties); 192 } 193 194 public float getLatestVersion() { 195 return LATEST_VERSION; 196 } 197 198 public void upgrade() { 199 if(getVersion() != LATEST_VERSION){ 200 201 } 202 } 203 204 public Object clone() throws CloneNotSupportedException { 205 ServiceConfiguration clone = new ServiceConfiguration(); 206 HashMap clonedata = (HashMap ) clone.saveData(); 207 208 Iterator i = (data.keySet()).iterator(); 209 while(i.hasNext()){ 210 Object key = i.next(); 211 clonedata.put(key, data.get(key)); 212 } 213 214 clone.loadData(clonedata); 215 return clone; 216 } 217 218 219 220 } 221 | Popular Tags |