Exemplo n.º 1
0
  TaskArtifactStateRepository createTaskArtifactStateRepository(
      Instantiator instantiator,
      TaskArtifactStateCacheAccess cacheAccess,
      StartParameter startParameter,
      FileSnapshotter fileSnapshotter,
      StringInterner stringInterner,
      FileResolver fileResolver,
      FileSystem fileSystem,
      FileCollectionFactory fileCollectionFactory,
      CachingTreeVisitor treeVisitor,
      TreeSnapshotRepository treeSnapshotRepository,
      ClassLoaderHierarchyHasher classLoaderHierarchyHasher) {
    FileCollectionSnapshotter fileCollectionSnapshotter =
        new DefaultFileCollectionSnapshotter(
            fileSnapshotter,
            cacheAccess,
            stringInterner,
            fileResolver,
            treeVisitor,
            treeSnapshotRepository);
    FileCollectionSnapshotter discoveredFileCollectionSnapshotter =
        new MinimalFileSetSnapshotter(
            fileSnapshotter, cacheAccess, stringInterner, fileResolver, fileSystem);

    OutputFilesCollectionSnapshotter outputFilesSnapshotter =
        new OutputFilesCollectionSnapshotter(fileCollectionSnapshotter, stringInterner);

    SerializerRegistry serializerRegistry = new DefaultSerializerRegistry();
    fileCollectionSnapshotter.registerSerializers(serializerRegistry);
    outputFilesSnapshotter.registerSerializers(serializerRegistry);
    discoveredFileCollectionSnapshotter.registerSerializers(serializerRegistry);

    TaskHistoryRepository taskHistoryRepository =
        new CacheBackedTaskHistoryRepository(
            cacheAccess,
            new CacheBackedFileSnapshotRepository(
                cacheAccess,
                serializerRegistry.build(FileCollectionSnapshot.class),
                new RandomLongIdGenerator(),
                treeSnapshotRepository),
            stringInterner);

    return new ShortCircuitTaskArtifactStateRepository(
        startParameter,
        instantiator,
        new DefaultTaskArtifactStateRepository(
            taskHistoryRepository,
            instantiator,
            outputFilesSnapshotter,
            fileCollectionSnapshotter,
            discoveredFileCollectionSnapshotter,
            fileCollectionFactory,
            classLoaderHierarchyHasher));
  }
 public void registerSerializers(SerializerRegistry registry) {
   DefaultSerializerRegistry nested = new DefaultSerializerRegistry();
   snapshotter.registerSerializers(nested);
   registry.register(
       OutputFilesCollectionSnapshot.class,
       new OutputFilesCollectionSnapshot.SerializerImpl(
           nested.build(FileCollectionSnapshot.class), stringInterner));
 }