IComponentsManager
AbstractComponentRepository
, AbstractExtComponentRepository
public interface IComponentsRepository
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.Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
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.
|
static java.lang.String |
COMPONENT_REPO_MODE |
System property indicating the operational mode the component repositories are used with.
|
static java.lang.String |
COMPONENT_REPO_MODE_RELAXED |
|
static java.lang.String |
COMPONENT_REPO_MODE_STRICT |
Modifier and Type | Method | Description |
---|---|---|
java.util.Collection<java.lang.String> |
findComponents(X propertyExpression) |
shorthand for
findComponents(X, boolean) with a
false second parameter. |
java.util.Collection<java.lang.String> |
findComponents(X propertyExpression,
boolean localOnly) |
finds all components satisfying a query condition.
|
IComponentDescriptor |
getComponent(java.lang.String component) |
shorthand for
getComponent(String, boolean) with a
false second parameter. |
IComponentDescriptor |
getComponent(java.lang.String component,
boolean localOnly) |
retrieves a component descriptor for a fully qualified component, e.g.
|
java.util.Set<java.lang.String> |
getModules() |
Retrieve the set of modules provided by this repository
|
java.util.Set<java.lang.String> |
getModules(boolean localOnly) |
Retrieve the set of modules provided by this repository.
|
long |
getRevision(java.lang.String componentName) |
Shorthand for
getRevision(String, boolean) with a
false second parameter. |
long |
getRevision(java.lang.String componentName,
boolean localOnly) |
return the most current revision of the component as available by the
provider.
|
java.io.File |
retrieve(java.lang.String name) |
shorthand for
retrieve(String, boolean) with a
false second parameter. |
java.io.File |
retrieve(java.lang.String name,
boolean localOnly) |
Retrieve a component's resource folder.
|
static final java.lang.String COMPONENT_REPO_IMPLEMENTATION
static final java.lang.String COMPONENT_REPO_MODE
static final java.lang.String COMPONENT_REPO_MODE_RELAXED
static final java.lang.String COMPONENT_REPO_MODE_STRICT
long getRevision(java.lang.String componentName, boolean localOnly) throws java.io.IOException
If localOnly is set to true, only this repository is looked up. Otherwise all repositories in the chain with lower priority are considered too.
java.io.IOException
long getRevision(java.lang.String componentName) throws java.io.IOException
getRevision(String, boolean)
with a
false
second parameter.java.io.IOException
java.util.Collection<java.lang.String> findComponents(X propertyExpression, boolean localOnly) throws java.io.IOException
If localOnly is set to true, only this repository is looked up. Otherwise all repositories in the chain with lower priority are considered too.
java.io.IOException
java.util.Collection<java.lang.String> findComponents(X propertyExpression) throws java.io.IOException
findComponents(X, boolean)
with a
false
second parameter.java.io.IOException
IComponentDescriptor getComponent(java.lang.String component, boolean localOnly)
<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.
IComponentDescriptor getComponent(java.lang.String component)
getComponent(String, boolean)
with a
false
second parameter.java.io.File retrieve(java.lang.String name, boolean localOnly) throws java.io.IOException
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.
null
, if
the component does not exist.java.io.IOException
java.io.File retrieve(java.lang.String name) throws java.io.IOException
retrieve(String, boolean)
with a
false
second parameter.java.io.IOException
java.util.Set<java.lang.String> getModules() throws java.io.IOException
java.io.IOException
java.util.Set<java.lang.String> getModules(boolean localOnly) throws java.io.IOException
localOnly
is true, the methods returns only those modules
that are provided by the very repository.java.io.IOException