Skip to content

Instantly share code, notes, and snippets.

@Naios
Last active September 5, 2015 19:14
Show Gist options
  • Save Naios/8f5790bce28fae39de9a to your computer and use it in GitHub Desktop.
Save Naios/8f5790bce28fae39de9a to your computer and use it in GitHub Desktop.
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.felix.main.AutoProcessor;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
public class Main
{
private final static String ext = "javafx.animation, javafx.application, javafx.beans, javafx.beans.binding, javafx.beans.property, javafx.beans.property.adapter, javafx.beans.value," +
"javafx.collections, javafx.collections.transformation, javafx.concurrent, javafx.embed.swing, javafx.embed.swt, javafx.event, javafx.fxml, javafx.geometry, javafx.scene, javafx.scene.canvas," +
"javafx.scene.chart, javafx.scene.control, javafx.scene.control.cell, javafx.scene.effect, javafx.scene.image, javafx.scene.input, javafx.scene.layout," +
"javafx.scene.media, javafx.scene.paint, javafx.scene.shape, javafx.scene.text, javafx.scene.transform, javafx.scene.web, javafx.stage, javafx.util," +
"javafx.util.converter, javafx.css," +
"com.sun.javafx, com.sun.javafx.collections, com.sun.javafx.css, com.sun.javafx.css.converters," +
"com.sun.javafx.event, com.sun.javafx.runtime, com.sun.javafx.scene.control, com.sun.javafx.scene.control.behavior," +
"com.sun.javafx.scene.control.skin, com.sun.javafx.scene.text, com.sun.javafx.scene.traversal," +
"com.sun.javafx.tk, com.sun.javafx.webkit, com.sun.webkit";
private static final String bundleDir = "bundles";
public static void main(final String[] args)
{
final PrintStream outfile;
try
{
outfile = new PrintStream(new BufferedOutputStream(new FileOutputStream("WIde.log")));
System.setOut(outfile);
System.setErr(outfile);
}
catch (final FileNotFoundException e1)
{
e1.printStackTrace();
return;
}
// new JFrame("im running").setVisible(true);
// final Map<String, String> config = org.apache.felix.main.Main.loadConfigProperties();
// org.apache.felix.main.Main.copySystemProperties(config);
final Map<String, String> config = new HashMap<>();
System.getProperties().forEach((key, value) -> config.put(key.toString(), value.toString()));
config.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERTY, bundleDir);
config.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERTY, "install,update,start");
config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
config.put(Constants.FRAMEWORK_STORAGE, "cache");
// Use ext path
config.put("org.osgi.framework.system.packages.extra", ext);
// config.put("felix.log.level", "1");
config.put("org.ops4j.pax.logging.DefaultServiceLog.level", "INFO");
/*
config.put("log4j.rootLogger", "WARN" + ", A1");
config.put("log4j.appender.A1", "org.apache.log4j.ConsoleAppender");
config.put("log4j.appender.A1.layout", "org.apache.log4j.TTCCLayout");
*/
final FrameworkFactory factory = new org.apache.felix.framework.FrameworkFactory();
final Framework framework = factory.newFramework(config);
config.entrySet().stream().forEach(e -> System.out.println(String.format("%s = %s", e.getKey(), e.getValue())));
System.out.println("Starting environment...");
try
{
framework.init();
AutoProcessor.process(config, framework.getBundleContext());
FrameworkEvent event;
do
{
framework.start();
event = framework.waitForStop(0L);
}
while (event.getType() == 128);
}
catch (final Throwable e)
{
e.printStackTrace();
}
outfile.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment