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
Attribute
s as defined by describe()
.
This base implementation uses JavaBean convention to identify configurable attributes.- Author:
- Nicolas De Loof
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncheck
(CNode c, ConfigurationContext context) Run the same logic asConfigurator.configure(CNode, ConfigurationContext)
in dry-run mode.protected Mapping
compare
(T instance, T reference, ConfigurationContext context) configure
(CNode c, ConfigurationContext context) Configures/creates a Jenkins object based on a tree.protected void
configure
(Mapping config, T instance, boolean dryrun, ConfigurationContext context) Run configuration process on the target instanceprotected Attribute
createAttribute
(String name, BaseConfigurator.TypePair type) describe()
Determine the list of Attribute available for configuration of the managed component.boolean
Attribute names that are detected by introspection but should be excludedprotected final void
handleUnknown
(Mapping config, ConfigurationContext context) int
hashCode()
protected abstract T
instance
(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, wait
Methods 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:Configurator
Determine the list of Attribute available for configuration of the managed component.- Specified by:
describe
in interfaceConfigurator<T>
- Returns:
- A set of
Attribute
s 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:Configurator
Configures/creates a Jenkins object based on a tree.- Specified by:
configure
in 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:Configurator
Run 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:
check
in 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()
-