Modified example to work with Felix 1.8.0 release.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@783473 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/examples/extenderbased.host/pom.xml b/examples/extenderbased.host/pom.xml
index ecf33fd..1818d58 100644
--- a/examples/extenderbased.host/pom.xml
+++ b/examples/extenderbased.host/pom.xml
@@ -36,7 +36,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
- <version>1.0.4</version>
+ <version>1.8.0</version>
</dependency>
</dependencies>
<build>
@@ -48,10 +48,12 @@
<extensions>true</extensions>
<configuration>
<instructions>
+ <_donotcopy>(CVS|.svn|config.properties)</_donotcopy>
<Main-Class>org.apache.felix.example.extenderbased.host.Activator</Main-Class>
- <Import-Package>!android.dalvik,org.osgi.framework,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker,*</Import-Package>
+ <Import-Package>!android.*,!dalvik.*,org.osgi.framework,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker,*</Import-Package>
<Export-Package>org.apache.felix.example.extenderbased.host.extension.*</Export-Package>
- <Private-Package>org.apache.felix.example.extenderbased.host.*,org.apache.felix.moduleloader.*,org.apache.felix.framework.*,org.apache.felix.main,org.osgi.*</Private-Package>
+ <Private-Package>org.apache.felix.example.extenderbased.host.*</Private-Package>
+ <Embed-Dependency>*;artifactId=org.apache.felix.main;inline=true</Embed-Dependency>
<Bundle-Activator>org.apache.felix.example.extenderbased.host.Activator</Bundle-Activator>
<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
</instructions>
diff --git a/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java b/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java
index 6ab9149..9d49538 100644
--- a/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java
+++ b/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java
@@ -49,9 +49,8 @@
* launch the stand-alone application, it must be run from this bundle's
* installation directory using "<tt>java -jar</tt>".
**/
-public class Activator implements BundleActivator, Runnable
+public class Activator implements BundleActivator
{
- private BundleContext m_context = null;
private DrawingFrame m_frame = null;
private ShapeTracker m_shapetracker = null;
@@ -61,24 +60,34 @@
* and repainting issues.
* @param context The context of the bundle.
**/
- public void start(BundleContext context)
+ public void start(final BundleContext context)
{
- m_context = context;
- if (SwingUtilities.isEventDispatchThread())
- {
- run();
- }
- else
- {
- try
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {
+ // This creates of the application window.
+ public void run()
{
- javax.swing.SwingUtilities.invokeAndWait(this);
+ m_frame = new DrawingFrame();
+ m_frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ m_frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent evt)
+ {
+ try
+ {
+ context.getBundle(0).stop();
+ }
+ catch (BundleException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ m_frame.setVisible(true);
+
+ m_shapetracker = new ShapeTracker(context, m_frame);
+ m_shapetracker.open();
}
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
+ });
}
/**
@@ -87,39 +96,31 @@
**/
public void stop(BundleContext context)
{
- m_shapetracker.close();
- m_frame.setVisible(false);
- m_frame.dispose();
- }
-
- /**
- * This method actually performs the creation of the application window.
- * It is intended to be called by the Swing event thread and should not
- * be called directly.
- **/
- public void run()
- {
- m_frame = new DrawingFrame();
-
- m_frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- m_frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent evt)
+ Runnable runner = new Runnable() {
+ // This disposes of the application window.
+ public void run()
{
- try
- {
- m_context.getBundle(0).stop();
- }
- catch (BundleException ex)
- {
- ex.printStackTrace();
- }
+ m_shapetracker.close();
+ m_frame.setVisible(false);
+ m_frame.dispose();
}
- });
+ };
- m_frame.setVisible(true);
-
- m_shapetracker = new ShapeTracker(m_context, m_frame);
- m_shapetracker.open();
+ if (SwingUtilities.isEventDispatchThread())
+ {
+ runner.run();
+ }
+ else
+ {
+ try
+ {
+ javax.swing.SwingUtilities.invokeAndWait(runner);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
}
/**
@@ -146,20 +147,14 @@
});
Map configMap = new StringMap(false);
- configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
- "org.osgi.framework; version=1.3.0," +
- "org.osgi.service.packageadmin; version=1.2.0," +
- "org.osgi.service.startlevel; version=1.0.0," +
- "org.osgi.service.url; version=1.0.0," +
- "org.osgi.util.tracker; version=1.3.2," +
- "org.apache.felix.example.extenderbased.host.extension; version=1.0.0," +
- "javax.swing");
+ configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
+ "org.apache.felix.example.extenderbased.host.extension; version=1.0.0");
configMap.put(AutoActivator.AUTO_START_PROP + ".1",
"file:../extenderbased.circle/target/extenderbased.circle-1.0.0.jar " +
"file:../extenderbased.square/target/extenderbased.square-1.0.0.jar " +
"file:../extenderbased.triangle/target/extenderbased.triangle-1.0.0.jar");
- configMap.put(FelixConstants.LOG_LEVEL_PROP, "1");
- configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, cachedir.getAbsolutePath());
+ configMap.put(FelixConstants.LOG_LEVEL_PROP, "4");
+ configMap.put(Constants.FRAMEWORK_STORAGE, cachedir.getAbsolutePath());
// Create list to hold custom framework activators.
List list = new ArrayList();
@@ -167,11 +162,13 @@
list.add(new AutoActivator(configMap));
// Add our own activator.
list.add(new Activator());
+ // Add our custom framework activators to the configuration map.
+ configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
try
{
// Now create an instance of the framework.
- Felix felix = new Felix(configMap, list);
+ Felix felix = new Felix(configMap);
felix.start();
}
catch (Exception ex)
@@ -199,4 +196,4 @@
}
file.delete();
}
-}
+}
\ No newline at end of file