Class DefaultIndexingContext

java.lang.Object
org.apache.maven.index.context.AbstractIndexingContext
org.apache.maven.index.context.DefaultIndexingContext
All Implemented Interfaces:
IndexingContext

public class DefaultIndexingContext extends AbstractIndexingContext
The default IndexingContext implementation.
Author:
Jason van Zyl, Tamas Cservenak
  • Field Details Link icon

  • Constructor Details Link icon

  • Method Details Link icon

    • getIndexDirectory Link icon

      public org.apache.lucene.store.Directory getIndexDirectory()
    • setIndexDirectoryFile Link icon

      protected void setIndexDirectoryFile(File dir) throws IOException
      Sets index location. As usually index is persistent (is on disk), this will point to that value, but in some circumstances (ie, using RAMDisk for index), this will point to an existing tmp directory.
      Throws:
      IOException
    • getIndexDirectoryFile Link icon

      public File getIndexDirectoryFile()
    • isSearchable Link icon

      public boolean isSearchable()
      Description copied from interface: IndexingContext
      Is the context searchable when doing "non-targeted" searches? Ie. Should it take a part when searching without specifying context?
      Returns:
    • setSearchable Link icon

      public void setSearchable(boolean searchable)
      Description copied from interface: IndexingContext
      Sets is the context searchable when doing "non-targeted" searches.
      Parameters:
      searchable -
    • getId Link icon

      public String getId()
      Description copied from interface: IndexingContext
      Returns this indexing context id.
    • updateTimestamp Link icon

      public void updateTimestamp() throws IOException
      Throws:
      IOException
    • updateTimestamp Link icon

      public void updateTimestamp(boolean save) throws IOException
      Throws:
      IOException
    • updateTimestamp Link icon

      public void updateTimestamp(boolean save, Date timestamp) throws IOException
      Throws:
      IOException
    • getTimestamp Link icon

      public Date getTimestamp()
      Description copied from interface: IndexingContext
      Returns index update time
    • getSize Link icon

      public int getSize() throws IOException
      Description copied from interface: IndexingContext
      Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more data indexed?). The number return does not represent the count of ArtifactInfos, neither other "meaningful" info, it is purely to be used for inter-context comparisons only!
      Returns:
      Throws:
      IOException
    • getRepositoryId Link icon

      public String getRepositoryId()
      Description copied from interface: IndexingContext
      Returns repository id.
    • getRepository Link icon

      public File getRepository()
      Description copied from interface: IndexingContext
      Returns location for the local repository.
    • getRepositoryUrl Link icon

      public String getRepositoryUrl()
      Description copied from interface: IndexingContext
      Returns public repository url.
    • getIndexUpdateUrl Link icon

      public String getIndexUpdateUrl()
      Description copied from interface: IndexingContext
      Returns url for the index update
    • getAnalyzer Link icon

      public org.apache.lucene.analysis.Analyzer getAnalyzer()
      Description copied from interface: IndexingContext
      Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher. Note: this method always creates a new instance of analyzer!
      Returns:
    • openAndWarmup Link icon

      protected void openAndWarmup() throws IOException
      Throws:
      IOException
    • getWriterConfig Link icon

      protected org.apache.lucene.index.IndexWriterConfig getWriterConfig()
      Returns new IndexWriterConfig instance
      Since:
      5.1
    • getIndexWriter Link icon

      public org.apache.lucene.index.IndexWriter getIndexWriter() throws IOException
      Description copied from interface: IndexingContext
      Returns the Lucene IndexWriter (thread safe, shared instance) of this context.
      Returns:
      indexWriter
      Throws:
      IOException
    • acquireIndexSearcher Link icon

      public org.apache.lucene.search.IndexSearcher acquireIndexSearcher() throws IOException
      Description copied from interface: IndexingContext
      Acquires a fresh instance of IndexSearcher. You have to release the received instance with IndexingContext.releaseIndexSearcher(IndexSearcher) otherwise you are about to introduce leak.
      Returns:
      Throws:
      IOException
    • releaseIndexSearcher Link icon

      public void releaseIndexSearcher(org.apache.lucene.search.IndexSearcher is) throws IOException
      Description copied from interface: IndexingContext
      Releases the IndexSearcher instance.
      Parameters:
      is -
      Throws:
      IOException
    • commit Link icon

      public void commit() throws IOException
      Description copied from interface: IndexingContext
      Commits changes to context, eventually refreshing readers/searchers too.
      Throws:
      IOException
    • rollback Link icon

      public void rollback() throws IOException
      Description copied from interface: IndexingContext
      Rolls back changes to context, eventually refreshing readers/searchers too.
      Throws:
      IOException
    • optimize Link icon

      public void optimize() throws org.apache.lucene.index.CorruptIndexException, IOException
      Description copied from interface: IndexingContext
      Optimizes index. According to Lucene 3.6+ Javadoc, there is no more sense to optimize, so this method might become "noop".
      Throws:
      org.apache.lucene.index.CorruptIndexException
      IOException
    • close Link icon

      public void close(boolean deleteFiles) throws IOException
      Description copied from interface: IndexingContext
      Shuts down this context.
      Throws:
      IOException
    • purge Link icon

      public void purge() throws IOException
      Description copied from interface: IndexingContext
      Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.
      Throws:
      IOException
    • replace Link icon

      public void replace(org.apache.lucene.store.Directory directory) throws IOException
      Description copied from interface: IndexingContext
      Replaces the Lucene index with the one from supplied directory.
      Parameters:
      directory -
      Throws:
      IOException
    • replace Link icon

      public void replace(org.apache.lucene.store.Directory directory, Set<String> allGroups, Set<String> rootGroups) throws IOException
      Throws:
      IOException
    • merge Link icon

      public void merge(org.apache.lucene.store.Directory directory) throws IOException
      Description copied from interface: IndexingContext
      Merges content of given Lucene directory with this context.
      Parameters:
      directory - - the directory to merge
      Throws:
      IOException
    • merge Link icon

      public void merge(org.apache.lucene.store.Directory directory, DocumentFilter filter) throws IOException
      Description copied from interface: IndexingContext
      Merges content of given Lucene directory with this context, but filters out the unwanted ones.
      Parameters:
      directory - - the directory to merge
      Throws:
      IOException
    • merge Link icon

      public void merge(org.apache.lucene.store.Directory directory, DocumentFilter filter, Set<String> allGroups, Set<String> rootGroups) throws IOException
      Description copied from interface: IndexingContext
      Merges content of given Lucene directory with this context, but filters out the unwanted ones and adds the groups to the context.
      Parameters:
      directory - - the directory to merge
      Throws:
      IOException
    • getGavCalculator Link icon

      public GavCalculator getGavCalculator()
      Description copied from interface: IndexingContext
      Returns the GavCalculator for this Context. Implies repository layout.
    • getIndexCreators Link icon

      public List<IndexCreator> getIndexCreators()
      Description copied from interface: IndexingContext
      List of IndexCreators used in this context.
      Returns:
      list of index creators.
    • rebuildGroups Link icon

      public void rebuildGroups() throws IOException
      Description copied from interface: IndexingContext
      Rebuilds stored group names from the index
      Throws:
      IOException
    • getAllGroups Link icon

      public Set<String> getAllGroups()
      Description copied from interface: IndexingContext
      Gets all group names stored in the current indexing context
    • setAllGroups Link icon

      public void setAllGroups(Collection<String> groups)
      Description copied from interface: IndexingContext
      Sets all group names stored in the current indexing context
    • getRootGroups Link icon

      public Set<String> getRootGroups() throws IOException
      Description copied from interface: IndexingContext
      Gets root group names stored in the current indexing context
      Throws:
      IOException
    • setRootGroups Link icon

      public void setRootGroups(Collection<String> groups)
      Description copied from interface: IndexingContext
      Sets root group names stored in the current indexing context
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object