public Set<DiscoveredResourceDetails> discoverResources( ResourceDiscoveryContext<T> discoveryContext) throws InvalidPluginConfigurationException, Exception { Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(1); List<String> includes = determineIncludeGlobs(discoveryContext); List<String> excludes = determineExcludeGlobs(discoveryContext); Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration(); PropertySimple includeProps = getGlobList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP, includes); PropertySimple excludeProps = getGlobList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP, excludes); pluginConfig.put(includeProps); pluginConfig.put(excludeProps); try { checkFiles(pluginConfig); DiscoveredResourceDetails resource = createResourceDetails(discoveryContext, pluginConfig); discoveredResources.add(resource); log.debug( "Discovered " + discoveryContext.getResourceType().getName() + " Resource with key [" + resource.getResourceKey() + "]."); } catch (IllegalStateException e) { // Thrown by augeas if it can not read a file log.warn("Discovery failed: " + e.getMessage()); } return discoveredResources; }
@Override public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) { log.info("Discovering embedded extension resources"); Set<DiscoveredResourceDetails> discoveredResources = super.discoverResources(context); // call the parent discovery code Set<DiscoveredResourceDetails> extendedResources = new HashSet<DiscoveredResourceDetails>(); int i = -1; for (DiscoveredResourceDetails discoveredResource : discoveredResources) { String key = "Embedded Extension Resource Key" + (++i > 0 ? String.valueOf(i) : ""); String name = "Embedded Extension Resource"; String description = "This describes the Embedded Extension Resource"; discoveredResource.setResourceKey(key); discoveredResource.setResourceName(name); discoveredResource.setResourceDescription(description); extendedResources.add(discoveredResource); } return extendedResources; }