FileDocCategorySizeDatePackage
DASResourcesUtil.javaAPI DocGlassfish v2 API7116Fri May 04 22:34:26 BST 2007com.sun.enterprise.connectors.util

DASResourcesUtil

public class DASResourcesUtil extends ResourcesUtil
This class overrides the isReferenced method in the ResourcesUtil class. An instance of this class is always returned when ResourcesUtil.getInstance() happens in the DAS
author
Aditya Gore, Kshitiz Saxena
version

Fields Summary
boolean
noReferenceCheckNeeded
Flags if a getConnection call is coming from the connector runtime. Only for such a call, we should not be checking isReferenced The reason for this is that the getConnection call might be happening in the DAS for a jdbc resource which does not have a resource-ref in the DAS. However, we still need to give a connection from that resource, so we should not check for referencing info.
Constructors Summary
protected DASResourcesUtil()

    
       
        super();
    
protected DASResourcesUtil(ConfigContext configContext)

        super(configContext);
    
Methods Summary
public java.lang.StringgetApplicationDeployLocation(java.lang.String appName)
Gets the deployment location for a J2EE application.

param
rarName
return

        //Use admin config context, as in DAS, the server config context would
        //not have the latest config context changes until the end of the deploy
        //event
        ConfigContext adminConfigCtx = com.sun.enterprise.admin.server.core.
                AdminService.getAdminService().getAdminContext().getAdminConfigContext();
        Domain domain = null;
        try {
             domain = ServerBeansFactory.getDomainBean(adminConfigCtx);
        } catch (ConfigException e) {
            String message = localStrings.getString("error.getting.domain");
            _logger.log(Level.WARNING, message + e.getMessage());
            _logger.log(Level.FINE,message + e.getMessage(), e);
            return null;
        }
        J2eeApplication app = domain.
                getApplications().getJ2eeApplicationByName(appName);
        return RelativePathResolver.resolvePath(app.getLocation());
        
    
public java.lang.StringgetLocation(java.lang.String moduleName)

        if(moduleName == null) {
            return null;
        }
        
        //Use admin config context, as in DAS, the server config context would
        //not have the latest config context changes until the end of the deploy
        //event
        ConfigContext adminConfigCtx = com.sun.enterprise.admin.server.core.
                AdminService.getAdminService().getAdminContext().getAdminConfigContext();
        Domain domain = null;
        try {
             domain = ServerBeansFactory.getDomainBean(adminConfigCtx);
        } catch (ConfigException e) {
            String message = localStrings.getString("error.getting.domain");
            _logger.log(Level.WARNING, message + e.getMessage());
            _logger.log(Level.FINE,message + e.getMessage(), e);
             return null;
        }
        ConnectorModule connectorModule = domain.
                getApplications().getConnectorModuleByName(moduleName);
        
        if (connectorModule == null) {
            return null;
        }
        
        String connectorModuleLocation = connectorModule.getLocation();
        String connectorModuleLocationResolved = RelativePathResolver.
                resolvePath(connectorModuleLocation);
        return connectorModuleLocationResolved;
    
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 in DASResourcesUtil:: " + resourceName);
        }
        
        if (noReferenceCheckNeeded) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.fine("getConnectionFromConnectorRuntime :: true");
            }
            return true;
        }
        
        return super.isReferenced( resourceName );
    
public static voidresetAdminConfigContext()

        localResourcesUtil.set(null);
    
public static voidsetAdminConfigContext()

        if(!isDAS()){
            String message = localStrings.getString("cannot.set.admin.context");
            throw new ConfigException(message);
        }
        DASResourcesUtil resUtil = new DASResourcesUtil(com.sun.enterprise.admin.server.core.
                AdminService.getAdminService().getAdminContext().getAdminConfigContext());
        resUtil.noReferenceCheckNeeded = true;
        localResourcesUtil.set(resUtil);