Package com.priint.pubserver.config
Class PluginConfigCollection
java.lang.Object
com.priint.pubserver.config.PluginConfigCollection
- All Implemented Interfaces:
Serializable
The PluginConfigCollection class helps to manage a collection of configurations provided as
plain XML Strings or PluginConfig objects. Properties are kept alongside the
configurations and will be created on demand, if none are set explicitly.
Examples:
Examples:
PluginConfigCollection myConfigSet = PluginConfigCollection.createEmptySet(myLogin, MyCustomClass.class); // add a configuration to this collection. MyCustomClass.class (as provided as the default for this collection) // will be used for marshaling and unmarshalling this configuration: myConfigs.addConfig(firstPath, firstObject); // this will actually be the same like the default properties, in real life you // probably would customize the properties: myConfigSet.addProperties(firstPath, new ConfigFileProperties(login, path)); // add another configuration. This object requires AnotherCustomClass for // marshaling and unmarshalling: myConfigSet.addConfig(secondPath, secondObject, AnotherCustomClass.class); // you can mix XML and Objects in a collection: myConfigSet.addXml(thirdPath, thirdConfig); // and get XML or Objects for any configuration managed in this collection at any time: PluginConfig object = myConfigSet.getObject(thirdPath); String xml = myConfigSet.getXml(firstPath); // configurations in this collection are stored as PluginConfigDataHandler objects, // in order to avoid unnecessary serialization / deserialization, you should work // with these objects whenever possible: PluginConfigDataHandler config = myConfigSet.getHandle(firstPath); String xml2 = config.getXml();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfig(String path, PluginConfig object, Class<?>... overrideClazz) Add a configuration object at the given path.voidaddConfigCollection(PluginConfigCollection collection) Add all configurations from the given collection to this collection.voidaddConfigDataHandler(String path, PluginConfigDataHandler pluginConfigDataHandler) Add a configuration handler to this collection.voidAdd byte[] data to this configuration collectionvoidaddDefaultProperties(String path) Add the default ConfigFileProperties at the given pathvoidaddProperties(String path, ConfigFileProperties properties) Add ConfigFileProperties at the given pathvoidAdd a configuration provided as XML String at the given pathvoidAdd configurations provided as XML Strings at the paths given by the key in the map.voidclear()Removes all of the configurations from this collection.booleancontainsConfiguration(String path) Returns true if this internal list contains a configuration for the specified path.booleancontainsProperties(String path) Returns true if this internal list contains a configuration for the specified path.static PluginConfigCollectioncreateCopy(PluginConfigCollection source) Create a shallow copy of a PluginConfigCollection.static PluginConfigCollectioncreateEmptySet(Class<?>... customClazz) Create an empty configuration collection.static PluginConfigCollectioncreateEmptySet(String login, Class<?>... customClazz) Create an empty configuration collection.Get the Object representation of a particular configurationgetConfigDataHandler(String path) Get the data handler for a particular configuration.Class<?>[]Get the custom classes for this configuration collectionClass<?>[]getCustomClass(String path) Get the custom classes for a particular configuration item in this configuration collectionGet the keys of all configurations managed in this collection.
The method returns getKeySetOfConfigurations.Get the keys of all configurations managed in this collection.Get the keys of all configurations missing in this collection, i.e.: properties have been provided for this key, but no configuration was added.Get the keys of all properties missing in this collection, i.e.: a configuration has been added for this key, but no properties have been provided.getProperties(String path) Get the properties for a given path.Get the XML String representation of a particular configuration.Get a path / XML representation map for all configurations in this collection.Get a path / XML representation map for all configurations in this collection.booleanisEmpty()Is this configuration empty?voidremoveConfig(String path) Remove a configuration and associated properties from this PluginConfig Setintsize()Number of items in the collection
-
Method Details
-
createEmptySet
Create an empty configuration collection.
If default properties are generated for this configuration collection, the anonymous login name from Constants.ANONYMOUS_LOGIN will be used.
Optionally a list of default custom classes can be provided, which will be used for marshalling / unmarshalling, if not overridden for a particular configuration.- Parameters:
customClazz-- Returns:
- empty configuration collection
-
createEmptySet
Create an empty configuration collection.
"login" must be provided in order to process correct default properties for configurations managed by this collection. Optionally a list of default custom classes can be provided, which will be used for marshalling / unmarshalling, if not overridden for a particular configuration.- Parameters:
login-customClazz-- Returns:
- empty configuration collection
-
createCopy
Create a shallow copy of a PluginConfigCollection.- Parameters:
source-- Returns:
- new PluginConfigCollection
-
getKeySet
Get the keys of all configurations managed in this collection.
The method returns getKeySetOfConfigurations.- Returns:
- collection of keys
-
getKeySetOfConfigurations
Get the keys of all configurations managed in this collection.- Returns:
- collection of keys
-
getMissingPropertiesKeys
Get the keys of all properties missing in this collection, i.e.: a configuration has been added for this key, but no properties have been provided.- Returns:
- collection of keys
-
getMissingConfigKeys
Get the keys of all configurations missing in this collection, i.e.: properties have been provided for this key, but no configuration was added.- Returns:
- collection of keys
-
addXml
Add a configuration provided as XML String at the given path- Parameters:
path-xml-overrideClazz-
-
addData
Add byte[] data to this configuration collection- Parameters:
path-data-overrideClazz-
-
addDefaultProperties
Add the default ConfigFileProperties at the given path- Parameters:
path-
-
addProperties
Add ConfigFileProperties at the given path- Parameters:
path-properties-
-
addConfig
Add a configuration object at the given path. Optionally a list of custom classes applicable for this particular PluginConfig can be provided.- Parameters:
path-object-overrideClazz-
-
addConfigDataHandler
Add a configuration handler to this collection. In order to avoid unnecessary serialization / deserialization, you should work with PluginConfigDataHandler objects whenever possible- Parameters:
path-pluginConfigDataHandler-
-
addConfigCollection
Add all configurations from the given collection to this collection.- Parameters:
collection-
-
addXmlMap
Add configurations provided as XML Strings at the paths given by the key in the map.- Parameters:
configs-
-
getConfig
Get the Object representation of a particular configuration- Parameters:
path-- Returns:
- PluginConfig object of the configuration identified by path or null if it does not exist.
- Throws:
jakarta.xml.bind.JAXBException
-
getConfigDataHandler
Get the data handler for a particular configuration. Whenever possible, you should use the PluginConfigDataHandler representation.- Parameters:
path-- Returns:
- PluginConfigDataHandler for the configuration identified by path
-
getXml
Get the XML String representation of a particular configuration.- Parameters:
path-- Returns:
- XML string for the configuration identified by path
- Throws:
jakarta.xml.bind.JAXBException
-
getXmlMap
Get a path / XML representation map for all configurations in this collection. The key represents full repository path inclusive file name.- Returns:
- map with (path, XML) for all configurations in this collection
- Throws:
jakarta.xml.bind.JAXBException
-
getXmlMapWithoutFullPath
Get a path / XML representation map for all configurations in this collection. The key represents only file name.- Returns:
- map with (path, XML) for all configurations in this collection
- Throws:
jakarta.xml.bind.JAXBException
-
getCustomClass
Get the custom classes for this configuration collection- Returns:
- list of custom classes
-
getCustomClass
Get the custom classes for a particular configuration item in this configuration collection- Parameters:
path-- Returns:
- list of custom classes
-
getProperties
Get the properties for a given path. The method will- return null, if no configuration exists at this path
- create and return default properties, if a configuration exists, but no properties have been provided
- return the properties collection for the given path, if available
- Parameters:
path-- Returns:
- properties or null, if no configuration is available for this path
-
removeConfig
Remove a configuration and associated properties from this PluginConfig Set- Parameters:
path-
-
size
public int size()Number of items in the collection- Returns:
- size of the collection
-
isEmpty
public boolean isEmpty()Is this configuration empty?
- Returns:
- true, if empty, false otherwise
-
containsConfiguration
Returns true if this internal list contains a configuration for the specified path.- Parameters:
path-- Returns:
- true if a configuration exist for the path
-
containsProperties
Returns true if this internal list contains a configuration for the specified path.- Parameters:
path-- Returns:
- true if a configuration exist for the path
-
clear
public void clear()Removes all of the configurations from this collection.
-