FileDocCategorySizeDatePackage
ApplicationHelper.javaAPI DocGlassfish v2 API10222Sat Dec 24 18:47:54 GMT 2005com.sun.enterprise.config.serverbeans

ApplicationHelper

public class ApplicationHelper extends ReferenceHelperBase

Fields Summary
protected static final com.sun.enterprise.util.i18n.StringManager
_strMgr
private static ApplicationHelper
_theInstance
Constructors Summary
public ApplicationHelper()

    
    
      
        super();
    
Methods Summary
public static com.sun.enterprise.config.ConfigBeanfindApplication(com.sun.enterprise.config.ConfigContext configContext, java.lang.String appName)

        Applications root = ((Domain)configContext.getRootConfigBean()).
                                    getApplications();

        ConfigBean app = root.getJ2eeApplicationByName(appName);
        if ( app != null)
            return app;

        app = root.getEjbModuleByName(appName);
        if ( app != null)
            return app;

        app = root.getWebModuleByName(appName);
        if ( app != null)
            return app;

        app = root.getConnectorModuleByName(appName);
        if ( app != null)
            return app;
        
        app = root.getAppclientModuleByName(appName);
        if ( app != null)
            return app;

        app = root.getLifecycleModuleByName(appName);
        if ( app != null)
            return app;

        app = root.getMbeanByName(appName);
        if ( app != null)
            return app;

        return null;
    
public static TransformationRulefindTransformationRule(com.sun.enterprise.config.ConfigContext cfgContext, java.lang.String appId, java.lang.String epName, java.lang.String ruleName)
Given an application ID, end point name and transformation rule name this method returns the matching TransformationRule ConfigBean.

param
cfgContext Config context to be used
param
appId Application or module name
param
epName Endpoint's name
param
ruleName Transformation rule's name


        ConfigBean appBean = findApplication(cfgContext, appId);
        if (appBean == null) {
            throw new ConfigException(_strMgr.getString("noSuchApplication", 
                appId));
        } 
        WebServiceEndpoint wsep = null;
		if (appBean instanceof J2eeApplication) {
            wsep = ((J2eeApplication) appBean).getWebServiceEndpointByName(
                    epName);
        } else if (appBean instanceof EjbModule) {
            wsep = ((EjbModule) appBean).getWebServiceEndpointByName( epName);
        } else if (appBean instanceof WebModule) {
            wsep = ((WebModule) appBean).getWebServiceEndpointByName( epName);
        }
        if (wsep == null) {
            throw new ConfigException(_strMgr.getString("noSuchWSEP", 
                epName));
        } 
        TransformationRule tRule = wsep.getTransformationRuleByName(ruleName);
        if (tRule == null) {
            throw new ConfigException(
                _strMgr.getString("noSuchTransformationRule", ruleName));
        } else {
            return tRule;
        }

    
public static java.lang.StringgetApplicationReferenceesAsString(com.sun.enterprise.config.ConfigContext configContext, java.lang.String appName)
Find all the servers or clusters associated with the given configuration and return them as a comma separated list.

        
        return getInstance().getReferenceesAsString(configContext, appName);
    
public static java.lang.StringgetApplicationType(com.sun.enterprise.config.ConfigContext ctx, java.lang.String id)
Returns the type of a given application

		ConfigBean appBean = findApplication(ctx, id);
		if (appBean instanceof J2eeApplication)
			return Applications.J2EE_APPLICATION;
		if (appBean instanceof EjbModule)
			return Applications.EJB_MODULE;
		if (appBean instanceof WebModule)
			return Applications.WEB_MODULE;
		if (appBean instanceof LifecycleModule)
			return Applications.LIFECYCLE_MODULE;
		if (appBean instanceof AppclientModule)
			return Applications.APPCLIENT_MODULE;
		if (appBean instanceof ConnectorModule)
			return Applications.CONNECTOR_MODULE;
		if (appBean instanceof Mbean)
			return Applications.MBEAN;
		return null;
	
public static java.lang.String[]getApplicationsInDomain(com.sun.enterprise.config.ConfigContext configContext)

        ArrayList result = new ArrayList();
        final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);
        final Applications applications = domain.getApplications();
        AppclientModule[] appclients = applications.getAppclientModule();
        for (int i = 0; i < appclients.length; i++) {
            result.add(appclients[i].getName());
        }
        ConnectorModule[] connectors = applications.getConnectorModule();
        for (int i = 0; i < connectors.length; i++) {
            result.add(connectors[i].getName());
        }
        EjbModule[] ebjs = applications.getEjbModule();
        for (int i = 0; i < ebjs.length; i++) {
            result.add(ebjs[i].getName());
        }
        J2eeApplication[] apps = applications.getJ2eeApplication();
        for (int i = 0; i < apps.length; i++) {
            result.add(apps[i].getName());
        }
        LifecycleModule[] lifecycles = applications.getLifecycleModule();
        for (int i = 0; i < lifecycles.length; i++) {
            result.add(lifecycles[i].getName());
        }
        WebModule[] webs = applications.getWebModule();
        for (int i = 0; i < webs.length; i++) {
            result.add(webs[i].getName());
        }
        Mbean[] mbeans = applications.getMbean();
        for (int i = 0; i < mbeans.length; i++) {
            result.add(mbeans[i].getName());
        }
        return (String[])result.toArray(new String[result.size()]);
    
private static synchronized com.sun.enterprise.config.serverbeans.ApplicationHelpergetInstance()

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

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

        return ServerHelper.getServersReferencingApplication(configContext, name); 
    
public static booleanisApplicationReferenced(com.sun.enterprise.config.ConfigContext configContext, java.lang.String appName)
Is the configuration referenced by anyone (i.e. any server instance or cluster

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

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

        
        return getInstance().isReferencedByServerOnly(configContext, appName, serverName);
    
public static booleanisSystemApp(com.sun.enterprise.config.ConfigContext ctx, java.lang.String appId)

        ConfigBean bean = findApplication(ctx, appId);
        if (bean == null) {
            throw new ConfigException(_strMgr.getString("noSuchApplication", 
                appId));
        } 
        String objectType = null;
        try {
            objectType = bean.getAttributeValue(ServerTags.OBJECT_TYPE);
        } catch (Exception ex) {
            //if the object-type attribute does not exist, then assume that
            //the app is not a system app.
            return false;
        }
        if (objectType.equals(IAdminConstants.SYSTEM_ALL) || 
            objectType.equals(IAdminConstants.SYSTEM_ADMIN) ||
            objectType.equals(IAdminConstants.SYSTEM_INSTANCE)) {
            return true;
        } else {
            return false;
        }