Class BaseConfigurator<T>

java.lang.Object
io.jenkins.plugins.casc.BaseConfigurator<T>
All Implemented Interfaces:
Configurator<T>
Direct Known Subclasses:
AdminWhitelistRuleConfigurator, DataBoundConfigurator, DescriptorConfigurator, ExtensionConfigurator, GlobalConfigurationCategoryConfigurator, JenkinsConfigurator, LabelAtomConfigurator, MavenConfigurator, SelfConfigurator, UnsecuredAuthorizationStrategyConfigurator, UpdateCenterConfigurator, UpdateSiteConfigurator

public abstract class BaseConfigurator<T> extends Object implements Configurator<T>
a General purpose abstract Configurator implementation based on introspection. Target component is identified by implementing instance(Mapping, ConfigurationContext) then configuration is applied on Attributes as defined by describe(). This base implementation uses JavaBean convention to identify configurable attributes.
Author:
Nicolas De Loof
  • Constructor Details

    • BaseConfigurator

      public BaseConfigurator()
  • Method Details

    • describe

      @NonNull public Set<Attribute<T,?>> describe()
      Description copied from interface: Configurator
      Determine the list of Attribute available for configuration of the managed component.
      Specified by:
      describe in interface Configurator<T>
      Returns:
      A set of Attributes that describes this object
    • exclusions

      protected Set<String> exclusions()
      Attribute names that are detected by introspection but should be excluded
    • createAttribute

      protected Attribute createAttribute(String name, BaseConfigurator.TypePair type)
    • instance

      protected abstract T instance(Mapping mapping, ConfigurationContext context) throws ConfiguratorException
      Build or identify the target component this configurator has to handle based on the provided configuration node.
      Parameters:
      mapping - configuration for target component. Implementation may consume some entries to create a fresh new instance.
      context - Fully configured Jenkins object used as the starting point for this configuration.
      Returns:
      instance to be configured, but not yet fully configured, see configure(Mapping, Object, boolean, ConfigurationContext)
      Throws:
      ConfiguratorException - something went wrong...
    • configure

      @NonNull public T configure(CNode c, ConfigurationContext context) throws ConfiguratorException
      Description copied from interface: Configurator
      Configures/creates a Jenkins object based on a tree.
      Specified by:
      configure in interface Configurator<T>
      Parameters:
      c - Map/List/primitive objects (think YAML) that represents the configuration from which a Jenkins object is configured.
      context - Fully configured Jenkins object used as the starting point for this configuration.
      Returns:
      Fully configured Jenkins object that results from this configuration. if no new objects got created, but some existing objects may have been modified, return updated target object.
      Throws:
      ConfiguratorException - if something went wrong, depends on the concrete implementation
    • check

      public T check(CNode c, ConfigurationContext context) throws ConfiguratorException
      Description copied from interface: Configurator
      Run the same logic as Configurator.configure(CNode, ConfigurationContext) in dry-run mode. Used to verify configuration is fine before being actually applied to a live jenkins controller.
      Specified by:
      check in interface Configurator<T>
      Parameters:
      c - Map/List/primitive objects (think YAML) that represents the configuration from which a Jenkins object is configured.
      context - Fully configured Jenkins object used as the starting point for this configuration.
      Throws:
      ConfiguratorException - on configuration error
    • configure

      protected void configure(Mapping config, T instance, boolean dryrun, ConfigurationContext context) throws ConfiguratorException
      Run configuration process on the target instance
      Parameters:
      config - configuration to apply. Can be partial if instance(Mapping, ConfigurationContext) did already used some entries
      instance - target instance to configure
      dryrun - only check configuration is valid regarding target component. Don't actually apply changes to jenkins controller instance
      context - Fully configured Jenkins object used as the starting point for this configuration.
      Throws:
      ConfiguratorException - something went wrong...
    • handleUnknown

      protected final void handleUnknown(Mapping config, ConfigurationContext context) throws ConfiguratorException
      Throws:
      ConfiguratorException
    • compare

      @NonNull protected Mapping compare(T instance, T reference, ConfigurationContext context) throws Exception
      Throws:
      Exception
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object