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 genericConfigurator
to configure components with aDataBoundConstructor
. Intended to replicate Stapler's request-to-instance lifecycle, includingPostConstruct
init methods. Will rely on JEP-205 once implemented- Author:
- Nicolas De Loof
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.jenkins.plugins.casc.BaseConfigurator
BaseConfigurator.TypePair
-
-
Constructor Summary
Constructors Constructor Description DataBoundConfigurator(Class<T> clazz)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
check(CNode config, ConfigurationContext context)
Run the same logic asConfigurator.configure(CNode, ConfigurationContext)
in dry-run mode.T
configure(CNode c, ConfigurationContext context)
Configures/creates a Jenkins object based on a tree.Set<Attribute<T,?>>
describe()
Determine the list of Attribute available for configuration of the managed component.CNode
describe(T instance, ConfigurationContext context)
Describe a component as a Configuration NodesCNode
to be exported as yaml.static Constructor
getDataBoundConstructor(Class type)
String
getDisplayName()
Class
getImplementedAPI()
String
getName()
Get a configurator name.List<String>
getNames()
Get all possible configurator namesClass
getTarget()
Target type this configurator can handle.protected T
instance(Mapping config, ConfigurationContext context)
Build a fresh new component based on provided configuration andDataBoundConstructor
-
Methods inherited from class io.jenkins.plugins.casc.BaseConfigurator
compare, configure, createAttribute, equals, exclusions, handleUnknown, hashCode
-
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, describeStructure, getAttributes, getConfigurators
-
-
-
-
Method Detail
-
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 andDataBoundConstructor
- Specified by:
instance
in classBaseConfigurator<T>
- Parameters:
config
- configuration for target component. Implementation may consume some entries to create a fresh new instance.- Returns:
- instance to be configured, but not yet fully configured, see
BaseConfigurator.configure(Mapping, Object, boolean, ConfigurationContext)
- Throws:
ConfiguratorException
-
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 interfaceConfigurator<T>
- Overrides:
configure
in classBaseConfigurator<T>
- Parameters:
c
- Map/List/primitive objects (think YAML) that represents the configuration from which a Jenkins object is configured.- 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 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>
- Overrides:
check
in classBaseConfigurator<T>
- Throws:
ConfiguratorException
-
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 seeConfigurator.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 interfaceConfigurator<T>
- Overrides:
describe
in classBaseConfigurator<T>
- Returns:
- A set of
Attribute
s 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 NodesCNode
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.
-
-