private Environment getEnvironment()

in plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java [399:450]


    private Environment getEnvironment(IModule module) {
        Trace.tracePoint("Enter", Activator.traceInternal, "DependencyHelper.getEnvironment", module);
        
        // if module's environment is in the cache, get it from the cache
        if(environmentCache.containsKey(module)) {
             return environmentCache.get(module);
        }

        Environment environment = null;
        if (GeronimoUtils.isWebModule(module)) {
            if (getWebDeploymentPlan(module) != null) {
                WebApp plan = getWebDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        }
        else if (GeronimoUtils.isEjbJarModule(module)) {
            if (getOpenEjbDeploymentPlan(module) != null) {
                OpenejbJar plan = getOpenEjbDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        }
        else if (GeronimoUtils.isEarModule(module)) {
            if (getApplicationDeploymentPlan(module) != null) {
                Application plan = getApplicationDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        }
        else if (GeronimoUtils.isRARModule(module)) {
            if (getConnectorDeploymentPlan(module) != null) {
                Connector plan = getConnectorDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        }else if (GeronimoUtils.isAppClientModule(module)) {
            if (getAppClientDeploymentPlan(module) != null) {
                ApplicationClient plan = getAppClientDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getServerEnvironment();
            }
        }
        
        //put module's environment into the cache for next retrieve
        if (environment != null) {
            environmentCache.put(module, environment);
        } 

        Trace.tracePoint("Exit ", Activator.traceInternal, "DependencyHelper.getEnvironment", environment);
        return environment;
    }