FileDocCategorySizeDatePackage
ConfigMBeanUtil.javaAPI DocGlassfish v2 API6329Fri May 04 22:24:08 BST 2007com.sun.enterprise.admin.mbeans

ConfigMBeanUtil

public class ConfigMBeanUtil extends Object
Static utility class for common functions in config mbeans. Place all common utility type functions into this class for access across all config mbeans.
author
Rob Ruyak

Fields Summary
private static final com.sun.enterprise.util.i18n.StringManager
localStrings
i18n strings manager object
Constructors Summary
private ConfigMBeanUtil()

    
    
    //disallow the instantiation of this object
      
    
Methods Summary
public static booleanattributeDefinedInList(java.util.List list, java.lang.String name)
Given a list and an Attribute object, returns whether or not the attribute with the specified name exists.

param
list the list of Attribute objects
param
name the name of the attribute to find
return
true/false

        if(name != null) {            
            for(java.util.Iterator itr = list.iterator(); itr.hasNext(); ) {
                Attribute attr = (Attribute) itr.next();
                if(name != null && name.equals(attr.getName())) {
                    return true; 
                } 
            }
        }
        return false;
    
public static javax.management.MBeanServergetMBeanServer()

        return com.sun.enterprise.admin.common.MBeanServerFactory.getMBeanServer();
    
public static com.sun.enterprise.admin.target.TargetgetTarget(java.lang.String targetName, com.sun.enterprise.admin.target.TargetType[] targetTypes, com.sun.enterprise.config.ConfigContext configContext)

        
                
        try {               
            Target target = TargetBuilder.INSTANCE.createTarget(
                    targetTypes, targetName, configContext);
            if (target.getType() == TargetType.SERVER || 
                target.getType() == TargetType.DAS) {
                //If we are operating on a server, ensure that the server is the only entity 
                //referencing its config
                String configName = ServerHelper.getConfigForServer(configContext,
                    target.getName()).getName();
                if (!ConfigAPIHelper.isConfigurationReferencedByServerOnly(configContext, 
                    configName, target.getName())) {
                        throw new ConfigException(localStrings.getString(
                            "configurationHasMultipleRefs", target.getName(), configName, 
                            ConfigAPIHelper.getConfigurationReferenceesAsString(
                                configContext, configName)));   
                }                                              
            } else if (target.getType() == TargetType.CLUSTER) {
                //If we are operating on a cluster, ensure that the cluster is the only entity 
                //referencing its config
                String configName = ClusterHelper.getConfigForCluster(configContext, 
                    target.getName()).getName();
                if (!ConfigAPIHelper.isConfigurationReferencedByClusterOnly(configContext, 
                    configName, target.getName())) {
                        throw new ConfigException(localStrings.getString(
                            "configurationHasMultipleRefs", target.getName(), configName, 
                            ConfigAPIHelper.getConfigurationReferenceesAsString(
                                configContext, configName))); 
                }     
            }
            return target;
        }
        catch (Exception e) {
            throw MBeanExceptionFormatter.toMBeanException(e, null);
        }