FileDocCategorySizeDatePackage
HttpListenerVirtualServerAssociationMgr.javaAPI DocGlassfish v2 API6683Fri May 04 22:24:10 BST 2007com.sun.enterprise.admin.mbeans

HttpListenerVirtualServerAssociationMgr

public class HttpListenerVirtualServerAssociationMgr extends Object

Fields Summary
private static final com.sun.enterprise.util.i18n.StringManager
strMgr
i18n strings manager object
private final com.sun.enterprise.config.serverbeans.Config
config
Constructors Summary
public HttpListenerVirtualServerAssociationMgr(com.sun.enterprise.config.ConfigContext cctx, String configRef)


        
                                                              
         
    
        checkArg(cctx, strMgr.getString("http_listener_vs_assoc_mgr.null_context"));
        checkArg(configRef, strMgr.getString("http_listener_vs_assoc_mgr.null_config_ref"));
        final Domain domain = (Domain)cctx.getRootConfigBean();
        config = domain.getConfigs().getConfigByName(configRef);
        checkArg(config, strMgr.getString("http_listener_vs_assoc_mgr.no_such_element", configRef));
    
Methods Summary
public voidaddHttpListenerRef(java.lang.String listenerId)

        final String defaultVS = getHttpListener(listenerId).getDefaultVirtualServer();
        final Set s = getHttpListeners(defaultVS);
        s.add(listenerId);
        setHttpListeners(defaultVS, s);
    
public voidchangeHttpListenerRef(java.lang.String listenerId, java.lang.String oldVs, java.lang.String newVs)

        Set s = getHttpListeners(oldVs);
        s.remove(listenerId);
        setHttpListeners(oldVs, s);

        s = getHttpListeners(newVs);
        s.add(listenerId);
        setHttpListeners(newVs, s);
    
private voidcheckArg(java.lang.Object o, java.lang.Object msg)

        if (null == o)
        {
            throw new ConfigException(msg.toString());
        }
    
public voiddeleteHttpListenerRef(java.lang.String listenerId)

        VirtualServer[] servers = config.getHttpService().getVirtualServer();
        if (servers != null)
        {
            for (int i = 0; i < servers.length; i++)
            {
                Set httpListeners = getHttpListeners(servers[i].getId());
                if (httpListeners.contains(listenerId))
                {
                    httpListeners.remove(listenerId);
                    servers[i].setHttpListeners(setToStr(httpListeners));
                }
            }
        }
    
protected com.sun.enterprise.config.serverbeans.HttpListenergetHttpListener(java.lang.String id)

        HttpListener listener = config.getHttpService().getHttpListenerById(id);
        checkArg(listener, strMgr.getString("http_listener_vs_assoc_mgr.no_such_element", id));
        return listener;
    
java.util.SetgetHttpListeners(java.lang.String vsID)

        return strToSet(getVirtualServer(vsID).getHttpListeners());
    
protected com.sun.enterprise.config.serverbeans.VirtualServergetVirtualServer(java.lang.String id)

        VirtualServer vs = config.getHttpService().getVirtualServerById(id);
        checkArg(vs, strMgr.getString("http_listener_vs_assoc_mgr.no_such_element", id));
        return vs;
    
voidsetHttpListeners(java.lang.String vsID, java.util.Set httpListeners)

        getVirtualServer(vsID).setHttpListeners(setToStr(httpListeners));
    
private java.lang.StringsetToStr(java.util.Set httpListeners)

        String s = null;
        final Iterator it = httpListeners.iterator();
        if (it.hasNext())
        {
            StringBuffer sb = new StringBuffer();
            while (it.hasNext())
            {
                sb.append((String)it.next());
                if (it.hasNext()) { sb.append(',"); }
            }
            s = sb.toString();
        }
        return s;
    
private java.util.SetstrToSet(java.lang.String httpListeners)

        final Set s = new LinkedHashSet();
        if (null != httpListeners)
        {
            StringTokenizer strTok = new StringTokenizer(httpListeners, ",");
            while (strTok.hasMoreTokens())
            {
                s.add(strTok.nextToken());
            }
        }
        return s;