FileDocCategorySizeDatePackage
ResourcesUtil.javaAPI DocGlassfish v2 API70309Fri Jun 29 05:02:08 BST 2007com.sun.enterprise.connectors.util

ResourcesUtil

public class ResourcesUtil extends Object
author
Srikanth P, Sivakumar Thyagarajan, Aditya Gore, Kshitiz Saxena
version

Fields Summary
static final int
NO_OF_ALL_CONNECTOR_RESOURCE_TYPE
static final int
NO_OF_CONNECTOR_RESOURCE_TYPE
static final int
NO_OF_JDBC_RESOURCE_TYPE
public static final String
RA_CONFIGS
public static final String
CONNECTION_POOLS
public static final String
RESOURCES
static ThreadLocal
localResourcesUtil
static ServerContext
sc_
Resources
res
Domain
dom
ConfigContext
configContext_
static Logger
_logger
static com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
protected ResourcesUtil()

        this(sc_.getConfigContext());
    
protected ResourcesUtil(ConfigContext configContext)

        try{
            configContext_ = configContext;
            dom = ServerBeansFactory.getDomainBean(configContext_);
            res = dom.getResources();
        }catch(ConfigException ex){
            String message = localStrings.getStringWithDefault(
                    "caught_config_exception",
                    "Caught ConfigException while instantiating ResourcesUtil or DASResourcesUtil : ");
            throw new ConfigException(message, ex);
            
        }
    
Methods Summary
public booleanadminObjectBelongsToSystemRar(java.lang.String adminObject)

        AdminObjectResource aor =
                res.getAdminObjectResourceByJndiName(adminObject);
        if(aor != null) {
            return belongToSystemRar(aor.getResAdapter());
        }
        return false;
    
public booleanbelongToEmbeddedRar(java.lang.String resourceAdapterName)

        String appName = getAppNameToken(resourceAdapterName);
        if(appName==null)
            return false;
        Applications apps = dom.getApplications();
        J2eeApplication j2eeApp = apps.getJ2eeApplicationByName(appName);
        if(j2eeApp == null)
            return false;
        return true;
    
private booleanbelongToEmbeddedRarAndEnabled(java.lang.String resourceAdapterName)

        String appName = getAppNameToken(resourceAdapterName);
        if(appName==null)
            return false;
        Applications apps = dom.getApplications();
        J2eeApplication j2eeApp = apps.getJ2eeApplicationByName(appName);
        if(j2eeApp == null || !j2eeApp.isEnabled())
            return false;
        return isApplicationReferenceEnabled(appName);
    
public booleanbelongToRar(java.lang.String rarName, ConnectorConnectionPool ccp)

        if(ccp == null || rarName== null) {
            return false;
        }
        if(ccp.getResourceAdapterName().equals(rarName)) {
            return true;
        } else {
            return false;
        }
    
public booleanbelongToRar(java.lang.String rarName, ConnectorResource cr)

        if(cr == null || rarName== null) {
            return false;
        }
        String poolName = cr.getPoolName();
        ConnectorConnectionPool ccp = res.getConnectorConnectionPoolByName(poolName);
        if (ccp == null) {
            return false;
        }
        return belongToRar(rarName, ccp);
    
public booleanbelongToRar(java.lang.String rarName, AdminObjectResource aor)

        if(aor == null || rarName== null) {
            return false;
        }
        if(aor.getResAdapter().equals(rarName)) {
            return true;
        } else {
            return false;
        }
    
public booleanbelongToStandAloneRar(java.lang.String resourceAdapterName)

        Applications apps = dom.getApplications();
        ConnectorModule connectorModule = apps.getConnectorModuleByName(resourceAdapterName);
        if(connectorModule == null)
            return false;
        return true;
    
public booleanbelongToSystemRar(java.lang.String resourceAdapterName)

        Iterator<String> iter = ConnectorRuntime.systemRarNames.iterator();
        while(iter.hasNext()){
            if(resourceAdapterName.equals(iter.next()))
                return true;
        }
        return false;
    
public static com.sun.enterprise.connectors.util.ResourcesUtilcreateInstance()

        if(localResourcesUtil.get() != null)
            return localResourcesUtil.get();
        if(sc_ == null){
            String message = localStrings.getStringWithDefault(
                    "server_context_is_null",
                    "Server context is null. Hence cannot create instance of ResourcesUtil or DASResourcesUtil.");
            _logger.log(Level.SEVERE, message);
            return null;
        }
        try{
            if (isDAS()) {
                return new DASResourcesUtil();
            } else {
                return new ResourcesUtil();
            }
        }catch(ConfigException ex){
            String message = localStrings.getStringWithDefault(
                    "caught_config_exception",
                    "Caught ConfigException while instantiating ResourcesUtil or DASResourcesUtil : ");
            
            _logger.log(Level.SEVERE,
                   message + ex.getMessage(), ex);
            return null;
        }
    
public java.util.MapgetAllConnectorResources()

        return getFilteredAllConnectorResources(false, false, null);
    
public ConfigBean[][]getAllConnectorResourcesForRar(java.lang.String rarName)

        
        ConfigBean configBeanArray[][] =
                new ConfigBean[NO_OF_CONNECTOR_RESOURCE_TYPE][];
        Map allConnectorResources = getFilteredAllConnectorResources(false, false, rarName);
        configBeanArray[0] = (ConfigBean[]) allConnectorResources.get(CONNECTION_POOLS);
        configBeanArray[1] = (ConfigBean[]) allConnectorResources.get(RESOURCES);
        configBeanArray[2] = getFilteredAdminObjectResources(false, false, rarName);
        return configBeanArray;
        
    
public AdminObjectResource[]getAllJmsAdminObjects()

        AdminObjectResource[] aor = (AdminObjectResource[]) getFilteredAdminObjectResources(false, false,
                ConnectorConstants.DEFAULT_JMS_ADAPTER);
        
        return aor;
    
public ConnectorResource[]getAllJmsResources()

        ConnectorResource[] cr = (ConnectorResource[]) getFilteredAllConnectorResources(false, false, 
                ConnectorConstants.DEFAULT_JMS_ADAPTER).get(RESOURCES);
        
        return cr;
    
public java.lang.StringgetAppName(ConnectorConnectionPool ccp)

param
ccp connector connection pool
return
App Name for the given connector connection pool

        if(ccp == null)
            return null;
        String resourceAdapterName = ccp.getResourceAdapterName();
        int delimIdx = resourceAdapterName.indexOf(ConnectorConstants.
                        EMBEDDEDRAR_NAME_DELIMITER);
        if (delimIdx == -1) {
            return null;
        } else {
            return resourceAdapterName.substring(0, delimIdx);
        }
    
private java.lang.StringgetAppNameToken(java.lang.String rarName)

        if(rarName == null) {
            return null;
        }
        int index = rarName.indexOf(
                ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER);
        if(index != -1) {
            return rarName.substring(0,index);
        } else {
            return null;
        }
    
public java.lang.StringgetApplicationDeployLocation(java.lang.String appName)
Gets the deployment location for a J2EE application.

param
rarName
return

        J2eeApplication app = dom.getApplications().getJ2eeApplicationByName(appName);
        return RelativePathResolver.resolvePath(app.getLocation());
    
private com.sun.enterprise.instance.AppsManagergetAppsManager()

        InstanceEnvironment iEnv = sc_.getInstanceEnvironment();
        return InstanceFactory.createAppsManager(iEnv, false);
    
public com.sun.enterprise.config.serverbeans.ConnectorConnectionPoolgetConnectorConnectionPoolByName(java.lang.String poolName)

        return res.getConnectorConnectionPoolByName( poolName );
    
public java.lang.Object[]getConnectorConnectionPoolNames(java.lang.String moduleName)

        Vector poolNamesVector = new Vector();
        ConnectorConnectionPool[] connectorConnectionPool=
                res.getConnectorConnectionPool();
        if (connectorConnectionPool== null
                || connectorConnectionPool.length == 0) {
            return null;
        }
        
        for(int i=0; i<connectorConnectionPool.length; ++ i) {
            if(connectorConnectionPool[i].getResourceAdapterName().equals(
                    moduleName)) {
                poolNamesVector.add(connectorConnectionPool[i].getName());
            }
        }
        return poolNamesVector.toArray();
    
public ConnectorConnectionPool[]getConnectorConnectionPools()

        ConnectorConnectionPool[] connectorConnectionPool = null;
        connectorConnectionPool = res.getConnectorConnectionPool();
        if (connectorConnectionPool == null || connectorConnectionPool.length == 0)
            return null;
        return connectorConnectionPool;
    
public com.sun.enterprise.deployment.ConnectorDescriptorgetConnectorDescriptorFromUri(java.lang.String appName, java.lang.String raLoc)

        AppsManager am = getAppsManager();
        Application app = am.getAppDescriptor(appName,
                ASClassLoaderUtil.getSharedClassLoader());
        return app.getRarDescriptorByUri(raLoc);
    
public ConfigBean[][]getConnectorResources()

        return getConnectorResources(false);
    
public ConfigBean[][]getConnectorResources(boolean onlystandAloneRars)

        
        ConfigBean[][] configBeanArray  = new ConfigBean[NO_OF_ALL_CONNECTOR_RESOURCE_TYPE][];
        Map allConnectorResources = getFilteredAllConnectorResources(onlystandAloneRars, false, null);
        configBeanArray[0] = (ConfigBean[]) allConnectorResources.get(RA_CONFIGS);
        configBeanArray[1] = (ConfigBean[]) allConnectorResources.get(CONNECTION_POOLS);
        configBeanArray[2] = (ConfigBean[]) allConnectorResources.get(RESOURCES);
        configBeanArray[3] = getFilteredAdminObjectResources(onlystandAloneRars, false, null);
        return configBeanArray;
    
public java.lang.Object[]getConnectorResourcesJndiNames(java.lang.String poolName)

        Vector jndiNamesVector = new Vector();
        ConnectorResource[] connectorResource = res.getConnectorResource();
        if (connectorResource == null || connectorResource.length == 0) {
            return null;
        }
        
        for(int i=0; i<connectorResource.length; ++ i) {
            if(connectorResource[i].getPoolName().equals(poolName)) {
                jndiNamesVector.add(connectorResource[i].getJndiName());
            }
        }
        return jndiNamesVector.toArray();
    
protected java.lang.StringgetCorrespondingCmpResourceName(java.lang.String resourceName)

        
        int index = resourceName.lastIndexOf("__pm");
        if(index != -1) {
            return resourceName.substring(0,index);
        }
        return null;
    
protected com.sun.enterprise.connectors.DeferredResourceConfiggetDeferredAdminObjectConfigs(java.lang.String resourceName)
Returns the deffered admin object config. This can be admin object of JMS RA which is lazily loaded. Or for other connector RA which is not loaded at startup. The connector RA which does not have any resource or admin object associated with it are not loaded at startup. They are all lazily loaded.

        
        if(resourceName == null) {
            return null;
        }
        ConfigBean[] resourcesToload = new ConfigBean[1];
        
        try {
            if(!isReferenced(resourceName)){
                return null;
            }
        } catch (ConfigException e) {
            String message = localStrings.getString(
                    "error.finding.resources.references",
                    resourceName);
            _logger.log(Level.WARNING, message + e.getMessage());
            _logger.log(Level.FINE,message + e.getMessage(), e);
        }
        
        AdminObjectResource adminObjectResource =
                res.getAdminObjectResourceByJndiName(resourceName);
        if(adminObjectResource == null || !adminObjectResource.isEnabled()) {
            return null;
        }
        String rarName = adminObjectResource.getResAdapter();
        if(rarName != null){
            resourcesToload[0] = adminObjectResource;
            ResourceAdapterConfig[] resourceAdapterConfig =
                    new ResourceAdapterConfig[1];
            resourceAdapterConfig[0] =
                    res.getResourceAdapterConfigByResourceAdapterName(rarName);
            DeferredResourceConfig resourceConfig =
                    new DeferredResourceConfig(rarName,adminObjectResource,
                    null,null,null,null,resourceAdapterConfig);
            resourceConfig.setResourcesToLoad(resourcesToload);
            return resourceConfig;
        }
        return null;
    
protected com.sun.enterprise.connectors.DeferredResourceConfiggetDeferredConnectorPoolConfigs(java.lang.String poolName)
Returns the deffered connector connection pool config. This can be pool of JMS RA which is lazily loaded. Or for other connector RA which is not loaded at startup. The connector RA which does not have any resource or admin object associated with it are not loaded at startup. They are all lazily loaded.

        
        ConfigBean[] resourcesToload = new ConfigBean[1];
        if(poolName == null) {
            return null;
        }
        
        
        ConnectorConnectionPool ccPool =
                res.getConnectorConnectionPoolByName(poolName);
        if(ccPool == null) {
            return null;
        }
        
        String rarName = ccPool.getResourceAdapterName();
        
        if(rarName != null){
            resourcesToload[0] = ccPool;
            ResourceAdapterConfig[] resourceAdapterConfig =
                    new ResourceAdapterConfig[1];
            resourceAdapterConfig[0] =
                    res.getResourceAdapterConfigByResourceAdapterName(
                    rarName);
            DeferredResourceConfig resourceConfig =
                    new DeferredResourceConfig(rarName,null,ccPool,
                    null,null,null,resourceAdapterConfig);
            resourceConfig.setResourcesToLoad(resourcesToload);
            return resourceConfig;
        }
        return null;
    
protected com.sun.enterprise.connectors.DeferredResourceConfiggetDeferredConnectorResourceConfigs(java.lang.String resourceName)
Returns the deffered connector resource config. This can be resource of JMS RA which is lazily loaded. Or for other connector RA which is not loaded at startup. The connector RA which does not have any resource or admin object associated with it are not loaded at startup. They are all lazily loaded.

        
        if(resourceName == null) {
            return null;
        }
        ConfigBean[] resourcesToload = new ConfigBean[2];
        
        try {
            if(!isReferenced(resourceName)){
                return null;
            }
        } catch (ConfigException e) {
            String message = localStrings.getString(
                    "error.finding.resources.references",
                    resourceName);
            _logger.log(Level.WARNING, message + e.getMessage());
            _logger.log(Level.FINE,message + e.getMessage(), e);
        }
        
        
        ConnectorResource connectorResource =
                res.getConnectorResourceByJndiName(resourceName);
        if(connectorResource == null || !connectorResource.isEnabled()) {
            return null;
        }
        String poolName = connectorResource.getPoolName();
        ConnectorConnectionPool ccPool =
                res.getConnectorConnectionPoolByName(poolName);
        if(ccPool == null) {
            return null;
        }
        String rarName = ccPool.getResourceAdapterName();
        if(rarName != null){
            resourcesToload[0] = ccPool;
            resourcesToload[1] = connectorResource;
            ResourceAdapterConfig[] resourceAdapterConfig =
                    new ResourceAdapterConfig[1];
            resourceAdapterConfig[0] =
                    res.getResourceAdapterConfigByResourceAdapterName(
                    rarName);
            DeferredResourceConfig resourceConfig =
                    new DeferredResourceConfig(rarName,null,ccPool,
                    connectorResource,null,null,
                    resourceAdapterConfig);
            resourceConfig.setResourcesToLoad(resourcesToload);
            return resourceConfig;
        }
        return null;
    
protected com.sun.enterprise.connectors.DeferredResourceConfiggetDeferredJdbcPoolConfigs(java.lang.String poolName)

        
        ConfigBean[] resourcesToload = new ConfigBean[1];
        if(poolName == null) {
            return null;
        }
        
        JdbcConnectionPool jdbcPool =
                res.getJdbcConnectionPoolByName(poolName);
        if(jdbcPool == null) {
            return null;
        }
        String rarName = getRAForJdbcConnectionPool(jdbcPool);
        
        if(rarName != null && belongToSystemRar(rarName)) {
            resourcesToload[0] = jdbcPool;
            DeferredResourceConfig resourceConfig =
                    new DeferredResourceConfig(rarName,null,null,
                    null,jdbcPool,null,null);
            resourceConfig.setResourcesToLoad(resourcesToload);
            return resourceConfig;
        }
        return null;
    
protected com.sun.enterprise.connectors.DeferredResourceConfiggetDeferredJdbcResourceConfigs(java.lang.String resourceName)

        
        ConfigBean[] resourcesToload = new ConfigBean[2];
        if(resourceName == null) {
            return null;
        }
        
        try {
            //__pm does not have a domain.xml entry and hence will not
            //be referenced
            if(!(resourceName.endsWith("__pm"))){
                if(!isReferenced(resourceName)){
                    return null;
                }
            }
        } catch (ConfigException e) {
            String message = localStrings.getString(
                    "error.finding.resources.references",
                    resourceName);
            _logger.log(Level.WARNING, message + e.getMessage());
            _logger.log(Level.FINE,message + e.getMessage(), e);
        }
        
        JdbcResource jdbcResource = res.getJdbcResourceByJndiName(resourceName);
        if(jdbcResource == null || !jdbcResource.isEnabled()) {
            String cmpResourceName =
                    getCorrespondingCmpResourceName(resourceName);
            jdbcResource =res.getJdbcResourceByJndiName(cmpResourceName);
            if(jdbcResource == null) {
                return null;
            }
        }
        JdbcConnectionPool jdbcPool =
                res.getJdbcConnectionPoolByName(jdbcResource.getPoolName());
        if(jdbcPool == null) {
            return null;
        }
        String rarName = getRAForJdbcConnectionPool(jdbcPool);
        if(rarName != null && belongToSystemRar(rarName)) {
            resourcesToload[0] = jdbcPool;
            resourcesToload[1] = jdbcResource;
            DeferredResourceConfig resourceConfig =
                    new DeferredResourceConfig(rarName,null,null,
                    null,jdbcPool,jdbcResource,null);
            resourceConfig.setResourcesToLoad(resourcesToload);
            return resourceConfig;
        }
        return null;
    
public com.sun.enterprise.connectors.DeferredResourceConfiggetDeferredPoolConfig(java.lang.String poolName)

        
        DeferredResourceConfig resConfig = getDeferredConnectorPoolConfigs(
                poolName);
        if(resConfig != null) {
            return resConfig;
        }
        
        if(poolName == null){
            return null;
        }
        
        resConfig = getDeferredJdbcPoolConfigs(poolName);
        
        return resConfig;
    
public com.sun.enterprise.connectors.DeferredResourceConfiggetDeferredResourceConfig(java.lang.String resourceName)

        DeferredResourceConfig resConfig = getDeferredConnectorResourceConfigs(
                resourceName);
        if(resConfig != null) {
            return resConfig;
        }
        
        resConfig = getDeferredJdbcResourceConfigs(
                resourceName);
        
        if(resConfig != null) {
            return resConfig;
        }
        
        resConfig = getDeferredAdminObjectConfigs(
                resourceName);
        
        return resConfig;
    
public com.sun.enterprise.deployment.Application[]getDeployedApplications()
Gets the list of applications deployed.

param
none
return
Application[] of deloyed applications.

        _logger.log(Level.FINE, "in ResourcesUtil.getApplicationNames()");
        
        // Get list of deployed "Applications"
        Applications apps = dom.getApplications();
        // From Applications, get the J2ee Applications and ejb modules
        J2eeApplication[] j2ee_apps = apps.getJ2eeApplication();
        EjbModule[] ejb_modules = apps.getEjbModule();
        
        // This array would contain the deployment descriptors of all the
        // ejbmodules and aplications.
        ArrayList deployedAppsDescriptorList = new ArrayList();
        
        if ((j2ee_apps.length + ejb_modules.length) == 0)
            return (new Application[] {});
        
        // Get the respective Managers to retrieve Deployment descriptors
        AppsManager appsManager = getAppsManager();
        EjbModulesManager ejbModulesManager = getEjbModulesManager();
        
        // Get Deployment desc for J2EE apps.
        for (int i=0; i<j2ee_apps.length; i++){
            String appName = j2ee_apps[i].getName();
            // Check if the application is referenced by the server instance on
            // which recovery is happening.
            if (!(ServerHelper.serverReferencesApplication(configContext_, sc_.getInstanceName(), appName) ))
                continue;
            
            try{
                Application appDescriptor =
                        appsManager.getAppDescriptor(appName,
                        ASClassLoaderUtil.getSharedClassLoader());
                deployedAppsDescriptorList.add(appDescriptor);
            } catch (Exception e){
                String message = localStrings.getString(
                    "error.getting.application.DD",
                    appName);
                _logger.log(Level.WARNING, message + e.getMessage());
                _logger.log(Level.FINE,message + e.getMessage(), e);
            }
        }
        
        // Get deployment desc for EJB modules.
        for (int i=0; i<ejb_modules.length; i++){
            String modName = ejb_modules[i].getName();
            
            if (!(ServerHelper.serverReferencesApplication(configContext_, sc_.getInstanceName(), modName) ))
                continue;
            
            try{
                Application appDescriptor =
                        ejbModulesManager.getDescriptor(modName,
                        ASClassLoaderUtil.getSharedClassLoader());
                deployedAppsDescriptorList.add(appDescriptor);
            } catch (Exception e){
                String message = localStrings.getString(
                    "error.getting.module.DD",
                    modName);
                _logger.log(Level.WARNING, message + e.getMessage());
                _logger.log(Level.FINE,message + e.getMessage(), e);
            }
        }
        
        return (Application[])(deployedAppsDescriptorList.toArray(new Application[] {}));
        
    
private com.sun.enterprise.instance.EjbModulesManagergetEjbModulesManager()

        InstanceEnvironment iEnv = sc_.getInstanceEnvironment();
        return InstanceFactory.createEjbModuleManager(iEnv, false);
    
public ConfigBean[]getEmbeddedRarResourceAdapterConfigs(java.lang.String appName)

        Applications apps = dom.getApplications();
        J2eeApplication j2eeApp = apps.getJ2eeApplicationByName(appName);
        if(j2eeApp == null || !j2eeApp.isEnabled()) {
            return null;
        }
        
        ResourceAdapterConfig[] raConfigBeans = res.getResourceAdapterConfig();
        
        if(raConfigBeans == null) {
            return null;
        }
        String appNameToken = null;
        Vector tmpVector = new Vector();
        for(int i=0;i<raConfigBeans.length;++i) {
            appNameToken =
                    getAppNameToken(raConfigBeans[i].getResourceAdapterName());
            if(appNameToken != null && appName.equals(appNameToken)) {
                tmpVector.add(raConfigBeans[i]);
            }
        }
        if(tmpVector.size() == 0)
            return null;
        ConfigBean[] result = new ConfigBean[tmpVector.size()];
        return (ConfigBean[])tmpVector.toArray(result);
    
public ConfigBean[]getEnabledAdminObjectResources(java.lang.String rarName)

        return getFilteredAdminObjectResources(false, false, rarName);
    
private ConfigBean[]getFilteredAdminObjectResources(boolean onlystandAloneRars, boolean onlynonSystemRars, java.lang.String rarName)

        
        int noOfAdminObjectResources = res.sizeAdminObjectResource();
        if(noOfAdminObjectResources == 0) {
            return null;
        }
        Vector<AdminObjectResource> standAloneRarAdminObjectResourcesVector = 
                new Vector<AdminObjectResource>();
        Vector<AdminObjectResource> embeddedRarAdminObjectResourcesVector = 
                new Vector<AdminObjectResource>();
        for(int i=0; i< noOfAdminObjectResources; ++i) {
            AdminObjectResource adminObjectResource = res.getAdminObjectResource(i);
            if(adminObjectResource == null)
                continue;
            String resourceAdapterName = adminObjectResource.getResAdapter();
            if(resourceAdapterName == null)
                continue;
            if(rarName!= null && !rarName.equals(resourceAdapterName))
                continue;
            // skips the admin resource if it is not referenced by the server
            if(!isEnabled(adminObjectResource))
                continue;
            if(belongToSystemRar(resourceAdapterName)){
                if(!onlynonSystemRars)
                    standAloneRarAdminObjectResourcesVector.add(adminObjectResource);
            }else if(belongToStandAloneRar(resourceAdapterName)){
                standAloneRarAdminObjectResourcesVector.add(adminObjectResource);
            }else if(belongToEmbeddedRar(resourceAdapterName)){
                embeddedRarAdminObjectResourcesVector.add(adminObjectResource);
            }else{
                String message = localStrings.getString("no.resource.adapter.found",
                        resourceAdapterName, adminObjectResource.getJndiName());
                _logger.warning(message);
            }
        }
        
        if(onlystandAloneRars) {
            AdminObjectResource[] standAloneRarAdminObjectResources =
                    new AdminObjectResource[standAloneRarAdminObjectResourcesVector.size()];
            standAloneRarAdminObjectResources =
                    (AdminObjectResource[])standAloneRarAdminObjectResourcesVector.toArray(
                    standAloneRarAdminObjectResources);
            return standAloneRarAdminObjectResources;
        } else {
            Vector<AdminObjectResource> allAdminObjectResourcesVector = 
                    new Vector<AdminObjectResource>();
            allAdminObjectResourcesVector.addAll(
                    standAloneRarAdminObjectResourcesVector);
            allAdminObjectResourcesVector.addAll(
                    embeddedRarAdminObjectResourcesVector);
            AdminObjectResource[] allAdminObjectResources =
                    new AdminObjectResource[allAdminObjectResourcesVector.size()];
            allAdminObjectResources =
                    (AdminObjectResource[])allAdminObjectResourcesVector.toArray(
                    allAdminObjectResources);
            return allAdminObjectResources;
        }
    
private java.util.MapgetFilteredAllConnectorResources(boolean onlystandAloneRars, boolean onlynonSystemRars, java.lang.String rarName)

        
        HashMap allConnectorResources = new HashMap();
        int noOfConnectorResources = res.sizeConnectorResource();
        
        if(noOfConnectorResources == 0) {
            return allConnectorResources;
        }
        
        HashSet<ConnectorResource> standAloneRarConnectorResourcesVector =
                new HashSet<ConnectorResource>();
        HashSet<ConnectorResource> embeddedRarConnectorResourcesVector  =
                new HashSet<ConnectorResource>();
        HashSet<ConnectorConnectionPool> standAloneRarPoolsVector =
                new HashSet<ConnectorConnectionPool>();
        HashSet<ConnectorConnectionPool> embeddedRarPoolsVector  =
                new HashSet<ConnectorConnectionPool>();
        HashSet<ResourceAdapterConfig> standAloneRarConfigsVector =
                new HashSet<ResourceAdapterConfig>();
        HashSet<ResourceAdapterConfig> embeddedRarConfigsVector =
                new HashSet<ResourceAdapterConfig>();
        
        for(int i=0; i< noOfConnectorResources; ++i) {
            ConnectorResource ccResource = res.getConnectorResource(i);
            if(ccResource == null)
                continue;
            ConnectorConnectionPool ccPool = getConnectorConnectionPoolByName(
                    ccResource.getPoolName());
            if(ccPool == null)
                continue;
            String resourceAdapterName = ccPool.getResourceAdapterName();
            if(resourceAdapterName == null)
                continue;
            if(rarName != null && !rarName.equals(resourceAdapterName))
                continue;
            
            if(!isEnabled(ccResource))
                continue;
            
            if(belongToSystemRar(resourceAdapterName)){
                if(!onlynonSystemRars){
                    standAloneRarPoolsVector.add(ccPool);
                    standAloneRarConnectorResourcesVector.add(ccResource);
                }
            }else{
                ResourceAdapterConfig resAdapterConfig =
                            res.getResourceAdapterConfigByResourceAdapterName(
                            resourceAdapterName);
                if(belongToStandAloneRar(resourceAdapterName)){
                    standAloneRarConfigsVector.add(resAdapterConfig);
                    standAloneRarPoolsVector.add(ccPool);
                    standAloneRarConnectorResourcesVector.add(ccResource);
                }else if(belongToEmbeddedRar(resourceAdapterName)) {
                    embeddedRarConfigsVector.add(resAdapterConfig);
                    embeddedRarPoolsVector.add(ccPool);
                    embeddedRarConnectorResourcesVector.add(ccResource);
                }else{
                    String message = localStrings.getString("no.resource.adapter.found", 
                            resourceAdapterName, ccResource.getJndiName());
                    _logger.warning(message);
                }
            }   
        }
        
        ResourceAdapterConfig[] raConfigs = null;
        ConnectorConnectionPool[] ccPools = null;
        ConnectorResource[] ccResources = null;
        if(onlystandAloneRars){
            raConfigs = new ResourceAdapterConfig[standAloneRarConfigsVector.size()];
            raConfigs = (ResourceAdapterConfig[])standAloneRarConfigsVector.toArray(raConfigs);
            ccPools = new ConnectorConnectionPool[standAloneRarPoolsVector.size()];
            ccPools = (ConnectorConnectionPool[])standAloneRarPoolsVector.toArray(ccPools);
            ccResources = new ConnectorResource[standAloneRarConnectorResourcesVector.size()];
            ccResources = (ConnectorResource[])standAloneRarConnectorResourcesVector.toArray(ccResources);
        } else{
            Vector<ConnectorResource> allConnectorResourcesVector = new Vector<ConnectorResource>();
            Vector<ConnectorConnectionPool> allPoolsVector = new Vector<ConnectorConnectionPool>();
            Vector<ResourceAdapterConfig> allRaConfigs = new Vector<ResourceAdapterConfig>();
            allConnectorResourcesVector.addAll(standAloneRarConnectorResourcesVector);
            allConnectorResourcesVector.addAll(embeddedRarConnectorResourcesVector);
            allPoolsVector.addAll(standAloneRarPoolsVector);
            allPoolsVector.addAll(embeddedRarPoolsVector);
            allRaConfigs.addAll(standAloneRarConfigsVector);
            allRaConfigs.addAll(embeddedRarConfigsVector);
            raConfigs = new ResourceAdapterConfig[allRaConfigs.size()];
            raConfigs = (ResourceAdapterConfig[])allRaConfigs.toArray(raConfigs);
            ccPools = new ConnectorConnectionPool[allPoolsVector.size()];
            ccPools = (ConnectorConnectionPool[])allPoolsVector.toArray(ccPools);
            ccResources = new ConnectorResource[allConnectorResourcesVector.size()];
            ccResources = (ConnectorResource[])allConnectorResourcesVector.toArray(ccResources);
        }
        allConnectorResources.put(RA_CONFIGS, raConfigs);
        allConnectorResources.put(CONNECTION_POOLS, ccPools);
        allConnectorResources.put(RESOURCES, ccResources);
        return allConnectorResources;
    
public com.sun.enterprise.config.serverbeans.JdbcConnectionPoolgetJDBCPoolForResource(java.lang.String resourceName)

        JdbcResource jr = res.getJdbcResourceByJndiName(resourceName);
        if (isEnabled(jr)) {
            return this.getJdbcConnectionPoolByName(jr.getPoolName());
        }
        return null;
    
public com.sun.enterprise.config.serverbeans.JdbcConnectionPoolgetJdbcConnectionPoolByName(java.lang.String poolName)

        return res.getJdbcConnectionPoolByName( poolName );
    
public JdbcConnectionPool[]getJdbcConnectionPools()

        JdbcConnectionPool[] jdbcConnectionPool = res.getJdbcConnectionPool();
        if(jdbcConnectionPool == null || jdbcConnectionPool.length == 0)
            return null;
        return jdbcConnectionPool;
    
public JdbcResourcegetJdbcResourceByJndiName(java.lang.String jndiName)
Gets a JDBC resource on the basis of its jndi name

param
jndiName the jndi name of the JDBC resource to lookup
param
checkReference if true, returns this JDBC resource only if it is referenced in this server. If false, returns the JDBC resource irrespective of whether it is referenced or not.

        
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("ResourcesUtil :: looking up jdbc resource, jndiName is :"
                    + jndiName );
        }
        
        JdbcResource jdbcRes =
                res.getJdbcResourceByJndiName( jndiName );
        
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("ResourcesUtil :: looked up jdbc resource:" + jdbcRes.getJndiName() );
        }
        //does the isReferenced method throw NPE for null value? Better be safe
        if (jdbcRes == null) {
            return null;
        }
        
        try {
            return isReferenced( jndiName ) ? jdbcRes : null;
        }catch( ConfigException ce ) {
            return null;
        }
    
public ConfigBean[][]getJdbcResources()

        ConfigBean configBeanArray[][] =
                new ConfigBean[NO_OF_JDBC_RESOURCE_TYPE][];
        Map allJdbcResources  = getJdbcResourcesAsMap();
        configBeanArray[0] = (ConfigBean[]) allJdbcResources.get(CONNECTION_POOLS);
        configBeanArray[1] = (ConfigBean[]) allJdbcResources.get(RESOURCES);
        return configBeanArray;
    
public java.util.MapgetJdbcResourcesAsMap()

        
        HashMap allJdbcResources = new HashMap();
        int noOfJdbcResources = res.sizeJdbcResource();
        
        if(noOfJdbcResources == 0) {
            return allJdbcResources;
        }
        
        Vector<JdbcResource> jdbcResourcesVector =
                new Vector<JdbcResource>();
        Vector<JdbcConnectionPool> jdbcPoolsVector =
                new Vector<JdbcConnectionPool>();
        
        for(int i=0; i< noOfJdbcResources; ++i) {
            JdbcResource jdbcResource = res.getJdbcResource(i);
            if(jdbcResource == null)
                continue;
            JdbcConnectionPool jdbcPool = getJdbcConnectionPoolByName(
                    jdbcResource.getPoolName());
            if(jdbcPool == null)
                continue;
            
            if(!isEnabled(jdbcResource))
                continue;
            
            jdbcResourcesVector.add(jdbcResource);
            
            if(!jdbcPoolsVector.contains(jdbcPool))
                jdbcPoolsVector.add(jdbcPool);
        }
        
        if(jdbcResourcesVector.size() == 0)
            return allJdbcResources;
        
        ConfigBean[]jdbcPools = new JdbcConnectionPool[jdbcPoolsVector.size()];
        ConfigBean[]jdbcResources = new JdbcResource[jdbcResourcesVector.size()];
        jdbcPools = (JdbcConnectionPool[]) jdbcPoolsVector.toArray(
                jdbcPools);
        jdbcResources = (JdbcResource[]) jdbcResourcesVector.toArray(
                jdbcResources);
        allJdbcResources.put(CONNECTION_POOLS, jdbcPools);
        allJdbcResources.put(RESOURCES, jdbcResources);
        return allJdbcResources;
    
public java.lang.StringgetLocation(java.lang.String moduleName)

        
        if(moduleName == null) {
            return null;
        }
        String location  = null;
        ConnectorModule connectorModule =
                dom.getApplications().getConnectorModuleByName(moduleName);
        if(connectorModule != null) {
            location = RelativePathResolver.
                    resolvePath(connectorModule.getLocation());
        }
        return location;
        
    
public PersistenceManagerFactoryResourcegetPMFResourceByJndiName(java.lang.String jndiName)
Gets a PMF resource on the basis of its jndi name

param
jndiName the jndi name of the PMF resource to lookup
param
checkReference if true, returns this PMF resource only if it is referenced in this server. If false, returns the PMF resource irrespective of whether it is referenced or not.

        
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("ResourceUtil :: looking up pmf resource, jndiName is :"
                    + jndiName );
        }
        PersistenceManagerFactoryResource pmf =
                res.getPersistenceManagerFactoryResourceByJndiName( jndiName );
        
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("getPMFResourceByJndiName:: looked up pmf resource : "
                    + pmf);
        }
        //does the isReferenced method throw NPE for null value? Better be safe
        if (pmf == null) {
            return null;
        }
        
        try {
            return isReferenced( jndiName ) ? pmf : null;
        }catch( ConfigException ce ) {
            return null;
        }
    
public java.util.MapgetPoolMap()

        ConnectorConnectionPool[] cp = getConnectorConnectionPools();
        if (cp == null) {
            return null;
        }
        
        Map<ConnectorConnectionPool, MonitorableResourcePool> poolMap = 
            new HashMap<ConnectorConnectionPool, MonitorableResourcePool>();
        Map allPools = Switch.getSwitch().getPoolManager().getPoolTable();

        for( int i = 0 ; i < cp.length; i++ ) {
            if (!(cp[i].getName().equalsIgnoreCase(
                            ConnectorConstants.DEFAULT_JMS_ADAPTER))) {
                ResourcePool p = (ResourcePool) allPools.get( cp[i].getName() );

                if (p != null && (p instanceof MonitorableResourcePool )) {
                    poolMap.put(cp[i], (MonitorableResourcePool)p);
                }
            }
        }
        return poolMap;
    
public java.lang.StringgetRAForJdbcConnectionPool(JdbcConnectionPool pool)
This method takes in an admin JdbcConnectionPool and returns the RA that it belongs to.

param
pool - The pool to check
return
The name of the JDBC RA that provides this pool's datasource

        String dsRAName = ConnectorConstants.JDBCDATASOURCE_RA_NAME;
        
        if ( pool.getResType() == null ) {
            return dsRAName;
        }
        
        //check if its XA
        if ( "javax.sql.XADataSource".equals( pool.getResType() ) ) {
            if ( pool.getDatasourceClassname() == null ) {
                return dsRAName;
            }
            try {
                Class dsClass=Utility.loadClass(pool.getDatasourceClassname());
                if (javax.sql.XADataSource.class.isAssignableFrom(dsClass)) {
                    return ConnectorConstants.JDBCXA_RA_NAME;
                }
            } catch( ClassNotFoundException cnfe) {
                return dsRAName;
            }
        }
        
        //check if its CP
        if ("javax.sql.ConnectionPoolDataSource".equals(pool.getResType())) {
            if ( pool.getDatasourceClassname() == null ) {
                return dsRAName;
            }
            try {
                Class dsClass=Utility.loadClass(pool.getDatasourceClassname());
                if(javax.sql.ConnectionPoolDataSource.class.isAssignableFrom(
                        dsClass) ) {
                    return
                            ConnectorConstants.JDBCCONNECTIONPOOLDATASOURCE_RA_NAME;
                }
            } catch( ClassNotFoundException cnfe) {
                return dsRAName;
            }
        }
        //default to __ds
        return dsRAName;
    
public java.lang.StringgetRAName(ConnectorConnectionPool ccp)

param
ccp connector connection pool
return
RA Name for the given connector connection pool

        if(ccp == null)
            return null;
        String resourceAdapterName = ccp.getResourceAdapterName();
        int delimIdx = resourceAdapterName.indexOf(ConnectorConstants.
                        EMBEDDEDRAR_NAME_DELIMITER);
        if (delimIdx == -1) {
            return resourceAdapterName;
        } else {
            return resourceAdapterName.substring(delimIdx + 1);
        }
    
public ConfigBean[]getResourceAdapterConfigs()

        ResourceAdapterConfig[] raConfigBeans = res.getResourceAdapterConfig();
        if(raConfigBeans == null || raConfigBeans.length == 0)
            return null;
        //Only referenced resource adapter configs must be returned
        Vector referencedResourceAdapterConfigs = new Vector();
        for(int i=0; i<raConfigBeans.length; i++){
            if(isRarEnabled(raConfigBeans[i].getResourceAdapterName()))
                referencedResourceAdapterConfigs.add(raConfigBeans[i]);
        }
        ConfigBean[] results = new ConfigBean[referencedResourceAdapterConfigs.size()];
        return (ConfigBean[]) referencedResourceAdapterConfigs.toArray(results);
    
public ConfigBean[]getResourceAdapterConfigs(java.lang.String rarName)

        ResourceAdapterConfig[] raConfigBeans = res.getResourceAdapterConfig();
        if(raConfigBeans == null || raConfigBeans.length == 0) {
            return null;
        }
        for(int i=0;raConfigBeans != null && i<raConfigBeans.length;++i) {
            if(raConfigBeans[i].getResourceAdapterName().equals(rarName)){
                return new ConfigBean[]{raConfigBeans[i]};
            }
        }
        return null;
    
public java.lang.StringgetResourceType(ConfigBean cb)

        if(cb instanceof ConnectorConnectionPool) {
            return ResourceDeployEvent.RES_TYPE_CCP;
        } else if(cb instanceof ConnectorResource) {
            return ResourceDeployEvent.RES_TYPE_CR;
        } else if(cb instanceof AdminObjectResource) {
            return ResourceDeployEvent.RES_TYPE_AOR;
        } else if(cb instanceof ResourceAdapterConfig) {
            return ResourceDeployEvent.RES_TYPE_RAC;
        } else if (cb instanceof JdbcConnectionPool) {
            return ResourceDeployEvent.RES_TYPE_JCP;
        } else if (cb instanceof JdbcResource) {
            return ResourceDeployEvent.RES_TYPE_JDBC;
        }
        return null;
    
public intgetShutdownTimeout()
Gets the shutdown-timeout attribute from domain.xml via the connector server config bean.

return

        try {
            ConnectorService connectorServiceElement = ServerBeansFactory
                    .getConnectorServiceBean(ApplicationServer.getServerContext().
                    getConfigContext());
            int shutdownTimeout;
            if (connectorServiceElement == null) {
                //Connector service element is not specified in
                //domain.xml and hence going with the default time-out
                shutdownTimeout =
                        ConnectorConstants.DEFAULT_RESOURCE_ADAPTER_SHUTDOWN_TIMEOUT;
                _logger.log(Level.FINE, "Shutdown timeout set to "
                        +  shutdownTimeout
                        + "through default");
                return shutdownTimeout;
            } else {
                shutdownTimeout = (new Integer(connectorServiceElement.
                        getShutdownTimeoutInSeconds())).intValue();
                _logger.log(Level.FINE, "Shutdown timeout set to "
                        + shutdownTimeout + " from domain.xml");
                return shutdownTimeout;
            }
        } catch (Exception e) {
            ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
            crex.initCause(e);
            throw crex;
        }
    
public ConfigBean[][]getStandAloneNonSystemRarConnectorResourcesWithoutRAConfigs()

        
        boolean onlystandAloneRars = true;
        ConfigBean configBeanArray[][] =
                new ConfigBean[NO_OF_CONNECTOR_RESOURCE_TYPE][];
        Map allConnectorResources = getFilteredAllConnectorResources(onlystandAloneRars, true, null);
        configBeanArray[0] = (ConfigBean[]) allConnectorResources.get(CONNECTION_POOLS);
        configBeanArray[1] = (ConfigBean[]) allConnectorResources.get(RESOURCES);
        configBeanArray[2] = getFilteredAdminObjectResources(onlystandAloneRars, true, null);
        return configBeanArray;
    
public java.lang.String[]getdbUserPasswordOfConnectorConnectionPool(ConnectorConnectionPool connectorConnectionPool)

        
        String[] userPassword = new String[2];
        userPassword[0]=null;
        userPassword[1]=null;
        ElementProperty[] elementProperty =
                connectorConnectionPool.getElementProperty();
        if(elementProperty != null && elementProperty.length != 0) {
            boolean foundUserPassword = false;
            for (int i=0; i<elementProperty.length;i++) {
                String prop = elementProperty[i].getName().toUpperCase();
                
                if( "USERNAME".equals( prop ) || "USER".equals( prop ) ) {
                    userPassword[0]=elementProperty[i].getValue();
                    foundUserPassword = true;
                } else if("PASSWORD".equals( prop ) ) {
                    userPassword[1]=elementProperty[i].getValue();
                    foundUserPassword = true;
                }
            }
            if(foundUserPassword == true) {
                return userPassword;
            }
        }
        
        String poolName = connectorConnectionPool.getName();
        String rarName = connectorConnectionPool.getResourceAdapterName();
        String connectionDefName =
                connectorConnectionPool.getConnectionDefinitionName();
        ConnectorRegistry connectorRegistry =
                ConnectorRegistry.getInstance();
        ConnectorDescriptor connectorDescriptor =
                connectorRegistry.getDescriptor(rarName);
        ConnectionDefDescriptor cdd =
                connectorDescriptor.getConnectionDefinitionByCFType(
                connectionDefName);
        Set configProps = cdd.getConfigProperties();
        for(Iterator iter = configProps.iterator(); iter.hasNext();) {
            EnvironmentProperty envProp= (EnvironmentProperty)iter.next();
            String prop = envProp.getName().toUpperCase();
            
            if("USER".equals( prop ) || "USERNAME".equals( prop )) {
                
                userPassword[0]=envProp.getValue();
            } else if( "PASSWORD".equals(prop) ) {
                userPassword[1]=envProp.getValue();
            }
            
        }
        
        if ( userPassword[0] != null && ! "".equals(userPassword[0].trim()) ) {
            return userPassword;
        }
        
        //else read the default username and password from the ra.xml
        ManagedConnectionFactory mcf =
                connectorRegistry.getManagedConnectionFactory( poolName );
        userPassword[0] = ConnectionPoolObjectsUtils.getValueFromMCF(
                "UserName", poolName, mcf);
        userPassword[1] = ConnectionPoolObjectsUtils.getValueFromMCF(
                "Password", poolName, mcf);
        
        return userPassword;
    
public java.lang.String[]getdbUserPasswordOfJdbcConnectionPool(JdbcConnectionPool jdbcConnectionPool)

        
        String[] userPassword = new String[2];
        userPassword[0]=null;
        userPassword[1]=null;
        ElementProperty[] elementProperty =
                jdbcConnectionPool.getElementProperty();
        if(elementProperty==null || elementProperty.length == 0) {
            return userPassword;
        }
        
        for (int i=0; i<elementProperty.length;i++) {
            String prop = elementProperty[i].getName().toUpperCase();
            if ("USERNAME".equals( prop ) || "USER".equals( prop ) ) {
                userPassword[0]=elementProperty[i].getValue();
            } else if("PASSWORD".equals( prop ) ) {
                userPassword[1]=elementProperty[i].getValue();
            }
        }
        return userPassword;
    
private booleanisADeployEvent()
Checks whether call is from a deploy event. Since in case of deploy event, the localResourceUtil will be set, so check is based on that.

        if(localResourcesUtil.get() != null)
            return true;
        return false;
    
private booleanisApplicationReferenceEnabled(java.lang.String appName)
Checks if a resource reference is enabled

since
SJSAS 9.1 PE/SE/EE

        ApplicationRef appRef = ServerHelper.getServerByName( configContext_,
                sc_.getInstanceName()).getApplicationRefByRef(appName);
        if (appRef == null) {
            _logger.fine("ResourcesUtil :: isApplicationReferenceEnabled null ref");
            if(isADeployEvent())
                return true;
            else
                return false;
        }
        _logger.fine("ResourcesUtil :: isApplicationReferenceEnabled appRef enabled ?" + appRef.isEnabled());
        return appRef.isEnabled();
    
public static booleanisDAS()

        try {
            return ServerHelper.isDAS( com.sun.enterprise.admin.server.core.AdminService.getAdminService().getAdminContext().getAdminConfigContext(), sc_.getInstanceName() );
        } catch( ConfigException ce ) {
            //better be more restrictive by returning false
            return false;
        }
    
public booleanisEnabled(ConnectorResource cr)

        
        if(cr == null || !cr.isEnabled())
            return false;
        
        if(!isResourceReferenceEnabled(cr.getJndiName()))
            return false;
        
        String poolName = cr.getPoolName();
        ConnectorConnectionPool ccp = res.getConnectorConnectionPoolByName(poolName);
        if (ccp == null) {
            return false;
        }
        return isEnabled(ccp);
    
public booleanisEnabled(AdminObjectResource aot)

        if(aot == null || !aot.isEnabled())
            return false;
        if(!isResourceReferenceEnabled(aot.getJndiName()))
            return false;
        
        String raName = aot.getResAdapter();
        return isRarEnabled(raName);
    
public booleanisEnabled(ConnectorConnectionPool ccp)

        if(ccp == null) {
            return false;
        }
        String raName = ccp.getResourceAdapterName();
        return isRarEnabled(raName);
    
public booleanisEnabled(JdbcResource jr)

        
        if(jr == null || !jr.isEnabled())
            return false;
        
        if(!isResourceReferenceEnabled(jr.getJndiName()))
            return false;
        
        return true;
    
public booleanisEnabled(ResourceAdapterConfig rac)

        
        if(rac == null)
            return false;
        
        return isRarEnabled(rac.getResourceAdapterName());
    
public booleanisEnabled(ConfigBean res)
Checks if a Resource is enabled. Since 8.1 PE/SE/EE, A resource [except resource adapter configs, connector and JDBC connection pools which are global and hence enabled always] is enabled only when the resource is enabled and there exists a resource ref to this resource in this server instance and that resource ref is enabled. Before a resource is loaded or deployed, it is checked to see if it is enabled.

since
8.1 PE/SE/EE

        _logger.fine("ResourcesUtil :: isEnabled");
        if(res == null)
            return false;
        if(res instanceof JdbcResource)
            return isEnabled((JdbcResource)res);
        else if(res instanceof ConnectorResource)
            return isEnabled((ConnectorResource)res);
        else if(res instanceof AdminObjectResource)
            return isEnabled((AdminObjectResource)res);
        else if(res instanceof ResourceAdapterConfig)
            return isEnabled((ResourceAdapterConfig)res);
        else if(res instanceof ConnectorConnectionPool)
            return isEnabled((ConnectorConnectionPool)res);
        else if(res instanceof JdbcConnectionPool)
            //JDBC RA is system RA and is always enabled
            return true;

        if(!res.isEnabled())
            return false;
        
        Server server = ServerBeansFactory.getServerBean(configContext_);
        //using ServerTags, otherwise have to resort to reflection or multiple instanceof/casts
        ResourceRef resRef = server.getResourceRefByRef(res.getAttributeValue(ServerTags.JNDI_NAME));

        if(resRef == null)
            return false;
        
        return resRef.isEnabled();
    
public booleanisJdbcPoolReferredInServerInstance(java.lang.String jdbcPoolName)
Determines if a JDBC connection pool is referred in a server-instance via resource-refs

param
jdbcPoolName
return
boolean true if pool is referred in this server instance, false otherwise
throws
ConfigException

        JdbcResource[] jdbcRes = res.getJdbcResource();
        
        for (int i = 0; i < jdbcRes.length; i++) {
            _logger.fine("poolname " + jdbcRes[i].getPoolName()
            + "resource " + jdbcRes[i].getJndiName()
            + " referred " + isReferenced(jdbcRes[i].getJndiName()));
            //Have to check isReferenced here!
            if ((jdbcRes[i].getPoolName().equalsIgnoreCase(jdbcPoolName))
            && isReferenced(jdbcRes[i].getJndiName())){
                _logger.fine("JDBC resource "  + jdbcRes[i].getJndiName() +
                        "refers " + jdbcPoolName + "in this server instance");
                return true;
            }
        }
        _logger.fine("No JDBC resource refers " + jdbcPoolName +
                "in this server instance");
        return false;
    
public booleanisPoolReferredInServerInstance(java.lang.String poolName)
Determines if a connector connection pool is referred in a server-instance via resource-refs

param
poolName
return
boolean true if pool is referred in this server instance, false otherwise
throws
ConfigException

        ConnectorResource[] connRes = res.getConnectorResource();
        
        for (int i = 0; i < connRes.length; i++) {
            _logger.fine("poolname " + connRes[i].getPoolName()
            + "resource " + connRes[i].getJndiName());
            
            if ((connRes[i].getPoolName().equalsIgnoreCase(poolName))){
                _logger.fine("Connector resource "  + connRes[i].getJndiName() +
                        "refers " + poolName + "in this server instance");
                return true;
            }
        }
        
        _logger.fine("No JDBC resource refers " + poolName
                + "in this server instance");
        return false;
    
private booleanisRarEnabled(java.lang.String raName)

        if(raName == null || raName.length() == 0)
            return false;
        ConnectorModule module = dom.getApplications().getConnectorModuleByName(raName);
        if(module != null) {
            if(!module.isEnabled())
                return false;
            return isApplicationReferenceEnabled(raName);
        } else if(belongToSystemRar(raName)) {
            return true;
        } else {
            return belongToEmbeddedRarAndEnabled(raName);
        }
    
protected booleanisReferenced(java.lang.String resourceName)
Returns true if the given resource is referenced by this server.

param
resourceName the name of the resource
return
true if the named resource is used/referred by this server
throws
ConfigException if an error while parsing domain.xml

        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("isReferenced :: " + resourceName + " - "
                    + ServerHelper.serverReferencesResource(
                    configContext_, sc_.getInstanceName(),
                    resourceName));
        }
        
        return ServerHelper.serverReferencesResource(configContext_,
                sc_.getInstanceName(), resourceName);
    
private booleanisResourceReferenceEnabled(java.lang.String resourceName)
Checks if a resource reference is enabled

since
SJSAS 8.1 PE/SE/EE

        ResourceRef ref = ServerHelper.getServerByName( configContext_,
                sc_.getInstanceName()).getResourceRefByRef(resourceName);
        if (ref == null) {
            _logger.fine("ResourcesUtil :: isResourceReferenceEnabled null ref");
            if(isADeployEvent())
                return true;
            else
                return false;
        }
        _logger.fine("ResourcesUtil :: isResourceReferenceEnabled ref enabled ?" + ref.isEnabled());
        return ref.isEnabled();
    
public voidloadSystemRAResources()
Loads all system RA resources not used till now This method is used when user accesses jndi tree.

        InitialContext ctx;
        
        try {
            ctx = new InitialContext();
        } catch (NamingException ex) {
            String message = localStrings.getString(
                    "error.getting.intial.context");
            _logger.log(Level.SEVERE, message);
            _logger.log(Level.FINE, ex.getMessage(), ex);
            return;
        }
        
        try {
            ConnectorResource[] cr = getAllJmsResources();
            for(int i=0; i<cr.length; i++){
                try {
                    ctx.lookup(cr[i].getJndiName());
                } catch (NamingException ex) {
                    String message = localStrings.getString(
                            "error.looking.up.resource",
                            cr[i].getJndiName());
                    _logger.log(Level.SEVERE, message);
                    _logger.log(Level.FINE, ex.getMessage(), ex);
                }
            }
        } catch (ConfigException ex) {
            String message = localStrings.getString(
                    "error.getting.jms.resources");
            _logger.log(Level.SEVERE, message);
        }
        try {
            AdminObjectResource[] aor = getAllJmsAdminObjects();
            for(int i=0; i<aor.length; i++){
                try {
                    ctx.lookup(aor[i].getJndiName());
                } catch (NamingException ex) {
                    String message = localStrings.getString(
                            "error.looking.up.resource",
                            aor[i].getJndiName());
                    _logger.log(Level.SEVERE, message);
                    _logger.log(Level.FINE, ex.getMessage(), ex);
                }
            }
        } catch (ConfigException ex) {
            String message = localStrings.getString(
                    "error.getting.jms.admin.objects");
            _logger.log(Level.SEVERE, message);
            _logger.log(Level.FINE, ex.getMessage(), ex);
        }
        
        try {
            JdbcResource[] jdbc = (JdbcResource[]) getJdbcResourcesAsMap().get(RESOURCES);
            for(int i=0; i<jdbc.length; i++){
                try {
                    ctx.lookup(jdbc[i].getJndiName());
                } catch (NamingException ex) {
                    String message = localStrings.getString(
                            "error.looking.up.resource",
                            jdbc[i].getJndiName());
                    _logger.log(Level.SEVERE, message);
                    _logger.log(Level.FINE, ex.getMessage(), ex);
                }
            }
        } catch (ConfigException ex) {
            String message = localStrings.getString(
                    "error.getting.jdbc.resources");
            _logger.log(Level.SEVERE, message);
            _logger.log(Level.FINE, ex.getMessage(), ex);
        }
    
public booleanpoolBelongsToSystemRar(java.lang.String poolName)

        ConnectorConnectionPool ccPool =
                res.getConnectorConnectionPoolByName(poolName);
        if(ccPool != null){
            return belongToSystemRar(ccPool.getResourceAdapterName());
        } else {
            JdbcConnectionPool jdbcPool = 
                    res.getJdbcConnectionPoolByName(poolName);
            if(jdbcPool != null) {
                return true;
            }
        }
        return false;
    
public static voidresetEventConfigContext()

        localResourcesUtil.set(null);
    
public booleanresourceBelongsToSystemRar(java.lang.String resourceName)

        ConnectorResource connectorResource =
                res.getConnectorResourceByJndiName(resourceName);
        if(connectorResource != null){
            return poolBelongsToSystemRar(connectorResource.getPoolName());
        } else {
            JdbcResource jdbcResource =
                    res.getJdbcResourceByJndiName(resourceName);
            if(jdbcResource != null) {
                return true;
            }
        }
        return false;
    
public static voidsetEventConfigContext(ConfigContext ctx)

        ResourcesUtil resUtil = null;
        if(isDAS())
            resUtil = new DASResourcesUtil(ctx);
        else
            resUtil = new ResourcesUtil(ctx);
        localResourcesUtil.set(resUtil);
    
public static voidsetServerContext(ServerContext sc)

    
        
        sc_ = sc;