public DeploymentContext buildConfiguration()

in platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/ServiceMixConfigBuilder.java [216:285]


    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId, Object plan,
                    JarFile jarFile, Collection configurationStores, ArtifactResolver artifactResolver,
                    ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException {
        if (plan == null) {
            LOGGER.warn("Expected a Descriptor but received null");
            return null;
        }
        if (plan instanceof DeploymentPlanWrapper == false) {
            LOGGER.warn("Expected a Descriptor but received a {}", plan.getClass().getName());
            return null;
        }
        if (((DeploymentPlanWrapper)plan).getServicemixDescriptor() == null) {
            LOGGER.warn("Expected a SM Descriptor but received null");
            return null;
        }
        File configurationDir;
        try {
            configurationDir = targetConfigurationStore.createNewConfigurationDir(configId);
        } catch (ConfigurationAlreadyExistsException e) {
            throw new DeploymentException(e);
        }

        Environment environment = new Environment();
        environment.setConfigId(configId);
        EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);

        DeploymentPlanWrapper wrapper = (DeploymentPlanWrapper) plan;
        if (wrapper.getGeronimoPlan() != null) {
                	
        	if (wrapper.getGeronimoPlan().getJbi() != null) {
        		EnvironmentType environmentType = wrapper.getGeronimoPlan().getJbi().getEnvironment();
        		if (environmentType != null) {
        			LOGGER.debug("Environment found in Geronimo Plan for ServiceMix {}", environmentType);
        			Environment geronimoPlanEnvironment = EnvironmentBuilder.buildEnvironment(environmentType);
        			EnvironmentBuilder.mergeEnvironments(environment, geronimoPlanEnvironment);
        		} else {
        			LOGGER.debug("no additional environment entry found in deployment plan for JBI component");
        		}
        	}
        }

        DeploymentContext context = null;
        try {
            Descriptor descriptor = wrapper.getServicemixDescriptor();
            Map name = new HashMap();
            name.put("Config", configId.toString());
            context = new DeploymentContext(configurationDir,
                            inPlaceDeployment ? DeploymentUtil.toFile(jarFile) : null, environment,
                            new AbstractName(configId, name),
                            ConfigurationModuleType.SERVICE, kernel.getNaming(), ConfigurationUtil
                                            .getConfigurationManager(kernel), repositories);
            if (descriptor.getComponent() != null) {
                buildComponent(descriptor, context, jarFile);
            } else if (descriptor.getServiceAssembly() != null) {
                buildServiceAssembly(descriptor, context, jarFile);
            } else if (descriptor.getSharedLibrary() != null) {
                buildSharedLibrary(descriptor, context, jarFile);
            } else {
                throw new IllegalStateException("Invalid jbi descriptor");
            }
        } catch (Exception e) {
            if (context != null) {
                context.close();
            }
            DeploymentUtil.recursiveDelete(configurationDir);
            throw new DeploymentException("Unable to deploy", e);
        }

        return context;
    }