Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: wtk
    • Labels:
      None
    1. pivot-osgi.patch
      4 kB
      Stephen Evanchik

      Activity

      Hide
      Andrei Pozolotin added a comment -

      Sandro:
      do you need me to produce a patch for introductory steps:
      1) add 3 files from PIVOT-742
      <run existing tests>
      2) replace TCCL for pivot-core
      <run existing tests>
      3) replace TCCL for pivot-wtk
      <run existing tests>
      ?
      Andrei

      Show
      Andrei Pozolotin added a comment - Sandro: do you need me to produce a patch for introductory steps: 1) add 3 files from PIVOT-742 <run existing tests> 2) replace TCCL for pivot-core <run existing tests> 3) replace TCCL for pivot-wtk <run existing tests> ? Andrei
      Hide
      Andrei Pozolotin added a comment -

      Service::
      public static Object getProvider(String providerName) {
      first uses TCCL
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      InputStream serviceInputStream = classLoader.getResourceAsStream(serviceName);
      but then system loader
      providerClass = Class.forName(providerClassName);

      etc.

      there are few default Class.forName calls:
      14 in pivot-core
      16 in pivot-wtk

      Show
      Andrei Pozolotin added a comment - Service:: public static Object getProvider(String providerName) { first uses TCCL ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream serviceInputStream = classLoader.getResourceAsStream(serviceName); but then system loader providerClass = Class.forName(providerClassName); etc. there are few default Class.forName calls: 14 in pivot-core 16 in pivot-wtk
      Hide
      Andrei Pozolotin added a comment -

      1) cool, got it. my current osgi test is developed here (feel free to scavange, its bsd):
      https://github.com/carrot-garden/carrot-tester/tree/master/carrot-test-osgi-ws
      but its all maven, which Greg hates, and I can not go back to ant

      2) the major change would be mass edit of TCCL, which is covered by your current tests

      3) there are some problematic areas, which I do not fully see through; like this:

      a)
      public BXMLSerializer() {
      uses
      scriptEngineManager = new javax.script.ScriptEngineManager();
      and not
      public ScriptEngineManager(ClassLoader loader) {

      b)
      public BXMLSerializer(final ClassLoader classLoader) {
      is used
      if (classLoader == null)

      { propertyClass = Class.forName(propertyClassName); }

      else

      { propertyClass = Class.forName(propertyClassName, true, classLoader); }

      separately from TCCL (so you currently you have to use both TCCL and non default constructor)

      Show
      Andrei Pozolotin added a comment - 1) cool, got it. my current osgi test is developed here (feel free to scavange, its bsd): https://github.com/carrot-garden/carrot-tester/tree/master/carrot-test-osgi-ws but its all maven, which Greg hates, and I can not go back to ant 2) the major change would be mass edit of TCCL, which is covered by your current tests 3) there are some problematic areas, which I do not fully see through; like this: a) public BXMLSerializer() { uses scriptEngineManager = new javax.script.ScriptEngineManager(); and not public ScriptEngineManager(ClassLoader loader) { b) public BXMLSerializer(final ClassLoader classLoader) { is used if (classLoader == null) { propertyClass = Class.forName(propertyClassName); } else { propertyClass = Class.forName(propertyClassName, true, classLoader); } separately from TCCL (so you currently you have to use both TCCL and non default constructor)
      Hide
      Sandro Martini added a comment -

      Andrei, as you I'd start to look at PIVOT-742, but at the moment we don't have an OSGi test ... to speedup things if you have one please attach here (and grant for inclusion in ASF derived work), or I'll try to make something and post here some update, but not before some weeks (we have to close the 2.0.1 release before) ...thank you very much for now.

      Bye,
      Sandro

      Show
      Sandro Martini added a comment - Andrei, as you I'd start to look at PIVOT-742 , but at the moment we don't have an OSGi test ... to speedup things if you have one please attach here (and grant for inclusion in ASF derived work), or I'll try to make something and post here some update, but not before some weeks (we have to close the 2.0.1 release before) ...thank you very much for now. Bye, Sandro
      Hide
      Andrei Pozolotin added a comment -

      Sandro: thanks for looking into this. I do not understand pivot deep enogh to make up my mind. Forced to make decision right now, I would go with https://issues.apache.org/jira/browse/PIVOT-742 (pluggable classloader). Few issues cause perplexity; for example, if I load pivot-wtk and pivot-skin-terra in system bundle and then download custom pivot skin in plugin bundle, how can I expose new skin to the wtk? etc. Andrei.

      Show
      Andrei Pozolotin added a comment - Sandro: thanks for looking into this. I do not understand pivot deep enogh to make up my mind. Forced to make decision right now, I would go with https://issues.apache.org/jira/browse/PIVOT-742 (pluggable classloader). Few issues cause perplexity; for example, if I load pivot-wtk and pivot-skin-terra in system bundle and then download custom pivot skin in plugin bundle, how can I expose new skin to the wtk? etc. Andrei.
      Hide
      Sandro Martini added a comment - - edited

      Hi Andrei, thanks for all the info ...

      On the Classloader refactoring I'm with you, I like the idea to have something like a centralized/class handling a general way how Pivot classes load other classes.
      In the article ( http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html ) I like Option 1 (for a common, centralized solution, with 1..n implementations, our or in applications code) or 3 (like we currently do in BXMLSerializer).

      But on the part with (so much) Code refactoring I think it would be better for a future release of Pivot (3.0) ?
      So maybe we could split this (complex) task in many jira tickets.

      Related issues (but at the moment not subtasks):
      https://issues.apache.org/jira/browse/PIVOT-742
      https://issues.apache.org/jira/browse/PIVOT-743

      Greg (and all others), Andrei, comments ?

      Bye,
      Sandro

      Show
      Sandro Martini added a comment - - edited Hi Andrei, thanks for all the info ... On the Classloader refactoring I'm with you, I like the idea to have something like a centralized/class handling a general way how Pivot classes load other classes. In the article ( http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html ) I like Option 1 (for a common, centralized solution, with 1..n implementations, our or in applications code) or 3 (like we currently do in BXMLSerializer). But on the part with (so much) Code refactoring I think it would be better for a future release of Pivot (3.0) ? So maybe we could split this (complex) task in many jira tickets. Related issues (but at the moment not subtasks): https://issues.apache.org/jira/browse/PIVOT-742 https://issues.apache.org/jira/browse/PIVOT-743 Greg (and all others), Andrei, comments ? Bye, Sandro
      Show
      Andrei Pozolotin added a comment - one set of solutions: http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html
      Hide
      Andrei Pozolotin added a comment -

      good problem definition; (does not work for non-equinox frameworks)

      http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements

      Show
      Andrei Pozolotin added a comment - good problem definition; (does not work for non-equinox frameworks) http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements
      Hide
      Andrei Pozolotin added a comment -

      also, additional pivot refactoring is required to resolve this:

      https://issues.apache.org/jira/browse/FELIX-2951

      http://stackoverflow.com/questions/2198928/better-handling-of-thread-context-classloader-in-osgi

      ClassLoader tccl = Thread.currentThread().getContextClassLoader();
      try

      { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); /* * Start threads, or establish connections, here, now */ }

      finally

      { Thread.currentThread().setContextClassLoader(tccl); }
      Show
      Andrei Pozolotin added a comment - also, additional pivot refactoring is required to resolve this: https://issues.apache.org/jira/browse/FELIX-2951 http://stackoverflow.com/questions/2198928/better-handling-of-thread-context-classloader-in-osgi ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); /* * Start threads, or establish connections, here, now */ } finally { Thread.currentThread().setContextClassLoader(tccl); }
      Hide
      Andrei Pozolotin added a comment -

      1) testing bundles are produced here:
      https://github.com/carrot-garden/carrot-apache-pivot

      2) note that pivot packages need refactoring, like put private classes into "org.apache.pivot.xxx.impl.xxx"
      http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
      Default Behavior
      <Export-Package> is now assumed to be the set of packages in your local Java sources, excluding the default package '.' and any packages containing 'impl' or 'internal'.

      3) currently pivot exports probably too much:

      Manifest-Version: 1.0
      Export-Package: org.apache.pivot.json;uses:="org.apache.pivot.beans,or
      g.apache.pivot.collections,org.apache.pivot.util,org.apache.pivot.ser
      ialization,org.apache.pivot.io",org.apache.pivot.xml;uses:="org.apach
      e.pivot.collections,org.apache.pivot.util,javax.xml.stream,org.apache
      .pivot.serialization",org.apache.pivot.serialization;uses:="org.apach
      e.pivot.collections,org.apache.pivot.util,org.apache.pivot.io,org.apa
      che.pivot.beans,org.apache.pivot.collections.adapter",org.apache.pivo
      t.collections;uses:="org.apache.pivot.util",org.apache.pivot.collecti
      ons.adapter;uses:="org.apache.pivot.collections,org.apache.pivot.util
      ",org.apache.pivot.collections.concurrent;uses:="org.apache.pivot.col
      lections,org.apache.pivot.util",org.apache.pivot.collections.immutabl
      e;uses:="org.apache.pivot.collections,org.apache.pivot.util",org.apac
      he.pivot.util;uses:="org.apache.pivot.serialization,org.apache.pivot.
      collections,org.apache.pivot.json",org.apache.pivot.util.concurrent;u
      ses:="org.apache.pivot.collections,org.apache.pivot.util",org.apache.
      pivot.beans;uses:="org.apache.pivot.collections,javax.script,javax.xm
      l.stream,javax.xml.stream.util,org.apache.pivot.util,org.apache.pivot
      .serialization,org.apache.pivot.json",org.apache.pivot.sql;uses:="org
      .apache.pivot.collections,org.apache.pivot.util",org.apache.pivot.io;
      uses:="org.apache.pivot.collections.adapter,javax.activation,org.apac
      he.pivot.serialization,org.apache.pivot.util.concurrent",org.apache.p
      ivot.text
      Built-By: user1
      Tool: Bnd-1.15.0
      Bundle-Name: pivot-core
      Created-By: Apache Maven Bundle Plugin
      Bundle-Vendor: carrotgarden
      Build-Jdk: 1.6.0_23
      Bundle-Version: 2.1.0.SNAPSHOT
      Bnd-LastModified: 1305056779822
      Bundle-ManifestVersion: 2
      Bundle-License: http://www.opensource.org/licenses/bsd-license.php
      Bundle-Description: pivot-core
      Bundle-DocURL: http://www.carrotgarden.com/
      Bundle-SymbolicName: com.carrotgarden.pivot-core
      Import-Package: javax.activation,javax.script,javax.xml.stream,javax.x
      ml.stream.util

      Show
      Andrei Pozolotin added a comment - 1) testing bundles are produced here: https://github.com/carrot-garden/carrot-apache-pivot 2) note that pivot packages need refactoring, like put private classes into "org.apache.pivot.xxx.impl.xxx" http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html Default Behavior <Export-Package> is now assumed to be the set of packages in your local Java sources, excluding the default package '.' and any packages containing 'impl' or 'internal'. 3) currently pivot exports probably too much: Manifest-Version: 1.0 Export-Package: org.apache.pivot.json;uses:="org.apache.pivot.beans,or g.apache.pivot.collections,org.apache.pivot.util,org.apache.pivot.ser ialization,org.apache.pivot.io",org.apache.pivot.xml;uses:="org.apach e.pivot.collections,org.apache.pivot.util,javax.xml.stream,org.apache .pivot.serialization",org.apache.pivot.serialization;uses:="org.apach e.pivot.collections,org.apache.pivot.util,org.apache.pivot.io,org.apa che.pivot.beans,org.apache.pivot.collections.adapter",org.apache.pivo t.collections;uses:="org.apache.pivot.util",org.apache.pivot.collecti ons.adapter;uses:="org.apache.pivot.collections,org.apache.pivot.util ",org.apache.pivot.collections.concurrent;uses:="org.apache.pivot.col lections,org.apache.pivot.util",org.apache.pivot.collections.immutabl e;uses:="org.apache.pivot.collections,org.apache.pivot.util",org.apac he.pivot.util;uses:="org.apache.pivot.serialization,org.apache.pivot. collections,org.apache.pivot.json",org.apache.pivot.util.concurrent;u ses:="org.apache.pivot.collections,org.apache.pivot.util",org.apache. pivot.beans;uses:="org.apache.pivot.collections,javax.script,javax.xm l.stream,javax.xml.stream.util,org.apache.pivot.util,org.apache.pivot .serialization,org.apache.pivot.json",org.apache.pivot.sql;uses:="org .apache.pivot.collections,org.apache.pivot.util",org.apache.pivot.io; uses:="org.apache.pivot.collections.adapter,javax.activation,org.apac he.pivot.serialization,org.apache.pivot.util.concurrent",org.apache.p ivot.text Built-By: user1 Tool: Bnd-1.15.0 Bundle-Name: pivot-core Created-By: Apache Maven Bundle Plugin Bundle-Vendor: carrotgarden Build-Jdk: 1.6.0_23 Bundle-Version: 2.1.0.SNAPSHOT Bnd-LastModified: 1305056779822 Bundle-ManifestVersion: 2 Bundle-License: http://www.opensource.org/licenses/bsd-license.php Bundle-Description: pivot-core Bundle-DocURL: http://www.carrotgarden.com/ Bundle-SymbolicName: com.carrotgarden.pivot-core Import-Package: javax.activation,javax.script,javax.xml.stream,javax.x ml.stream.util
      Hide
      Niclas Hedhman added a comment - - edited

      Instead of introducing Maven just for this, i suggest that you use the BND tool's Ant support directly. The Maven plugin is effectively just a wrapper around BND anyway. See http://www.aqute.biz/Bnd

      Show
      Niclas Hedhman added a comment - - edited Instead of introducing Maven just for this, i suggest that you use the BND tool's Ant support directly. The Maven plugin is effectively just a wrapper around BND anyway. See http://www.aqute.biz/Bnd
      Hide
      Sandro Martini added a comment -

      Greg, is it ok for you if I assign this ticket to me (so I can better remember to make some test on it) ?
      And the first of (all) us that has some time and interest on this, re-assign to him ...

      Show
      Sandro Martini added a comment - Greg, is it ok for you if I assign this ticket to me (so I can better remember to make some test on it) ? And the first of (all) us that has some time and interest on this, re-assign to him ...
      Hide
      Sandro Martini added a comment -

      As a starting point, I'm thinking to add the generation of OSGi-compatible manifest inside our jars, but only in a maven build environment (but absolutely NOT as a replacement for our current Ant based build system), so anyone needing this feature could use it.
      And maybe to simplify maybe only adding the OSGi-fy jars task for existing Pivot jars (if possible).

      Last, I'm not sure (by license constraints) if we can use the library needed to do the wrap, and if not possible here, move this stuff in one of our secondary projects (with relaxed license constraints).

      After this, we have to see inside an OSGi environment if Pivot works good, but that's another story ...

      Sandro

      Show
      Sandro Martini added a comment - As a starting point, I'm thinking to add the generation of OSGi-compatible manifest inside our jars, but only in a maven build environment (but absolutely NOT as a replacement for our current Ant based build system), so anyone needing this feature could use it. And maybe to simplify maybe only adding the OSGi-fy jars task for existing Pivot jars (if possible). Last, I'm not sure (by license constraints) if we can use the library needed to do the wrap, and if not possible here, move this stuff in one of our secondary projects (with relaxed license constraints). After this, we have to see inside an OSGi environment if Pivot works good, but that's another story ... Sandro
      Hide
      Sandro Martini added a comment - - edited

      Some reference to articles explaining how to do this:

      http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

      http://www.lucamasini.net/Home/osgi-with-felix/creating-osgi-bundles-of-your-maven-dependencies

      Maybe for the 2.1 release we could try to see what happens enabling this (but enabling maven build only for this).

      And after, we should have also some unit test (maybe defined and executed in the same maven build file) to see if all is working in a (felix) OSGi environment.

      Show
      Sandro Martini added a comment - - edited Some reference to articles explaining how to do this: http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html http://www.lucamasini.net/Home/osgi-with-felix/creating-osgi-bundles-of-your-maven-dependencies Maybe for the 2.1 release we could try to see what happens enabling this (but enabling maven build only for this). And after, we should have also some unit test (maybe defined and executed in the same maven build file) to see if all is working in a (felix) OSGi environment.
      Hide
      Todd Volkert added a comment -

      Stephen, I've submitted the patch - thanks!

      Show
      Todd Volkert added a comment - Stephen, I've submitted the patch - thanks!
      Hide
      Stephen Evanchik added a comment -

      Here is a patch that wraps the current Maven build structure so that it not only builds Pivot (binary and source packages) but also wraps them with the necessary OSGi metadata. I have attempted to make the WTK package sane: I don't think it requires the LiveConnect code or javax.script in all execution cases so I have made their resolution optional.

      Show
      Stephen Evanchik added a comment - Here is a patch that wraps the current Maven build structure so that it not only builds Pivot (binary and source packages) but also wraps them with the necessary OSGi metadata. I have attempted to make the WTK package sane: I don't think it requires the LiveConnect code or javax.script in all execution cases so I have made their resolution optional.
      Hide
      Greg Brown added a comment -

      You might look at Apache Felix:

      http://felix.apache.org/site/index.html

      Show
      Greg Brown added a comment - You might look at Apache Felix: http://felix.apache.org/site/index.html
      Hide
      Todd Volkert added a comment -

      Since this ticket is marked against Pivot 2.0, it means it's pretty forward-looking and not really scoped at all. For the PDFLens project, I'd suggest that you build application-level plug-in support in the application code itself.

      Show
      Todd Volkert added a comment - Since this ticket is marked against Pivot 2.0, it means it's pretty forward-looking and not really scoped at all. For the PDFLens project, I'd suggest that you build application-level plug-in support in the application code itself.
      Hide
      倪森 added a comment -

      We will begin a pdf gui base pdfbox. We choose Pivot as GUI API. We need a plugins system.

      Show
      倪森 added a comment - We will begin a pdf gui base pdfbox. We choose Pivot as GUI API. We need a plugins system.

        People

        • Assignee:
          Sandro Martini
          Reporter:
          Greg Brown
        • Votes:
          2 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

          • Created:
            Updated:

            Development