Package io.jenkins.plugins.casc
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
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheck(CNode c, ConfigurationContext context) Run the same logic asConfigurator.configure(CNode, ConfigurationContext)in dry-run mode.protected Mappingcompare(T instance, T reference, ConfigurationContext context) configure(CNode c, ConfigurationContext context) Configures/creates a Jenkins object based on a tree.protected voidconfigure(Mapping config, T instance, boolean dryrun, ConfigurationContext context) Run configuration process on the target instanceprotected AttributecreateAttribute(String name, BaseConfigurator.TypePair type) describe()Determine the list of Attribute available for configuration of the managed component.booleanAttribute names that are detected by introspection but should be excludedprotected final voidhandleUnknown(Mapping config, ConfigurationContext context) inthashCode()protected abstract Tinstance(Mapping mapping, ConfigurationContext context) Build or identify the target component this configurator has to handle based on the provided configuration node.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jenkins.plugins.casc.Configurator
canConfigure, describe, describeStructure, getAttributes, getConfigurators, getDisplayName, getImplementedAPI, getName, getNames, getTarget
-
Constructor Details
-
BaseConfigurator
public BaseConfigurator()
-
-
Method Details
-
describe
Description copied from interface:ConfiguratorDetermine the list of Attribute available for configuration of the managed component.- Specified by:
describein interfaceConfigurator<T>- Returns:
- A set of
Attributes that describes this object
-
exclusions
Attribute names that are detected by introspection but should be excluded -
createAttribute
-
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
Description copied from interface:ConfiguratorConfigures/creates a Jenkins object based on a tree.- Specified by:
configurein interfaceConfigurator<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
Description copied from interface:ConfiguratorRun the same logic asConfigurator.configure(CNode, ConfigurationContext)in dry-run mode. Used to verify configuration is fine before being actually applied to a live jenkins controller.- Specified by:
checkin interfaceConfigurator<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 ifinstance(Mapping, ConfigurationContext)did already used some entriesinstance- target instance to configuredryrun- only check configuration is valid regarding target component. Don't actually apply changes to jenkins controller instancecontext- 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
-
hashCode
public int hashCode()
-