FileDocCategorySizeDatePackage
ConnectorRegistry.javaAPI DocGlassfish v2 API12991Fri May 04 22:34:24 BST 2007com.sun.enterprise.connectors

ConnectorRegistry

public class ConnectorRegistry extends Object
This is an registry class which holds various objects in hashMaps, hash tables, and vectors. These objects are updated and queried during various funtionalities of rar deployment/undeployment, resource creation/destruction Ex. of these objects are ResourcesAdapter instances, security maps for pool managed connection factories. It follows singleton patter. i.e only one instance at any point of time.
author
Binod P.G and Srikanth P
version

Fields Summary
static final Logger
_logger
protected static final ConnectorRegistry
connectorRegistryInstance
protected final Map
resourceAdapters
resourceAdapters keeps track of all active resource adapters in the connector runtime. String:resourceadapterName Vs ActiveResourceAdapter
protected final Map
factories
protected final Map
resourceAdapterConfig
Constructors Summary
protected ConnectorRegistry()
Protected constructor. It is protected as it follows singleton pattern.

        resourceAdapters = Collections.synchronizedMap(new HashMap<String, ActiveResourceAdapter>());
        factories = Collections.synchronizedMap(new HashMap<String, PoolMetaData>());
        resourceAdapterConfig = Collections.synchronizedMap(new HashMap<String, ResourceAdapterConfig>());
        _logger.log(Level.FINE,"initialized the connector registry");
    
Methods Summary
public voidaddActiveResourceAdapter(java.lang.String rarModuleName, ActiveResourceAdapter rar)
Adds the object implementing ActiveResourceAdapter interface to the registry.

param
rarModuleName RarName which is the key
param
rar ActiveResourceAdapter instance which is the value.

	resourceAdapters.put(rarModuleName,rar);
        _logger.log(Level.FINE,
                    "Added the active resource adapter to connector registry", 
                    rarModuleName);
    
public voidaddManagedConnectionFactory(java.lang.String poolName, PoolMetaData pmd)
Add MCF instance pertaining to the poolName to the registry.

param
poolName Name of the pool
param
factory MCF instance to be added.

        factories.put(poolName, pmd);
        _logger.fine("Added MCF to connector registry for: "+  poolName);
    
public voidaddResourceAdapterConfig(java.lang.String rarName, ResourceAdapterConfig raConfig)
Add the resource adapter config properties object to registry against the rarName.

param
rarName Name of the rar
param
raConfig ResourceAdapter configuration object

        if( rarName != null) {
            _logger.log(Level.FINE,
                 "Adding the resourceAdapter Config to connector registry.", 
                 rarName);
            resourceAdapterConfig.put(rarName,raConfig);
        }
    
public ActiveResourceAdaptergetActiveResourceAdapter(java.lang.String rarModuleName)
Retrieves the object implementing ActiveResourceAdapter interface from the registry. Key is the rarName.

param
rarModuleName Rar name. It is the key
return
object implementing ActiveResourceAdapter interface

        if(rarModuleName != null) {
            _logger.log(Level.FINE,
               "returning/found the resource adapter from connector registry",
               rarModuleName);
            return  resourceAdapters.get(rarModuleName);
        } else {
            _logger.log(Level.FINE,
               "Resourceadapter not found in connector registry.Returning null",
               rarModuleName);
            return null;
        }
    
public ActiveResourceAdapter[]getAllActiveResourceAdapters()
Returns all Active Resource Adapters in the connector runtime.

return
All active resource adapters in the connector runtime

        return (ActiveResourceAdapter[])
                this.resourceAdapters.values().
                        toArray(new ActiveResourceAdapter[]{});
    
public com.sun.enterprise.deployment.ConnectorDescriptorgetDescriptor(java.lang.String rarModuleName)
Gets the connector descriptor pertaining the rar

param
rarModuleName rarName
return
ConnectorDescriptor which represents the ra.xml

        ActiveResourceAdapter ar = null;
        if(rarModuleName != null) {
            ar =  resourceAdapters.get(rarModuleName);
        }
        if (ar != null) {
            _logger.log(Level.FINE,
                 "Found/returing Connector descriptor in connector registry.", 
                 rarModuleName);
            return ar.getDescriptor();
        } else { 
            _logger.log(Level.FINE,
                 "Couldnot find Connector descriptor in connector registry.", 
                 rarModuleName);
            return null;
        }
    
public static com.sun.enterprise.connectors.ConnectorRegistrygetInstance()
Return the ConnectorRegistry instance

return
ConnectorRegistry instance which is a singleton

    
                     
        
        _logger.fine("returning the connector registry");
        return connectorRegistryInstance;
    
public javax.resource.spi.ManagedConnectionFactorygetManagedConnectionFactory(java.lang.String poolName)
Retrieve MCF instance pertaining to the poolName from the registry.

param
poolName Name of the pool
return
factory MCF instance retrieved.

        if(poolName != null) {
            _logger.log(Level.FINE,
                 "Returning the MCF from connector registry.", poolName);
            
            PoolMetaData pmd =  factories.get( poolName );
	    if (pmd != null) {
                return pmd.getMCF();
            }

        } 
        return null;
    
public PoolMetaDatagetPoolMetaData(java.lang.String poolName)

        return  factories.get( poolName );
    
public ResourceAdapterConfiggetResourceAdapterConfig(java.lang.String rarName)
Get the resource adapter config properties object registered with registry against the rarName.

param
rarName Name of the rar
return
ResourceAdapter configuration object

        if(rarName != null) {
            _logger.log(Level.FINE,
              "Returing the resourceadapter Config from registry.",rarName);
            return resourceAdapterConfig.get(rarName);
        } else {
            return null;
        }
    
public com.sun.enterprise.connectors.authentication.RuntimeSecurityMapgetRuntimeSecurityMap(java.lang.String poolName)
Gets the runtime equivalent of policies enforced by the Security Maps pertaining to a pool from the Pool's Meta Data.

param
poolName Name of the pool
return
runtimeSecurityMap in the form of HashMap of HashMaps (user and groups).
see
SecurityMapUtils.processSecurityMaps(SecurityMap[])

        if(poolName != null) {
            _logger.log(Level.FINE,
              "Returing the security map from connector registry.", poolName);
            PoolMetaData pmd = factories.get(poolName);
            return pmd.getRuntimeSecurityMap();
        } else {
            return null;
        }
    
public booleanisMCFCreated(java.lang.String poolName)
Checks if the MCF pertaining to the pool is instantiated and present in the registry. Each pool has its own MCF instance.

param
poolName Name of the pool
return
true if the MCF is found. false if MCF is not found

        boolean created = factories.containsKey( poolName );
        _logger.fine("isMCFCreated " + poolName + " - " + created);
        return created;
    
public booleanisRegistered(java.lang.String rarModuleName)
Checks whether the rar is already deployed i.e registered with connector registry

param
rarModuleName rar Name.
return
true if rar is registered false if rar is not registered.

        _logger.log(Level.FINE,
            "Checking for MCF presence in connector registry.",rarModuleName);
        return resourceAdapters.containsKey(rarModuleName);
    
public booleanremoveActiveResourceAdapter(java.lang.String rarModuleName)
Removes the object implementing ActiveResourceAdapter interface from the registry. This method is called whenever an active connector module is removed from the Connector runtime. [eg. undeploy/recreate etc]

param
rarModuleName RarName which is the key
return
true if successfully removed false if deletion fails.

       	Object o = resourceAdapters.remove( rarModuleName ); 
	
        if( o == null) {
            _logger.fine("Failed to remove the resource adapter from connector registry" +
               rarModuleName);
            return false;
        } else {
            _logger.log(Level.FINE,
                 "removed the active resource adapter from connector registry",
                 rarModuleName);
            return true;
        }
    
public booleanremoveManagedConnectionFactory(java.lang.String poolName)
Remove MCF instance pertaining to the poolName from the registry.

param
poolName Name of the pool
return
true if successfully removed. false if removal fails.

        if(factories.remove(poolName) == null) {
            _logger.log(Level.FINE,
               "Failed to remove the MCF from connector registry.", poolName);
            return false;
        } else {
            _logger.fine("removeMCF " + poolName + " - " + !factories.containsKey(poolName));
            return true;
        }
    
public booleanremoveResourceAdapterConfig(java.lang.String rarName)
Remove the resource adapter config properties object from registry

param
rarName Name of the rar
return
true if successfully deleted false if deletion fails

        if(resourceAdapterConfig.remove(rarName) == null) {
            _logger.log(Level.FINE,
                 "failed to remove the resourceAdapter config from registry.", 
                 rarName);
            return false;
        } else {
            _logger.log(Level.FINE,
                 "Removed the resourceAdapter config map from registry.", 
                 rarName);
            return true;
        }