| 1 | /** |
| 2 | * |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.sensorframework.dao.memory; |
| 5 | |
| 6 | import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory; |
| 7 | import de.uka.ipd.sdq.sensorframework.entities.dao.IExperimentDAO; |
| 8 | import de.uka.ipd.sdq.sensorframework.entities.dao.IExperimentRunDAO; |
| 9 | import de.uka.ipd.sdq.sensorframework.entities.dao.IMeasurementDAO; |
| 10 | import de.uka.ipd.sdq.sensorframework.entities.dao.ISensorDAO; |
| 11 | import de.uka.ipd.sdq.sensorframework.entities.dao.IStateDAO; |
| 12 | |
| 13 | /** |
| 14 | * @author Steffen Becker |
| 15 | * |
| 16 | */ |
| 17 | public class MemoryDAOFactory implements IDAOFactory { |
| 18 | |
| 19 | private IExperimentDAO experimentDAO; |
| 20 | private IExperimentRunDAO experimentRunDAO; |
| 21 | private IMeasurementDAO measurementDAO; |
| 22 | private ISensorDAO sensorDAO; |
| 23 | private IStateDAO stateDAO; |
| 24 | private long id; |
| 25 | |
| 26 | public MemoryDAOFactory(long id) { |
| 27 | this.id = id; |
| 28 | } |
| 29 | |
| 30 | public MemoryDAOFactory(String config) { |
| 31 | this(IDAOFactory.ID_NOT_SET); |
| 32 | } |
| 33 | |
| 34 | /* (non-Javadoc) |
| 35 | * @see de.uka.ipd.sdq.sensorfactory.entities.dao.IDAOFactory#createExperimentDAO() |
| 36 | */ |
| 37 | public IExperimentDAO createExperimentDAO() { |
| 38 | if (this.experimentDAO == null) |
| 39 | this.experimentDAO = new MemoryExperimentDAO(this); |
| 40 | return this.experimentDAO; |
| 41 | } |
| 42 | |
| 43 | /* (non-Javadoc) |
| 44 | * @see de.uka.ipd.sdq.sensorfactory.entities.dao.IDAOFactory#createExperimentRunDAO() |
| 45 | */ |
| 46 | public IExperimentRunDAO createExperimentRunDAO() { |
| 47 | if (this.experimentRunDAO == null) |
| 48 | this.experimentRunDAO = new MemoryExperimentRunDAO(this); |
| 49 | return this.experimentRunDAO; |
| 50 | } |
| 51 | |
| 52 | /* (non-Javadoc) |
| 53 | * @see de.uka.ipd.sdq.sensorfactory.entities.dao.IDAOFactory#createMeasurementDAO() |
| 54 | */ |
| 55 | public IMeasurementDAO createMeasurementDAO() { |
| 56 | if (this.measurementDAO == null) |
| 57 | this.measurementDAO = new MemoryMeasurementDAO(this); |
| 58 | return this.measurementDAO; |
| 59 | } |
| 60 | |
| 61 | /* (non-Javadoc) |
| 62 | * @see de.uka.ipd.sdq.sensorfactory.entities.dao.IDAOFactory#createSensorDAO() |
| 63 | */ |
| 64 | public ISensorDAO createSensorDAO() { |
| 65 | if (this.sensorDAO == null) |
| 66 | this.sensorDAO = new MemorySensorDAO(this); |
| 67 | return this.sensorDAO; |
| 68 | } |
| 69 | |
| 70 | /* (non-Javadoc) |
| 71 | * @see de.uka.ipd.sdq.sensorfactory.entities.dao.IDAOFactory#createStateDAO() |
| 72 | */ |
| 73 | public IStateDAO createStateDAO() { |
| 74 | if (this.stateDAO == null) |
| 75 | this.stateDAO = new MemoryStateDAO(this); |
| 76 | return this.stateDAO; |
| 77 | } |
| 78 | |
| 79 | public String getDescription() { |
| 80 | return "A datasource stored in memory. Changes are lost, when unsafed"; |
| 81 | } |
| 82 | |
| 83 | public String getName() { |
| 84 | return "Memory Datasource"; |
| 85 | } |
| 86 | |
| 87 | public void finalizeAndClose() { |
| 88 | } |
| 89 | |
| 90 | public long getID() { |
| 91 | return this.id; |
| 92 | } |
| 93 | |
| 94 | public void setID(long i) { |
| 95 | this.id = i; |
| 96 | } |
| 97 | |
| 98 | public String getPersistendInfo() { |
| 99 | return ""; |
| 100 | } |
| 101 | |
| 102 | public void reload() { |
| 103 | // Nothing to do here |
| 104 | } |
| 105 | |
| 106 | public void store() { |
| 107 | // Nothing to do here |
| 108 | } |
| 109 | } |