@Override public List<PropertyDescriptor> getPropertyDescriptors() { return configurableComponent.getPropertyDescriptors(); }
@Override public List<PropertyDescriptor> getPropertyDescriptors() { try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, getComponent().getClass(), getComponent().getIdentifier())) { return getComponent().getPropertyDescriptors(); } }
for (final Map.Entry<String, String> entry : properties.entrySet()) { final PropertyDescriptor descriptor = getComponent().getPropertyDescriptor(entry.getKey()); if (descriptor.isDynamicClasspathModifier()) { classpathChanged = true; logger.info("Updating classpath for " + this.componentType + " with the ID " + this.getIdentifier()); final Set<URL> additionalUrls = getAdditionalClasspathResources(getComponent().getPropertyDescriptors()); try { reload(additionalUrls);
public boolean removeProperty(final String property) { Objects.requireNonNull(property); final PropertyDescriptor fullyPopulatedDescriptor = component.getPropertyDescriptor(property); String value = null; if ((value = properties.remove(fullyPopulatedDescriptor)) != null) { if (!value.equals(fullyPopulatedDescriptor.getDefaultValue())) { component.onPropertyModified(fullyPopulatedDescriptor, value, null); } return true; } return false; }
private final void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, getComponent().getClass(), getComponent().getIdentifier())) { getComponent().onPropertyModified(descriptor, oldValue, newValue); } }
@Override public void cleanUpResources() { extensionManager.removeInstanceClassLoader(configurableComponent.getIdentifier()); } }
@Override public PropertyDescriptor getPropertyDescriptor(final String name) { try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, getComponent().getClass(), getComponent().getIdentifier())) { return getComponent().getPropertyDescriptor(name); } }
@Override public PropertyDescriptor getPropertyDescriptor(String propertyName) { return configurableComponent.getPropertyDescriptor(propertyName); }
instance.onPropertyModified(descriptor, oldValue, newValue); } catch (final Exception e) { final String message = "Unable to invoke onPropertyModified from scripted LookupService: " + e;
/** * Validates the current properties, returning ValidationResults for any * invalid properties. All processor defined properties will be validated. * If they are not included in the in the purposed configuration, the * default value will be used. * * @return Collection of validation result objects for any invalid findings * only. If the collection is empty then the processor is valid. Guaranteed * non-null */ public Collection<ValidationResult> validate() { final List<ValidationResult> results = new ArrayList<>(); final ValidationContext validationContext = new MockValidationContext(this, stateManager, variableRegistry); final Collection<ValidationResult> componentResults = component.validate(validationContext); results.addAll(componentResults); final Collection<ValidationResult> serviceResults = validateReferencedControllerServices(validationContext); results.addAll(serviceResults); // verify all controller services are enabled for (Map.Entry<String, ControllerServiceConfiguration> service : getControllerServices().entrySet()) { if (!service.getValue().isEnabled()) { results.add(new ValidationResult.Builder() .explanation("Controller service " + service.getKey() + " for " + this.getName() + " is not enabled") .valid(false) .build()); } } return results; }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof ConfigurableComponent)) { return false; } final ConfigurableComponent other = (ConfigurableComponent) obj; return getIdentifier().equals(other.getIdentifier()); }
/** * Updates the value of the property with the given PropertyDescriptor to * the specified value IF and ONLY IF the value is valid according to the * descriptor's validator. Otherwise, the property value is not updated. In * either case, the ValidationResult is returned, indicating whether or not * the property is valid * * @param descriptor of property to modify * @param value new value * @return result */ public ValidationResult setProperty(final PropertyDescriptor descriptor, final String value) { requireNonNull(descriptor); requireNonNull(value, "Cannot set property to null value; if the intent is to remove the property, call removeProperty instead"); final PropertyDescriptor fullyPopulatedDescriptor = component.getPropertyDescriptor(descriptor.getName()); final ValidationResult result = fullyPopulatedDescriptor.validate(value, new MockValidationContext(this, stateManager, variableRegistry)); String oldValue = properties.put(fullyPopulatedDescriptor, value); if (oldValue == null) { oldValue = fullyPopulatedDescriptor.getDefaultValue(); } if ((value == null && oldValue != null) || (value != null && !value.equals(oldValue))) { component.onPropertyModified(fullyPopulatedDescriptor, oldValue, value); } return result; }
@Override public PropertyDescriptor getPropertyDescriptor(final String name) { try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getComponent().getClass(), getComponent().getIdentifier())) { return getComponent().getPropertyDescriptor(name); } }
private final void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getComponent().getClass(), getComponent().getIdentifier())) { getComponent().onPropertyModified(descriptor, oldValue, newValue); } }
@Override public PropertyValue getProperty(final String propertyName) { final PropertyDescriptor descriptor = component.getPropertyDescriptor(propertyName); if (descriptor == null) { return null; } final String setPropertyValue = properties.get(descriptor); final String propValue = (setPropertyValue == null) ? descriptor.getDefaultValue() : setPropertyValue; return new MockPropertyValue(propValue, this, variableRegistry, (enableExpressionValidation && allowExpressionValidation) ? descriptor : null); }
instance.onPropertyModified(descriptor, oldValue, newValue); } catch (final Exception e) { final String message = "Unable to invoke onPropertyModified from scripted LookupService: " + e;
protected Collection<ValidationResult> computeValidationErrors(final ValidationContext validationContext) { Throwable failureCause = null; try { final Collection<ValidationResult> results = getComponent().validate(validationContext); logger.debug("Computed validation errors with Validation Context {}; results = {}", validationContext, results); return results; } catch (final ControllerServiceDisabledException e) { getLogger().debug("Failed to perform validation due to " + e, e); return Collections.singleton( new DisabledServiceValidationResult("Component", e.getControllerServiceId(), "performing validation depends on referencing a Controller Service that is currently disabled")); } catch (final Exception e) { // We don't want to log this as an error because we will return a ValidationResult that is // invalid. However, we do want to make the stack trace available if needed, so we log it at // a debug level. getLogger().debug("Failed to perform validation due to " + e, e); failureCause = e; } catch (final Error e) { getLogger().error("Failed to perform validation due to " + e, e); failureCause = e; } return Collections.singleton(new ValidationResult.Builder() .subject("Component") .valid(false) .explanation("Failed to perform validation due to " + failureCause) .build()); }
@Override public Map<PropertyDescriptor, String> getProperties() { final List<PropertyDescriptor> supported = component.getPropertyDescriptors(); if (supported == null || supported.isEmpty()) { return Collections.unmodifiableMap(properties); } else { final Map<PropertyDescriptor, String> props = new LinkedHashMap<>(); for (final PropertyDescriptor descriptor : supported) { props.put(descriptor, null); } props.putAll(properties); return props; } }
@Override public List<PropertyDescriptor> getPropertyDescriptors() { try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getComponent().getClass(), getComponent().getIdentifier())) { return getComponent().getPropertyDescriptors(); } }
@Override public void teardown(ConfigurableComponent component) { try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, component.getClass(), component.getIdentifier())) { ControllerService controllerService = (ControllerService) component; final ComponentLog logger = new MockComponentLogger(); final MockConfigurationContext context = new MockConfigurationContext(); ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, controllerService, logger, context); } finally { extensionManager.removeInstanceClassLoader(component.getIdentifier()); } } }