org.wso2.carbon.registry.core.config
Class RegistryContext

java.lang.Object
  extended by org.wso2.carbon.registry.core.config.RegistryContext

public class RegistryContext
extends Object

This class provides access to core registry configurations. Registry context is associated with each mounted registry instance. The base registry context can be accessed via the getBaseInstance method.


Nested Class Summary
static interface RegistryContext.RegURLSupplier
          Deprecated. 
 
Constructor Summary
protected RegistryContext()
          Create a registry context with default values.
protected RegistryContext(InputStream configStream, org.wso2.carbon.user.core.service.RealmService realmService)
          Create a registry context with custom configuration and realm service.
protected RegistryContext(InputStream configStream, org.wso2.carbon.user.core.service.RealmService realmService, boolean populateConfiguration)
          Create a registry context with custom configuration and realm service.
protected RegistryContext(InputStream configStream, RegistryContext.RegURLSupplier urlSupplier)
          Create a registry context with custom configuration and realm service.
protected RegistryContext(org.wso2.carbon.user.core.service.RealmService realmService, boolean populateConfiguration)
          Create a new registry context object with a custom realm service
 
Method Summary
 void addAspect(String name, Aspect aspect, int tenantId)
          Add an aspect of the name for a given tenant id
 void addDBConfig(String name, DataBaseConfiguration config)
          Add database configuration with the given name.
 void addHandlerConfiguration(HandlerConfiguration handlerConfiguration)
          Deprecated. 
 void addMediaTypeHandler(MediaTypeHandlerConfiguration mediaTypeHandlerConfiguration)
          Deprecated. 
 void addQueryProcessor(QueryProcessorConfiguration queryProcessorConfiguration)
          Add a new query processor.
 void addStatisticsCollector(StatisticsCollector statisticsCollector)
          Method to add a statistics collector
 void addURLHandler(String urlHandler)
          Deprecated. 
static void destroy()
          destroy the registry context
 Aspect getAspect(String name, int tenantId)
          Return an aspect of given name and given tenant id.
 String[] getAspectNames(int tenantId)
          Return engaged aspect names for a given tenant
static RegistryContext getBaseInstance()
          Get an instance of the base (not cloned),
static RegistryContext getBaseInstance(InputStream configStream, org.wso2.carbon.user.core.service.RealmService realmService)
          Return a singleton object of the registry context with a custom configuration, customer realm service.
static RegistryContext getBaseInstance(InputStream configStream, RegistryContext.RegURLSupplier urlSupplier)
          Deprecated. 
static RegistryContext getBaseInstance(org.wso2.carbon.user.core.service.RealmService realmService)
          Return a singleton object of the base registry context with custom realm service If a registry context doesn't exist, it will create a new one and return it.
static RegistryContext getBaseInstance(org.wso2.carbon.user.core.service.RealmService realmService, boolean populateConfiguration)
          Return a singleton object of the base registry context with custom realm service If a registry context doesn't exist, it will create a new one and return it.
 String getBasePath()
          Return the base path calculated using the url supplier.
static RegistryContext getCloneContext()
          Create an return a registry context.
 String getCollectionMediaTypes()
          Method to obtain collection media types.
 CustomEditManager getCustomEditManager()
          Return a custom edit manager, which is used by custom UI implementations.
 String getCustomUIMediaTypes()
          Method to obtain custom UI media types.
 DataAccessManager getDataAccessManager()
          Return the data access manager, created using the database configuration associated with the registry context
 DataBaseConfiguration getDBConfig(String dbConfigName)
          Get the database configuration of a given configuration name
 Iterator<String> getDBConfigNames()
          Get the available database configuration names.
 DataBaseConfiguration getDefaultDataBaseConfiguration()
          Return the default database configuration.
 EmbeddedRegistryService getEmbeddedRegistryService()
          Return a embedded registry service.
 List<HandlerConfiguration> getHandlerConfigurations()
          Deprecated. 
 HandlerManager getHandlerManager()
          Return the handler manager.
 HandlerManager getHandlerManager(String lifecyclePhase)
          Return the handler manager.
 LogWriter getLogWriter()
          Method to obtain the logWriter instance.
 int getMaxCache()
          Deprecated. 
 List getMediaTypeHandlers()
          Deprecated. 
 List<Mount> getMounts()
          Return a list of mounted registry configurations (Mount object).
 String getNodeIdentifier()
          Get a unique identifier for this registry node.
 String getProfilesPath()
          Return the profile storage path.
 QueryProcessorManager getQueryProcessorManager()
          Return a query processor.
 List getQueryProcessors()
          Return a list of available query processor.
 org.wso2.carbon.user.core.service.RealmService getRealmService()
          Return the associated realm service.
 String getRegistryRoot()
          Return the registry root.
 List<RemoteConfiguration> getRemoteInstances()
          Return a list of mounted remote instances.
 Repository getRepository()
          Return the repository object, which provides an interface to put, get resources to the repository.
 String getResourceMediaTypes()
          Method to obtain resource media types.
 String getServicePath()
          Get the service storage path.
 StatisticsCollector[] getStatisticsCollectors()
          Method to obtain a list of statistics collectors.
 List getUrlHandlers()
          Deprecated. 
 VersionRepository getVersionRepository()
          Return the version repository object, which provides an interface to create versions, retrieve old versions of resources
 boolean isCacheEnabled()
          Return whether the registry caching is enabled or not.
 boolean isClone()
          To check whether this is a clone or a base registry context.
 boolean isNoCachePath(String path)
          Method to determine whether caching is disabled for the given path.
 boolean isReadOnly()
          Return whether the registry is read-only or not.
 boolean isSetup()
          Whether the "setup" system property is set at the start.
 boolean isSystemResourcePathRegistered(String absolutePath)
          Method to determine whether a system resource (or collection) path has been registered.
 boolean isVersionOnChange()
          Whether the version should be created automatically on a change (only for non-collection resources)
 void registerNoCachePath(String path)
          Method to register a no-cache path.
 void registerSystemResourcePath(String absolutePath)
          Method to register a system resource (or collection) path.
 boolean removeAspect(String name, int tenantId)
          Remove an aspect with the given name for a given tenant id
 void removeStatisticsCollector(StatisticsCollector statisticsCollector)
          Method to remove a statistics collector
 DataBaseConfiguration selectDBConfig(String dbConfigName)
          Select a database configuration among the available database configuration.
 void setCacheEnabled(boolean enableCache)
          Set whether the registry caching is enabled or not.
 void setClone(boolean clone)
          Set the flag if the current registry context is a clone and not base
 void setCollectionMediaTypes(String collectionMediaTypes)
          Method to set collection media types.
 void setCustomEditManager(CustomEditManager customEditManager)
          Set a custom edit manager.
 void setCustomUIMediaTypes(String customUIMediaTypes)
          Method to set custom UI media types.
 void setDataAccessManager(DataAccessManager dataAccessManager)
          Set the data access manager.
 void setDefaultDataBaseConfiguration(DataBaseConfiguration dataBaseConfiguration)
          Sets the default database configuration.
 void setHandlerConfigurations(List<HandlerConfiguration> handlerConfigurations)
          Deprecated. 
 void setLogWriter(LogWriter logWriter)
          Method to set the logWriter instance.
 void setMaxCache(int maxCache)
          Deprecated. 
 void setMediaTypeHandlers(List mediaTypeHandlers)
          Deprecated. 
 void setMounts(List<Mount> mounts)
          Set a list of mounted registry configurations.
 void setProfilesPath(String path)
          Set profile storage path.
 void setQueryProcessorManager(QueryProcessorManager queryProcessorManager)
          Set a query processor object
 void setQueryProcessors(List<QueryProcessorConfiguration> queryProcessors)
          Set the query processor list.
 void setReadOnly(boolean readOnly)
          Set whether the registry is read-only or not
 void setRegistryRoot(String registryRoot)
          Set the registry root.
 void setRemoteInstances(List<RemoteConfiguration> remoteInstances)
          Set list of remote instances.
 void setRepository(Repository repository)
          Set the repository object.
 void setResourceMediaTypes(String resourceMediaTypes)
          Method to set resource media types.
 void setServicePath(String servicePath)
          Set the service storage path
 void setSetup(boolean setup)
          Set if the "setup" system property is set at the start.
 void setUrlHandlers(List urlHandlers)
          Deprecated. 
 void setVersionOnChange(boolean versionOnChange)
          Set whether the version should be created automatically on a change (only for non-collection resources)
 void setVersionRepository(VersionRepository versionRepository)
          Set a version repository object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryContext

protected RegistryContext(org.wso2.carbon.user.core.service.RealmService realmService,
                          boolean populateConfiguration)
                   throws RegistryException
Create a new registry context object with a custom realm service

Parameters:
realmService - associated realm service
populateConfiguration - whether the configuration must be populated or not.
Throws:
RegistryException - throws if the construction failed.

RegistryContext

protected RegistryContext(InputStream configStream,
                          org.wso2.carbon.user.core.service.RealmService realmService)
                   throws RegistryException
Create a registry context with custom configuration and realm service.

Parameters:
configStream - configuration stream. (registry.xml input stream)
realmService - the associated realm service
Throws:
RegistryException - throws if the construction failed.

RegistryContext

protected RegistryContext(InputStream configStream,
                          org.wso2.carbon.user.core.service.RealmService realmService,
                          boolean populateConfiguration)
                   throws RegistryException
Create a registry context with custom configuration and realm service.

Parameters:
configStream - configuration stream. (registry.xml input stream)
realmService - the associated realm service
populateConfiguration - whether the configuration must be populated or not.
Throws:
RegistryException - throws if the construction failed.

RegistryContext

protected RegistryContext(InputStream configStream,
                          RegistryContext.RegURLSupplier urlSupplier)
                   throws RegistryException
Create a registry context with custom configuration and realm service.

Parameters:
configStream - configuration stream. (registry.xml input stream)
urlSupplier - url supplier object.
Throws:
RegistryException - throws if the construction failed.

RegistryContext

protected RegistryContext()
Create a registry context with default values.

Method Detail

getNodeIdentifier

public String getNodeIdentifier()
Get a unique identifier for this registry node. This is used to establish uniqueness among multiple nodes of a cluster or a multi-product deployment. Please node that this identifier is not persisted, and its regenerated once per each restart.

Returns:
the unique identifier of this node.

getResourceMediaTypes

public String getResourceMediaTypes()
Method to obtain resource media types.

Returns:
the resource media types.

setResourceMediaTypes

public void setResourceMediaTypes(String resourceMediaTypes)
Method to set resource media types.

Parameters:
resourceMediaTypes - the resource media types.

getCollectionMediaTypes

public String getCollectionMediaTypes()
Method to obtain collection media types.

Returns:
the collection media types.

setCollectionMediaTypes

public void setCollectionMediaTypes(String collectionMediaTypes)
Method to set collection media types.

Parameters:
collectionMediaTypes - the collection media types.

getCustomUIMediaTypes

public String getCustomUIMediaTypes()
Method to obtain custom UI media types.

Returns:
the custom UI media types.

setCustomUIMediaTypes

public void setCustomUIMediaTypes(String customUIMediaTypes)
Method to set custom UI media types.

Parameters:
customUIMediaTypes - the custom UI media types.

isClone

public boolean isClone()
To check whether this is a clone or a base registry context.

Returns:
true if this is clone, false if this is the base registry context.

setClone

public void setClone(boolean clone)
Set the flag if the current registry context is a clone and not base

Parameters:
clone - whether it is a clone or not

getBaseInstance

public static RegistryContext getBaseInstance()
Get an instance of the base (not cloned),

Returns:
base registry context

getCloneContext

public static RegistryContext getCloneContext()
Create an return a registry context.

Returns:
new registry context

destroy

public static void destroy()
destroy the registry context


getBaseInstance

public static RegistryContext getBaseInstance(org.wso2.carbon.user.core.service.RealmService realmService)
Return a singleton object of the base registry context with custom realm service If a registry context doesn't exist, it will create a new one and return it. Otherwise it will create the current base registry context

Parameters:
realmService - realm service
Returns:
the base registry context

getBaseInstance

public static RegistryContext getBaseInstance(org.wso2.carbon.user.core.service.RealmService realmService,
                                              boolean populateConfiguration)
Return a singleton object of the base registry context with custom realm service If a registry context doesn't exist, it will create a new one and return it. Otherwise it will create the current base registry context

Parameters:
realmService - realm service
populateConfiguration - whether the configuration must be populated or not.
Returns:
the base registry context

getBaseInstance

public static RegistryContext getBaseInstance(InputStream configStream,
                                              org.wso2.carbon.user.core.service.RealmService realmService)
Return a singleton object of the registry context with a custom configuration, customer realm service. If a registry context doesn't exist, it will create a new one and return it. Otherwise it will create the current base registry context

Parameters:
configStream - config stream (registry.xml)
realmService - realm service to create a registry context with
Returns:
the registry context

getBaseInstance

@Deprecated
public static RegistryContext getBaseInstance(InputStream configStream,
                                                         RegistryContext.RegURLSupplier urlSupplier)
Deprecated. 

Return a singleton object of the registry context with a custom url supplier and custom config. If a registry context doesn't exist, it will create a new one and return it. Otherwise it will create the current base registry context

Parameters:
configStream - config stream (registry.xml)
urlSupplier - url supplier
Returns:
the singleton object of the registry context.

getRegistryRoot

public String getRegistryRoot()
Return the registry root. (configured in registry.xml)

Returns:
the registry root

setRegistryRoot

public void setRegistryRoot(String registryRoot)
Set the registry root.

Parameters:
registryRoot - the value of the registry root

isReadOnly

public boolean isReadOnly()
Return whether the registry is read-only or not.

Returns:
true if readonly, false otherwise.

setReadOnly

public void setReadOnly(boolean readOnly)
Set whether the registry is read-only or not

Parameters:
readOnly - the read-only flag

isCacheEnabled

public boolean isCacheEnabled()
Return whether the registry caching is enabled or not.

Returns:
true if enabled, false otherwise.

setCacheEnabled

public void setCacheEnabled(boolean enableCache)
Set whether the registry caching is enabled or not.

Parameters:
enableCache - the enable-cache flag

getRealmService

public org.wso2.carbon.user.core.service.RealmService getRealmService()
Return the associated realm service.

Returns:
realm service.

setMaxCache

@Deprecated
public void setMaxCache(int maxCache)
Deprecated. 

Set a maximum entries for cache value

Parameters:
maxCache - the maximum number for cache value.

getMaxCache

@Deprecated
public int getMaxCache()
Deprecated. 

Get the number of maximum cache entries

Returns:
number of maximum cache entries

getRepository

public Repository getRepository()
Return the repository object, which provides an interface to put, get resources to the repository.

Returns:
the repository object

setRepository

public void setRepository(Repository repository)
Set the repository object.

Parameters:
repository - the repository object.

getVersionRepository

public VersionRepository getVersionRepository()
Return the version repository object, which provides an interface to create versions, retrieve old versions of resources

Returns:
a version repository object.

setVersionRepository

public void setVersionRepository(VersionRepository versionRepository)
Set a version repository object.

Parameters:
versionRepository - version repository test

getQueryProcessorManager

public QueryProcessorManager getQueryProcessorManager()
Return a query processor.

Returns:
the query processor object.

setQueryProcessorManager

public void setQueryProcessorManager(QueryProcessorManager queryProcessorManager)
Set a query processor object

Parameters:
queryProcessorManager - the query processor object.

isVersionOnChange

public boolean isVersionOnChange()
Whether the version should be created automatically on a change (only for non-collection resources)

Returns:
true, if version is changing automatically on a change. false, otherwise.

setVersionOnChange

public void setVersionOnChange(boolean versionOnChange)
Set whether the version should be created automatically on a change (only for non-collection resources)

Parameters:
versionOnChange - Flag to set whether the version should be created,

isSetup

public boolean isSetup()
Whether the "setup" system property is set at the start.

Returns:
true if the "setup" system property is set, false otherwise.

setSetup

public void setSetup(boolean setup)
Set if the "setup" system property is set at the start.

Parameters:
setup - the flag for the setup property.

getEmbeddedRegistryService

public EmbeddedRegistryService getEmbeddedRegistryService()
                                                   throws RegistryException
Return a embedded registry service. If there is no registry service existing, this will create a registry service an return

Returns:
the newly create registry service.
Throws:
RegistryException - throws if the retrieval of the embedded registry service is failed.

getDefaultDataBaseConfiguration

public DataBaseConfiguration getDefaultDataBaseConfiguration()
Return the default database configuration.

Returns:
the default database configuration.

setDefaultDataBaseConfiguration

public void setDefaultDataBaseConfiguration(DataBaseConfiguration dataBaseConfiguration)
Sets the default database configuration.

Parameters:
dataBaseConfiguration - the default database configuration.

selectDBConfig

public DataBaseConfiguration selectDBConfig(String dbConfigName)
Select a database configuration among the available database configuration.

Parameters:
dbConfigName - name of the selecting database configuration.
Returns:
selected database configuration.

getDBConfigNames

public Iterator<String> getDBConfigNames()
Get the available database configuration names.

Returns:
string iterator of available database configurations

getDBConfig

public DataBaseConfiguration getDBConfig(String dbConfigName)
Get the database configuration of a given configuration name

Parameters:
dbConfigName - database configuration name
Returns:
database configuration object

addDBConfig

public void addDBConfig(String name,
                        DataBaseConfiguration config)
Add database configuration with the given name.

Parameters:
name - the name of the database configuration.
config - database configuration.

addAspect

public void addAspect(String name,
                      Aspect aspect,
                      int tenantId)
Add an aspect of the name for a given tenant id

Parameters:
name - name of the aspect
aspect - Aspect object
tenantId - tenant id

removeAspect

public boolean removeAspect(String name,
                            int tenantId)
Remove an aspect with the given name for a given tenant id

Parameters:
name - Name of the aspect
tenantId - tenant id
Returns:
true if the aspect existed and removed, false otherwise

getAspect

public Aspect getAspect(String name,
                        int tenantId)
Return an aspect of given name and given tenant id.

Parameters:
name - name of the aspect
tenantId - tenant id
Returns:
the aspect object.

getAspectNames

public String[] getAspectNames(int tenantId)
Return engaged aspect names for a given tenant

Parameters:
tenantId - tenant id
Returns:
the array of aspects.

getQueryProcessors

public List getQueryProcessors()
Return a list of available query processor.

Returns:
list of query processor

setQueryProcessors

public void setQueryProcessors(List<QueryProcessorConfiguration> queryProcessors)
Set the query processor list.

Parameters:
queryProcessors - the list of query processors to be set.

addQueryProcessor

public void addQueryProcessor(QueryProcessorConfiguration queryProcessorConfiguration)
Add a new query processor.

Parameters:
queryProcessorConfiguration - query processor to be set.

getBasePath

public String getBasePath()
Return the base path calculated using the url supplier.

Returns:
the base path calculated using the url supplier.

getDataAccessManager

public DataAccessManager getDataAccessManager()
Return the data access manager, created using the database configuration associated with the registry context

Returns:
the data access manager

setDataAccessManager

public void setDataAccessManager(DataAccessManager dataAccessManager)
Set the data access manager.

Parameters:
dataAccessManager - data access manager to be set.

getHandlerManager

public HandlerManager getHandlerManager()
Return the handler manager.

Returns:
handler manager

getHandlerManager

public HandlerManager getHandlerManager(String lifecyclePhase)
Return the handler manager.

Parameters:
lifecyclePhase - The name of the lifecycle phase.
Returns:
handler manager

getCustomEditManager

public CustomEditManager getCustomEditManager()
Return a custom edit manager, which is used by custom UI implementations.

Returns:
the CustomEditManager object.

setCustomEditManager

public void setCustomEditManager(CustomEditManager customEditManager)
Set a custom edit manager.

Parameters:
customEditManager - the CustomEditManager to be set.

getRemoteInstances

public List<RemoteConfiguration> getRemoteInstances()
Return a list of mounted remote instances.

Returns:
remote instance list.

setRemoteInstances

public void setRemoteInstances(List<RemoteConfiguration> remoteInstances)
Set list of remote instances.

Parameters:
remoteInstances - the list of remote instances to be set.

getMounts

public List<Mount> getMounts()
Return a list of mounted registry configurations (Mount object).

Returns:
a list of mount

setMounts

public void setMounts(List<Mount> mounts)
Set a list of mounted registry configurations.

Parameters:
mounts - list of mount to be set.

setProfilesPath

public void setProfilesPath(String path)
Set profile storage path.

Parameters:
path - the path to be set

getProfilesPath

public String getProfilesPath()
Return the profile storage path.

Returns:
path of the profile

getServicePath

public String getServicePath()
Get the service storage path.

Returns:
the service path.

setServicePath

public void setServicePath(String servicePath)
Set the service storage path

Parameters:
servicePath - service path to be set.

getHandlerConfigurations

@Deprecated
public List<HandlerConfiguration> getHandlerConfigurations()
Deprecated. 


setHandlerConfigurations

@Deprecated
public void setHandlerConfigurations(List<HandlerConfiguration> handlerConfigurations)
Deprecated. 


addHandlerConfiguration

@Deprecated
public void addHandlerConfiguration(HandlerConfiguration handlerConfiguration)
Deprecated. 


getMediaTypeHandlers

@Deprecated
public List getMediaTypeHandlers()
Deprecated. 


setMediaTypeHandlers

@Deprecated
public void setMediaTypeHandlers(List mediaTypeHandlers)
Deprecated. 


addMediaTypeHandler

@Deprecated
public void addMediaTypeHandler(MediaTypeHandlerConfiguration mediaTypeHandlerConfiguration)
Deprecated. 


getUrlHandlers

@Deprecated
public List getUrlHandlers()
Deprecated. 


setUrlHandlers

@Deprecated
public void setUrlHandlers(List urlHandlers)
Deprecated. 


addURLHandler

@Deprecated
public void addURLHandler(String urlHandler)
Deprecated. 


getLogWriter

public LogWriter getLogWriter()
Method to obtain the logWriter instance.

Returns:
the logWriter instance.

setLogWriter

public void setLogWriter(LogWriter logWriter)
Method to set the logWriter instance.

Parameters:
logWriter - the logWriter instance.

isSystemResourcePathRegistered

public boolean isSystemResourcePathRegistered(String absolutePath)
Method to determine whether a system resource (or collection) path has been registered.

Parameters:
absolutePath - the absolute path of the system resource (or collection)
Returns:
true if the system resource (or collection) path is registered or false if not.

registerSystemResourcePath

public void registerSystemResourcePath(String absolutePath)
Method to register a system resource (or collection) path.

Parameters:
absolutePath - the absolute path of the system resource (or collection)

isNoCachePath

public boolean isNoCachePath(String path)
Method to determine whether caching is disabled for the given path.

Parameters:
path - the path to test
Returns:
true if caching is disabled or false if not.

registerNoCachePath

public void registerNoCachePath(String path)
Method to register a no-cache path. If caching is disabled for a collection, all downstream resources and collections won't be cached.

Parameters:
path - the path of a resource (or collection) for which caching is disabled.

getStatisticsCollectors

public StatisticsCollector[] getStatisticsCollectors()
Method to obtain a list of statistics collectors.

Returns:
array of statistics collectors if one or more statistics collectors exist, or an empty array.

addStatisticsCollector

public void addStatisticsCollector(StatisticsCollector statisticsCollector)
Method to add a statistics collector

Parameters:
statisticsCollector - the statistics collector to be added.

removeStatisticsCollector

public void removeStatisticsCollector(StatisticsCollector statisticsCollector)
Method to remove a statistics collector

Parameters:
statisticsCollector - the statistics collector to be removed.


Copyright © 2014 WSO2 Inc. All Rights Reserved.