FileDocCategorySizeDatePackage
ConnectorResourceDeployer.javaAPI DocGlassfish v2 API7771Fri May 04 22:35:14 BST 2007com.sun.enterprise.resource

ConnectorResourceDeployer

public class ConnectorResourceDeployer extends Object implements com.sun.enterprise.server.ResourceDeployer
author
Srikanth P

Fields Summary
static Logger
_logger
Constructors Summary
Methods Summary
private voidcheckAndDeletePool(com.sun.enterprise.config.serverbeans.ConnectorResource cr)
Checks if no more resource-refs to resources exists for the connector connection pool and then deletes the pool

param
cr ConnectorResource
throws
Exception (ConfigException / undeploy exception)
since
8.1 pe/se/ee

        try {
            String poolName = cr.getPoolName();
            Resources res = (Resources) cr.parent();

            boolean poolReferred = 
                ResourcesUtil.createInstance().isPoolReferredInServerInstance(poolName);
            if (!poolReferred) {
                _logger.fine("Deleting pool " + poolName + "as there is no more " +
                        "resource-refs to the pool in this server instance");
                com.sun.enterprise.config.serverbeans.ConnectorConnectionPool ccp 
                                    = res.getConnectorConnectionPoolByName(poolName);
                //Delete/Undeploy Pool
                ConnectorConnectionPoolDeployer deployer = 
                        new ConnectorConnectionPoolDeployer();
                deployer.undeployResource(ccp);
            }
            
        } catch (ConfigException ce) {
            _logger.warning(ce.getMessage());
            _logger.fine("Exception while deleting pool : " + ce );
            throw ce;
        }
    
private voidcreatePool(com.sun.enterprise.config.serverbeans.ConnectorConnectionPool cp)

        ConnectorConnectionPoolDeployer deployer = 
            new ConnectorConnectionPoolDeployer();
        
        deployer.deployResource(cp);
    
public synchronized voiddeployResource(java.lang.Object resource)

           

        ConnectorResource domainResource = 
            (com.sun.enterprise.config.serverbeans.ConnectorResource)resource;
        String jndiName = domainResource.getJndiName();
        String poolName = domainResource.getPoolName();
        ConnectorRuntime crt = ConnectorRuntime.getRuntime();
        _logger.log(Level.FINE,
                   "Calling backend to add connector resource",jndiName);

        // load connection pool if not loaded from the ctx in event 
        loadPool(domainResource);

        crt.createConnectorResource(jndiName,poolName,null);
        _logger.log(Level.FINE,
                   "Added connector resource in backend",jndiName);
    
public synchronized voiddisableResource(java.lang.Object resource)

        undeployResource(resource);
    
public synchronized voidenableResource(java.lang.Object resource)

        deployResource(resource);
    
public java.lang.ObjectgetResource(java.lang.String name, com.sun.enterprise.config.serverbeans.Resources rbeans)


        Object res = rbeans.getConnectorResourceByJndiName(name);
        if (res == null) {
            Exception ex = new Exception("No such resource");
            _logger.log(Level.SEVERE,"no_resource",name);
            _logger.log(Level.SEVERE,"",ex);
            throw ex;
        }
        return res;

    
private voidloadPool(com.sun.enterprise.config.serverbeans.ConnectorResource cr)


        String poolName = cr.getPoolName();
        Resources resources = (Resources) cr.parent();
        ConfigBean cb = resources.getConnectorConnectionPoolByName(poolName);
        com.sun.enterprise.config.serverbeans.ConnectorConnectionPool cp = 
        	(com.sun.enterprise.config.serverbeans.ConnectorConnectionPool)cb;
        if (cb != null) {
        	if (ConnectionPoolObjectsUtils.isPoolSystemPool(poolName)){
        	    createPool(cp);
        	} else {
        	    try {
                    InitialContext ic = new InitialContext();
                    ic.lookup(ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolName));
                } catch (Exception e) {
                    // pool is not loaded
                    createPool(cp);
                }
        	}
        }
    
public synchronized voidredeployResource(java.lang.Object resource)

    
public synchronized voidundeployResource(java.lang.Object resource)

        ConnectorResource domainResource = 
           (com.sun.enterprise.config.serverbeans.ConnectorResource)resource;
        String jndiName = domainResource.getJndiName();
        ConnectorRuntime crt = ConnectorRuntime.getRuntime();
        crt.deleteConnectorResource(jndiName);
        
        //Since 8.1 PE/SE/EE - if no more resource-ref to the pool 
        //of this resource in this server instance, remove pool from connector
        //runtime
        checkAndDeletePool(domainResource);