Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [concierge-dev] Concierge embedded in JavaFX application

This is tested in the framework.launch TCK.

--Jan.

Inactive hide details for Jochen Hiller ---12/03/2014 06:58:28 AM---Hi all, in OSGi Spec R5 Chapter 10.1.6.48 there is a OSGi pJochen Hiller ---12/03/2014 06:58:28 AM---Hi all, in OSGi Spec R5 Chapter 10.1.6.48 there is a OSGi property

From: Jochen Hiller <jo.hiller@xxxxxxxxxxxxxx>
To: Concierge developer discussions <concierge-dev@xxxxxxxxxxx>
Date: 12/03/2014 06:58 AM
Subject: Re: [concierge-dev] Concierge embedded in JavaFX application
Sent by: concierge-dev-bounces@xxxxxxxxxxx





Hi all,

in OSGi Spec R5 Chapter 10.1.6.48 there is a OSGi property "org.osgi.framework.bundle.parent" which can be app, boot, ext, framework.
I assume the Equinox property is mapped internally to this setting.

Concierge actually supports this configuration, and even "ext" should work (goes up to root classloader). See Concierge constructor.

@Ladislav: can you retest that by setting this property, not "osgi.parent"?

@Jan, is that reflected in TCK? Maybe we have to add test cases?


Bye, Jochen


On Wed, Dec 3, 2014 at 1:21 PM, Tim Verbelen <tim.verbelen@xxxxxxxxxxxxxx> wrote:
    Hi,

    Indeed, apparently Equinox allows you to set a parent classloader, in this case set to "ext", which means the system classloader will load any of the packages in .jars in the ext folder of the JVM. This will probably contain the javafx packages.

    In Concierge we don't have such a property, as this is something Equinox specific (I think) and is not described in the OSGi core spec. The org.osgi.framework.bootdelegation property on the other hand is part of the OSGi core spec, and actually achieves the same result.

    Cheers,

    Tim


    On 12/03/2014 12:34 PM, Ladislav Török wrote:
      Thanks all.
      Problem resolved!
      But I have other question.
      Equinox not set none javafx.* packages at starting framework. And also in bundles for sample 'DukePad' below not set none javafx.* packages in header Import-Package in MANFEST:FILE.
      Is it possible for Concierge?
      I think that related with line initialProperties.put("osgi.parentClassloader","ext"); What is it?
      Thanks again to all.


      2014-12-03 11:10 GMT+01:00 Jochen Hiller <jo.hiller@xxxxxxxxxxxxxx>:
        Hi,
        there are two OSGi properties which are required to understand:

        "org.osgi.framework.system.packages.extra" adds Java packages to "Export-Packages" to System bundle (=Concierge)
        Add here packages if a bundle can not be resolved. If your bundle makes an "Import-Package: javafx.scene" you have to add this to system packages extra as Tim mentioned.
        In your stacktrace I do not see that bundle can not be resolved, so seems to be OK.

        "org.osgi.framework.bootdelegation": adds java packages which will be loaded from System ClassLoader instead of a bundle classloader.
        Concierge does only load java.* classes from System ClassLoader, which is exactly according to OSGi spec.
        If you will use other classes from rt.jar (javax.*, sun.*) or in your case (javafx.*) you have to add them to this property.

        So: set of org.osgi.framework.bootdelegation=javafx.* may help.

        Bye, Jochen






        On Wed, Dec 3, 2014 at 10:59 AM, Tim Verbelen <tim.verbelen@xxxxxxxxxxxxxx> wrote:
          Hi,

          You will also have to include all used Java FX packages to
          Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA if you want to access them from within OSGi bundles. So in this case you should at least add "javafx.scene".

          Best regards,

          Tim



          On 12/03/2014 10:56 AM, Ladislav Török wrote:
            Now I get exception:

            ---------------------------------------------------------
              Concierge OSGi 5.0.0.alpha on Windows 7 6.1 starting ... (default) startlevel=3
            ---------------------------------------------------------
            ---------------------------------------------------------
              Framework started in 0.003 seconds.
            ---------------------------------------------------------
            Loading XBundle
            Hello from my firstbundle...
            org.osgi.framework.BundleException: Error starting bundle [sk.ltorok.xbundle-1.0.0]
                at org.eclipse.concierge.BundleImpl.activate0(BundleImpl.java:521)
                at org.eclipse.concierge.BundleImpl.activate(BundleImpl.java:473)
                at org.eclipse.concierge.BundleImpl.start(BundleImpl.java:427)
                at org.eclipse.concierge.BundleImpl.start(BundleImpl.java:367)
                at com.javafx.experiments.dukepad.starter.StarterApplication.lambda$startOSGi$27(StarterApplication.java:167)
                at com.javafx.experiments.dukepad.starter.StarterApplication$$Lambda$99/1094701973.run(Unknown Source)
                at com.javafx.experiments.dukepad.starter.StarterApplication$2.run(StarterApplication.java:193)
                at com.sun.javafx.application.PlatformImpl.lambda$null$169(PlatformImpl.java:295)    at com.sun.javafx.application.PlatformImpl.lambda$null$169(PlatformImpl.java:295)
                at com.sun.javafx.application.PlatformImpl$$Lambda$48/540370836.run(Unknown Source)
                at java.security.AccessController.doPrivileged(Native Method)
                at com.sun.javafx.application.PlatformImpl.lambda$runLater$170(PlatformImpl.java:294)
                at com.sun.javafx.application.PlatformImpl$$Lambda$47/1232367853.run(Unknown Source)
                at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
                at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
                at com.sun.glass.ui.win.WinApplication.lambda$null$144(WinApplication.java:101)
                at com.sun.glass.ui.win.WinApplication$$Lambda$36/1161082381.run(Unknown Source)
                at java.lang.Thread.run(Thread.java:745)
            Caused by: java.lang.NoClassDefFoundError: javafx/scene/Scene
                at sk.ltorok.xbundle.Activator.start(Activator.java:20)
                at org.eclipse.concierge.BundleImpl.activate0(BundleImpl.java:496)
                ... 16 more
            Caused by: java.lang.ClassNotFoundException: javafx.scene.Scene
                at org.eclipse.concierge.BundleImpl$Revision$BundleClassLoader.findClass(BundleImpl.java:2431)
                at org.eclipse.concierge.BundleImpl$Revision$BundleClassLoader.loadClass(BundleImpl.java:2410)
                ... 18 more
            BUILD STOPPED (total time: 36 seconds

            What I could still try?

            Thanks.

            2014-12-03 8:39 GMT+01:00 Jan S Rellermeyer <rellermeyer@xxxxxxxxxx>:
              From looking at your code I could imagine that our use of Constants.FRAMEWORK_SYSTEMPACKAGES is causing the problem. I would recommend to better use Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA instead because otherwise you are overwriting the defaults and that could cause the resolver to fail because nothing exports org.osgi.framework anymore. The "EXTRA" version keeps the defaults and allows you to add additional packages to it which is what you really want.

              --Jan.  


              Inactive hide details for
                                      Ladislav Török ---12/03/2014
                                      01:16:33 AM---I'm trying to
                                      replace Equinox to Concierge in
                                      project DukeLadislav Török ---12/03/2014 01:16:33 AM---I'm trying to replace Equinox to Concierge in project Dukepad - see: https://wiki.openjdk.java.net/d

              From:
              Ladislav Török <ltorokrl@xxxxxxxxx>
              To:
              Concierge developer discussions <concierge-dev@xxxxxxxxxxx>
              Date:
              12/03/2014 01:16 AM
              Subject:
              Re: [concierge-dev] Concierge embedded in JavaFX application
              Sent by:
              concierge-dev-bounces@xxxxxxxxxxx




              I'm trying to replace Equinox to Concierge in project Dukepad - see:
              https://wiki.openjdk.java.net/display/OpenJFX/DukePad


              I am using class ' StarterApplication' as my main JavaFX application:

              package com.javafx.experiments.dukepad.starter;

              import javafx.application.Application;
              import javafx.application.Platform;
              import javafx.scene.DepthTest;
              import javafx.scene.Group;
              import javafx.scene.PerspectiveCamera;
              import javafx.scene.Scene;
              import javafx.scene.image.Image;
              import javafx.scene.image.ImageView;
              import javafx.scene.paint.Color;
              import javafx.scene.text.Font;
              import javafx.scene.text.Text;
              import javafx.stage.Stage;
              import javafx.stage.StageStyle;
              import org.eclipse.core.runtime.adaptor.EclipseStarter;
              import org.osgi.framework.Bundle;
              import org.osgi.framework.BundleContext;
              import org.osgi.framework.BundleException;

              import java.io.File;
              import java.net.MalformedURLException;
              import java.util.*;
              import org.eclipse.concierge.Factory;
              import org.osgi.framework.Constants;
              import org.osgi.framework.launch.Framework;

              /**
               * Starter for DukePad platform
               */
              public class StarterApplication extends Application {
                  private Framework framework;
                 
                  private Stage primaryStage;
                  private Scene scene;
                  private final LinkedList<Runnable> loadingTasks = new LinkedList<>();
                  private final List<Bundle> bundles = new ArrayList<>();

                  public void start(Stage primaryStage) {
                      // create main window and show splash screen
                      this.primaryStage = primaryStage;
                      ImageView bootScreen = new ImageView(new Image(StarterApplication.class.getResource("/Duke-Startup.jpg").toExternalForm(),false));
                      Text loadingText = new Text("Loading...");
                      loadingText.setFont(Font.font("System",24));
                      loadingText.setFill(Color.rgb(255, 255, 255, 0.8));
                      loadingText.setX(30);
                      loadingText.setY(50);
                      scene = new Scene(new Group(bootScreen,loadingText), 1300, 800);
              //        scene.setFill(Color.BLACK);
              //        scene.setFill(Color.TRANSPARENT);
                      scene.setFill(Color.RED);
              //        primaryStage.initStyle(StageStyle.UNDECORATED);
                      primaryStage.initStyle(StageStyle.TRANSPARENT);
                      primaryStage.setScene(scene);
                      primaryStage.show();

                      // boot OSGi in own thread
                      Platform.runLater(() -> startOSGi(loadingText));
                  }

                  private void startOSGi(final Text loadingText) {
                      try {
                          // CONFIGURE OSGI
                          //String[] equinoxArgs = {"-clean",/*"-consoleLog",*/"-console","-dev","bin"};
                          Map<String,String> initialProperties = new HashMap<>();
              //            initialProperties.put("osgi.console.enable.builtin", "true");
              //            initialProperties.put("osgi.parentClassloader","ext");
              //            initialProperties.put("org.osgi.framework.system.packages","sun.misc,java,javax,javax.net.ssl,javax.security.cert,javax.naming,javax.naming.directory,javax.security.auth,javax.security.auth.x500");
              //            EclipseStarter.setInitialProperties(initialProperties);
                         
                          initialProperties.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT);
                          initialProperties.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "sun.misc,java,javax,javax.net.ssl,javax.security.cert,javax.naming,javax.naming.directory,javax.security.auth,javax.security.auth.x500");
                         
                          // START OSGI
                          //final BundleContext context = EclipseStarter.startup(equinoxArgs, null);
                          Factory factory = new Factory();
                          framework = factory.newFramework(initialProperties);
                          framework.init();
                          framework.start();
                         
                          final BundleContext context = framework.getBundleContext();
                          // REGISTER SCENE AND STAGE AS SERVICES
                          context.registerService(Scene.class,scene, null);
                          context.registerService(Stage.class,primaryStage, null);

                          // Create tasks to install all jar bundles in bundles directory
                          File bundleDir = new File("bundles");
                          if (bundleDir.exists()) {
                              File[] bundleJars = bundleDir.listFiles();
                              if (bundleJars != null) {
                                  // load app modules
                                  for (final File file: bundleJars) {
                                      if (file.getName().endsWith(".jar")) {
                                          loadingTasks.add(() -> {
                                              final String name = file.getName().substring(0,file.getName().lastIndexOf('.'));
                                              loadingText.setText("Loading " + name);
                                              System.out.println("Loading " + name);
                                              try {
                                                  bundles.add(context.installBundle(file.toURI().toURL().toExternalForm()));
                                              } catch (Exception e) {
                                                  e.printStackTrace();
                                              }
                                          });
                                      }
                                  }
                              }
                          }
                          // Create task to start all bundles
                          loadingTasks.add(() -> {
                              for (Bundle b: bundles) {
                                  loadingTasks.push(() -> {
                                      loadingText.setText("Starting " + b.getSymbolicName());
                                      System.out.println("Starting " + b.getSymbolicName());
                                      try {
                                          b.start();
                                      } catch (BundleException e) {
                                          e.printStackTrace();
                                      }
                                  });
                              }
                          });
                          // Create task to install and start all bundles in apps directory
                          File appDir = new File("D:\\applications");
                          if (appDir.exists()) {
                              File[] appJars = appDir.listFiles();
                              if (appJars != null) {
                                  // sort alphabetical
                                  Arrays.sort(appJars,new Comparator<File>() {
                                      @Override public int compare(File o1, File o2) {
                                      return o1.getName().compareTo(o2.getName());
                                      }
                                  });
                                  // load app modules
                                  for (File file: appJars) {
                                      if (file.getName().endsWith(".jar")) {
                                          loadingTasks.add(() -> {
                                              final String name = file.getName().substring(0,file.getName().lastIndexOf('.'));
                                              loadingText.setText("Loading " + name);
                                              System.out.println("Loading " + name);
                                              try {
                                                  Bundle bundle = context.installBundle(file.toURI().toURL().toExternalForm());
                                                  bundle.start();
                                              } catch (Exception e) {
                                                  e.printStackTrace();
                                              }
                                          });
                                      }
                                  }
                              }
                          }
                      } catch(Exception e) {
                          e.printStackTrace();
                      }

                      // start executing all the tasks we have queued up
                      runNextStartupTask();
                  }

                  /**
                   * Execute each task from list in order in separate platform.runLater(). This allows FX to draw the screen
                   * between tasks.
                   */
                  private void runNextStartupTask() {
                      if (loadingTasks.isEmpty()) return;
                      final Runnable task = loadingTasks.pop();
                      Platform.runLater(new Runnable() {
                          @Override public void run() {
                              task.run();
                              runNextStartupTask();
                          }
                      });
                  }

                  @Override public void stop() throws Exception {
                      System.out.println("StarterApplication.stop");
                      //EclipseStarter.shutdown();
                      framework.stop();
                  }

                  public static void main(String[] args) {
              //        System.setProperty("org.osgi.framework.system.packages.extra","javafx.application");
                      launch(args);
                  }
              }

              and class 'Activator' as bundle:

              package sk.ltorok.xbundle;

              import javafx.scene.Scene;
              import javafx.scene.paint.Color;
              import org.osgi.framework.BundleActivator;
              import org.osgi.framework.BundleContext;

              public class Activator implements BundleActivator {

                  @Override
                  public void start(BundleContext context) throws Exception {
                      System.out.println("Hello from my firstbundle...");

                      // Get Scene Service
                      Scene scene = context.getService(context.getServiceReference(Scene.class));
              //        System.out.println(scene.toString());
              //        System.out.println(scene.getFill().toString());
              //        scene.setFill(Color.YELLOW);
                  }

                  @Override
                  public void stop(BundleContext context) throws Exception {
                      System.out.println("Bye from my firstbundle...");
                  }

              }

              MANIFEST.MF file for bundle above is:

              Manifest-Version: 1.0
              Ant-Version: Apache Ant 1.9.2
              Created-By: 1.8.0_40-ea-b15 (Oracle Corporation)
              Bundle-Version: 1.0.0
              Bundle-Name: sk.ltorok.xbundle
              Bundle-Activator: sk.ltorok.xbundle.Activator
              Bundle-ManifestVersion: 2
              Bundle-SymbolicName: sk.ltorok.xbundle
              Import-Package: org.osgi.framework
              Require-Bundle: sk.ltorok.xbundle

              after run 'StarterApplication' I get Exception:

              ---------------------------------------------------------
                Concierge OSGi 5.0.0.alpha on Windows 7 6.1 starting ... (default) startlevel=3
              ---------------------------------------------------------
              ---------------------------------------------------------
                Framework started in 0.003 seconds.
              ---------------------------------------------------------
              Loading XBundle
              org.osgi.framework.BundleException: Resolution failed [BundleRequirement{Import-Package org.osgi.framework}]
                  at org.eclipse.concierge.Concierge.resolve(Concierge.java:2435)
                  at org.eclipse.concierge.BundleImpl$Revision.resolve(BundleImpl.java:1816)
                  at org.eclipse.concierge.BundleImpl.activate(BundleImpl.java:453)
                  at org.eclipse.concierge.BundleImpl.start(BundleImpl.java:427)
                  at org.eclipse.concierge.BundleImpl.start(BundleImpl.java:367)
                  at com.javafx.experiments.dukepad.starter.StarterApplication.lambda$startOSGi$27(StarterApplication.java:167)
                  at com.javafx.experiments.dukepad.starter.StarterApplication$$Lambda$101/1330056022.run(Unknown Source)
                  at com.javafx.experiments.dukepad.starter.StarterApplication$2.run(StarterApplication.java:193)
                  at com.sun.javafx.application.PlatformImpl.lambda$null$169(PlatformImpl.java:295)    at com.sun.javafx.application.PlatformImpl.lambda$null$169(PlatformImpl.java:295)
                  at com.sun.javafx.application.PlatformImpl$$Lambda$48/540370836.run(Unknown Source)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at com.sun.javafx.application.PlatformImpl.lambda$runLater$170(PlatformImpl.java:294)
                  at com.sun.javafx.application.PlatformImpl$$Lambda$47/1232367853.run(Unknown Source)
                  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
                  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
                  at com.sun.glass.ui.win.WinApplication.lambda$null$144(WinApplication.java:101)
                  at com.sun.glass.ui.win.WinApplication$$Lambda$36/1161082381.run(Unknown Source)
                  at java.lang.Thread.run(Thread.java:745)
              BUILD STOPPED (total time: 1 minute 54 seconds)

              When I replace line initialProperties.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT); to initialProperties.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_EXT);
              result is the same.

              Thanks for any help.

              2014-12-02 21:03 GMT+01:00 Jan S Rellermeyer <
              rellermeyer@xxxxxxxxxx>:
                Hi Ladislav,

                Concierge in JavaFX is an interesting problem and I have not tried that myself, nor am I aware of anybody else who did.
                Would you be able to share some basic code/test case that leads to the failure that you describe? That would help us to look into the problem.

                --Jan.


                Inactive hide details for
                                      Ladislav Török ---12/02/2014
                                      02:02:12 PM---I have a problem. I
                                      am embedding (hosting) Concierge
                                      in JaLadislav Török ---12/02/2014 02:02:12 PM---I have a problem. I am embedding (hosting) Concierge in JavaFX application.

                From:
                Ladislav Török <ltorokrl@xxxxxxxxx>
                To:
                concierge-dev@xxxxxxxxxxx
                Date:
                12/02/2014 02:02 PM
                Subject:
                [concierge-dev] Concierge embedded in JavaFX application
                Sent by:
                concierge-dev-bounces@xxxxxxxxxxx




                I have a problem.
                I am embedding (hosting) Concierge in JavaFX application.
                I have created bundle. Bundle after install and start change background color in main javafx application, but after start bundle  I get exception.
                Is possible embedded-hosted Concierge in JavaFX application? Please any simple example. Thanks.
                _______________________________________________
                concierge-dev mailing list

                concierge-dev@xxxxxxxxxxx
                To change your delivery options, retrieve your password, or unsubscribe from this list, visit

                https://dev.eclipse.org/mailman/listinfo/concierge-dev

                _______________________________________________
                concierge-dev mailing list

                concierge-dev@xxxxxxxxxxx
                To change your delivery options, retrieve your password, or unsubscribe from this list, visit

                https://dev.eclipse.org/mailman/listinfo/concierge-dev 
              _______________________________________________
              concierge-dev mailing list

              concierge-dev@xxxxxxxxxxx
              To change your delivery options, retrieve your password, or unsubscribe from this list, visit

              https://dev.eclipse.org/mailman/listinfo/concierge-dev

              _______________________________________________
              concierge-dev mailing list

              concierge-dev@xxxxxxxxxxx
              To change your delivery options, retrieve your password, or unsubscribe from this list, visit

              https://dev.eclipse.org/mailman/listinfo/concierge-dev



            _______________________________________________
            concierge-dev mailing list
            concierge-dev@xxxxxxxxxxx
            To change your delivery options, retrieve your password, or unsubscribe from this list, visit
            https://dev.eclipse.org/mailman/listinfo/concierge-dev


          --
          Tim Verbelen
          Department of Information Technology
          Broadband Communication Networks (IBCN)
          Ghent University - iMinds
          Gaston Crommenlaan 8 (Bus 201), B-9050 Gent, Belgium
          T: +32 9 33 14940 ; T Secr: +32 9 33 14900
          F: +32 9 33 14899
          E:
          tim.verbelen@xxxxxxxxxxxxxx
          W :
          www.ibcn.intec.UGent.be


          _______________________________________________
          concierge-dev mailing list

          concierge-dev@xxxxxxxxxxx
          To change your delivery options, retrieve your password, or unsubscribe from this list, visit

          https://dev.eclipse.org/mailman/listinfo/concierge-dev


        _______________________________________________
        concierge-dev mailing list

        concierge-dev@xxxxxxxxxxx
        To change your delivery options, retrieve your password, or unsubscribe from this list, visit

        https://dev.eclipse.org/mailman/listinfo/concierge-dev



      _______________________________________________
      concierge-dev mailing list
      concierge-dev@xxxxxxxxxxx
      To change your delivery options, retrieve your password, or unsubscribe from this list, visit
      https://dev.eclipse.org/mailman/listinfo/concierge-dev


    --
    Tim Verbelen
    Department of Information Technology
    Broadband Communication Networks (IBCN)
    Ghent University - iMinds
    Gaston Crommenlaan 8 (Bus 201), B-9050 Gent, Belgium
    T: +32 9 33 14940 ; T Secr: +32 9 33 14900
    F: +32 9 33 14899
    E:
    tim.verbelen@xxxxxxxxxxxxxx
    W :
    www.ibcn.intec.UGent.be


    _______________________________________________
    concierge-dev mailing list

    concierge-dev@xxxxxxxxxxx
    To change your delivery options, retrieve your password, or unsubscribe from this list, visit

    https://dev.eclipse.org/mailman/listinfo/concierge-dev
_______________________________________________
concierge-dev mailing list
concierge-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/concierge-dev

GIF image


Back to the top