FileDocCategorySizeDatePackage
ConfigAPIHelper.javaAPI DocGlassfish v2 API8277Sat Dec 24 18:47:58 GMT 2005com.sun.enterprise.config.serverbeans

ConfigAPIHelper

public class ConfigAPIHelper extends ReferenceHelperBase implements com.sun.enterprise.admin.util.IAdminConstants

Fields Summary
protected static final com.sun.enterprise.util.i18n.StringManager
_strMgr
private static ConfigAPIHelper
_theInstance
private static final String[]
ILLEGAL_NAME_STRINGS
Constructors Summary
public ConfigAPIHelper()


    
      
        super();
    
Methods Summary
public static voidcheckLegalName(java.lang.String name)
Given a server or cluster name, checks if the name is legal according to our defined specs.

		// we don't want an instance with, say, "--" in the name.
		// this will cause havoc with CLI
		// we throw the Exception so that we can document *what* the
		// exact problem with the name is
		
		for(int i = 0; i < ILLEGAL_NAME_STRINGS.length; i++)
		{
			if(name.indexOf(ILLEGAL_NAME_STRINGS[i]) >= 0)
			{
				String s = _strMgr.getString("illegalName", ILLEGAL_NAME_STRINGS[i]);
				throw new ConfigException(s);
			}
		}
    
public static com.sun.enterprise.config.serverbeans.ConfiggetConfigByName(com.sun.enterprise.config.ConfigContext configContext, java.lang.String configName)
Return the configuration associated with the given configName. An exception is thrown if the configuration does not exist.

        final Domain domain = getDomainConfigBean(configContext);        
        final Config config = domain.getConfigs().getConfigByName(configName);
        if (config == null) {
            throw new ConfigException(_strMgr.getString("noSuchConfig", configName));
        }
        return config;
    
public static com.sun.enterprise.config.serverbeans.Config[]getConfigsInDomain(com.sun.enterprise.config.ConfigContext configContext)
Return all the configurations in the domain. We dont check for null here because we assume there is always at least one configuration in the domain.

        final Domain domain = getDomainConfigBean(configContext);          
        return domain.getConfigs().getConfig(); 
    
public static java.lang.StringgetConfigurationReferenceesAsString(com.sun.enterprise.config.ConfigContext configContext, java.lang.String configName)
Find all the servers or clusters associated with the given configuration and return them as a comma separated list.

        
       return getInstance().getReferenceesAsString(configContext, configName);
    
public static com.sun.enterprise.config.serverbeans.DomaingetDomainConfigBean(com.sun.enterprise.config.ConfigContext configCtxt)

                                  
        return ServerBeansFactory.getDomainBean(configCtxt);        
    
private static synchronized com.sun.enterprise.config.serverbeans.ConfigAPIHelpergetInstance()

        if (_theInstance == null) {
            _theInstance = new ConfigAPIHelper();
        }
        return _theInstance;
    
protected com.sun.enterprise.config.serverbeans.Cluster[]getReferencingClusters(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name)

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

        return ServerHelper.getServersReferencingConfig(configContext, name); 
    
public static java.lang.StringgetStandAloneConfigurationName(java.lang.String name)

        return name + STANDALONE_CONFIGURATION_SUFFIX;
    
public static booleanisAConfig(com.sun.enterprise.config.ConfigContext configContext, java.lang.String configName)
Return true if the given configName is a configuration.

        final Domain domain = getDomainConfigBean(configContext);           
        final Config config = domain.getConfigs().getConfigByName(configName);
        return (config != null ? true : false);
    
public static booleanisConfigurationNameStandAlone(java.lang.String configName, java.lang.String name)
Returns true if the given configuration and cluster or instance name represents a standalone configuration.

        return configName.equals(getStandAloneConfigurationName(
            name)) ? true : false; 
    
public static booleanisConfigurationReferenced(com.sun.enterprise.config.ConfigContext configContext, java.lang.String configName)
Is the configuration referenced by anyone (i.e. any server instance or cluster

        return getInstance().isReferenced(configContext, configName);
    
public static booleanisConfigurationReferencedByClusterOnly(com.sun.enterprise.config.ConfigContext configContext, java.lang.String configName, java.lang.String clusterName)
Return true if the configuration is referenced by no-one other than the given cluster.

                       
        return getInstance().isReferencedByClusterOnly(configContext, configName, clusterName);
    
public static booleanisConfigurationReferencedByServerOnly(com.sun.enterprise.config.ConfigContext configContext, java.lang.String configName, java.lang.String serverName)
Return true if the configuration is referenced by no-one other than the given server instance.

        
        return getInstance().isReferencedByServerOnly(configContext, configName, serverName);
    
public static booleanisNameUnique(com.sun.enterprise.config.ConfigContext configContext, java.lang.String name)
Returns true if the name is unique across a namespace including: server instances, configurations, clusters, node agents.

        final Server[] servers = ServerHelper.getServersInDomain(configContext);
        for (int i = 0; i < servers.length; i++) {
            if (servers[i].getName().equals(name)) {
                return false;
            }
        }
        
        final Config[] configs = getConfigsInDomain(configContext);
        for (int i = 0; i < configs.length; i++) {
            if (configs[i].getName().equals(name)) {
                return false;
            }
        }
        
        final Cluster[] clusters = ClusterHelper.getClustersInDomain(configContext);
        for (int i = 0; i < clusters.length; i++) {
            if (clusters[i].getName().equals(name)) {
                return false;
            }
        }
        
        final NodeAgent[] controllers = NodeAgentHelper.getNodeAgentsInDomain(configContext);
        for (int i = 0; i < controllers.length; i++) {
            if (controllers[i].getName().equals(name)) {
                return false;
            }
        }
        return true;