use of org.osmorc.run.ui.SelectedBundle in project intellij-plugins by JetBrains.
the class ConciergeRunner method setupParameters.
/**
* See <a href="http://concierge.sourceforge.net/properties.html">Concierge Startup Properties</a>.
*/
@Override
protected void setupParameters(@NotNull JavaParameters parameters) {
ParametersList vmParameters = parameters.getVMParametersList();
// bundles and start levels
MultiMap<Integer, String> startBundles = new MultiMap<>();
List<String> installBundles = ContainerUtil.newSmartList();
for (SelectedBundle bundle : myBundles) {
String bundlePath = bundle.getBundlePath();
if (bundlePath == null)
continue;
boolean isFragment = CachingBundleInfoProvider.isFragmentBundle(bundlePath);
String bundleUrl = toFileUri(bundlePath);
if (bundle.isStartAfterInstallation() && !isFragment) {
int startLevel = getBundleStartLevel(bundle);
startBundles.putValue(startLevel, bundleUrl);
} else {
installBundles.add(bundleUrl);
}
}
for (Integer startLevel : startBundles.keySet()) {
vmParameters.addProperty("osgi.auto.start." + startLevel, StringUtil.join(startBundles.get(startLevel), " "));
}
if (!installBundles.isEmpty()) {
vmParameters.addProperty("osgi.auto.install", StringUtil.join(installBundles, " "));
}
int startLevel = getFrameworkStartLevel();
vmParameters.addProperty("osgi.startlevel.framework", String.valueOf(startLevel));
int defaultStartLevel = myRunConfiguration.getDefaultStartLevel();
vmParameters.addProperty("osgi.startlevel.bundle", String.valueOf(defaultStartLevel));
// framework-specific options
vmParameters.addProperty("osgi.init", "true");
if (GenericRunProperties.isDebugMode(myAdditionalProperties)) {
vmParameters.addProperty("ch.ethz.iks.concierge.debug", "true");
}
parameters.setMainClass(MAIN_CLASS);
}
use of org.osmorc.run.ui.SelectedBundle in project intellij-plugins by JetBrains.
the class FelixRunner method setupParameters.
/**
* See <a href="http://felix.apache.org/site/apache-felix-framework-configuration-properties.html">Felix Configuration Properties</a>.
*/
@Override
protected void setupParameters(@NotNull JavaParameters parameters) {
ParametersList vmParameters = parameters.getVMParametersList();
// bundles and start levels
MultiMap<Integer, String> startBundles = new MultiMap<>();
List<String> installBundles = ContainerUtil.newSmartList();
for (SelectedBundle bundle : myBundles) {
String bundlePath = bundle.getBundlePath();
if (bundlePath == null)
continue;
boolean isFragment = CachingBundleInfoProvider.isFragmentBundle(bundlePath);
String bundleUrl = toFileUri(bundlePath);
if (bundle.isStartAfterInstallation() && !isFragment) {
int startLevel = getBundleStartLevel(bundle);
startBundles.putValue(startLevel, bundleUrl);
} else {
installBundles.add(bundleUrl);
}
}
for (Integer startLevel : startBundles.keySet()) {
vmParameters.addProperty("felix.auto.start." + startLevel, StringUtil.join(startBundles.get(startLevel), " "));
}
if (!installBundles.isEmpty()) {
vmParameters.addProperty("felix.auto.install.1", StringUtil.join(installBundles, " "));
}
int startLevel = getFrameworkStartLevel();
vmParameters.addProperty("org.osgi.framework.startlevel.beginning", String.valueOf(startLevel));
int defaultStartLevel = myRunConfiguration.getDefaultStartLevel();
vmParameters.addProperty("felix.startlevel.bundle", String.valueOf(defaultStartLevel));
// framework-specific options
vmParameters.addProperty("org.osgi.framework.storage.clean", "onFirstInit");
if (GenericRunProperties.isDebugMode(myAdditionalProperties)) {
vmParameters.addProperty("felix.log.level", "4");
}
parameters.setMainClass(MAIN_CLASS);
}
use of org.osmorc.run.ui.SelectedBundle in project intellij-plugins by JetBrains.
the class StartLevelComparatorTest method testCompare.
@Test
public void testCompare() {
Comparator<SelectedBundle> testObject = OsgiRunState.START_LEVEL_COMPARATOR;
SelectedBundle bundle1 = new SelectedBundle(SelectedBundle.BundleType.Module, "org.osmorc.testBundle1", null);
SelectedBundle bundle2 = new SelectedBundle(SelectedBundle.BundleType.Module, "org.osmorc.testBundle2", null);
bundle1.setStartLevel(1);
bundle2.setStartLevel(1);
assertThat(testObject.compare(bundle1, bundle2), equalTo(0));
bundle1.setStartLevel(1);
bundle2.setStartLevel(2);
assertThat(testObject.compare(bundle1, bundle2), lessThan(0));
bundle1.setStartLevel(4);
bundle2.setStartLevel(2);
assertThat(testObject.compare(bundle1, bundle2), greaterThan(0));
}
use of org.osmorc.run.ui.SelectedBundle in project intellij-plugins by JetBrains.
the class AbstractFrameworkRunner method createJavaParameters.
@Override
public JavaParameters createJavaParameters(@NotNull OsgiRunConfiguration runConfiguration, @NotNull List<SelectedBundle> bundles) throws ExecutionException {
myRunConfiguration = runConfiguration;
myInstance = myRunConfiguration.getInstanceToUse();
assert myInstance != null : myRunConfiguration;
myIntegrator = FrameworkIntegratorRegistry.getInstance().findIntegratorByInstanceDefinition(myInstance);
assert myIntegrator != null : myInstance;
myInstanceManager = myIntegrator.getFrameworkInstanceManager();
myAdditionalProperties = myRunConfiguration.getAdditionalProperties();
myBundles = bundles;
JavaParameters params = new JavaParameters();
if (myRunConfiguration.isGenerateWorkingDir()) {
myWorkingDir = new File(PathManager.getSystemPath(), "osmorc/run." + System.currentTimeMillis());
} else {
myWorkingDir = new File(myRunConfiguration.getWorkingDir());
}
if (!myWorkingDir.isDirectory() && !myWorkingDir.mkdirs()) {
throw new CantRunException("Cannot create work directory '" + myWorkingDir.getPath() + "'");
}
params.setWorkingDirectory(myWorkingDir);
// only add JDK classes to the classpath, the rest is to be provided by bundles
String jreHome = myRunConfiguration.isUseAlternativeJre() ? myRunConfiguration.getAlternativeJrePath() : null;
JavaParametersUtil.configureProject(myRunConfiguration.getProject(), params, JavaParameters.JDK_ONLY, jreHome);
// class path
Collection<SelectedBundle> systemBundles = myInstanceManager.getFrameworkBundles(myInstance, FrameworkBundleType.SYSTEM);
if (systemBundles.isEmpty()) {
throw new CantRunException("Libraries required to start the framework not found - please check the installation");
}
for (SelectedBundle bundle : systemBundles) {
String path = bundle.getBundlePath();
assert path != null : bundle;
params.getClassPath().add(path);
}
if (GenericRunProperties.isStartConsole(myAdditionalProperties)) {
Collection<SelectedBundle> shellBundles = myInstanceManager.getFrameworkBundles(myInstance, FrameworkBundleType.SHELL);
if (shellBundles.isEmpty()) {
throw new CantRunException("Console requested but no shell bundles can be found - please check the installation");
}
List<SelectedBundle> allBundles = ContainerUtil.newArrayList(shellBundles);
allBundles.addAll(myBundles);
myBundles = allBundles;
}
if (myRunConfiguration.isIncludeAllBundlesInClassPath()) {
for (SelectedBundle bundle : myBundles) {
String path = bundle.getBundlePath();
if (path != null) {
params.getClassPath().add(path);
}
}
}
// runner options
params.setUseDynamicVMOptions(!myBundles.isEmpty());
params.setUseDynamicParameters(!myBundles.isEmpty());
HttpConfigurable.getInstance().getJvmProperties(false, null).forEach(p -> params.getVMParametersList().addProperty(p.first, p.second));
params.getVMParametersList().addParametersString(myRunConfiguration.getVmParameters());
String additionalProgramParams = myRunConfiguration.getProgramParameters();
if (!StringUtil.isEmptyOrSpaces(additionalProgramParams)) {
params.getProgramParametersList().addParametersString(additionalProgramParams);
}
String bootDelegation = GenericRunProperties.getBootDelegation(myAdditionalProperties);
if (!StringUtil.isEmptyOrSpaces(bootDelegation)) {
params.getVMParametersList().addProperty("org.osgi.framework.bootdelegation", bootDelegation);
}
String systemPackages = GenericRunProperties.getSystemPackages(myAdditionalProperties);
if (!StringUtil.isEmptyOrSpaces(systemPackages)) {
params.getVMParametersList().addProperty("org.osgi.framework.system.packages.extra", systemPackages);
}
// framework-specific options
setupParameters(params);
return params;
}
use of org.osmorc.run.ui.SelectedBundle in project intellij-plugins by JetBrains.
the class AbstractFrameworkRunner method getFrameworkStartLevel.
protected int getFrameworkStartLevel() {
if (myRunConfiguration.isAutoStartLevel()) {
int startLevel = 0;
for (SelectedBundle bundle : myBundles) {
int bundleStartLevel = getBundleStartLevel(bundle);
startLevel = Math.max(bundleStartLevel, startLevel);
}
return startLevel;
} else {
return myRunConfiguration.getFrameworkStartLevel();
}
}
Aggregations