@Override public void run(final TrellisConfiguration config, final Environment environment) throws IOException { // Partition data configuration final String dataLocation = config.getResources().getPath(); // Partition BaseURL configuration final String baseUrl = config.getBaseUrl(); final CuratorFramework curator = TrellisUtils.getCuratorClient(config); final Producer<String, String> producer = new KafkaProducer<>(getKafkaProperties(config)); final IdentifierService idService = new UUIDGenerator(); final ResourceService resourceService = new FileResourceService(dataLocation, baseUrl, curator, producer, new KafkaPublisher(producer, TOPIC_EVENT), idService.getSupplier(), config.getAsync()); final NamespaceService namespaceService = new Namespaces(curator, new TreeCache(curator, ZNODE_NAMESPACES), config.getNamespaces().getFile()); final BinaryService binaryService = new FileBasedBinaryService(config.getBinaries().getPath(), idService.getSupplier("file:", config.getBinaries().getLevels(), config.getBinaries().getLength())); // IO Service final CacheService<String, String> profileCache = new TrellisCache<>(newBuilder() .maximumSize(config.getJsonLdCacheSize()) .expireAfterAccess(config.getJsonLdCacheExpireHours(), HOURS).build()); final IOService ioService = new JenaIOService(namespaceService, TrellisUtils.getAssetConfiguration(config), config.getJsonLdWhitelist(), config.getJsonLdDomainWhitelist(), profileCache); // Health checks environment.healthChecks().register("zookeeper", new ZookeeperHealthCheck(curator)); environment.healthChecks().register("kafka", new KafkaHealthCheck(curator)); getAuthFilters(config).ifPresent(filters -> environment.jersey().register(new ChainedAuthFilter<>(filters))); // Resource matchers environment.jersey().register(new LdpResource(resourceService, ioService, binaryService, baseUrl)); // Filters environment.jersey().register(new AgentAuthorizationFilter(new SimpleAgent(), emptyList())); environment.jersey().register(new CacheControlFilter(config.getCacheMaxAge())); // Authorization getWebacConfiguration(config).ifPresent(webacCache -> environment.jersey().register(new WebAcFilter( asList("Authorization"), new WebACService(resourceService, webacCache)))); // CORS getCorsConfiguration(config).ifPresent(cors -> environment.jersey().register( new CrossOriginResourceSharingFilter(cors.getAllowOrigin(), cors.getAllowMethods(), cors.getAllowHeaders(), cors.getExposeHeaders(), cors.getAllowCredentials(), cors.getMaxAge()))); }