com.zfabrik.components.provider
Interface IComponentsRepository

All Known Subinterfaces:
IComponentsManager
All Known Implementing Classes:
AbstractComponentRepository

public interface IComponentsRepository

A component repository provides component meta data and resources to the z2 runtime. In other words: Component repositories define the system's view of the world.

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:

Repositorypriority
dev750
l1500

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.jsp
 
In 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
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.
 
Method Summary
 java.util.Collection<java.lang.String> findComponents(X propertyExpression)
          find all components satisfying a query condition
 IComponentDescriptor getComponent(java.lang.String component)
          retrieves a component descriptor.
 long getRevision(java.lang.String componentName)
          return the most current revision of the component as available by the provider.
 java.io.File retrieve(java.lang.String name)
          retrieve a package or a component's resources in executable representation.
 

Field Detail

COMPONENT_REPO_IMPLEMENTATION

static final 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.

See Also:
Constant Field Values
Method Detail

getRevision

long getRevision(java.lang.String componentName)
                 throws java.io.IOException
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

Throws:
java.io.IOException

findComponents

java.util.Collection<java.lang.String> findComponents(X propertyExpression)
                                                      throws java.io.IOException
find all components satisfying a query condition

Throws:
java.io.IOException

getComponent

IComponentDescriptor getComponent(java.lang.String component)
retrieves a component descriptor. The component must be named as <package>/<component of package>


retrieve

java.io.File retrieve(java.lang.String name)
                      throws java.io.IOException
retrieve a package or a component's resources in executable representation. An implementation owns a repository structure and may not need to do any action of physical retrieval. 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. For example, Java code components require a certain file system structure. Other components may have no such requirement whatsoever.

Parameters:
the - naming scheme follows the package and component naming scheme. A missing component specification (as tail) indicates that package global resources are supposed to be retrieved
Returns:
the folder where local access to the package or component was provided
Throws:
java.io.IOException