pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrei Pozolotin <andrei.pozolo...@gmail.com>
Subject Re: pivot + osgi : class loading?
Date Sat, 14 May 2011 04:11:58 GMT
may be Richard will help us:
https://issues.apache.org/jira/browse/FELIX-2951

-------- Original Message  --------
Subject: Re: pivot  + osgi : class loading?
From: Andrei Pozolotin <Andrei.Pozolotin@gmail.com>
To: user@pivot.apache.org
Date: Fri 13 May 2011 10:52:26 PM CDT
> having to use this all the time with pivot:
> 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);
> }|
> would be a bit too much!
>
> -------- Original Message  --------
> Subject: pivot  + osgi : class loading?
> From: Andrei Pozolotin <Andrei.Pozolotin@gmail.com>
> To: user@pivot.apache.org
> Date: Fri 13 May 2011 10:35:37 PM CDT
>>
>>     *Greg, *hello;
>>
>>      
>>     1) I am hitting in the following issue while trying to run pivot
>>     in osgi environment:
>>
>>     this example
>>           http://pivot.apache.org/tutorials/labels-and-image-views.html
>>
>>     |<||Window| |title||=||"Labels"| |maximized||=||"true"|
>>     |    ||xmlns:bxml||=||"http://pivot.apache.org/bxml"|
>>     |    ||xmlns||=||"org.apache.pivot.wtk"||>|
>>     |    ||<||BoxPane| |styles||=||"{padding:4,
>>     verticalAlignment:'center'}"||>|
>>     |        ||<||ImageView| |image||=||"/clock.png"||/>|
>>     |        ||<||Label| |text||=||"What time is it?"||/>|
>>     |    ||</||BoxPane||>|
>>     |</||Window||>|
>>
>>
>>     2) in terms of |ImageView| properties, it is getting translated
>>     by BXMLSerializer into a call |*setImage(String imageName)*| ,
>>     which fails to locate resource:
>>
>>     |||ImageView ::
>>         /**
>>          * Sets the image view's image by {@linkplain
>>     ClassLoader#getResource(String)
>>          * resource name}.
>>          *
>>          * @param imageName
>>          * The resource name of the image to set.
>>          *
>>          * @see #setImage(URL)
>>          */
>>     *    public final void setImage(String imageName) {
>>     *        if (imageName == null) {
>>                 throw new IllegalArgumentException("imageName is null.");
>>             }
>>
>>     *        ClassLoader classLoader =
>>     Thread.currentThread().getContextClassLoader();
>>             setImage(classLoader.getResource(imageName.substring(1)));
>>     *    }
>>
>>     |2) note that in my case the pivot package classes and 
>>     [AWT-EventQueue-0] event queues are instantiated in osgi host
>>     class loader
>>          
>>     http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>>     but the actual call to |setImage(String imageName)| is executed
>>     in osgi plugin class loader;
>>
>>     just to give you an example, when this snipped gets executed
>>     inside osgi plugin bundle:
>>
>>                             // class loader used by pivot
>>                             ClassLoader loader =
>>     Thread.currentThread().getContextClassLoader();
>>                             URL urlPivot = loader.getResource("");
>>     *                        log.info("urlPivot : {} ", urlPivot);
>>     *
>>                             // class loader used by plugin bundle
>>                             URL urlOSGI = getClass().getResource("");
>>     *                        log.info("urlOSGI  : {}", urlOSGI);
>>     *
>>     it produces this log:
>>
>>     22:08:46.876 [AWT-EventQueue-0] INFO 
>>     com.carrotgarden.core.LoginComponent - urlPivot :
>>     file:/home/user1/Workspaces/github/carrot-tester/carrot-test-osgi-ws/carrot-test-osgi-pivot-host/target/test-classes/
>>
>>
>>     22:08:46.876 [AWT-EventQueue-0] INFO 
>>     com.carrotgarden.core.LoginComponent - urlOSGI  :
>>     bundle://7.0:1/com/carrotgarden/core/
>>
>>     as you can see,
>>     *      urlPivot :
>>     file:/home/user1/Workspaces/github/carrot-tester/carrot-test-osgi-ws/carrot-test-osgi-pivot-host/target/test-classes/
>>
>>     *resolves back to osgi host class loader which is not visible by
>>     the the client plugin
>>
>>     and
>>     *     urlOSGI  : bundle://7.0:1/com/carrotgarden/core/
>>     *resolves inside calling osgi bundle name space as expected;
>>
>>
>>     3) am I missing something obvious?
>>     why do you use current class loading approach in pivot?
>>     are you open to change this?
>>     what would your recommend instead?
>>
>>
>>     Thank you,
>>
>>     Andrei.
>>
>


Mime
View raw message