[Registry-dev] Refactoring of registry constructors

Chathura C. Ekanayake chathura at wso2.com
Mon Dec 17 01:56:46 PST 2007


Hi,

I refactored the registry constructors, so now the instantiation is much 
simpler. I also added a RegistryRealm class, which extends the user 
manager's DefaultRealm. It restricts some actions based on the 
parameters, so that the registry user store doesn't get inconsistent. 
For example, it blocks the deletion of predefined users like system, 
admin, anonymous and performs default actions like adding each user to 
the "EVERYONE" role upon creation. It also simplifies the initiation of 
realms.

Below are the steps for creating registry instances for various scenarios.

1) In memory registry without security

    Registry registry = new InMemoryJDBCRegistry();

2) In memory registry with security

    RegistryRealm registryRealm = new InMemoryRegistryRealm();
    Registry registry = new InMemoryJDBCRegistry(registryRealm);
    SecureRegistry secureRegistry = new SecureRegistry("user", 
"password", registry, registryRealm);

3) Secure registry using a data source

    RegistryRealm registryRealm = new RegistryRealm(datasource);
    Registry registry = new JDBCRegistry(datasource, registryRealm);
    SecureRegistry secureRegistry = new SecureRegistry("user", 
"password", registry, registryRealm);

4) Secure registry using a database connection URL (In this case, the 
RegistryDataSource creates a Apache DBCP data source and handles 
connection pooling)

    RegistryDataSource datasource = new RegistryDataSource(dbURL, 
driverName, userName, password);
    RegistryRealm registryRealm = new RegistryRealm(datasource);
    Registry registry = new JDBCRegistry(datasource, registryRealm);
    SecureRegistry secureRegistry = new SecureRegistry("user", 
"password", registry, registryRealm);

Note that we have to give the realm to the JDBC registry as well, as 
media type handlers may use it to set authorizations on automatically 
imported resources.

Thanks,
Chathura




More information about the Registry-dev mailing list