felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r783473 - in /felix/trunk/examples/extenderbased.host: pom.xml src/main/java/org/apache/felix/example/extenderbased/host/Activator.java
Date Wed, 10 Jun 2009 19:54:15 GMT
Author: rickhall
Date: Wed Jun 10 19:54:15 2009
New Revision: 783473

URL: http://svn.apache.org/viewvc?rev=783473&view=rev
Log:
Modified example to work with Felix 1.8.0 release.

Modified:
    felix/trunk/examples/extenderbased.host/pom.xml
    felix/trunk/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java

Modified: felix/trunk/examples/extenderbased.host/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/examples/extenderbased.host/pom.xml?rev=783473&r1=783472&r2=783473&view=diff
==============================================================================
--- felix/trunk/examples/extenderbased.host/pom.xml (original)
+++ felix/trunk/examples/extenderbased.host/pom.xml Wed Jun 10 19:54:15 2009
@@ -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>

Modified: felix/trunk/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java?rev=783473&r1=783472&r2=783473&view=diff
==============================================================================
--- felix/trunk/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java
(original)
+++ felix/trunk/examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/Activator.java
Wed Jun 10 19:54:15 2009
@@ -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,18 +60,61 @@
      * and repainting issues.
      * @param context The context of the bundle.
     **/
-    public void start(BundleContext context)
+    public void start(final BundleContext context)
     {
-        m_context = context;
+        javax.swing.SwingUtilities.invokeLater(new Runnable() {
+            // This creates of the application window.
+            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)
+                    {
+                        try
+                        {
+                            context.getBundle(0).stop();
+                        }
+                        catch (BundleException ex)
+                        {
+                            ex.printStackTrace();
+                        }
+                    }
+                });
+
+                m_frame.setVisible(true);
+
+                m_shapetracker = new ShapeTracker(context, m_frame);
+                m_shapetracker.open();
+            }
+        });
+    }
+
+    /**
+     * Stops extension tracking and disposes of the application window.
+     * @param context The context of the bundle.
+    **/
+    public void stop(BundleContext context)
+    {
+        Runnable runner = new Runnable() {
+            // This disposes of the application window.
+            public void run()
+            {
+                m_shapetracker.close();
+                m_frame.setVisible(false);
+                m_frame.dispose();
+            }
+        };
+
         if (SwingUtilities.isEventDispatchThread())
         {
-            run();
+            runner.run();
         }
         else
         {
             try
             {
-                javax.swing.SwingUtilities.invokeAndWait(this);
+                javax.swing.SwingUtilities.invokeAndWait(runner);
             }
             catch (Exception ex)
             {
@@ -82,47 +124,6 @@
     }
 
     /**
-     * Stops extension tracking and disposes of the application window.
-     * @param context The context of the bundle.
-    **/
-    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)
-            {
-                try
-                {
-                    m_context.getBundle(0).stop();
-                }
-                catch (BundleException ex)
-                {
-                    ex.printStackTrace();
-                }
-            }
-        });
-
-        m_frame.setVisible(true);
-
-        m_shapetracker = new ShapeTracker(m_context, m_frame);
-        m_shapetracker.open();
-    }
-
-    /**
      * Enables the bundle to run as a stand-alone application. When this
      * static <tt>main()</tt> method is invoked, the application creates
      * its own embedded Felix framework instance and interacts with the
@@ -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



Mime
View raw message