For IntelliJ IDEA and
Android Studio


@Override public void run() { if (change.getType() == ChangeType.REMOVED) { removeProcessor(configPath); } else { updateProcessor(configPath); } } };
/** * Post a change event for a resource provider change * @param type The change type * @param info The resource provider */ private void postResourceProviderChange(final ProviderEvent event) { final ObservationReporter or = this.providerReporter; if ( or != null ) { final ResourceChange change = new ResourceChange(event.isAdd ? ChangeType.PROVIDER_ADDED : ChangeType.PROVIDER_REMOVED, event.path, false); or.reportChanges(Collections.singletonList(change), false); } }
@Override public void run() { checkRemoval(change.getPath()); }
IResourceChangeListener resourceChange = new ResourceChange(); ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChange, IResourceChangeEvent.POST_CHANGE);
/** * Match a change against the configuration * @param change The change * @param config The configuration * @return {@code true} whether it matches */ private boolean matches(final ResourceChange change, final ResourceChangeListenerInfo config) { if (!config.getResourceChangeTypes().contains(change.getType()) && !config.getProviderChangeTypes().contains(change.getType())) { return false; } if (!config.isExternal() && change.isExternal()) { return false; } return true; } }
/** * Match a change against the configuration * @param change The change * @param config The configuration * @return {@code true} whether it matches */ private boolean matches(final ResourceChange change, final ObserverConfiguration config) { if (!config.getChangeTypes().contains(change.getType())) { return false; } if (!config.includeExternal() && change.isExternal()) { return false; } if (config.getPaths().matches(change.getPath()) == null ) { return false; } if ( config.getExcludedPaths().matches(change.getPath()) != null ) { return false; } return true; }
logger.debug("Received event {}", resourceChange); final String path = resourceChange.getPath();
public void refresh(String path) { if (resourceProviderRegistration != null) { // Only execute for non-legacy RP's if (getProviderContext() != null) { final List<ResourceChange> resourceChangeList = new ArrayList<ResourceChange>(); final ResourceChange resourceChange = new ResourceChange( ResourceChange.ChangeType.CHANGED, path, false, Collections.<String>emptySet(), Collections.<String>emptySet(), Collections.<String>emptySet() ); resourceChangeList.add(resourceChange); getProviderContext().getObservationReporter().reportChanges(resourceChangeList, false); } else { log.warn("Unable to obtain a Observation Changer for AEM Fiddle script resource provider"); } } else { // AEM 6.2 Support - Legacy Sling Resource Provider Implementation final Map<String, String> props = Collections.singletonMap(SlingConstants.PROPERTY_PATH, path); eventAdmin.sendEvent(new Event(SlingConstants.TOPIC_RESOURCE_CHANGED, props)); } }
/** * @see org.apache.sling.api.resource.observation.ResourceChangeListener#onChange(java.util.List) */ @Override public void onChange(List<ResourceChange> changes) { for(final ResourceChange change : changes ) { if ( change.getPath() != null && change.getPath().startsWith(this.configuration.getScheduledJobsPath(true)) ) { if ( change.getType() == ResourceChange.ChangeType.REMOVED ) { // removal logger.debug("Remove scheduled job {}", change.getPath()); this.scheduledJobHandler.handleRemove(change.getPath()); } else { // add or update logger.debug("Add or update scheduled job {}, event {}", change.getPath(), change.getType()); this.scheduledJobHandler.handleAddUpdate(change.getPath()); } } } } }
if (change.isExternal()) { switch (change.getType()) { case ADDED: log.debug("Change Type ADDED: {}", change); if (change.getAddedPropertyNames().contains("someProperty")) { props.put("path", change.getPath()); props.put("userId", change.getUserId()); jobManager.addJob("com/adobe/acs/commons/samples/somePropertyAdded", props); case CHANGED: log.debug("Change Type CHANGED: {}", change); if (change.getChangedPropertyNames().contains("someOtherProperty")) {
final Resource resource = resourceResolver.getResource(change.getPath()); if (resource == null) { log.trace("Could not get resource for '{}' for event {}", change.getPath(), change.getType()); return false; log.debug("Found new dictionary entry: New {} resource in '{}' detected", JcrResourceBundle.RT_MESSAGE_ENTRY, change.getPath()); return true; log.debug("Found new dictionary entry: New {} resource in '{}' detected", JcrResourceBundle.MIXIN_MESSAGE, change.getPath()); return true; if (change.getPath().endsWith(".json")) { log.debug("Found new dictionary: New {} resource in '{}' detected", JcrResourceBundle.MIXIN_LANGUAGE, change.getPath()); return true;
Dictionary<String, Object> props = new Hashtable<String, Object>(); String topic; switch (change.getType()) { case ADDED: topic = SlingConstants.TOPIC_RESOURCE_ADDED; props.put(SlingConstants.PROPERTY_PATH, change.getPath()); if (change.getUserId() != null) { props.put(SlingConstants.PROPERTY_USERID, change.getUserId()); if (change.getAddedPropertyNames() != null ) { props.put(SlingConstants.PROPERTY_ADDED_ATTRIBUTES, change.getAddedPropertyNames().toArray(new String[change.getAddedPropertyNames().size()])); if (change.getChangedPropertyNames() != null) { props.put(SlingConstants.PROPERTY_CHANGED_ATTRIBUTES, change.getChangedPropertyNames().toArray(new String[change.getChangedPropertyNames().size()])); if ( change.getRemovedPropertyNames() != null ) { props.put(SlingConstants.PROPERTY_REMOVED_ATTRIBUTES, change.getRemovedPropertyNames().toArray(new String[change.getRemovedPropertyNames().size()])); if (change.getType() != ChangeType.REMOVED) { Resource resource = resolver.getResource(change.getPath()); if (resource == null) { resolver.refresh(); resource = resolver.getResource(change.getPath()); if (change.isExternal()) { props.put("event.application", "unknown");
private void onChange(ResourceChange change) { log.trace("handleChange: Detecting change {} for path '{}'", change.getType(), change.getPath()); if (languageRootPaths.contains(change.getPath())) { log.debug( "handleChange: Detected change of cached language root '{}', removing all cached ResourceBundles", change.getPath()); scheduleReloadBundles(true); } else { for (final String root : languageRootPaths) { if (change.getPath().startsWith(root)) { log.debug("handleChange: Refreshed all affected resource bundles for path '{}'", change.getPath()); return;