public void onFileEvent(final FileEvent fileEvent) { if (metadataDependencyRegistry == null) { metadataDependencyRegistry = getMetadataDependencyRegistry(); } Validate.notNull(metadataDependencyRegistry, "MetadataDependencyRegistry is required"); if (metadataService == null) { metadataService = getMetadataService(); } Validate.notNull(metadataService, "MetadataService is required"); if (typeLocationService == null) { typeLocationService = getTypeLocationService(); } Validate.notNull(typeLocationService, "TypeLocationService is required"); final String fileIdentifier = fileEvent.getFileDetails().getCanonicalPath(); // Check to see if file is of interest if (fileIdentifier.endsWith(".java") && fileEvent.getOperation() != FileOperation.MONITORING_FINISH && !fileIdentifier.endsWith("package-info.java")) { // Figure out the PhysicalTypeIdentifier final String id = typeLocationService.getPhysicalTypeIdentifier(fileIdentifier); if (id == null) { return; } // Now we've worked out the id, we can publish the event in case // others were interested metadataService.evictAndGet(id); metadataDependencyRegistry.notifyDownstream(id); } }
/** * Notifies downstream dependencies of a change if and only if the passed * metadata item has a different hash code than the existing metadata item. * This is aimed at reducing needless notifications if nothing has actually * changed since the last notification. * * @param metadataItem the potentially-updated metadata item (required; must * be a metadata item of the same class as all other items * presented to this class) */ protected void notifyIfRequired(final MetadataItem metadataItem) { final String instanceId = MetadataIdentificationUtils.getMetadataInstance(metadataItem.getId()); final Integer existing = hashes.get(instanceId); final int newHash = metadataItem.hashCode(); if (existing != null && newHash == existing) { // No need to notify return; } // To get this far, we need to notify and replace/add the metadata // item's hash for future reference hashes.put(instanceId, newHash); // Eagerly insert into the cache to so any recursive gets for this // metadata item will be returned successfully getMetadataService().put(metadataItem); if (getMetadataDependencyRegistry() != null) { getMetadataDependencyRegistry().notifyDownstream(metadataItem.getId()); } }
private void updateProjectMetadataForModules(final Iterable<Pom> newPoms) { for (final Pom pom : newPoms) { final String projectMetadataId = ProjectMetadata.getProjectIdentifier(pom.getModuleName()); getMetadataService().evictAndGet(projectMetadataId); getMetadataDependencyRegistry().notifyDownstream(projectMetadataId); } }
registry.notifyDownstream(downstreamDependency);
public void onFileEvent(final FileEvent fileEvent) { if (metadataDependencyRegistry == null) { metadataDependencyRegistry = getMetadataDependencyRegistry(); } Validate.notNull(metadataDependencyRegistry, "MetadataDependencyRegistry is required"); if (metadataService == null) { metadataService = getMetadataService(); } Validate.notNull(metadataService, "MetadataService is required"); if (typeLocationService == null) { typeLocationService = getTypeLocationService(); } Validate.notNull(typeLocationService, "TypeLocationService is required"); final String fileIdentifier = fileEvent.getFileDetails().getCanonicalPath(); // Check to see if file is of interest if (fileIdentifier.endsWith(".java") && fileEvent.getOperation() != FileOperation.MONITORING_FINISH && !fileIdentifier.endsWith("package-info.java")) { // Figure out the PhysicalTypeIdentifier final String id = typeLocationService.getPhysicalTypeIdentifier(fileIdentifier); if (id == null) { return; } // Now we've worked out the id, we can publish the event in case // others were interested metadataService.evictAndGet(id); metadataDependencyRegistry.notifyDownstream(id); } }
getMetadataDependencyRegistry().notifyDownstream( downstreamDependency);
getMetadataDependencyRegistry().notifyDownstream( downstreamDependency);