DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
| No Format |
|---|
launcher/
lib/
org.apache.felix.main-12.40.0.jar
bundle/
org.apache.felix.shell-1.4.0.2.jar
org.apache.felix.shell.tui-1.4.0.2.jar
src/
example/
Main.java
|
...
| Code Block |
|---|
package example; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.HashMap; import org.osgi.framework.Constants; import org.apache.felix.framework.Felix; import org.apache.felix.framework.util.FelixConstantslaunch.Framework; import org.apache.felix.main.AutoActivatorAutoProcessor; public class Main { private static FelixFramework m_felixfwk = null; public static void main(String[] argv) throws Exception { // Print welcome banner. System.out.println("\nWelcome to Felix."); System.out.println("=================\n"); try Map configMap = new HashMap();{ configMap.put(AutoActivator.AUTO_START_PROP + ".1", Map configMap = new HashMap(); "file:bundle/org.apache.felix.shell-1.0.2.jar " +m_fwk = getFrameworkFactory().newInstance(configMap); m_fwk.init() "file:bundle/org.apache.felix.shell.tui-1.0.2.jar"AutoProcessor.process(configMap, m_fwk.getBundleContext()); List list = new ArrayListm_fwk.start(); list.add(new AutoActivator(configMap)); m_fwk.waitForStop(); System.exit(0); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); System.exit(-1); } } private static FrameworkFactory getFrameworkFactory() throws Exception { URL url = Main.class.getClassLoader().getResource( "META-INF/services/org.osgi.framework.launch.FrameworkFactory"); if (url != null) { BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream())); try { for (String s = br.readLine(); s != null; s = br.readLine()) { s = s.trim(); // Try to load first non-empty, non-commented line. if ((s.length() > 0) && (s.charAt(0) != '#')) configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list); try{ { m_felix =return new Felix(configMap(FrameworkFactory) Class.forName(s).newInstance(); m_felix.start(); } m_felix.waitForStop(); System.exit(0); } } catch (Exception ex) finally { System.err.println("Could not create framework: " + ex if (br != null) br.close(); ex.printStackTrace();} } System.exit(-1); throw new Exception("Could not find framework }factory."); } } |
This launcher has all information hard coded in it, unlike the default Felix launcher, which loads configuration properties from files and performs variable substitution. This simple relies on the default behavior of AutoProcessor for auto-deploy of the shell bundles. This simple, generic launcher provides a good starting point if the features of the default launcher are not necessary. Since very few configuration properties are specified, the default values are used. In the case of For the bundle auto-deploy directory, "bundle" in the current directory is used, while for the framework bundle cache, it will use "felix-cache" in the current directory is used.
By breaking down the above source code into small chunks, it is quite easy to see what is going on.
...