1
2
3
4
5
6
7 package gov.bnl.gums.persistence;
8
9 import gov.bnl.gums.configuration.Configuration;
10 import gov.bnl.gums.db.AccountPoolMapperDB;
11 import gov.bnl.gums.db.ManualAccountMapperDB;
12 import gov.bnl.gums.db.ManualUserGroupDB;
13 import gov.bnl.gums.db.UserGroupDB;
14 import gov.bnl.gums.db.ConfigurationDB;
15
16 import java.lang.ref.SoftReference;
17 import java.util.Properties;
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 public abstract class PersistenceFactory {
33
34
35
36 static public String getTypeStatic() {
37 return "abstract";
38 }
39
40 private String name = "";
41 private boolean storeConfig = false;
42 private String description = "";
43 private Properties properties;
44 private SoftReference configurationRef;
45
46
47
48
49 public PersistenceFactory() {
50 }
51
52
53
54
55
56
57 public PersistenceFactory(Configuration configuration) {
58 this.configurationRef = new SoftReference(configuration);
59 }
60
61
62
63
64
65
66
67 public PersistenceFactory(Configuration configuration, String name) {
68 this.name = name;
69 this.configurationRef = new SoftReference(configuration);
70 }
71
72
73
74
75
76
77
78 public abstract PersistenceFactory clone(Configuration configuration);
79
80
81
82
83
84
85 public Configuration getConfiguration() {
86 if (configurationRef==null)
87 return null;
88 return (Configuration)configurationRef.get();
89 }
90
91
92
93
94
95
96 public String getDescription() {
97 return description;
98 }
99
100
101
102
103
104
105 public String getName() {
106 return name;
107 }
108
109
110
111
112
113
114
115 public Properties getProperties() {
116 return properties;
117 }
118
119
120
121
122 public String getType() {
123 return "abstract";
124 }
125
126 public boolean getStoreConfig() {
127 return storeConfig;
128 }
129
130 public abstract AccountPoolMapperDB retrieveAccountPoolMapperDB(String name);
131
132 public abstract ConfigurationDB retrieveConfigurationDB();
133
134 public abstract ManualAccountMapperDB retrieveManualAccountMapperDB(String name);
135
136 public abstract ManualUserGroupDB retrieveManualUserGroupDB(String name);
137
138 public abstract UserGroupDB retrieveUserGroupDB(String name);
139
140
141
142
143
144
145 public void setConfiguration(Configuration configuration) {
146 this.configurationRef = new SoftReference(configuration);
147 }
148
149
150
151
152
153
154 public void setDescription(String description) {
155 this.description = description;
156 }
157
158
159
160
161
162
163 public void setName(String name) {
164 this.name = name;
165 }
166
167
168
169
170
171
172
173 public void setProperties(Properties properties) {
174 if (properties!=null && "net.sf.hibernate.dialect.MySQLDialect".equals(properties.get("mysql.hibernate.dialect")))
175 properties.setProperty("mysql.hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
176 if (properties!=null && "net.sf.hibernate.dialect.MySQLDialect".equals(properties.get("hibernate.dialect")))
177 properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
178 this.properties = properties;
179 }
180
181 public void setStoreConfig(boolean storeConfig) {
182 this.storeConfig = storeConfig;
183 }
184
185
186
187
188
189
190 public abstract String toXML();
191 }