protected Environment buildEnvironment(ConfigurationData configurationData) { Environment environment = new Environment(defaultEnvironment); environment.setConfigId(configurationData.getId()); return environment; }
/** * Guarantees that the argument Environment will have a present and fully * qualified module ID when this method returns. If the Environment is * missing a module ID, or has a partial module ID (isResolved() == false) * then this method will fill in any missing values. If the module ID is * present and resolved, then this method does nothing. * * @param environment The Environment to check and populate * @param defaultArtifactId The artifactId to use if the Envrionment does * not have a module ID at all * @param defaultType The type to use if the Environment is lacking * a module ID or the module ID is lacking a type */ public void resolve(Environment environment, String defaultArtifactId, String defaultType) { if(environment.getConfigId() == null) { environment.setConfigId(resolve(new Artifact(null, defaultArtifactId, (Version)null, defaultType), defaultType)); } else if(!environment.getConfigId().isResolved()) { environment.setConfigId(resolve(environment.getConfigId(), defaultType)); } } }
public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException { storeDelegate.install(clusterInfo, configurationData); installSlaveConfiguration(configurationData); Environment environment = configurationData.getEnvironment(); Artifact slaveConfigId = environment.getConfigId(); Artifact masterConfigId = configNameBuilder.buildMasterConfigurationName(slaveConfigId); environment.setConfigId(masterConfigId); installMasterConfiguration(configurationData, slaveConfigId); }
private void createTempManifest() throws DeploymentException, IOException { Environment env = new Environment(environment); Artifact id = env.getConfigId(); env.setConfigId(new Artifact(id.getGroupId(), id.getArtifactId() + "-DEPLOYMENT", id.getVersion(), id.getType())); env.addToBundleClassPath(bundleClassPath); env.setBundleActivator(null); env.addDynamicImportPackage("*"); OSGiMetaDataBuilder osgiMetaDataBuilder = new OSGiMetaDataBuilder(bundleContext, new DummyExportPackagesSelector()); try { osgiMetaDataBuilder.build(env); } catch (IllegalConfigurationException e) { throw new DeploymentException(e); } Manifest manifest; try { manifest = env.getManifest(); } catch (ManifestException e) { throw new DeploymentException(e); } File metaInf = new File(getConfigurationDir(), "META-INF"); metaInf.mkdirs(); FileWriter fw = new FileWriter(new File(metaInf, "MANIFEST.MF")); PrintWriter pw = new PrintWriter(fw); try { manifest.write(pw); } finally { pw.close(); fw.close(); } }
private static void insertEnvironment(Artifact configId, Artifact parentId, XmlCursor cursor, QName environmentQname, boolean suppressDefaultEnvironment) { positionEnvironment(cursor); Environment environment = new Environment(); environment.setConfigId(configId); if (parentId != null) { environment.addDependency(parentId, ImportType.ALL); } environment.setSuppressDefaultEnvironment(suppressDefaultEnvironment); extractDependencies(cursor, environment); EnvironmentType environmentType = EnvironmentBuilder.buildEnvironmentType(environment); cursor.beginElement(environmentQname); XmlCursor element = environmentType.newCursor(); try { element.copyXmlContents(cursor); } finally { element.dispose(); } }
applicationInfo.getEnvironment().setConfigId(configId); try { try {
if (environmentType != null) { if (environmentType.getModuleId() != null) { environment.setConfigId(toArtifact(environmentType.getModuleId(), null));
public static void mergeEnvironments(Environment environment, Environment additionalEnvironment) { if (additionalEnvironment != null) { //TODO merge configIds?? if (environment.getConfigId() == null) { environment.setConfigId(additionalEnvironment.getConfigId()); } environment.addDependencies(additionalEnvironment.getDependencies()); environment.addToBundleClassPath(additionalEnvironment.getBundleClassPath()); environment.addImportPackages(additionalEnvironment.getImportPackages()); environment.addExportPackages(additionalEnvironment.getExportPackages()); environment.addRequireBundles(additionalEnvironment.getRequireBundles()); environment.addDynamicImportPackages(additionalEnvironment.getDynamicImportPackages()); if (environment.getBundleActivator() == null && additionalEnvironment.getBundleActivator() != null) { environment.setBundleActivator(additionalEnvironment.getBundleActivator()); } environment.setSuppressDefaultEnvironment(environment.isSuppressDefaultEnvironment() || additionalEnvironment.isSuppressDefaultEnvironment()); ClassLoadingRules classLoadingRules = environment.getClassLoadingRules(); ClassLoadingRules additionalClassLoadingRules = additionalEnvironment.getClassLoadingRules(); classLoadingRules.merge(additionalClassLoadingRules); } }
if (environmentType != null) { if (environmentType.isSetModuleId()) { environment.setConfigId(toArtifact(environmentType.getModuleId(), null));