Skip to content

Commit 595a6b6

Browse files
authored
provide a full SchemaFactory singleton (#1473)
* provide a singleton full schema factory * privatize * lower lock
1 parent dfa6ac9 commit 595a6b6

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎common-tools/clas-io/src/main/java/org/jlab/utils/CLASResources.java‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
package org.jlab.utils;
22

3+
import org.jlab.jnp.hipo4.data.SchemaFactory;
4+
35
/**
46
*
57
* @author gavalian
68
* @author kenjo
79
*/
810
public class CLASResources {
9-
11+
12+
private static volatile SchemaFactory FULL_SCHEMA = null;
13+
14+
public static SchemaFactory getFullSchema() {
15+
synchronized (FULL_SCHEMA) {
16+
if (FULL_SCHEMA == null) {
17+
FULL_SCHEMA = new SchemaFactory();
18+
FULL_SCHEMA.initFromDirectory(getResourcePath("etc/bankdefs/hipo4"));
19+
}
20+
}
21+
SchemaFactory s = new SchemaFactory();
22+
s.copy(FULL_SCHEMA);
23+
return s;
24+
}
25+
1026
public static String getResourcePath(String resource){
1127
String CLAS12DIR = System.getenv("CLAS12DIR");
1228
String CLAS12DIRPROP = System.getProperty("CLAS12DIR");
@@ -44,4 +60,5 @@ public static String getEnvironmentVariable(String envvarname){
4460

4561
return null;
4662
}
63+
4764
}

0 commit comments

Comments
 (0)