Class AbstractExtComponentRepository<FSCRC extends FSCRDBComponent,DB extends FSComponentExtRepositoryDB<FSCRC>>
java.lang.Object
com.zfabrik.components.provider.util.AbstractExtComponentRepository<FSCRC,DB>
- All Implemented Interfaces:
IComponentsRepository
,ISynchronizer
- Direct Known Subclasses:
AbstractComponentRepository
public abstract class AbstractExtComponentRepository<FSCRC extends FSCRDBComponent,DB extends FSComponentExtRepositoryDB<FSCRC>>
extends Object
implements IComponentsRepository, ISynchronizer
Abstract implementation of a component repository. This is by far the
easiest way of implementing a component repository. The only methods needed
to implement are
scan(DB)
to compute an update of the available components, their properties and revisionsdownload(FSCRDC, File)
to download a component's resources, if any, to a local file system folder
- Author:
- hb
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
static interface
-
Field Summary
FieldsFields inherited from interface com.zfabrik.components.provider.IComponentsRepository
COMPONENT_REPO_IMPLEMENTATION, COMPONENT_REPO_MODE, COMPONENT_REPO_MODE_RELAXED, COMPONENT_REPO_MODE_STRICT
Fields inherited from interface com.zfabrik.util.sync.ISynchronizer
PRIO, TYPE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
Simple type helper forResource
implementations.protected void
Check offline mode and if so throw an exception.void
complete
(ISynchronization sync) synchronizers implement this method to re-establish any desired system state after all invalidations have been performed.protected void
configure
(int prio) Is actuallyconfigure(prio,null)
.protected void
Is actuallyconfigure(prio,evictionDelay,this.name)
.protected void
Finish configuration.abstract void
Download resources of a single component into the given folderfindComponents
(X x, boolean localOnly) finds all components satisfying a query condition.protected File
getComponent
(String cn, boolean localOnly) retrieves a component descriptor for a fully qualified component, e.g.gets the repository contextfinal DB
getDB()
returns the current DBprotected Properties
provided expected repository configuration.getModules
(boolean localOnly) Retrieve the set of modules provided by this repository.getName()
protected long
Overall revision of the repository - if availablelong
getRevision
(String cn, boolean localOnly) return the most current revision of the component as available by the provider.protected String
getURL()
Some URL style information on the external data source the repository implementation relies onstatic boolean
Simple type helper forResource
implementations.protected boolean
Operational mode checksvoid
pre invalidation collection of outdated componentsprotected void
preInvalidation
(DB currentDB, DB newDB, ISynchronization sync) Can be overridden to add additional invalidation behavior based on the current DB and the new DB.Retrieve a component's resource folder.abstract DB
Provide an updated DB.protected void
setEvictionDelay
(long evictionDelay) Set eviction of old component copiesvoid
start()
Start the repository and register it.void
stop()
Stop and unregister the repo.void
void
test_setDb
(DB db) void
test_setInited
(boolean inited) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.zfabrik.components.provider.IComponentsRepository
findComponents, getComponent, getModules, getRevision, retrieve
-
Field Details
-
ALL
-
-
Constructor Details
-
AbstractExtComponentRepository
-
-
Method Details
-
configure
Finish configuration. Must be called before using as repo and using root (not roots!) information. I.e. this should be called as early as possible BUT after determining the expected configuration that is used to decide whether a repo cache is to be evicted.- Parameters:
prio
- Repository priority. SeeIComponentsRepository
.evictionDelay
- Delay of eviction for old component versions. This should be so high that concurrent home usage may not really happen. Defaults to 24h.repoKey
- A key of the repo that identifies its cache space. For different usages, same name, repo key should. For example the dev repo may be used for different workspaces and is still one repo
-
getExpectedConfiguration
provided expected repository configuration. This property set is used by theFSComponentRepositoryHelper
to make a decision on whether the repository cache is still valid. Any change in repository configuration between repository initialization will be taken as reason to completely purge the local repository. By default this method returns the complete repository configuration. -
configure
Is actuallyconfigure(prio,evictionDelay,this.name)
.- Parameters:
prio
- Repository priority. SeeIComponentsRepository
.evictionDelay
- Delay of eviction for old component versions. This should be so high that concurrent home usage may not really happen. Defaults to 24h.
-
configure
protected void configure(int prio) Is actuallyconfigure(prio,null)
.- Parameters:
prio
- Repository priority. SeeIComponentsRepository
.
-
getName
-
getCacheRoot
-
setEvictionDelay
protected void setEvictionDelay(long evictionDelay) Set eviction of old component copies -
has
Simple type helper forResource
implementations. Call this to check whether delegation to the component repository should be implemented -
as
Simple type helper forResource
implementations. Call this to check whether delegation to the component repository should be implemented -
getContext
gets the repository context -
stop
public void stop()Stop and unregister the repo. The instance becomes unusable after that -
start
public void start()Start the repository and register it. -
preInvalidation
pre invalidation collection of outdated components- Specified by:
preInvalidation
in interfaceISynchronizer
-
preInvalidation
Can be overridden to add additional invalidation behavior based on the current DB and the new DB. Standard behavior has already applied when this method is called- Parameters:
currentDB
-newDB
-sync
-
-
complete
Description copied from interface:ISynchronizer
synchronizers implement this method to re-establish any desired system state after all invalidations have been performed. Note that the set of synchronizer in this call may be different to before, due to new system content.- Specified by:
complete
in interfaceISynchronizer
-
getRevision
Description copied from interface:IComponentsRepository
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.
- Specified by:
getRevision
in interfaceIComponentsRepository
- Throws:
IOException
-
findComponents
Description copied from interface:IComponentsRepository
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.
- Specified by:
findComponents
in interfaceIComponentsRepository
- Throws:
IOException
-
getComponent
Description copied from interface:IComponentsRepository
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.
- Specified by:
getComponent
in interfaceIComponentsRepository
-
retrieve
Description copied from interface:IComponentsRepository
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.
- Specified by:
retrieve
in interfaceIComponentsRepository
- Returns:
- the component's folder resource folder or
null
, if the component does not exist. - Throws:
IOException
-
getModules
Description copied from interface:IComponentsRepository
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.- Specified by:
getModules
in interfaceIComponentsRepository
- Throws:
IOException
-
getRevision
protected long getRevision()Overall revision of the repository - if available -
getURL
Some URL style information on the external data source the repository implementation relies on -
isRelaxedMode
protected boolean isRelaxedMode()Operational mode checks -
checkOfflineMode
protected void checkOfflineMode()Check offline mode and if so throw an exception. This is to used in repository implementations in conjunction with the relaxed mode. That is: We consider the offline mode as one particular failure mode when trying to access remote resources. Only when in relaxed mode and sensible data is present, continuing in offline mode is advisable - as for any other remote access failure. -
scan
Provide an updated DB. This DB will be used to compute invalidations on synchronization and it will be used to serve component meta-data. If the repository implementation needs to attach additional meta-data to the DB, it should overwrite the DB class to do so, as the result of a scan potentially will be discarded. -
download
Download resources of a single component into the given folder -
getDB
returns the current DB- Throws:
IOException
-
toString
-
test_setInited
public void test_setInited(boolean inited) -
test_setContext
-
test_setDb
-