FileDocCategorySizeDatePackage
NodeAgentHelper.javaAPI DocGlassfish v2 API7007Mon Sep 25 21:44:08 BST 2006com.sun.enterprise.config.serverbeans

NodeAgentHelper

public class NodeAgentHelper extends ConfigAPIHelper
author
kebbs

Fields Summary
Constructors Summary
Methods Summary
public static com.sun.enterprise.admin.util.JMXConnectorConfiggetJMXConnectorInfo(com.sun.enterprise.config.ConfigContext configContext, java.lang.String nodeAgentName)
Returns mbean server connection info for the named node agent.

        
        JmxConnector connector = NodeAgentHelper.getNodeAgentSystemConnector(
            configContext, nodeAgentName);        
        String adminUser = IdentityManager.getUser();
        String adminPassword = IdentityManager.getPassword();     
        ElementProperty hostProp = connector.getElementPropertyByName(HOST_PROPERTY_NAME);    

        if (adminUser == null || adminPassword == null || hostProp == null) {
            throw new ConfigException(_strMgr.getString("missingAgentConnectorAuth", nodeAgentName));
        }
        return new JMXConnectorConfig(hostProp.getValue(), connector.getPort(),                 
            adminUser, adminPassword, connector.getProtocol());
    
public static com.sun.enterprise.config.serverbeans.NodeAgentgetNodeAgentByName(com.sun.enterprise.config.ConfigContext configContext, java.lang.String agentName)

        final Domain domain = getDomainConfigBean(configContext);               
        final NodeAgent controller = domain.getNodeAgents().getNodeAgentByName(agentName);
        if (controller == null) {
            throw new ConfigException(_strMgr.getString("noSuchAgent", 
                agentName));
        }
        return controller;
    
public static com.sun.enterprise.config.serverbeans.NodeAgentgetNodeAgentForServer(com.sun.enterprise.config.ConfigContext configContext, java.lang.String instanceName)

        
        final Server server = ServerHelper.getServerByName(configContext, instanceName);
        final Domain domain = getDomainConfigBean(configContext);          
        final NodeAgent controller = domain.getNodeAgents().getNodeAgentByName(
            server.getNodeAgentRef());
        if (controller == null) {
            throw new ConfigException(_strMgr.getString("noSuchAgentForInstance", 
                instanceName, server.getNodeAgentRef()));
        }
        return controller;
    
public static com.sun.enterprise.config.serverbeans.JmxConnectorgetNodeAgentSystemConnector(com.sun.enterprise.config.ConfigContext configContext, java.lang.String agentName)

        final NodeAgent controller = getNodeAgentByName(configContext, agentName);        
        final String systemConnectorName = controller.getSystemJmxConnectorName();
        final JmxConnector connector = controller.getJmxConnector();
        if (connector == null) {
            throw new ConfigException(_strMgr.getString("noAgentSystemConnector", agentName, 
                systemConnectorName));
        }
        return connector;
    
public static java.lang.StringgetNodeAgentsAsString(com.sun.enterprise.config.serverbeans.NodeAgent[] nas)
Returns Node Agents as comma-separated list with each element being name of NA. Returns an empty String if there are no node-agents in the array passed or the parameter is null.

         String nasas = "";
         if (nas != null) {
             for (int i = 0 ; i < nas.length ; i++) {
                 nasas += nas[i].getName();
                 if (i < nas.length - 1)
                     nasas += ",";
             }
         }
         return nasas;
     
public static com.sun.enterprise.config.serverbeans.NodeAgent[]getNodeAgentsForCluster(com.sun.enterprise.config.ConfigContext configContext, java.lang.String clusterName)

     
        final ArrayList result = new ArrayList();
        final Server[] servers = ServerHelper.getServersInCluster(configContext, clusterName);
        for (int i = 0; i < servers.length; i++) {
            NodeAgent controller = getNodeAgentForServer(configContext, 
                servers[i].getName());
            if (!result.contains(controller)) {
                result.add(controller);
            }
        }
        return (NodeAgent[])result.toArray(new NodeAgent[result.size()]);
    
public static com.sun.enterprise.config.serverbeans.NodeAgent[]getNodeAgentsInDomain(com.sun.enterprise.config.ConfigContext configContext)

        final Domain domain = getDomainConfigBean(configContext);  
        NodeAgent[] nas = new NodeAgent[0];
        if (domain.getNodeAgents() != null) 
            nas = domain.getNodeAgents().getNodeAgent();
        return nas;
    
public static booleanhasNodeAgentRendezvousd(com.sun.enterprise.config.ConfigContext configContext, com.sun.enterprise.config.serverbeans.NodeAgent agent)

        
        ElementProperty rendezvousProperty = agent.getElementPropertyByName(
            IAdminConstants.RENDEZVOUS_PROPERTY_NAME);
        String rendezvous=rendezvousProperty.getValue();                
        if (rendezvous != null && rendezvousProperty.getValue().equals(Boolean.TRUE.toString())) {
            return true;
        }             
        return false;
    
public static booleanisANodeAgent(com.sun.enterprise.config.ConfigContext configContext, java.lang.String agentName)

        final Domain domain = getDomainConfigBean(configContext);    
        final NodeAgents controllers = domain.getNodeAgents();
        if (controllers == null) {
            return false;
        }
        final NodeAgent controller = controllers.getNodeAgentByName(agentName);
        return (controller != null ? true : false);