* Avoid double-checked-locking using the Initialization-on-demand holder idiom.
*/
static final class ContextHolder {
static final FudgeContext INSTANCE = constructContext();
private static FudgeContext constructContext() {
FudgeContext fudgeContext = new FudgeContext();
ExtendedFudgeBuilderFactory.init(fudgeContext.getObjectDictionary());
InnerClassFudgeBuilderFactory.init(fudgeContext.getObjectDictionary());
// hack to handle non-existent classpath directory entries
List<UrlType> urlTypes = Lists.newArrayList(Vfs.getDefaultUrlTypes());
urlTypes.add(0, new OGFileUrlType());
Vfs.setDefaultURLTypes(urlTypes);
// init annotation reflector, which needs this class loader
Set<ClassLoader> loaders = new HashSet<>();
loaders.add(OpenGammaFudgeContext.class.getClassLoader());
try {
loaders.add(Thread.currentThread().getContextClassLoader());
} catch (Exception ex) {
// ignore
}
Configuration config = new ConfigurationBuilder()
.setUrls(ClasspathHelper.forManifest(ClasspathHelper.forJavaClassPath()))
.setScanners(new TypeAnnotationsScanner(), new FieldAnnotationsScanner(), new SubTypesScanner(false))
.filterInputsBy(FilterBuilder.parse(AnnotationReflector.DEFAULT_ANNOTATION_REFLECTOR_FILTER))
.addClassLoaders(loaders)
.useParallelExecutor();
AnnotationReflector.initDefaultReflector(new AnnotationReflector(config));
AnnotationReflector reflector = AnnotationReflector.getDefaultReflector();
fudgeContext.getObjectDictionary().addAllAnnotatedBuilders(reflector);
fudgeContext.getTypeDictionary().addAllAnnotatedSecondaryTypes(reflector);
FudgeTypeDictionary td = fudgeContext.getTypeDictionary();
td.registerClassRename("com.opengamma.util.timeseries.zoneddatetime.ArrayZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.timeseries.zoneddatetime.ArrayZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.util.timeseries.zoneddatetime.ListZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);
td.registerClassRename("com.opengamma.timeseries.zoneddatetime.ListZonedDateTimeDoubleTimeSeries", ImmutableZonedDateTimeDoubleTimeSeries.class);