Class GitComponentRepositoryImpl

  • All Implemented Interfaces:
    com.zfabrik.components.provider.IComponentsRepository, com.zfabrik.util.sync.ISynchronizer

    public class GitComponentRepositoryImpl
    extends com.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository
    Git based components repository based on AbstractFileSystemComponentRepository

    The Git CR clones the source repo (i.e. the one defined by gitcr.path) into the z2-repo cache. On sync the cloned repo fetches all changes from the source repo, so that git does all the ugly stuff :-)

    Known GitCR properties:

    gitcr.uriThe URI to the source repo. Can be an absolute path, a local path relative to bin, or a remote URL
    gitcr.priority or gitcr.prioThe priority of the repository
    gitcr.branchThe branch to clone. Defaults to the active branch of the source repository
    gitcr.ref A Git ref to fetch and check out as active content. This can be a tag (refs/tags/<tag name>), or a branch (refs/heads/<branch name>) or HEAD for the default branch. For compatibility, it can also be a remote tracking branch (refs/remotes/origin/<branch name> or origin/<branch name>).

    As this information is used to compute a ref spec, this may not be a single commit, as git fetch requires some form of ref.

    In particular this can be "HEAD" to simply follow the remote default branch!

    Use this option, if you need more control than given by gitcr.branch. Note that the latter will be used with preference and hence needs to be omitted, if you want to use gitcr.ref.
    gitcr.rootsComma-separated list of paths relative to the repo root to search for modules. Can be left empty for the default, which is searching from the root
    Author:
    Udo Offermann, Henning Blohm
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.zfabrik.components.provider.util.AbstractExtComponentRepository

        com.zfabrik.components.provider.util.AbstractExtComponentRepository.Repo, com.zfabrik.components.provider.util.AbstractExtComponentRepository.RepoMBean
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String GITCR_BRANCH
      Branch to clone from the source repository.
      static java.lang.String GITCR_OPTIONAL
      If set to 'true', the gitcr will be ignore silently if the defined gitcr.uri is invalid.
      static java.lang.String GITCR_PRIO  
      static java.lang.String GITCR_PRIORITY
      Priority of the repository within the repository chain.
      static java.lang.String GITCR_PWD
      Password for authentication at the repository
      static java.lang.String GITCR_REF
      A Git ref to fetch and check out as active content.
      static java.lang.String GITCR_ROOTS
      A comma separated list of folders in the repo to search for components.
      static java.lang.String GITCR_TIMEOUT
      network timeout-value in seconds.
      static java.lang.String GITCR_URI
      URI of the git source repository.
      static java.lang.String GITCR_USER
      User name for authentication at the repository
      • Fields inherited from class com.zfabrik.components.provider.util.AbstractExtComponentRepository

        ALL
      • Fields 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 
      Constructor Description
      GitComponentRepositoryImpl​(java.lang.String name, java.util.Properties props)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Properties getExpectedConfiguration()
      provided expected repository configuration.
      java.lang.String getLabel()  
      java.io.File getLocalRepo()  
      static java.lang.String getRef​(java.lang.String name, java.util.Properties props)  
      com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB scan​(com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB current)
      Scans for changes in this GitCR which implies: if current is null the source repository will be cloned into the repository cache if the repository
      java.lang.String toString()  
      • Methods inherited from class com.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository

        download, getRoots, setRoots
      • Methods inherited from class com.zfabrik.components.provider.util.AbstractExtComponentRepository

        as, checkOfflineMode, complete, configure, configure, configure, findComponents, getCacheRoot, getComponent, getContext, getDB, getModules, getName, getRevision, getRevision, getURL, has, isRelaxedMode, preInvalidation, preInvalidation, retrieve, setEvictionDelay, start, stop, test_setContext, test_setDb, test_setInited
      • 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 Detail

      • GITCR_ROOTS

        public static final java.lang.String GITCR_ROOTS
        A comma separated list of folders in the repo to search for components. Can be left empty, if the repo is only at top level. Otherwise a list in order of decreasing priority can be given.
        See Also:
        Constant Field Values
      • GITCR_URI

        public static final java.lang.String GITCR_URI
        URI of the git source repository.
        See Also:
        Constant Field Values
      • GITCR_PRIORITY

        public static final java.lang.String GITCR_PRIORITY
        Priority of the repository within the repository chain. See IComponentsRepository. Both gitcr.priority and gitcr.prio are valid keys.
        See Also:
        Constant Field Values
      • GITCR_BRANCH

        public static final java.lang.String GITCR_BRANCH
        Branch to clone from the source repository. Setting this is equivalent to setting GITCR_REF with the branch name prefixed by refs/heads/.
        See Also:
        Constant Field Values
      • GITCR_REF

        public static final java.lang.String GITCR_REF
        A Git ref to fetch and check out as active content. This can be a tag (refs/tags/<tag name>), or a branch (refs/heads/<branch name>) or HEAD for the default branch. For compatibility, it can also be a remote tracking branch (refs/remotes/origin/<branch name> or origin/<branch name>).

        As this information is used to compute a ref spec, this may not be a single commit, as git fetch requires some form of ref.

        In particular this can be "HEAD" to simply follow the remote default branch!

        Use this option, if you need more control than given by gitcr.branch. Note that the latter will be used with preference and hence needs to be omitted, if you want to use gitcr.ref.
        See Also:
        Constant Field Values
      • GITCR_USER

        public static final java.lang.String GITCR_USER
        User name for authentication at the repository
        See Also:
        Constant Field Values
      • GITCR_PWD

        public static final java.lang.String GITCR_PWD
        Password for authentication at the repository
        See Also:
        Constant Field Values
      • GITCR_OPTIONAL

        public static final java.lang.String GITCR_OPTIONAL
        If set to 'true', the gitcr will be ignore silently if the defined gitcr.uri is invalid. Defaults to 'true', in which case only a warning is logged, when the origin repository is not reachable.
        See Also:
        Constant Field Values
      • GITCR_TIMEOUT

        public static final java.lang.String GITCR_TIMEOUT
        network timeout-value in seconds. Defaults to 10seconds.
        See Also:
        Constant Field Values
    • Constructor Detail

      • GitComponentRepositoryImpl

        public GitComponentRepositoryImpl​(java.lang.String name,
                                          java.util.Properties props)
    • Method Detail

      • getExpectedConfiguration

        protected java.util.Properties getExpectedConfiguration()
        Description copied from class: com.zfabrik.components.provider.util.AbstractExtComponentRepository
        provided expected repository configuration. This property set is used by the FSComponentRepositoryHelper 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.
        Overrides:
        getExpectedConfiguration in class com.zfabrik.components.provider.util.AbstractExtComponentRepository<com.zfabrik.components.provider.fs.RootBoundFSCRComponent,​com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB>
      • scan

        public com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB scan​(com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB current)
        Scans for changes in this GitCR which implies:
        • if current is null the source repository will be cloned into the repository cache
        • if the repository
        Overrides:
        scan in class com.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository
      • getLocalRepo

        public java.io.File getLocalRepo()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class com.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository
      • getLabel

        public java.lang.String getLabel()
      • getRef

        public static java.lang.String getRef​(java.lang.String name,
                                              java.util.Properties props)