public Artifact getId() { return environment.getConfigId(); }
public Artifact getConfigID() { return environment.getConfigId(); }
public ConfigurationData(Environment environment, Naming naming, GBeanState gbeanState) { if (environment == null) throw new NullPointerException("environment is null"); if (environment.getConfigId() == null) throw new NullPointerException("environment.configId is null"); if (naming == null) throw new NullPointerException("naming is null"); this.environment = environment; this.naming = naming; this.gbeanState = gbeanState; this.moduleType = ConfigurationModuleType.CAR; }
public Artifact getConfigurationID(Object plan, JarFile module, ModuleIDBuilder idBuilder) throws IOException, DeploymentException { ModuleType configType = (ModuleType) plan; EnvironmentType environmentType = configType.getEnvironment(); Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment); idBuilder.resolve(environment, module == null ? "" : new File(module.getName()).getName(), "car"); if(!environment.getConfigId().isResolved()) { throw new IllegalStateException("Service Module ID is not fully populated ("+environment.getConfigId()+")"); } return environment.getConfigId(); }
public ConfigurationData(ConfigurationModuleType moduleType, LinkedHashSet classPath, List gbeans, Map childConfigurations, Environment environment, File configurationDir, File inPlaceConfigurationDir, Naming naming) { if (naming == null) throw new NullPointerException("naming is null"); this.naming = naming; if (moduleType != null) { this.moduleType = moduleType; } else { this.moduleType = ConfigurationModuleType.CAR; } if (classPath != null) { this.classPath.addAll(classPath); } gbeanState = ConfigurationUtil.newGBeanState(gbeans); if (childConfigurations != null) { this.childConfigurations.putAll(childConfigurations); } if (environment == null) throw new NullPointerException("environment is null"); if (environment.getConfigId() == null) throw new NullPointerException("environment.configId is null"); this.environment = environment; this.configurationDir = configurationDir; this.inPlaceConfigurationDir = inPlaceConfigurationDir; }
public Artifact getConfigurationID(Object plan, JarFile module, ModuleIDBuilder idBuilder) throws IOException, DeploymentException { ApplicationInfo applicationInfo = (ApplicationInfo) plan; Artifact test = applicationInfo.getEnvironment().getConfigId(); if (!test.isResolved()) { throw new IllegalStateException("Module ID should be fully resolved by now (not " + test + ")"); } return test; }
public Environment(Environment environment) { this.configId = environment.getConfigId(); this.dependencies.addAll(environment.dependencies); this.hiddenClasses.addAll(environment.getHiddenClasses()); this.nonOverrideableClasses.addAll(environment.getNonOverrideableClasses()); this.inverseClassLoading = environment.isInverseClassLoading(); this.suppressDefaultEnvironment = environment.isSuppressDefaultEnvironment(); }
this.name = (name == null) ? environment.getConfigId().toString() : name; this.moduleURI = URI.create(""); } else {
/** * 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 GBeanData addGBean(String name, GBeanInfo gbeanInfo, Naming naming, Environment environment) { if (gbeanState != null) { throw new IllegalStateException("GBeans have been serialized, so no more GBeans can be added"); } String j2eeType = gbeanInfo.getJ2eeType(); if (j2eeType == null) j2eeType = "GBean"; AbstractName abstractName = naming.createRootName(environment.getConfigId(), name, j2eeType); GBeanData gBeanData = new GBeanData(abstractName, gbeanInfo); addGBean(gBeanData); return gBeanData; }
public GBeanData addGBean(String name, GBeanInfo gbeanInfo, Naming naming, Environment environment) { if (gbeanState != null) { throw new IllegalStateException("GBeans have been serialized, so no more GBeans can be added"); } String j2eeType = gbeanInfo.getJ2eeType(); if (j2eeType == null) j2eeType = "GBean"; AbstractName abstractName = naming.createRootName(environment.getConfigId(), name, j2eeType); GBeanData gBeanData = new GBeanData(abstractName, gbeanInfo); addGBean(gBeanData); return gBeanData; }
@Override public void initializeConfiguration() throws DeploymentException { try { ConfigurationData configurationData = new ConfigurationData(moduleType, null, childConfigurationDatas, environment, baseDir, inPlaceConfigurationDir, naming); configurationData.setBundleContext(bundle.getBundleContext()); createTempPluginMetadata(bundle); DependencyManager.updatePluginMetadata(bundle.getBundleContext(), bundle); configurationManager.loadConfiguration(configurationData); this.configuration = configurationManager.getConfiguration(environment.getConfigId()); } catch (Exception e) { throw new DeploymentException("Unable to create configuration for deployment", e); } }
public PluginType getPluginMetadata() { PluginType pluginType = new PluginType(); pluginType.setName("Temporary Plugin metadata for deployment"); PluginArtifactType instance = new PluginArtifactType(); instance.setModuleId(ArtifactType.newArtifactType(environment.getConfigId())); List<DependencyType> dependenciees = instance.getDependency(); for (Dependency dependency: environment.getDependencies()) { dependenciees.add(DependencyType.newDependencyType(dependency)); } pluginType.getPluginArtifact().add(instance); return pluginType; }
protected ConfigurationData buildMasterConfigurationData(ConfigurationData configurationData, Artifact slaveConfigId) { Environment environment = buildEnvironment(configurationData); Artifact configId = environment.getConfigId(); List<GBeanData> gbeans = buildControllerGBeans(configId, slaveConfigId); File configurationDir = delegate.createNewConfigurationDir(configId); return new ConfigurationData(ConfigurationModuleType.CAR, gbeans, Collections.EMPTY_MAP, environment, configurationDir, null, configurationData.getNaming()); }
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 Configuration createTempConfiguration() throws DeploymentException { LinkedHashSet<Artifact> resolvedParentIds = null; try { ConfigurationData configurationData = new ConfigurationData(moduleType, null, childConfigurationDatas, environment, baseDir, inPlaceConfigurationDir, naming); createTempManifest(); createPluginMetadata(); String location = BundleUtils.toReferenceFileLocation(getConfigurationDir()); tempBundle = bundleContext.installBundle(location); if (BundleUtils.canStart(tempBundle)) { tempBundle.start(Bundle.START_TRANSIENT); } configurationData.setBundleContext(tempBundle.getBundleContext()); configurationManager.loadConfiguration(configurationData); return configurationManager.getConfiguration(environment.getConfigId()); } catch (Exception e) { throw new DeploymentException("Unable to create configuration for deployment: dependencies: " + resolvedParentIds, e); } }
public void parseEnvironment(Environment env) { ArtifactType moduleId = environment.addNewModuleId(); Artifact configId = env.getConfigId(); moduleId.setGroupId(configId.getGroupId()); moduleId.setArtifactId(configId.getArtifactId()); moduleId.setVersion(configId.getVersion().toString()); moduleId.setType(configId.getType()); //List<Dependency> deps = env.getDependencies(); //for (int i = 0; i < deps.size(); i++) { // String depString = deps.get(i).toString(); // dependenciesSet.add(depString.substring(6, depString.length() - 1)); //} }
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); } }
public static EnvironmentType buildEnvironmentType(Environment environment) { EnvironmentType environmentType = EnvironmentType.Factory.newInstance(); if (environment.getConfigId() != null) { ArtifactType configId = toArtifactType(environment.getConfigId()); environmentType.setModuleId(configId);