org.opensolaris.opengrok.configuration
Class RuntimeEnvironment

java.lang.Object
  extended by org.opensolaris.opengrok.configuration.RuntimeEnvironment

public class RuntimeEnvironment
extends java.lang.Object

The RuntimeEnvironment class is used as a placeholder for the current configuration this execution context (classloader) is using.


Method Summary
 java.lang.String getBugPage()
          Returns the bug page for the history listing
 java.lang.String getBugPattern()
          Returns the bug regex for the history listing
 java.lang.String getCtags()
          Get the name of the ctags program in use
 java.io.File getDataRootFile()
          Get a file representing the index database
 java.lang.String getDataRootPath()
          Get the path to the where the index database is stored
 Project getDefaultProject()
          Get the project that is specified to be the default project to use.
 int getHistoryReaderTimeLimit()
          Get the max time a SMC operation may use to avoid beeing cached
 IgnoredNames getIgnoredNames()
           
 int getIndexWordLimit()
          Chandan wrote the following answer on the opengrok-discuss list: "Traditionally search engines (specially spiders) think that large files are junk.
static RuntimeEnvironment getInstance()
          Get the one and only instance of the RuntimeEnvironment
 java.util.List<Project> getProjects()
          Get all of the projects
 java.util.Map<java.lang.String,ExternalRepository> getRepositories()
          Get the map of external SCM repositories available
 java.io.File getSourceRootFile()
          Get a file representing the directory where the sources are located
 java.lang.String getSourceRootPath()
          Get the path to where the sources are located
 java.lang.String getUrlPrefix()
          Get the context name of the web application
 java.lang.String getUserPage()
          Returns the user page for the history listing
 java.lang.String getWebappLAF()
           
 boolean hasProjects()
          Do we have projects?
 boolean isAllowLeadingWildcard()
          Is leading wildcards allowed?
 boolean isGenerateHtml()
          Should we generate HTML or not during the indexing phase
 boolean isOptimizeDatabase()
           
 boolean isQuickContextScan()
           
 boolean isRemoteScmSupported()
           
 boolean isVerbose()
          Is the verbosity flag turned on?
 void readConfiguration(java.io.File file)
          Read an configuration file and set it as the current configuration.
 void register()
          Register this thread in the thread/configuration map (so that all subsequent calls to the RuntimeEnvironment from this thread will use the same configuration
 void setAllowLeadingWildcard(boolean allowLeadingWildcard)
          Specify if a search may start with a wildcard.
 void setBugPage(java.lang.String bugPage)
          Sets the bug page for the history listing
 void setBugPattern(java.lang.String bugPattern)
          Sets the bug regex for the history listing
 void setConfiguration(Configuration configuration)
           
 void setCtags(java.lang.String ctags)
          Specify the CTags program to use
 void setDataRoot(java.io.File data)
          Set the path to where the index database is stored
 void setDataRoot(java.lang.String dataRoot)
          Set the path to where the index database is stored
 void setDefaultProject(Project defaultProject)
          Set the project that is specified to be the default project to use.
 void setGenerateHtml(boolean generateHtml)
          Specify if we should generate HTML or not during the indexing phase
 void setHistoryReaderTimeLimit(int historyReaderTimeLimit)
          Specify the maximum time a SCM operation should take before it will be cached (in ms)
 void setIgnoredNames(IgnoredNames ignoredNames)
           
 void setIndexWordLimit(int indexWordLimit)
          Set the number of words in a file Lucene will index.
 void setOptimizeDatabase(boolean optimizeDatabase)
           
 void setProjects(java.util.List<Project> projects)
          Set the list of the projects
 void setQuickContextScan(boolean quickContextScan)
           
 void setRemoteScmSupported(boolean supported)
           
 void setRepositories(java.util.Map<java.lang.String,ExternalRepository> repositories)
          Set the map of external SCM repositories
 void setSourceRoot(java.lang.String sourceRoot)
          Specify the source root
 void setSourceRootFile(java.io.File source)
          Specify the source root
 void setUrlPrefix(java.lang.String urlPrefix)
          Set the web context name
 void setUseHistoryCache(boolean useHistoryCache)
          Specify if we should use history cache or not
 void setUserPage(java.lang.String userPage)
          Sets the user page for the history listing
 void setVerbose(boolean verbose)
          Set the verbosity flag (to add extra debug information in output)
 void setWebappLAF(java.lang.String laf)
           
 boolean startConfigurationListenerThread(java.net.SocketAddress endpoint)
          Start a thread to listen on a socket to receive new configurations to use.
 void stopConfigurationListenerThread()
          Try to stop the configuration listener thread
 boolean useHistoryCache()
          Is history cache currently enabled?
 boolean validateExuberantCtags()
          Validate that I have a Exuberant ctags program I may use
 void writeConfiguration(java.io.File file)
          Write the current configuration to a file
 void writeConfiguration(java.net.InetAddress host, int port)
          Write the current configuration to a socket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static RuntimeEnvironment getInstance()
Get the one and only instance of the RuntimeEnvironment

Returns:
the one and only instance of the RuntimeEnvironment

getDataRootPath

public java.lang.String getDataRootPath()
Get the path to the where the index database is stored

Returns:
the path to the index database

getDataRootFile

public java.io.File getDataRootFile()
Get a file representing the index database

Returns:
the index database

setDataRoot

public void setDataRoot(java.io.File data)
                 throws java.io.IOException
Set the path to where the index database is stored

Parameters:
data - the index database
Throws:
java.io.IOException - if the path cannot be resolved

setDataRoot

public void setDataRoot(java.lang.String dataRoot)
Set the path to where the index database is stored

Parameters:
dataRoot - the index database

getSourceRootPath

public java.lang.String getSourceRootPath()
Get the path to where the sources are located

Returns:
path to where the sources are located

getSourceRootFile

public java.io.File getSourceRootFile()
Get a file representing the directory where the sources are located

Returns:
A file representing the directory where the sources are located

setSourceRootFile

public void setSourceRootFile(java.io.File source)
                       throws java.io.IOException
Specify the source root

Parameters:
source - the location of the sources
Throws:
java.io.IOException - if the name cannot be resolved

setSourceRoot

public void setSourceRoot(java.lang.String sourceRoot)
Specify the source root

Parameters:
sourceRoot - the location of the sources

hasProjects

public boolean hasProjects()
Do we have projects?

Returns:
true if we have projects

getProjects

public java.util.List<Project> getProjects()
Get all of the projects

Returns:
a list containing all of the projects (may be null)

setProjects

public void setProjects(java.util.List<Project> projects)
Set the list of the projects

Parameters:
projects - the list of projects to use

register

public void register()
Register this thread in the thread/configuration map (so that all subsequent calls to the RuntimeEnvironment from this thread will use the same configuration


getUrlPrefix

public java.lang.String getUrlPrefix()
Get the context name of the web application

Returns:
the web applications context name

setUrlPrefix

public void setUrlPrefix(java.lang.String urlPrefix)
Set the web context name

Parameters:
urlPrefix - the web applications context name

getCtags

public java.lang.String getCtags()
Get the name of the ctags program in use

Returns:
the name of the ctags program in use

setCtags

public void setCtags(java.lang.String ctags)
Specify the CTags program to use

Parameters:
ctags - the ctags program to use

validateExuberantCtags

public boolean validateExuberantCtags()
Validate that I have a Exuberant ctags program I may use

Returns:
true if success, false otherwise

getHistoryReaderTimeLimit

public int getHistoryReaderTimeLimit()
Get the max time a SMC operation may use to avoid beeing cached

Returns:
the max time

setHistoryReaderTimeLimit

public void setHistoryReaderTimeLimit(int historyReaderTimeLimit)
Specify the maximum time a SCM operation should take before it will be cached (in ms)

Parameters:
historyReaderTimeLimit - the max time in ms before it is cached

useHistoryCache

public boolean useHistoryCache()
Is history cache currently enabled?

Returns:
true if history cache is enabled

setUseHistoryCache

public void setUseHistoryCache(boolean useHistoryCache)
Specify if we should use history cache or not

Parameters:
useHistoryCache - set false if you do not want to use history cache

isGenerateHtml

public boolean isGenerateHtml()
Should we generate HTML or not during the indexing phase

Returns:
true if HTML should be generated during the indexing phase

setGenerateHtml

public void setGenerateHtml(boolean generateHtml)
Specify if we should generate HTML or not during the indexing phase

Parameters:
generateHtml - set this to true to pregenerate HTML

isQuickContextScan

public boolean isQuickContextScan()

setQuickContextScan

public void setQuickContextScan(boolean quickContextScan)

getRepositories

public java.util.Map<java.lang.String,ExternalRepository> getRepositories()
Get the map of external SCM repositories available

Returns:
A map containing all available SCMs

setRepositories

public void setRepositories(java.util.Map<java.lang.String,ExternalRepository> repositories)
Set the map of external SCM repositories

Parameters:
repositories - the repositories to use

setDefaultProject

public void setDefaultProject(Project defaultProject)
Set the project that is specified to be the default project to use. The default project is the project you will search (from the web application) if the page request didn't contain the cookie..

Parameters:
defaultProject - The default project to use

getDefaultProject

public Project getDefaultProject()
Get the project that is specified to be the default project to use. The default project is the project you will search (from the web application) if the page request didn't contain the cookie..

Returns:
the default project (may be null if not specified)

getIndexWordLimit

public int getIndexWordLimit()
Chandan wrote the following answer on the opengrok-discuss list: "Traditionally search engines (specially spiders) think that large files are junk. Large files tend to be multimedia files etc., which text search spiders do not want to chew. So they ignore the contents of the file after a cutoff length. Lucene does this by number of words, which is by default is 10,000." By default OpenGrok will increase this limit to 60000, but it may be overridden in the configuration file

Returns:
The maximum words to index

setIndexWordLimit

public void setIndexWordLimit(int indexWordLimit)
Set the number of words in a file Lucene will index. See getIndexWordLimit for a better description.

Parameters:
indexWordLimit - the number of words to index in a single file

isVerbose

public boolean isVerbose()
Is the verbosity flag turned on?

Returns:
true if we can print extra information

setVerbose

public void setVerbose(boolean verbose)
Set the verbosity flag (to add extra debug information in output)

Parameters:
verbose - new value

setAllowLeadingWildcard

public void setAllowLeadingWildcard(boolean allowLeadingWildcard)
Specify if a search may start with a wildcard. Note that queries that start with a wildcard will give a significant impact on the search performace.

Parameters:
allowLeadingWildcard - set to true to activate (disabled by default)

isAllowLeadingWildcard

public boolean isAllowLeadingWildcard()
Is leading wildcards allowed?

Returns:
true if a search may start with a wildcard

getIgnoredNames

public IgnoredNames getIgnoredNames()

setIgnoredNames

public void setIgnoredNames(IgnoredNames ignoredNames)

getUserPage

public java.lang.String getUserPage()
Returns the user page for the history listing

Returns:
the URL string fragment preceeding the username

setUserPage

public void setUserPage(java.lang.String userPage)
Sets the user page for the history listing

Parameters:
userPage - the URL fragment preceeding the username from history

getBugPage

public java.lang.String getBugPage()
Returns the bug page for the history listing

Returns:
the URL string fragment preceeding the bug ID

setBugPage

public void setBugPage(java.lang.String bugPage)
Sets the bug page for the history listing

Parameters:
bugPage - the URL fragment preceeding the bug ID

getBugPattern

public java.lang.String getBugPattern()
Returns the bug regex for the history listing

Returns:
the regex that is looked for in history comments

setBugPattern

public void setBugPattern(java.lang.String bugPattern)
Sets the bug regex for the history listing

Parameters:
bugPattern - the regex to search history comments

getWebappLAF

public java.lang.String getWebappLAF()

setWebappLAF

public void setWebappLAF(java.lang.String laf)

isRemoteScmSupported

public boolean isRemoteScmSupported()

setRemoteScmSupported

public void setRemoteScmSupported(boolean supported)

isOptimizeDatabase

public boolean isOptimizeDatabase()

setOptimizeDatabase

public void setOptimizeDatabase(boolean optimizeDatabase)

readConfiguration

public void readConfiguration(java.io.File file)
                       throws java.io.IOException
Read an configuration file and set it as the current configuration.

Parameters:
file - the file to read
Throws:
java.io.IOException - if an error occurs

writeConfiguration

public void writeConfiguration(java.io.File file)
                        throws java.io.IOException
Write the current configuration to a file

Parameters:
file - the file to write the configuration into
Throws:
java.io.IOException - if an error occurs

writeConfiguration

public void writeConfiguration(java.net.InetAddress host,
                               int port)
                        throws java.io.IOException
Write the current configuration to a socket

Parameters:
host - the host address to receive the configuration
port - the port to use on the host
Throws:
java.io.IOException - if an error occurs

setConfiguration

public void setConfiguration(Configuration configuration)

stopConfigurationListenerThread

public void stopConfigurationListenerThread()
Try to stop the configuration listener thread


startConfigurationListenerThread

public boolean startConfigurationListenerThread(java.net.SocketAddress endpoint)
Start a thread to listen on a socket to receive new configurations to use.

Parameters:
endpoint - The socket address to listen on
Returns:
true if the endpoint was available (and the thread was started)