Class ConfigTypeContext
- java.lang.Object
-
- org.apache.sling.testing.mock.osgi.config.ConfigTypeContext
-
public final class ConfigTypeContext extends Object
Performs configuration management and component property type construction forConfigTypeandSetConfigannotations.
-
-
Constructor Summary
Constructors Constructor Description ConfigTypeContext(OsgiContextImpl osgiContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectconstructConfigType(@NotNull ConfigType annotation)Return a concrete instance of the OSGi config / Component Property Type represented by the givenConfigTypeannotation discovered via reflection.ObjectconstructConfigType(@NotNull ConfigType annotation, @Nullable String applyPid)Return a concrete instance of the OSGi config / Component Property Type represented by the givenConfigTypeannotation discovered via reflection.Optional<String>getConfigurationPid(@NotNull String pid, @NotNull Class component)Construct a configuration pid for use withConfigurationAdmin.getConfiguration(String).TypedConfignewTypedConfig(@NotNull Annotation annotation)Construct a collection typed config for the provided annotation.TypedConfignewTypedConfig(@NotNull Annotation annotation, @Nullable String applyPid)Construct a collection typed config for the provided annotation.voidupdateConfiguration(@NotNull String pid, @NotNull Map<String,Object> propertyMap)Updates aConfigurationfrom the provided pid and property map.voidupdateConfiguration(@NotNull SetConfig annotation)Updates aConfigurationfrom the provided annotation.
-
-
-
Constructor Detail
-
ConfigTypeContext
public ConfigTypeContext(OsgiContextImpl osgiContext)
-
-
Method Detail
-
getConfigurationPid
public Optional<String> getConfigurationPid(@NotNull @NotNull String pid, @NotNull @NotNull Class component)
Construct a configuration pid for use withConfigurationAdmin.getConfiguration(String). Ifpidis not empty and not equal toComponent.NAME("$"), returnpid. Otherwise, returncomponent.getName(), except in the case ofVoid, in which case returnempty().- Parameters:
pid- an explicit pid name, "$", or the empty stringcomponent- a class whose name to use when pid is "$", unlessVoid- Returns:
- a useful configuration pid or none
-
updateConfiguration
public void updateConfiguration(@NotNull @NotNull SetConfig annotation)Updates aConfigurationfrom the provided annotation.- Parameters:
annotation- anSetConfigannotation
-
updateConfiguration
public void updateConfiguration(@NotNull @NotNull String pid, @NotNull @NotNull Map<String,Object> propertyMap)Updates aConfigurationfrom the provided pid and property map.- Parameters:
pid- the configuration pidpropertyMap- config properties to set on the configuration
-
constructConfigType
public Object constructConfigType(@NotNull @NotNull ConfigType annotation)
Return a concrete instance of the OSGi config / Component Property Type represented by the givenConfigTypeannotation discovered via reflection.- Parameters:
annotation- theConfigType- Returns:
- a concrete instance of the type specified by the provided
ConfigType.type()
-
constructConfigType
public Object constructConfigType(@NotNull @NotNull ConfigType annotation, @Nullable @Nullable String applyPid)
Return a concrete instance of the OSGi config / Component Property Type represented by the givenConfigTypeannotation discovered via reflection.- Parameters:
annotation- theConfigTypeapplyPid- if not empty, override any specifiedConfigType.pid().- Returns:
- a concrete instance of the type specified by the provided
ConfigType.type()
-
newTypedConfig
public TypedConfig newTypedConfig(@NotNull @NotNull Annotation annotation)
Construct a collection typed config for the provided annotation.- Parameters:
annotation- a component property type annotation orConfigTypeannotation- Returns:
- a typed config
-
newTypedConfig
public TypedConfig newTypedConfig(@NotNull @NotNull Annotation annotation, @Nullable @Nullable String applyPid)
Construct a collection typed config for the provided annotation.- Parameters:
annotation- a component property type annotation orConfigTypeannotationapplyPid- optional non-empty configuration pid to apply if annotation is aConfigType- Returns:
- a typed config
-
-