FileDocCategorySizeDatePackage
ReferenceHelperBase.javaAPI DocGlassfish v2 API5710Sat Dec 24 18:48:20 GMT 2005com.sun.enterprise.config.serverbeans

ReferenceHelperBase

public abstract class ReferenceHelperBase extends Object

Fields Summary
protected static final com.sun.enterprise.util.i18n.StringManager
_strMgr
Constructors Summary
public ReferenceHelperBase()

        
       
      
    
Methods Summary
public java.lang.StringgetReferenceesAsString(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name)
Find all the servers or clusters associated with the given configuration and return them as a comma separated list.

        
        Server[] servers = getReferencingServers(configContext, name);
        Cluster[] clusters = getReferencingClusters(configContext, name);
        String serverList = ServerHelper.getServersAsString(servers);                
        String clusterList = ClusterHelper.getClustersAsString(clusters);
        if (serverList.length() > 0) {
            if (clusterList.length() > 0) {
                return serverList + "," + clusterList;
            } 
            return serverList;
        } else {
            return clusterList;
        }        
    
protected abstract com.sun.enterprise.config.serverbeans.Cluster[]getReferencingClusters(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name)

protected abstract com.sun.enterprise.config.serverbeans.Server[]getReferencingServers(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name)

public booleanisReferenced(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name)
Is the configuration referenced by anyone (i.e. any server instance or cluster

        //See if any servers are referencing the resource
        Server[] servers = getReferencingServers(configContext, name);        
        if (servers.length > 0) {
            return true;
        }
        //See if any clusters are referencing the resource
        Cluster[] clusters = getReferencingClusters(configContext, name);
        if (clusters.length > 0) {
            return true;
        }
        return false;
    
public booleanisReferencedByClusterOnly(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name, java.lang.String clusterName)
Return true if the configuration is referenced by no-one other than the given cluster.

                       
        //See if any clusters reference the config
        Cluster[] clusters = getReferencingClusters(configContext, name);
        if (clusters.length == 1 && clusters[0].getName().equals(clusterName)) {
            Server[] servers = getReferencingServers(configContext, name); 
            if (servers.length == 0) {
                return true;
            } else {
                //Check to see that the only servers referencing the configuration are those that
                //are also part of the cluster.
                Server[] clusterServers = ServerHelper.getServersInCluster(configContext, clusterName);
                if (clusterServers.length == servers.length) {
                    boolean found = false;
                    for (int i = 0; i < clusterServers.length; i++) {
                        found = false;
                        for (int j = 0; j < servers.length; j++) {
                            if (clusterServers[i].getName().equals(servers[j].getName())) {
                                found = true;
                                break;
                            }
                        }
                        if (!found) {
                            return false;
                        }
                    }
                    if (found) {
                        return true;
                    }
                }
            }
        }
        return false;
    
public booleanisReferencedByServerOnly(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name, java.lang.String serverName)
Return true if the configuration is referenced by no-one other than the given server instance.

        
        Server[] servers = getReferencingServers(configContext, name); 
        if (servers.length == 1 && servers[0].getName().equals(serverName)) {
            //The stated server is the only one referencing the config so see if any 
            //clusters reference the config
            Cluster[] clusters = getReferencingClusters(configContext, name);
            if (clusters.length == 0) {
                return true;
            } 
        }
        return false;