org.wso2.registry.jdbc
Class EmbeddedRegistry

java.lang.Object
  extended by org.wso2.registry.jdbc.EmbeddedRegistry
Direct Known Subclasses:
InMemoryEmbeddedRegistry

public class EmbeddedRegistry
extends java.lang.Object

This is a core class used by application that use registry in the embedded mode. This class is used to create embedded registry instances for user sessions. UserRegistry is the embedded mode implementation of the Registry API. In this mode, all registry accesses has to be done using a UserRegistry instance. And there has to be separate UserRegistry instance for each user to access the registry. These UserRegistry instances has be obtained from the EmbeddeedRegistry. It is recommended to have only one EmbeddedRegistry instance per application. But there can be exceptions, where it is required to maintain two or more registries pointing to different datasources. Applications should initialize an EmbeddedRegistry instance at the startup using following code. InputStream configStream = new FileInputStream("/projects/registry.xml"); RegistryContext registryContext = new RegistryContext(configStream); EmbeddedRegistry embeddedRegistry = new EmbeddedRegistry(registryContext); After initializing an EmbeddedRegistry instance it should be stored in some globally accessible location, so that it can be used by necessary modules to create UserRegistry instances. From this, it is possible to create UserRegistry instances using varous parameter combinations documeneted in getUserRegistry(...) methods. UserRegistry adminRegistry = embeddedRegistry.getUserRegistry("admin", "admin");


Field Summary
protected  RegistryContext registryContext
           
 
Constructor Summary
protected EmbeddedRegistry()
          This contructor is used by the inherited InMemoryEmbeddedRegistry class as it has to be instantiated using the default contructor.
  EmbeddedRegistry(RegistryContext context)
          Instantiates the EmbeddedRegistry using the configuration given in RegistryContext.
  EmbeddedRegistry(RegistryContext context, UserRealm realm)
          Intantiates the EmbeddedRegistry using the configuration given in the context and the given UserRealm.
 
Method Summary
protected  void configure()
           
protected  void configure(UserRealm defaultRealm)
           
 UserRegistry getSystemRegistry()
          Returns a registry to be used for system operations.
 UserRegistry getUserRegistry()
          Creates a UserRegistry instance for anonymous user.
 UserRegistry getUserRegistry(java.lang.String userName)
          Creates a UserRegistry instance for the given user.
 UserRegistry getUserRegistry(java.lang.String userName, java.lang.String password)
          Creates UserRegistry instances for normal users.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registryContext

protected RegistryContext registryContext
Constructor Detail

EmbeddedRegistry

public EmbeddedRegistry(RegistryContext context)
                 throws RegistryException
Instantiates the EmbeddedRegistry using the configuration given in RegistryContext. Datasource given in the context will be used for both resource store and the user store.

Parameters:
context - RegistryContext containing the configuration.
Throws:
RegistryException

EmbeddedRegistry

public EmbeddedRegistry(RegistryContext context,
                        UserRealm realm)
                 throws RegistryException
Intantiates the EmbeddedRegistry using the configuration given in the context and the given UserRealm. Datasource given in the context will be used for the resource store. User store is accessed from the given UserRealm, which may point to a different source.

Parameters:
context - RegistryContex containing the configuration.
realm - UserRealm containing the user store.
Throws:
RegistryException

EmbeddedRegistry

protected EmbeddedRegistry()
This contructor is used by the inherited InMemoryEmbeddedRegistry class as it has to be instantiated using the default contructor.

Method Detail

configure

protected void configure()
                  throws RegistryException
Throws:
RegistryException

configure

protected void configure(UserRealm defaultRealm)
                  throws RegistryException
Throws:
RegistryException

getUserRegistry

public UserRegistry getUserRegistry()
                             throws RegistryException
Creates a UserRegistry instance for anonymous user. Permissions set for anonymous user will be applied for all operations performed using this instance.

Returns:
UserRegistry for the anonymous user.
Throws:
RegistryException

getSystemRegistry

public UserRegistry getSystemRegistry()
                               throws RegistryException
Returns a registry to be used for system operations. Human users should not be allowed log in using this registry.

Returns:
User registry for system user.
Throws:
RegistryException

getUserRegistry

public UserRegistry getUserRegistry(java.lang.String userName,
                                    java.lang.String password)
                             throws RegistryException
Creates UserRegistry instances for normal users. Applications should use this method to create UserRegistry instances, unless there is a specific need documented in other methods. User name and the password will be authenticated by the EmbeddedRegistry before creating the requested UserRegistry instance.

Parameters:
userName - User name of the user.
password - Password of the user.
Returns:
UserRegistry instance for the given user.
Throws:
RegistryException

getUserRegistry

public UserRegistry getUserRegistry(java.lang.String userName)
                             throws RegistryException
Creates a UserRegistry instance for the given user. This method will NOT authenticate the user before creating the UserRegistry instance. It assumes that the user is authenticated outside the EmbeddedRegistry.

Parameters:
userName - User name of the user.
Returns:
UserRegistry instance for the given user.
Throws:
RegistryException


Copyright © 2007 Apache Web Services Project. All Rights Reserved.