FileDocCategorySizeDatePackage
ServerBeansFactory.javaAPI DocGlassfish v2 API65425Tue Dec 19 19:02:40 GMT 2006com.sun.enterprise.config.serverbeans

ServerBeansFactory

public final class ServerBeansFactory extends Object
Factory for retrieving a particular config. bean given the ConfigContext object. This is the central place where a server resolves the references. There should be no place in the code that accesses beans using context directly.
author
Sridatta
author
ruyak

Fields Summary
private static com.sun.enterprise.util.i18n.StringManager
localStrings
local string manager for i18n
Constructors Summary
private ServerBeansFactory()


      
        // disallow instantiation
    
Methods Summary
public static voidaddClusterMbeanReference(com.sun.enterprise.config.ConfigContext cc, java.lang.String toThisMbean, java.lang.String clusterName)

        final Cluster cluster  = ClusterHelper.getClusterByName(cc, clusterName);
        final ApplicationRef ar = new ApplicationRef();
        ar.setRef(toThisMbean);
        ar.setEnabled(true);
        cluster.addApplicationRef(ar);
    
public static voidaddMbeanDefinition(com.sun.enterprise.config.ConfigContext cc, Mbean m)

        final Domain d          = ServerBeansFactory.getDomainBean(cc);
        final Applications as   = d.getApplications();
        as.addMbean(m);
    
public static voidaddMbeanReference(com.sun.enterprise.config.ConfigContext cc, java.lang.String toThisMbean, java.lang.String server)

        final Domain d          = ServerBeansFactory.getDomainBean(cc);
        final Servers ss        = d.getServers();
        final Server s          = ss.getServerByName(server);
        final ApplicationRef ar = new ApplicationRef();
        ar.setRef(toThisMbean);
        ar.setEnabled(true);
        s.addApplicationRef(ar);
    
public static java.lang.StringgetAdminServiceLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getAdmin();
    
public static java.util.ListgetAllMBeanDefinitions(com.sun.enterprise.config.ConfigContext cc)
Method to get all the MBean definitions from the domain.xml. These are just the MBeans that are available in the given domain. No consideration of references. This is to make sure that names of applications, modules, mbeans are unique in the domain, even if they're referenced from different servers. For example, following structure is to be deemed invalid <applications> <mbean name="foo"> <mbean name="foo"> </applications>

        final Domain d          = ServerBeansFactory.getDomainBean(cc);
        final Applications as   = d.getApplications();
        final Mbean[] ma        = as.getMbean();
        final List<Mbean> ml    = Arrays.asList(ma);
        return ( Collections.unmodifiableList(ml) );
    
public static java.util.SetgetApplicationRefs(com.sun.enterprise.config.ConfigContext ctx)
Get all the application ref elements from the given configuration context wherever they are located.

param
ctx the context from which the application refs are required.
return
a {@link java.util.Set} of {@link ApplicationRef} objects from the given context. Never returns a null.

        final Set refs = new HashSet();
        for (final Iterator it = getServers(ctx).iterator(); it.hasNext();){
            refs.addAll(Arrays.asList(((Server) it.next()).getApplicationRef()));
        }

        for (final Iterator it = getClusters(ctx).iterator(); it.hasNext();){
            refs.addAll(Arrays.asList(((Cluster) it.next()).getApplicationRef()));
        }

        return refs;
    
private static java.util.SetgetApplicationRefsReferencing(java.lang.String name, com.sun.enterprise.config.ConfigContext ctx)

        final Set refers = new HashSet();
        for (final Iterator it = getApplicationRefs(ctx).iterator(); it.hasNext(); ){
            final ApplicationRef ar = (ApplicationRef) it.next();
            if (name.equals(ar.getRef())){
                refers.add(ar);
            }
        }
        return refers;
    
public static ApplicationsgetApplicationsBean(com.sun.enterprise.config.ConfigContext ctx)

       return ServerBeansFactory.getDomainBean(ctx).getApplications();
    
public static java.util.SetgetClusterRefs(com.sun.enterprise.config.ConfigContext ctx)
Get all the cluster refs in the given context, wherever they are located.

param
ctx the {@link ConfigContext} in which the search is to be conducted.
return
a {@link java.util.Set} (never null, possibly empty) containing all {@link ClusterRef} beans within the given context.
throws
ConfigException if there's a problem accesing the context.

        final Set lbconfigs = getLbConfigs(ctx);
        if (lbconfigs.isEmpty()){
            return Collections.EMPTY_SET;
        }
        final Set result = new HashSet();
        for (final Iterator it = lbconfigs.iterator(); it.hasNext();){
            final ConfigBean [] cr = ((LbConfig) it.next()).getClusterRef();
            if (null != cr){
                result.addAll(Arrays.asList(cr));
            }
        }
        return result;
    
public static java.util.SetgetClusters(com.sun.enterprise.config.ConfigContext ctx)
Get a set containing all the clusters within the given context.

param
ctx the context to be searched.
return
a non-null, possibly empty {@link java.util.Set} containing any and all {@link Cluster} instances found within the given context. All objects in this list will be Cluster objects.
throws
ConfigContext if there's a problem in accessing the context.

        if (null == ctx) {
            return Collections.EMPTY_SET;
        }
        final Domain dom = (Domain) ctx.getRootConfigBean();
        if (null == dom){
            return Collections.EMPTY_SET;
        }
        final Clusters clusters = dom.getClusters();
        if (null == clusters || null == clusters.getCluster()){
            return Collections.EMPTY_SET;
        }
        final Set result = new HashSet();
        result.addAll(Arrays.asList(clusters.getCluster()));
        return result;
    
public static ConfiggetConfigBean(com.sun.enterprise.config.ConfigContext ctx)
Returns the config bean for a particular instance.

returns
the config bean for the instance

        return ServerBeansFactory.getConfigModel(ctx);
    
public static ConfiggetConfigModel(com.sun.enterprise.config.ConfigContext configContext)
Get the config model for this server instance. This is the config bean for the server that is defined by the config-ref child element.

return
the config bean for this config ref model.

        if ( configContext == null ) {
            final String msg = localStrings.getString( "serverContext.config_context_is_null");
            throw new ConfigException(msg);
        }
        
        //create the config bean for this instance
        final Server server = ServerBeansFactory.getServerBean(configContext);
        final String configRef = server.getConfigRef();
        final String configXpath = ServerXPathHelper.getConfigIdXpath(configRef);
        final Config configModel = (Config)
            ConfigBeansFactory.getConfigBeanByXPath(configContext, configXpath);

        return configModel;
    
public static java.util.SetgetConfigs(com.sun.enterprise.config.ConfigContext ctx)
Get a set containing all the configs within the given context.

param
ctx the context to be searched.
return
a non-null, possibly empty {@link java.util.Set} containing any and all {@link LbConfig} instances found within the given context. All objects in this list will be LbConfig objects.
throws
ConfigContext if there's a problem in accessing the context.

        if (null == ctx) {
            return Collections.EMPTY_SET;
        }
        final Domain dom = (Domain) ctx.getRootConfigBean();
        if (null == dom){
            return Collections.EMPTY_SET;
        }
        final Configs configs = dom.getConfigs();
        if (null == configs || null == configs.getConfig()){
            return Collections.EMPTY_SET;
        }
        final Set result = new HashSet();
        result.addAll(Arrays.asList(configs.getConfig()));
        return result;
    
public static java.util.SetgetConnectorResources(com.sun.enterprise.config.ConfigContext ctx)
Get a set containing all the connector resources within the given context.

param
ctx the context to be searched.
return
a non-null, possibly empty {@link java.util.Set} containing any and all {@link ConnectorResource} instances found within the given context. All objects in this list will be ConnectorResource objects.
throws
ConfigContext if there's a problem in accessing the context.

        final Set result = new HashSet();
        final ConfigBean [] cr = getResources(ctx, ServerTags.CONNECTOR_RESOURCE);
        if (null != cr){
            result.addAll(Arrays.asList(cr));
        }
        return result;
    
public static ConnectorServicegetConnectorServiceBean(com.sun.enterprise.config.ConfigContext ctx)
Get the connector service object from the given config context

param
ctx the ConfigContext from which the connector service should be obtained
return
the connector service object (might be null)

        return getConfigBean(ctx).getConnectorService();
    
public static java.lang.StringgetCorbaLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getCorba();
    
public static DasConfiggetDasConfigBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       AdminService as = cfg.getAdminService();
       DasConfig ds = null;
       if(as != null) ds = as.getDasConfig();
       return ds; // can be null;
    
public static DomaingetDomainBean(com.sun.enterprise.config.ConfigContext ctx)

       return (Domain)ctx.getRootConfigBean();
    
public static java.lang.StringgetEjbContainerLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getEjbContainer();
    
public static java.util.ListgetFullyEnabledMBeans(com.sun.enterprise.config.ConfigContext cc, java.lang.String sn)
Method to get the completely enabled mbean definitions from the domain.xml, for a given server instance. Note that an MBean is truly enabled if and only if it is enabled in its definition and a reference to its definition from a server instance is enabled too.

param
cc server's ConfigContext
param
sn String representing name of a server instance
return
A List of Mbean elements. Never returns a null. Returns empty List in case no mbean is enabled
throws
ConfigException

        //while reaching here, if cc or sn are null, we are already in trouble
        final List<Mbean> em = new ArrayList<Mbean>();
        final Domain d = ServerBeansFactory.getDomainBean(cc);
        final Server[] ss = d.getServers().getServer();
        for(Server a : ss) {
            if (sn.equals(a.getName())) {
                ApplicationRef[] ars = a.getApplicationRef();
                for (ApplicationRef ar : ars) {
                    if (ar.isEnabled()) { // reference itself is enabled, this is generally not required, but to take care of some weird cases
                        final Mbean tmp = getMBeanDefinition(cc, ar.getRef());
                        if (tmp != null && tmp.isEnabled()) { // the definition is also enabled
                            //System.out.println(tmp.getName() + " will be loaded");
                            em.add(tmp);
                        }
                    }
                }
            }
        }
        return ( Collections.unmodifiableList(em) );
    
public static java.util.ListgetFullyEnabledUserDefinedMBeans(com.sun.enterprise.config.ConfigContext cc, java.lang.String sn)
Method to get the completely enabled "user-defined" mbean definitions from the domain.xml, for a given server instance. Note that an MBean is truly enabled if and only if it is enabled in its definition and a reference to its definition from a server instance is enabled too.

param
cc server's ConfigContext
param
sn String representing name of a server instance
return
A List of Mbean elements. Never returns a null. Returns empty List in case no mbean is enabled
throws
ConfigException
see
#getFullyEnabledMBeans

        final List<Mbean> em    = ServerBeansFactory.getFullyEnabledMBeans(cc, sn);
        final List<Mbean> uem    = new ArrayList<Mbean>();
        for (Mbean m : em) {
           assert (m.isEnabled());
           if (IAdminConstants.USER.equals(m.getObjectType())) {
               uem.add(m);
           }
        }
        return ( Collections.unmodifiableList(uem) );
    
public static HttpServicegetHttpServiceBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       HttpService httpService = cfg.getHttpService();
       return httpService;
    
public static java.util.SetgetHttpServices(com.sun.enterprise.config.ConfigContext ctx)
Get a set containing all the http services within the given context.

param
ctx the context to be searched.
return
a non-null, possibly empty {@link java.util.Set} containing any and all {@link HttpService} instances found within the given context. All objects in this list will be VirtualServer objects.
throws
ConfigContext if there's a problem in accessing the context.

        final Set result = new HashSet();
        for (final Iterator it = getConfigs(ctx).iterator(); it.hasNext(); ){
            result.add(((Config) it.next()).getHttpService());
        }
        return result;
    
public static IiopServicegetIiopServiceBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       IiopService iiopService = cfg.getIiopService();
       return iiopService;
    
public static JavaConfiggetJavaConfigBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       JavaConfig javaConfig = cfg.getJavaConfig();
       return javaConfig;
    
public static JmsHostgetJmsHostBean(com.sun.enterprise.config.ConfigContext ctx)

       JmsService jmsService = ServerBeansFactory.getJmsServiceBean(ctx);
       JmsHost[] hosts = jmsService.getJmsHost();
       return hosts[0];
    
public static JmsServicegetJmsServiceBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       JmsService jmsService = cfg.getJmsService();
       return jmsService;
    
public static java.util.SetgetLbConfigs(com.sun.enterprise.config.ConfigContext ctx)
Get a set containing all the lbconfigs within the given context.

param
ctx the context to be searched.
return
a non-null, possibly empty {@link java.util.Set} containing any and all {@link LbConfig} instances found within the given context. All objects in this list will be LbConfig objects.
throws
ConfigContext if there's a problem in accessing the context.

        if (null == ctx) {
            return Collections.EMPTY_SET;
        }
        final Domain dom = (Domain) ctx.getRootConfigBean();
        if (null == dom){
            return Collections.EMPTY_SET;
        }
        final LbConfigs lbconfigs = dom.getLbConfigs();
        if (null == lbconfigs || null == lbconfigs.getLbConfig()){
            return Collections.EMPTY_SET;
        }
        final Set result = new HashSet();
        result.addAll(Arrays.asList(lbconfigs.getLbConfig()));
        return result;
    
public static MbeangetMBeanDefinition(com.sun.enterprise.config.ConfigContext cc, java.lang.String n)

        final Domain d          = ServerBeansFactory.getDomainBean(cc);
        final Applications a    = d.getApplications();
        final Mbean[] ms        = a.getMbean();
        for (Mbean m : ms) {
            if (n.equals(m.getName())) {
                return ( m );
            }
        }
        return ( null );
    
public static MdbContainergetMdbContainerBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       MdbContainer container = cfg.getMdbContainer();
       return container;
    
public static java.lang.StringgetMdbContainerLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getMdbContainer();
    
public static java.util.ListgetReferencedMBeans(com.sun.enterprise.config.ConfigContext cc, java.lang.String sn)
Method to get mbean definitions from domain.xml that are referenced from a given server name.

param
cc a config context
param
sn String representing the name of the server
throws
ConfigException

        
        final List<Mbean> em = new ArrayList<Mbean>();
        final Domain d = ServerBeansFactory.getDomainBean(cc);
        final Server[] ss = d.getServers().getServer();
        for(Server a : ss) {
            if (sn.equals(a.getName())) {
                ApplicationRef[] ars = a.getApplicationRef();
                for (ApplicationRef ar : ars) {
                    final Mbean tmp = getMBeanDefinition(cc, ar.getRef());
                    if (tmp != null)
                        em.add(tmp);
                }
            }
        }
        return ( Collections.unmodifiableList(em) );
    
public static java.util.SetgetReferers(AdminObjectResource res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link AdminObjectResource} resource within the given {@link ConfigContext}

param
res the {@link AdminObjectResource}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getJndiName(), ctx);
    
public static java.util.SetgetReferers(AppclientModule cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link AppclientModule} within the given {@link ConfigContext}

param
cm the {@link AppclientModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getApplicationRefsReferencing(cm.getName(), ctx);
    
public static java.util.SetgetReferers(Config res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link Config} resource within the given {@link ConfigContext}

param
res the {@link Config}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty) containing either {@link Server} or {@link Cluster} objects.

        if (null == res || null == ctx) { return Collections.EMPTY_SET; }
        final Set result = new HashSet();
        for (final Iterator it = getServers(ctx).iterator(); it.hasNext();){
            final Server el = (Server) it.next();
            if (res.getName().equals(el.getConfigRef())){
                result.add(el);
            }
        }

        for (final Iterator it = getClusters(ctx).iterator(); it.hasNext();){
            final Cluster el = (Cluster) it.next();
            if (res.getName().equals(el.getConfigRef())){
                result.add(el);
            }
        }

        return result;
    
public static java.util.SetgetReferers(NodeAgent res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link NodeAgent} resource within the given {@link ConfigContext}

param
res the {@link NodeAgent}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty) containing either {@link Server} or {@link Cluster} objects.

        if (null == res || null == ctx) { return Collections.EMPTY_SET; }
        final Set result = new HashSet();
        for (final Iterator it = getServers(ctx).iterator(); it.hasNext();){
            final Server el = (Server) it.next();
            if (res.getName().equals(el.getNodeAgentRef())){
                result.add(el);
            }
        }
        return result;
    
public static java.util.SetgetReferers(ConnectorResource res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link ConnectorResource} resource within the given {@link ConfigContext}

param
res the {@link ConnectorResource}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getJndiName(), ctx);
    
public static java.util.SetgetReferers(Cluster cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link Cluster} within the given {@link ConfigContext}

param
cm the {@link Cluster}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        if (null == cm || null == ctx) {return Collections.EMPTY_SET;}

        final Set refs = getClusterRefs(ctx);
        if (refs.isEmpty()) { return Collections.EMPTY_SET; }

        final Set result = new HashSet();
        for (final Iterator it = refs.iterator(); it.hasNext(); ){
            final ClusterRef ref = (ClusterRef) it.next();
            if (cm.getName().equals(ref.getRef())){
                result.add(ref);
            }
        }
        return result;
    
public static java.util.SetgetReferers(ConnectorConnectionPool cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link ConnectorConnectionPool} within the given {@link ConfigContext}

param
cm the {@link ConnectorConnectionPool}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        if (null == cm || null == ctx) {return Collections.EMPTY_SET;}

        final Set crs = getConnectorResources(ctx);
        if (crs.isEmpty()) { return Collections.EMPTY_SET; }

        final Set result = new HashSet();
        for (final Iterator it = crs.iterator(); it.hasNext(); ){
            final ConnectorResource cr  = (ConnectorResource) it.next();
            if (cm.getName().equals(cr.getPoolName())){
                result.add(cr);
            }
        }
        return result;
    
public static java.util.SetgetReferers(ConnectorModule cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link ConnectorModule} within the given {@link ConfigContext}

param
cm the {@link ConnectorModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getApplicationRefsReferencing(cm.getName(), ctx);
    
public static java.util.SetgetReferers(CustomResource res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link CustomResource} resource within the given {@link ConfigContext}

param
res the {@link CustomResource}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getJndiName(), ctx);
    
public static java.util.SetgetReferers(EjbModule cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link EjbModule} within the given {@link ConfigContext}

param
cm the {@link EjbModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getApplicationRefsReferencing(cm.getName(), ctx);
    
public static java.util.SetgetReferers(ExternalJndiResource res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link ExternalJndiResource} resource within the given {@link ConfigContext}

param
res the {@link ExternalJndiResource}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getJndiName(), ctx);
    
public static java.util.SetgetReferers(J2eeApplication cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link J2eeApplication} within the given {@link ConfigContext}

param
cm the {@link J2eeApplication}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getApplicationRefsReferencing(cm.getName(), ctx);
    
public static java.util.SetgetReferers(JdbcResource res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link JdbcResource} resource within the given {@link ConfigContext}

param
res the {@link JdbcResource}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getJndiName(), ctx);
    
public static java.util.SetgetReferers(LifecycleModule cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link LifecycleModule} within the given {@link ConfigContext}

param
cm the {@link LifecycleModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getApplicationRefsReferencing(cm.getName(), ctx);
    
public static java.util.SetgetReferers(MailResource res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link MailResource} resource within the given {@link ConfigContext}

param
res the {@link MailResource}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getJndiName(), ctx);
    
public static java.util.SetgetReferers(PersistenceManagerFactoryResource res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link PersistenceManagerFactoryResource} resource within the given {@link ConfigContext}

param
res the {@link PersistenceManagerFactoryResource}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getJndiName(), ctx);
    
public static java.util.SetgetReferers(ResourceAdapterConfig res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link ResourceAdapterConfig} resource within the given {@link ConfigContext}

param
res the {@link ResourceAdapterConfig}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getResourceRefsReferencing(res.getResourceAdapterName(), ctx);
    
public static java.util.SetgetReferers(Server res, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link Server} resource within the given {@link ConfigContext}

param
res the {@link Server}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getServerRefsReferencing(res.getName(), ctx);
    
public static java.util.SetgetReferers(WebModule cm, com.sun.enterprise.config.ConfigContext ctx)
Return a set containing all the elements that reference the given {@link WebModule} within the given {@link ConfigContext}

param
cm the {@link WebModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing teh config context.
return
a {@link java.util.Set} (never null, possibly empty)

        return getApplicationRefsReferencing(cm.getName(), ctx);
    
public static java.util.SetgetResourceRefs(com.sun.enterprise.config.ConfigContext ctx)
Get all the resource ref elements from the given configuration context wherever they are located.

param
ctx the context from which the resource refs are required.
return
a {@link java.util.Set} of {@link ResourceRef} objects from the given context. Never returns a null.

        final Set refs = new HashSet();
        for (final Iterator it = getServers(ctx).iterator(); it.hasNext();){
            refs.addAll(Arrays.asList(((Server) it.next()).getResourceRef()));
        }

        for (final Iterator it = getClusters(ctx).iterator(); it.hasNext();){
            refs.addAll(Arrays.asList(((Cluster) it.next()).getResourceRef()));
        }

        return refs;
    
private static java.util.SetgetResourceRefsReferencing(java.lang.String name, com.sun.enterprise.config.ConfigContext ctx)

        final Set refers = new HashSet();
        for (final Iterator it = getResourceRefs(ctx).iterator(); it.hasNext(); ){
            final ResourceRef ar = (ResourceRef) it.next();
            if (name.equals(ar.getRef())){
                refers.add(ar);
            }
        }
        return refers;
    
public static com.sun.enterprise.config.ConfigBean[]getResources(com.sun.enterprise.config.ConfigContext ctx, java.lang.String type)

ctx
config context of the server.
type
type of the resource. maps to element name in dtd

       Resources r = getDomainBean(ctx).getResources();

       //ResourceRefs refs = getServerBean(ctx).getResourceRefs();

       // Implement the logic of getting only the resources referenced by the server

       // TBD
       //FIXME: validate the code.
       return r.getChildBeansByName(type);
    
public static java.lang.StringgetRootLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getRoot();
    
public static SecurityServicegetSecurityServiceBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       return cfg.getSecurityService();
    
public static java.lang.StringgetSecurityServiceLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       /*SecurityService securityService = cfg.getSecurityService();
       return securityService.getLogLevel();
        */
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getSecurity();
    
public static ServergetServerBean(com.sun.enterprise.config.ConfigContext ctx)
Returns server config bean.

returns
the server config bean

       final String serverName = java.lang.System.getProperty("com.sun.aas.instanceName");
       String xpath = ServerXPathHelper.getServerIdXpath(serverName);
       final Server server =
            (Server) ConfigBeansFactory.getConfigBeanByXPath(ctx, xpath);
       return server;
    
public static ServergetServerBeanFromArray(Server[] serverArray, java.lang.String serverName)
Returns the appropriate Server bean for an instance given an array of Server beans from the domain.xml config.

returns
the Server bean for the instance

        for (int i=0;i<serverArray.length;i++) {
            if (serverArray[i].getName().equals(serverName)) {
                return serverArray[i];
            }
        }
        //if no match is made, then return first server bean in array
        return serverArray[0];
    
public static java.util.SetgetServerRefs(com.sun.enterprise.config.ConfigContext ctx)
Get all the server ref elements from the given configuration context wherever they are located.

param
ctx the context from which the server refs are required.
return
a {@link java.util.Set} of {@link ServerRef} objects from the given context. Never returns a null.

        final Set refs = new HashSet();
        for (final Iterator it = getLbConfigs(ctx).iterator(); it.hasNext();){
            refs.addAll(Arrays.asList(((LbConfig) it.next()).getServerRef()));
        }
        
        for (final Iterator it = getClusters(ctx).iterator(); it.hasNext();){
            refs.addAll(Arrays.asList(((Cluster) it.next()).getServerRef()));
        }
        return refs;
    
private static java.util.SetgetServerRefsReferencing(java.lang.String name, com.sun.enterprise.config.ConfigContext ctx)

        final Set refers = new HashSet();
        for (final Iterator it = getServerRefs(ctx).iterator(); it.hasNext(); ){
            final ServerRef ar = (ServerRef) it.next();
            if (name.equals(ar.getRef())){
                refers.add(ar);
            }
        }
        return refers;
    
public static java.util.SetgetServers(com.sun.enterprise.config.ConfigContext ctx)
Get a set containing all the servers within the given context.

param
ctx the context to be searched.
return
a non-null, possibly empty {@link java.util.Set} containing any and all {@link Server} instances found within the given context. All objects in this list will be LbServer objects.
throws
ServerContext if there's a problem in accessing the context.

        if (null == ctx) {
            return Collections.EMPTY_SET;
        }
        final Domain dom = (Domain) ctx.getRootConfigBean();
        if (null == dom){
            return Collections.EMPTY_SET;
        }
        final Servers servers = dom.getServers();
        if (null == servers || null == servers.getServer()){
            return Collections.EMPTY_SET;
        }
        final Set result = new HashSet();
        result.addAll(Arrays.asList(servers.getServer()));
        return result;
    
public static Server[]getServersReferencingMBeanDefinition(com.sun.enterprise.config.ConfigContext cc, java.lang.String name)

        //check to see if two or more servers have references to this mbean
        Server[] ss = null;
        final List<Server> list = new ArrayList<Server> ();
        ss = ServerBeansFactory.getDomainBean(cc).getServers().getServer();
        int numberOfReferencingServers = 0;
        for (Server s : ss) {
            boolean referenced = false;
            final String sName = s.getName();
            referenced = ServerBeansFactory.isReferencedMBean(cc, sName, name);
            if (referenced) {
                list.add(s);
            }
        }
        final Server[] rss = new Server[list.size()];
        return ( list.toArray(rss) );
    
public static TransactionServicegetTransactionServiceBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       return cfg.getTransactionService();
    
public static java.lang.StringgetTransactionServiceLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getJts();

    
public static java.util.SetgetVirtualServers(com.sun.enterprise.config.ConfigContext ctx)
Get a set containing all the virtual servers within the given context.

param
ctx the context to be searched.
return
a non-null, possibly empty {@link java.util.Set} containing any and all {@link VirtualServer} instances found within the given context. All objects in this list will be VirtualServer objects.
throws
ConfigContext if there's a problem in accessing the context.

        final Set result = new HashSet();
        for (final Iterator it = getHttpServices(ctx).iterator(); it.hasNext(); ){
            final ConfigBean [] vs = ((HttpService) it.next()).getVirtualServer();
            if (null != vs){
                result.addAll(Arrays.asList(vs));
            }
        }
        return result;
    
public static java.lang.StringgetVirtualServersByAppName(com.sun.enterprise.config.ConfigContext ctx, java.lang.String appName)
Get virtual server given an Application Virtual servers are maintained in the reference contained in Server element. First, we need to find the server and then get the virtual server from the correct reference

param
ctx ConfigContext
param
appName Name of the app to get vs
return
virtual servers as a string (separated by space or comma)


    ApplicationRef ar = getServerBean(ctx).getApplicationRefByRef(appName);
    if (ar == null) return null; //fixme should I throw an exception??

    return ar.getVirtualServers();


                                            /*
         VirtualServer[] vsList = getConfigBean(ctx).getHttpService().getVirtualServer();

         if (vsList == null) return null;

         String ret ="";
         for(int i=0;i< vsList.length; i++) {
             if(!ret.equals("")) {
                 ret+="'";
             }
            ret += vsList[i].getId();
         }

         return ret;
                                             */
    
public static WebContainergetWebContainerBean(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       WebContainer webContainer = cfg.getWebContainer();
       return webContainer;
    
public static java.lang.StringgetWebContainerLogLevel(com.sun.enterprise.config.ConfigContext ctx)

       Config cfg = ServerBeansFactory.getConfigBean(ctx);
       LogService logService = cfg.getLogService();
       return logService.getModuleLogLevels().getWebContainer();
    
public static booleanisReferenced(AdminObjectResource res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link AdminObjectResource} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link AdminObjectResource} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getJndiName(), ctx);
    
public static booleanisReferenced(AppclientModule cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link AppclientModule} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link AppclientModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the appclient module is referenced within the context

        return isReferencedByApplicationRef(cm.getName(), ctx);
    
public static booleanisReferenced(Config res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link Config} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link Config} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        if (null == res || null == ctx) { return false; }
        for (final Iterator it = getServers(ctx).iterator(); it.hasNext();){
            if (res.getName().equals(((Server) it.next()).getConfigRef())){
                return true;
            }
        }

        for (final Iterator it = getClusters(ctx).iterator(); it.hasNext();){
            if (res.getName().equals(((Cluster) it.next()).getConfigRef())){
                return true;
            }
        }

        return false;
    
public static booleanisReferenced(NodeAgent res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link NodeAgent} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link NodeAgent} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        if (null == res || null == ctx) { return false; }
        for (final Iterator it = getServers(ctx).iterator(); it.hasNext();){
            if (res.getName().equals(((Server) it.next()).getNodeAgentRef())){
                return true;
            }
        }

        return false;
    
public static booleanisReferenced(ConnectorResource res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link ConnectorResource} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link ConnectorResource} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getJndiName(), ctx);
    
public static booleanisReferenced(Cluster cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link Cluster} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link Cluster}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the cluster is referenced within the context

        if (null == cm || null == ctx) {return false;}

        final Set refs = getClusterRefs(ctx);
        if (refs.isEmpty()) { return false; }
        for (final Iterator it = refs.iterator(); it.hasNext(); ){
            if (cm.getName().equals(((ClusterRef) it.next()).getRef())){
                return true;
            }
        }
        return false;
    
public static booleanisReferenced(ConnectorConnectionPool cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link ConnectorConnectionPool} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link ConnectorConnectionPool}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the cluster is referenced within the context

        if (null == cm || null == ctx) {return false;}

        final Set crs = getConnectorResources(ctx);
        if (crs.isEmpty()) { return false; }
        for (final Iterator it = crs.iterator(); it.hasNext(); ){
            if (cm.getName().equals(((ConnectorResource) it.next()).getPoolName())){
                return true;
            }
        }
        return false;
    
public static booleanisReferenced(ConnectorModule cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link ConnectorModule} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link ConnectorModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the connector module is referenced within the context

        return isReferencedByApplicationRef(cm.getName(), ctx);
    
public static booleanisReferenced(CustomResource res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link CustomResource} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link CustomResource} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getJndiName(), ctx);
    
public static booleanisReferenced(EjbModule cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link EjbModule} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link EjbModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the ejb module is referenced within the context

        return isReferencedByApplicationRef(cm.getName(), ctx);
    
public static booleanisReferenced(ExternalJndiResource res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link ExternalJndiResource} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link ExternalJndiResource} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getJndiName(), ctx);
    
public static booleanisReferenced(J2eeApplication cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link J2eeApplication} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link J2eeApplication}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the j2ee application is referenced within the context

        return isReferencedByApplicationRef(cm.getName(), ctx);
    
public static booleanisReferenced(JdbcResource res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link JdbcResource} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link JdbcResource} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getJndiName(), ctx);
    
public static booleanisReferenced(LifecycleModule cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link LifecycleModule} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link LifecycleModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the lifecycle module is referenced within the context

        return isReferencedByApplicationRef(cm.getName(), ctx);
    
public static booleanisReferenced(MailResource res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link MailResource} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link MailResource} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getJndiName(), ctx);
    
public static booleanisReferenced(PersistenceManagerFactoryResource res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link PersistenceManagerFactoryResource} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link PersistenceManagerFactoryResource} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getJndiName(), ctx);
    
public static booleanisReferenced(ResourceAdapterConfig res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link ResourceAdapterConfig} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link ResourceAdapterConfig} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByResourceRef(res.getResourceAdapterName(), ctx);
    
public static booleanisReferenced(Server res, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link Server} resource is referenced by one or more other elements within the given {@link ConfigContext}.

param
res the {@link Server} (possibly) referenced resource
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the resource is referenced within the context

        return isReferencedByServerRef(res.getName(), ctx);
    
public static booleanisReferenced(WebModule cm, com.sun.enterprise.config.ConfigContext ctx)
Indicate if the given {@link WebModule} element is referenced by one or more other elements within the given {@link ConfigContext}.

param
cm the {@link WebModule}
param
ctx the {@link ConfigContext}
throws
ConfigException if there's a problem in accessing the config context.
return
true iff the web module is referenced within the context

        for (final Iterator it = getVirtualServers(ctx).iterator(); it.hasNext(); ){
            if (cm.getName().equals(((VirtualServer) it.next()).getDefaultWebModule())){
                return true;
            }
        }
        
        return isReferencedByApplicationRef(cm.getName(), ctx);
    
private static booleanisReferencedByApplicationRef(java.lang.String name, com.sun.enterprise.config.ConfigContext ctx)

        for (final Iterator it = getApplicationRefs(ctx).iterator(); it.hasNext(); ){
            if (name.equals(((ApplicationRef) it.next()).getRef())){
                return true;
            }
        }
        return false;
    
private static booleanisReferencedByResourceRef(java.lang.String name, com.sun.enterprise.config.ConfigContext ctx)

        for (final Iterator it = getResourceRefs(ctx).iterator(); it.hasNext(); ){
            if (name.equals(((ResourceRef) it.next()).getRef())){
                return true;
            }
        }
        return false;
    
private static booleanisReferencedByServerRef(java.lang.String name, com.sun.enterprise.config.ConfigContext ctx)

        for (final Iterator it = getServerRefs(ctx).iterator(); it.hasNext(); ){
            if (name.equals(((ServerRef) it.next()).getRef())){
                return true;
            }
        }
        return false;
    
public static booleanisReferencedMBean(com.sun.enterprise.config.ConfigContext cc, java.lang.String sn, java.lang.String mn)

        final List<Mbean> rm = getReferencedMBeans(cc, sn);
        boolean refd = false;
        for (Mbean m : rm) {
            if (m.getName().equals(mn)) {
                refd = true;
                break;
            }
        }
        return ( refd );
    
public static booleanisReferencedMBeanInCluster(com.sun.enterprise.config.ConfigContext cc, java.lang.String cn, java.lang.String mn)
  • Returns true if all of the instances in the given cluster reference the given custom mbean
  • Return false if all of the instances in the given cluster do not reference the given custom mbean or if there are no instances in the cluster
  • throw a ConfigException if some instances have the ref and some do not.

    param
    cc the config context
    param
    cn the cluster's name
    param
    mn the mbean's name
    throws
    com.sun.enterprise.config.ConfigException see above
    return
    see above

            // by definition a cluster has no referenced mbeans -- only instances in the cluster do.
            assert cc != null && cn != null && mn != null;
            // in case asserts are off, return false.  Normally I'd log it but this
            // file has no logger and I'm just visiting...
            if(cc == null || cn == null || mn == null)
                return false;
            
            final Server[] ss = ServerHelper.getServersInCluster(cc, cn);
    
            if(ss == null || ss.length < 1)
                return false;
    
            final boolean[] isrefs = new boolean[ss.length];
            
            for(int i = 0; i < ss.length; i++)
            {
                isrefs[i] = isReferencedMBean(cc, ss[i].getName(), mn);
            }
    
            // see if they are not all exactly the same -- simply compare the first
            // with all the others.
            for(int i = 1; i < ss.length; i++)
            {
                if(isrefs[i] != isrefs[0])
                {
                    String messy = prepareMessyStringMessage(ss, isrefs);
                    String msg = StringManager.getManager(ServerBeansFactory.class).getString("CorruptClusterConfig", 
                            new Object[] { cn, mn, messy} );
                    throw new ConfigException(msg);
                }
            }
            return isrefs[0];   // they are all the same!
        
private static java.lang.StringprepareMessyStringMessage(Server[] ss, boolean[] isrefs)

        // the refs in this array of Servers are not the same.  I.e. we have a scary inconsistent
        // corrupted cluster configuration.  Let's painfully create a message for the user about it...
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < ss.length; i++)
        {
            if(i != 0)
                sb.append(", ");
            String s = isrefs[i] ? "referenced" : "not-referenced";
            sb.append(ss[i].getName()).append(":").append(s);
        }
        
        return sb.toString();
    
public static voidremoveClusterMbeanReference(com.sun.enterprise.config.ConfigContext cc, java.lang.String ref, java.lang.String clusterName)

        final Cluster cluster  = ClusterHelper.getClusterByName(cc, clusterName);
        final ApplicationRef ar = cluster.getApplicationRefByRef(ref);
        cluster.removeApplicationRef(ar);
    
public static voidremoveMbeanDefinition(com.sun.enterprise.config.ConfigContext cc, java.lang.String n)

        final Domain d          = ServerBeansFactory.getDomainBean(cc);
        final Applications as   = d.getApplications();
        as.removeMbean(as.getMbeanByName(n));
    
public static voidremoveMbeanReference(com.sun.enterprise.config.ConfigContext cc, java.lang.String ref, java.lang.String server)

        final Domain d          = ServerBeansFactory.getDomainBean(cc);
        final Servers ss        = d.getServers();
        final Server s          = ss.getServerByName(server);
        final ApplicationRef ar = s.getApplicationRefByRef(ref);
        s.removeApplicationRef(ar);