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 TypeClassDescriptionclassstatic 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_STRICTFields inherited from interface com.zfabrik.util.sync.ISynchronizer
PRIO, TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TSimple type helper forResourceimplementations.protected voidCheck offline mode and if so throw an exception.voidcomplete(ISynchronization sync) synchronizers implement this method to re-establish any desired system state after all invalidations have been performed.protected voidconfigure(int prio) Is actuallyconfigure(prio,null).protected voidIs actuallyconfigure(prio,evictionDelay,this.name).protected voidFinish configuration.abstract voidDownload resources of a single component into the given folderfindComponents(X x, boolean localOnly) finds all components satisfying a query condition.protected FilegetComponent(String cn, boolean localOnly) retrieves a component descriptor for a fully qualified component, e.g.gets the repository contextfinal DBgetDB()returns the current DBprotected Propertiesprovided expected repository configuration.getModules(boolean localOnly) Retrieve the set of modules provided by this repository.getName()protected longOverall revision of the repository - if availablelonggetRevision(String cn, boolean localOnly) return the most current revision of the component as available by the provider.protected StringgetURL()Some URL style information on the external data source the repository implementation relies onstatic booleanSimple type helper forResourceimplementations.protected booleanOperational mode checksvoidpre invalidation collection of outdated componentsprotected voidpreInvalidation(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 DBProvide an updated DB.protected voidsetEvictionDelay(long evictionDelay) Set eviction of old component copiesvoidstart()Start the repository and register it.voidstop()Stop and unregister the repo.voidvoidtest_setDb(DB db) voidtest_setInited(boolean inited) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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 theFSComponentRepositoryHelperto 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 forResourceimplementations. Call this to check whether delegation to the component repository should be implemented -
as
Simple type helper forResourceimplementations. 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:
preInvalidationin 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:ISynchronizersynchronizers 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:
completein interfaceISynchronizer
-
getRevision
Description copied from interface:IComponentsRepositoryreturn 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:
getRevisionin interfaceIComponentsRepository- Throws:
IOException
-
findComponents
Description copied from interface:IComponentsRepositoryfinds 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:
findComponentsin interfaceIComponentsRepository- Throws:
IOException
-
getComponent
Description copied from interface:IComponentsRepositoryretrieves a component descriptor for a fully qualified component, e.g.<module>/javafor 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:
getComponentin interfaceIComponentsRepository
-
retrieve
Description copied from interface:IComponentsRepositoryRetrieve 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:
retrievein interfaceIComponentsRepository- Returns:
- the component's folder resource folder or
null, if the component does not exist. - Throws:
IOException
-
getModules
Description copied from interface:IComponentsRepositoryRetrieve the set of modules provided by this repository. IflocalOnlyis true, the methods returns only those modules that are provided by the very repository.- Specified by:
getModulesin 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
-