IdRepoPluginsCache.java revision 8af80418ba1ec431c8027fa9668e5678658d3611
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: IdRepoPluginsCache.java,v 1.8 2009/11/10 01:52:37 hengming Exp $
*/
/**
*
* @author aravind
*/
public class IdRepoPluginsCache implements ServiceListener {
static boolean initializedListeners;
private static int svcRevisionNumber;
// Cache of IdRepo Plugins
// The Map contains <orgName, MAP<name, IdRepo object>>
// Needs to synchronized for get(), put() and clear()
protected IdRepoPluginsCache() {
// Initialize listeners
if (debug.messageEnabled()) {
}
}
throws IdRepoException, SSOException {
if (debug.messageEnabled()) {
orgName);
}
// Check the cache
return (readOrgRepos);
}
synchronized (idrepoPlugins) {
try {
if (debug.messageEnabled()) {
"Not in cache for: " + orgName);
}
// Initialize the plugins
orgRepos = new LinkedHashMap();
// Organization does not exist. Error condition
"Org does not exisit: " + orgName);
throw new IdRepoException(
}
if (debug.messageEnabled()) {
"Loading plugins: " + subConfigNames);
}
"getIdRepoPlugins SubConfig is null for" +
" orgName: " + orgName +
" subConfig Name: " + idRepoName);
}
// Add to cache
}
}
// Add internal repos
} catch (SMSException ex) {
}
}
// Cache a readonly copy
readOrgRepos = new OrderedSet();
}
}
}
}
return (readOrgRepos);
}
if (debug.messageEnabled()) {
}
return (answer);
}
answer = new OrderedSet();
}
}
}
}
if (debug.messageEnabled()) {
}
" Plugins: " + ps);
}
synchronized (idrepoPlugins) {
}
}
return (answer);
}
/**
* Delete an IdRepo plugin
*/
synchronized (idrepoPlugins) {
// Clear IdRepo plugins first since other threads should
// not access it during shutdown
// Iterate through the plugins
// Shutting down idrepo
if (debug.messageEnabled()) {
name);
}
// Remove from cache first
new ShutdownIdRepoPlugin(repo);
// Provide a delay of 500ms for existing operations
// to complete. the delay is in the forked thread.
break;
}
}
if (reinitialize) {
// Adding plugin back provides the atomic operation
// for the caller. Else, client will get No-plugins
// configured exception.
// Add the plugin back to the cache
}
}
}
}
// clear a readonly copy for the org Name
}
}
}
/**
* Delete all IdRepo plugin for the organization
*/
synchronized (idrepoPlugins) {
// Clear IdRepo plugins first
}
if (debug.messageEnabled()) {
}
// Provide a delay of 500ms for existing operations
// to complete. the delay is in the forked thread.
}
/**
* Clears the IdRepo plugin cache
*/
public void clearIdRepoPluginsCache() {
synchronized (idrepoPlugins) {
// Clear readonly cache first.
// Don't want other theads to get plugins that are
// shutdown.
}
// Iterate throught the orgName and shutdown the repos
}
}
}
/**
* Adds an IdRepo plugin to an organization given the configuration
* @param orgName organization to which IdRepo would be added
* @param configMap configuration of the IdRepo
*/
throws IdRepoException, SSOException {
if (debug.messageEnabled()) {
}
try {
orgName + " does not exisit");
throw new IdRepoException(
}
throw new IdRepoException(
}
} catch (SMSException smse) {
if (debug.warningEnabled()) {
}
return;
}
// Add to cache
synchronized (idrepoPlugins) {
// Clear the readonly plugins first.
// Other threads have to wait for the initialization to complete
// Will get updated when getPlugins gets called
boolean addInternalRepos = false;
repos = new LinkedHashMap();
addInternalRepos = true;
}
if (addInternalRepos) {
}
}
}
throws SSOException, IdRepoException {
// Check if AMSDK plugin needs to be added
if (ServiceManager.isCoexistenceMode()) {
}
// Check if AgentsRepos needs to be added
if (svcRevisionNumber >= 30) {
}
// Check if SpecialRepo needs to be added
if (ServiceManager.isConfigMigratedTo70() &&
}
}
protected void initializeListeners() {
synchronized (debug) {
if (!initializedListeners) {
// Add listeners to Service Schema and Config Managers
if (debug.messageEnabled()) {
"setting up ServiceListener");
}
try {
// Initialize configuration objects
// Initialize schema objects
// Get the version number
// Initialize listener for JAXRPCObject
new JAXRPCObjectImplEventListener());
initializedListeners = true;
} catch (SMSException smse) {
// Exceptions will be throws during install and config
// when these services will not be loaded
"Unable to set up a service listener for IdRepo",
smse);
}
} catch (SSOException ssoe) {
"Unable to set up a service listener for IdRepo.",
ssoe);
}
}
}
}
/**
* Constructs IdRepo plugin object and returns.
*/
if (debug.messageEnabled()) {
}
if (debug.warningEnabled()) {
"Cannot construct with empty config data");
}
return (null);
}
try {
}
// Add listener to this plugin class!
}
}
return (answer);
}
private static SSOToken getAdminToken() {
}
// Internal repos
private IdRepo getSpecialRepoPlugin()
throws SSOException, IdRepoException {
// Valid only for root realm
try {
if (debug.messageEnabled()) {
}
} catch (Exception e) {
}
return pluginClass;
}
throws SSOException, IdRepoException {
try {
if (debug.messageEnabled()) {
}
} catch (Exception e) {
}
// Add listener
if (pluginClass != null) {
}
// Retuns the plugin class
return pluginClass;
}
throws SSOException, IdRepoException {
try {
if (debug.messageEnabled()) {
}
} catch (Exception e) {
"Unable to instantiate plugin for Org: " + orgName, e);
}
if (pluginClass != null) {
// Add listener to this plugin class
}
return pluginClass;
}
/**
* Notification for global config changes to IdRepoService
*/
if (debug.messageEnabled()) {
}
return;
}
// FIXME: Clients don't have to call this !!
if (type != 1) {
}
} else {
// Special identities have changed, clear the cache
}
}
/**
* Notification for organization config changes to IdRepoService
*/
{
if (debug.messageEnabled()) {
}
// ignore componenet is "".
// if component is /" and type is 2(delete), need to remove hidden
// plugins.
// Organization has been deleted
// IdRepo has been either added, removed or modified
if (st.hasMoreTokens()) {
}
try {
if (!IdServicesImpl.isShutdownCalled()) {
// Reinitialize the plugin after shutdown
} else {
}
}
} catch (Exception e) {
}
}
}
/**
* Notification for schema changes to IdRepoService
*/
if (debug.messageEnabled()) {
" Service name: " + serviceName);
}
}
// Timer task to shutdown IdRepo plugins
private class ShutdownIdRepoPlugin implements Runnable {
}
}
public void run() {
// Shutdown the repo
try {
// Provide a delay of 500ms for caller operations
// to complete
} catch (InterruptedException e) {
if (debug.messageEnabled()) {
}
}
}
// Iterate through the plugins
// Shutting down idrepo
}
}
}
}
}