Interface IComponentsRepository
- All Known Subinterfaces:
IComponentsManager
- All Known Implementing Classes:
AbstractComponentRepository
,AbstractExtComponentRepository
This interface must be implemented by a component repository in order to
register at
IComponentsManager.registerRepository(int, IComponentsRepository)
.
Component repository must be registered at meaningful times, preferrably early in the startup process, to make sure components will be found by others when queried.
Component Repositories are prioritized and form a chain of responsibilities, given the repository with the higher priority preference over other ones with lower prio. In particular, a repository of higher priority is fully responsible of delegating calls to lower prio repositories.
The following table lists priorities of common component repositories:
Repository | priority |
---|---|
dev | 750 |
l1 | 500 |
Note that resources from repositories may be provided on-demand. Clients must
call the retrieve(String)
method to make sure component resources
are available locally as files.
Component descriptors however should be made available without possibly
unrequired resource downloads, as the system will use the descriptors to
implement component queries (see findComponents(X)
).
Typically component repositories are structured in a two-level hierarchy
comprising of a project name, i.e. some human-managable taxonomy
uniquely identifying and separating namespaces, like
com.zfabrik.aproject
or org.apache.log4j
, and a
component name that separates technical components within the
project.
For example, a project holding a web application will typically also hold a Java component and maybe a data source definition. In that case, the structure within the repository may look like this (not showing other sibling projects):
myproject/ datasource.properties java/ z.properties src.api/... src.impl/... web/ z.properties WebContent/ WEB-INF/ web.xml index.jspIn this case, components may be declared as simple property sets, e.g.
myproject/datasource
or as more complex components featuring a
folder structure like myproject/web
. This is a commonly
implemented structure. Component repository implementations may however chose
different storage structures for component properties and component
hierarchies.- Author:
- hb
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
component repository implementations should add this property to component properties when providing a component descriptor so that the runtime can declare dependeny on the repository implementation component when providing a component resource.static final String
System property indicating the operational mode the component repositories are used with.static final String
static final String
-
Method Summary
Modifier and TypeMethodDescriptiondefault Collection<String>
findComponents
(X propertyExpression) shorthand forfindComponents(X, boolean)
with afalse
second parameter.findComponents
(X propertyExpression, boolean localOnly) finds all components satisfying a query condition.default IComponentDescriptor
getComponent
(String component) shorthand forgetComponent(String, boolean)
with afalse
second parameter.getComponent
(String component, boolean localOnly) retrieves a component descriptor for a fully qualified component, e.g.Retrieve the set of modules provided by this repositorygetModules
(boolean localOnly) Retrieve the set of modules provided by this repository.default long
getRevision
(String componentName) Shorthand forgetRevision(String, boolean)
with afalse
second parameter.long
getRevision
(String componentName, boolean localOnly) return the most current revision of the component as available by the provider.default File
shorthand forretrieve(String, boolean)
with afalse
second parameter.Retrieve a component's resource folder.
-
Field Details
-
COMPONENT_REPO_IMPLEMENTATION
component repository implementations should add this property to component properties when providing a component descriptor so that the runtime can declare dependeny on the repository implementation component when providing a component resource.- See Also:
-
COMPONENT_REPO_MODE
System property indicating the operational mode the component repositories are used with. Supported values include- RELAXED
- When set (case-independent), failure to remote connect will not stop repository operations but simply fail to discover updates. Attempts to access resources that have not been provided locally previously will still lead to errors
- STRICT
- When set (case-independent), failure to remote connect for update checks (if so required) will lead to exceptions thrown during repository operations and may render the system inoperational. This is the default setting and recommended for productive systems to ensure consistency.
- See Also:
-
COMPONENT_REPO_MODE_RELAXED
- See Also:
-
COMPONENT_REPO_MODE_STRICT
- See Also:
-
-
Method Details
-
getRevision
return the most current revision of the component as available by the provider. providers must be able to count revs. A rev <0 indicates that the package is not known to the repository.If localOnly is set to true, only this repository is looked up. Otherwise all repositories in the chain with lower priority are considered too.
- Throws:
IOException
-
getRevision
Shorthand forgetRevision(String, boolean)
with afalse
second parameter.- Throws:
IOException
-
findComponents
finds all components satisfying a query condition. If localOnly is set to true, only this repository is queried. Otherwise all repositories in the chain with lower priority are considered too.If localOnly is set to true, only this repository is looked up. Otherwise all repositories in the chain with lower priority are considered too.
- Throws:
IOException
-
findComponents
shorthand forfindComponents(X, boolean)
with afalse
second parameter.- Throws:
IOException
-
getComponent
retrieves a component descriptor for a fully qualified component, e.g.<module>/java
for a Java component. If localOnly is set to true, only this repository is looked up. Otherwise all repositories in the chain with lower priority are considered too.If localOnly is set to true, only this repository is looked up. Otherwise all repositories in the chain with lower priority are considered too.
-
getComponent
shorthand forgetComponent(String, boolean)
with afalse
second parameter. -
retrieve
Retrieve a component's resource folder. Every component has by definition a resource folder that reflects its repository defined content if any, or may be empty. This folder is a temporary structure, valid until the next time a component update will be fetched. Assuming these constraints this folder may be used to store temporary component data (e.g. as cache content).A call to this method always returns a folder. Depending on the component type however, this folder may be empty, contain a single z.properties file or more.
If localOnly is set to true, only this repository is looked up. Otherwise all repositories in the chain with lower priority are considered too.
- Returns:
- the component's folder resource folder or
null
, if the component does not exist. - Throws:
IOException
-
retrieve
shorthand forretrieve(String, boolean)
with afalse
second parameter.- Throws:
IOException
-
getModules
Retrieve the set of modules provided by this repository. IflocalOnly
is true, the methods returns only those modules that are provided by the very repository.- Throws:
IOException
-
getModules
Retrieve the set of modules provided by this repository- Throws:
IOException
-