Class DataBoundConfigurator<T>

java.lang.Object
io.jenkins.plugins.casc.BaseConfigurator<T>
io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator<T>
All Implemented Interfaces:
Configurator<T>
Direct Known Subclasses:
HudsonPrivateSecurityRealmConfigurator, JNLPLauncherConfigurator

public class DataBoundConfigurator<T> extends BaseConfigurator<T>
A generic Configurator to configure components with a DataBoundConstructor. Intended to replicate Stapler's request-to-instance lifecycle, including PostConstruct init methods. Will rely on JEP-205 once implemented
Author:
Nicolas De Loof
  • Constructor Details

    • DataBoundConfigurator

      public DataBoundConfigurator(Class<T> clazz)
  • Method Details

    • getDataBoundConstructor

      @CheckForNull public static Constructor getDataBoundConstructor(@NonNull Class type)
    • getTarget

      public Class getTarget()
      Description copied from interface: Configurator
      Target type this configurator can handle.
    • instance

      protected T instance(Mapping config, ConfigurationContext context) throws ConfiguratorException
      Build a fresh new component based on provided configuration and DataBoundConstructor
      Specified by:
      instance in class BaseConfigurator<T>
      Parameters:
      config - 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 BaseConfigurator.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>
      Overrides:
      configure in class BaseConfigurator<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 config, 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>
      Overrides:
      check in class BaseConfigurator<T>
      Parameters:
      config - 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
    • getName

      @NonNull public String getName()
      Description copied from interface: Configurator
      Get a configurator name. This should return the default name for the configurator, used for exporting yaml see Configurator.getNames() for all possible names which will be considered when configuring.
      Returns:
      short name for this component when used in a configuration.yaml file
    • getNames

      @NonNull public List<String> getNames()
      Description copied from interface: Configurator
      Get all possible configurator names
      Returns:
      a list of all possible short names for this component when used in a configuration.yaml file
    • getImplementedAPI

      @NonNull public Class getImplementedAPI()
      Returns:
      The API implemented by target type, i.e. implemented ExtensionPoint for components to implement some jenkins APIs, or raw type for others.
    • 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>
      Overrides:
      describe in class BaseConfigurator<T>
      Returns:
      A set of Attributes that describes this object
    • describe

      @CheckForNull public CNode describe(T instance, ConfigurationContext context) throws Exception
      Description copied from interface: Configurator
      Describe a component as a Configuration Nodes CNode to be exported as yaml. Only export attributes which are not set to default value.
      Throws:
      Exception
    • getDisplayName

      public String getDisplayName()
      Returns:
      Human friendly display name for this component, used in generated documentation.