public static void registerUrlTypes() { final List<UrlType> urlTypes = new LinkedList<>(); urlTypes.add(new EmptyUrlType(ENDINGS)); urlTypes.addAll(Arrays.asList(Vfs.DefaultUrlTypes.values())); Vfs.setDefaultURLTypes(urlTypes); }
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 { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader != null) { loaders.add(loader); } } catch (Exception ex) { // ignore } int availableProcessors = Runtime.getRuntime().availableProcessors(); ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("Reflections-scan-%d").build(); ExecutorService executorService = Executors.newFixedThreadPool(availableProcessors, factory); try { 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) .setExecutorService(executorService); AnnotationReflector.initDefaultReflector(new AnnotationReflector(config)); AnnotationReflector reflector = AnnotationReflector.getDefaultReflector(); fudgeContext.getObjectDictionary().addAllAnnotatedBuilders(reflector); fudgeContext.getTypeDictionary().addAllAnnotatedSecondaryTypes(reflector); } finally { executorService.shutdown(); } 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); td.registerClassRename("com.opengamma.util.timeseries.localdate.ArrayLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class); td.registerClassRename("com.opengamma.timeseries.localdate.ArrayLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class); td.registerClassRename("com.opengamma.util.timeseries.localdate.ListLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class); td.registerClassRename("com.opengamma.timeseries.localdate.ListLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class); td.registerClassRename("com.opengamma.util.timeseries.localdate.MapLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class); td.registerClassRename("com.opengamma.timeseries.localdate.MapLocalDateDoubleTimeSeries", ImmutableLocalDateDoubleTimeSeries.class); td.registerClassRename("com.opengamma.id.Identifier", ExternalId.class); td.registerClassRename("com.opengamma.id.IdentifierBundleWithDates", ExternalIdBundleWithDates.class); td.registerClassRename("com.opengamma.id.IdentifierBundle", ExternalIdBundle.class); td.registerClassRename("com.opengamma.id.IdentifierWithDates", ExternalIdWithDates.class); td.registerClassRename("com.opengamma.id.ObjectIdentifier", ObjectId.class); td.registerClassRename("com.opengamma.id.UniqueIdentifier", UniqueId.class); return fudgeContext; }