[Yanel-dev] Default realm implementation extension
Cedric Staub
cedric.staub at wyona.com
Thu Jan 6 09:16:18 CET 2011
Hello
As mentioned on the list yesterday, I worked on the default realm
implementation to make it possible to access the data, ac-policies,
ac-identities and res-config repos using getRepository(String id).
This is how it worked before:
- The data repo was accessible through getRepository()
- The res-configs repo was accessible through getRTIRepository()
- Extra repos were accessible through getRepository(String id)
- The ac-policies, ac-identities repos were not accessible
With my fully backwards-compatible patch, it is now possible to access
the default repos (data, res-configs, ac-policies, ac-identities) using
the getRepository(String id) function with the following ids:
yanel_data
yanel_ac-policies
yanel_ac-identities
yanel_res-configs
So getRepository("yanel_data") is equivalent to getRepository().
The ac-policies and ac-identities repos can now be accessed, too.
And on top of that, I made sure all repositories are correctly closed
when the realm is shutdown/destroyed (ac-policies and ac-identities
repositories weren't closed before).
This means that my reindexer resource can now start reindexing processes
for all possible repositories within a realm.
Patch is attached :-)
Cheers
Cedric
-------------- next part --------------
Index: src/core/java/org/wyona/yanel/core/map/RealmDefaultImpl.java
===================================================================
--- src/core/java/org/wyona/yanel/core/map/RealmDefaultImpl.java (revision 55853)
+++ src/core/java/org/wyona/yanel/core/map/RealmDefaultImpl.java (working copy)
@@ -55,8 +55,10 @@
private String id;
private String mountPoint;
private String defaultLanguage;
- private Repository repository;
- private Repository rtiRepository;
+ private Repository repository = null;
+ private Repository rtiRepository = null;
+ private Repository identitiesRepository = null;
+ private Repository policiesRepository = null;
private PolicyManager privatePolicyManager;
private IdentityManager privateIdentityManager;
private WebAuthenticator privateWebAuthenticator;
@@ -471,11 +473,22 @@
}
public Repository getRepository(String id) throws Exception {
- Yanel yanel = Yanel.getInstance();
- RepositoryFactory extraRepoFactory = yanel.getRepositoryFactory(EXTRA_REPOSITORY_FACTORY_BEAN_ID);
- if (extraRepoFactory.exists(id)) {
- return extraRepoFactory.newRepository(id);
- }
+ if("yanel_data".equals(id)) {
+ return repository;
+ } else if("yanel_ac-policies".equals(id)) {
+ return policiesRepository;
+ } else if("yanel_ac-identities".equals(id)) {
+ return identitiesRepository;
+ } else if("yanel_res-configs".equals(id)) {
+ return rtiRepository;
+ } else {
+ Yanel yanel = Yanel.getInstance();
+ RepositoryFactory extraRepoFactory = yanel.getRepositoryFactory(EXTRA_REPOSITORY_FACTORY_BEAN_ID);
+ if (extraRepoFactory.exists(id)) {
+ return extraRepoFactory.newRepository(id);
+ }
+ }
+
return null;
}
@@ -488,13 +501,14 @@
}
/**
- *
+ * Destroy/shutdown realm
*/
public void destroy() throws Exception {
log.warn("Shutdown realm: " + getName());
- getRepository().close();
- getRTIRepository().close();
- // TODO: close ac-identities and ac-policies repository?
+ repository.close();
+ rtiRepository.close();
+ identitiesRepository.close();
+ policiesRepository.close();
}
/**
@@ -532,8 +546,8 @@
log.info("Default PolicyManager will be used for realm: " + getName());
File repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigElement.getValue()));
RepositoryFactory policiesRepoFactory = yanel.getRepositoryFactory("ACPoliciesRepositoryFactory");
- Repository policiesRepo = policiesRepoFactory.newRepository(getID(), repoConfig);
- policyManager = pmFactory.newPolicyManager(policiesRepo);
+ policiesRepository = policiesRepoFactory.newRepository(getID(), repoConfig);
+ policyManager = pmFactory.newPolicyManager(policiesRepository);
}
setPolicyManager(policyManager);
}
@@ -559,8 +573,8 @@
log.info("Default IdentityManager will be used for realm: " + getName());
File repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigElement.getValue()));
RepositoryFactory identitiesRepoFactory = yanel.getRepositoryFactory("ACIdentitiesRepositoryFactory");
- Repository identitiesRepo = identitiesRepoFactory.newRepository(getID(), repoConfig);
- identityManager = imFactory.newIdentityManager(identitiesRepo);
+ identitiesRepository = identitiesRepoFactory.newRepository(getID(), repoConfig);
+ identityManager = imFactory.newIdentityManager(identitiesRepository);
}
setIdentityManager(identityManager);
}
More information about the Yanel-development
mailing list