private Environment getEnvironment()

in plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/DependencyHelper.java [384:437]


    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)) {
            JAXBElement<WebApp> element = getWebDeploymentPlan(module);
            if (element != null) {
                WebApp plan = element.getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        } else if (GeronimoUtils.isEjbJarModule(module)) {
            JAXBElement<OpenejbJar> element = getOpenEjbDeploymentPlan(module);
            if (element != null) {
                OpenejbJar plan = element.getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        } else if (GeronimoUtils.isEarModule(module)) {
            JAXBElement<Application> element = getApplicationDeploymentPlan(module);
            if (element != null) {
                Application plan = element.getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        } else if (GeronimoUtils.isRARModule(module)) {
            JAXBElement<Connector> element = getConnectorDeploymentPlan(module);
            if (element != null) {
                Connector plan = element.getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        } else if (GeronimoUtils.isAppClientModule(module)) {
            JAXBElement<ApplicationClient> element = getAppClientDeploymentPlan(module);
            if (element != null) {
                ApplicationClient plan = element.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;
    }