Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322189 - [CSS] Allow non-extension point based property handler contributions
Summary: [CSS] Allow non-extension point based property handler contributions
Status: RESOLVED WONTFIX
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Bogdan Gheorghe CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-09 17:35 EDT by Bogdan Gheorghe CLA
Modified: 2014-03-18 17:06 EDT (History)
8 users (show)

See Also:


Attachments
POC -CSS Projects+Doc to register/unregister handler into OSGi and Pur Java context (229.54 KB, application/zip)
2010-08-12 06:40 EDT, Angelo ZERR CLA
no flags Details
Manage plugin.xml in NO OSGi-env (Projects + Tests + Samples with E4 CSSEngine + Docs) (211.96 KB, application/zip)
2010-08-16 03:00 EDT, Angelo ZERR CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bogdan Gheorghe CLA 2010-08-09 17:35:16 EDT
Currently the CSS engine makes use of extension points to allow for custom styling via property handlers. Pure java apps running without an OSGI framework will not be able to make use of the CSS engine for styling. 

API should be added to allow non-OSGI apps to use and extend the CSS engine.
Comment 1 Thomas Schindl CLA 2010-08-09 17:41:38 EDT
My suggestion would be to use DS instead of extension points this way we have a Java-API which will be called by DS in case of OSGi and by the Java-Programmer in plain Java-programs (or we make use of the service extensions provided by plain Java)
Comment 2 Oleg Besedin CLA 2010-08-10 10:13:52 EDT
(In reply to comment #1)
> My suggestion would be to use DS instead of extension points

Hmm... DS is very much OSGi-specific in both its logic and implementation.

The extension registry itself can work without OSGi. Now, somebody would have to populate it with data and some services (like NLS support) will be reduced, but it can work without OSGi.

That said, I'd question the point of this bug: it essentially sais that CSS engine needs some extensibility mechanism, and then it discounts two such mechanisms we have in Eclipse (OSGi and extensions) with the goal to create its own extension mechanism?
Comment 3 Thomas Schindl CLA 2010-08-10 10:30:53 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > My suggestion would be to use DS instead of extension points
> 
> Hmm... DS is very much OSGi-specific in both its logic and implementation.
> 
> The extension registry itself can work without OSGi. Now, somebody would have
> to populate it with data and some services (like NLS support) will be reduced,
> but it can work without OSGi.
> 
> That said, I'd question the point of this bug: it essentially sais that CSS
> engine needs some extensibility mechanism, and then it discounts two such
> mechanisms we have in Eclipse (OSGi and extensions) with the goal to create its
> own extension mechanism?

My impression is the other way round but well and I'd like to to get away with extension points because they force us to make our bundles singletons
Comment 4 Thomas Schindl CLA 2010-08-10 10:33:38 EDT
... and DS works a lot better with our DI story! You can look at my 30 minutes test in bug 321486 - i know it's a very very dirty implementation.
Comment 5 Thomas Schindl CLA 2010-08-10 10:37:42 EDT
One more thing to note is that we are talking about a plug-in system and well that's exactly what OSGi is about. What can be light-weighter than OSGi? 

The more I think about bug 321486 and this one the more I convince myself that these requests all ask us to reinvent the wheel named OSGi.
Comment 6 Oleg Besedin CLA 2010-08-10 10:53:55 EDT
(In reply to comment #5)
> these requests all ask us to reinvent the wheel named OSGi.

Yes, that's my impression too. If we do want to be OSGi-free I would:

- add direct access APIs to CSS that can be called by developers to add customization;  
- make OSGi-aware code work through those APIs;
- isolate OSGi-aware code into separe package(s); and "class not found" exception handlers around calls to those methods;
- make dependency on OSGi optional.

That said, there is always a question of how much value there is in being OSGi-free. A few years ago, on request like this, I changed extension registry to be able to work without OSGi. This made extension registry code more complicated (this is where "registry strategy" concept started) and took some time to implement. The end result? I am not sure if there is a single product out there that uses extension registry without OSGi. I am periodically asked if the extension registry can be used without OSGi (once in a few months), but I never got any actual bugs or requests for this mode of operations.
Comment 7 Angelo ZERR CLA 2010-08-11 09:38:54 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > these requests all ask us to reinvent the wheel named OSGi.
> 
> Yes, that's my impression too. If we do want to be OSGi-free I would:
> 
> - add direct access APIs to CSS that can be called by developers to add
> customization;  
> - make OSGi-aware code work through those APIs;
> - isolate OSGi-aware code into separe package(s); and "class not found"
> exception handlers around calls to those methods;
> - make dependency on OSGi optional.
> 
> That said, there is always a question of how much value there is in being
> OSGi-free. A few years ago, on request like this, I changed extension registry
> to be able to work without OSGi. This made extension registry code more
> complicated (this is where "registry strategy" concept started) and took some
> time to implement. The end result? I am not sure if there is a single product
> out there that uses extension registry without OSGi. I am periodically asked if
> the extension registry can be used without OSGi (once in a few months), but I
> never got any actual bugs or requests for this mode of operations.

Hi,

I have worked about this topic and I have found a solution to register the ICSSPropertyHandler for CSS engine into OSGi context and without OSGi context. 

More I have founded a solution into OSGi context to :
* register ICSSPropertyHandler when bundle (which contains ICSSPropertyHandler) start.
* unregister ICSSPropertyHandler when bundle (which contains ICSSPropertyHandler) stop.

So with this last feature you can register/unregister ICSSPropertyHandler by using OSGi console by starting/stopping bundle. 

The fisrt thing is that I don't use plugin.xml. I' m using a custom cssengine-config.xml which declare ICSSPropertyHandler to register.

I have a Bundle CSSEngine and anothers Bundles CSSEngine-handler-config1, CSSEngine-handler-config2, which contains cssengine-config.xml and register ICSSPropertyHandler into OSGi services registry. 

Into OSGi context : 

* CSSEngine-handler-config1, CSSEngine-handler-config2 load on Activator#start the cssengine-config.xml, parse it to create list of ICSSSPropertyHandler and publish the result as OSGi services.

* CSSEngine bundle use OSGi services to retrieve each OSGi services registered and register the handler for the whole CSSEngine instance.

When CSSEngine-handler-config1 is stopped, it unregister her ICSSPropertyHandler for the whole CSSEngine instances. When CSSEngine-handler-config1 is restarted it register her ICSSPropertyHandler for the whole CSSEngine instances.

So into OSGi context, it's not the CSSEngine which search ICSSPropertyHandler but it's CSSEngine-handler-config1, CSSEngine-handler-config2 which register ICSSPropertyHandler. 

CSSEngine-handler-config1 -> handler -> OSGi services regisrty -> CSSEngine instances
CSSEngine-handler-config2 -> handler -> OSGi services regisrty -> CSSEngine instances

Into Java context, it's the CSSEngine instances which search all cssengine-config.xml founded into the ClassLoader (one ClassLoader) and parse it to register ICSSPropertyHandler.

CSSEngine instances -> load -> CSSEngine-handler-config1/cssengine-config.xml
                    -> load -> CSSEngine-handler-config2/cssengine-config.xml

My work is just a POC and it doesn't use E4 CSSEngine. My test it's just a simple CSSEngine-like which display properties registered on the console every 5 sec. When you stop bundle handler config, some properties disappears from the console.

Into Java app context, the whole ICSSPropertyHandler from cssengine-config.xml files are registered.

Are you interested with my POC? I will try clean my work and send you my projects to see in action my explanation.

Regards Angelo
Comment 8 Angelo ZERR CLA 2010-08-12 06:40:33 EDT
Created attachment 176450 [details]
POC -CSS Projects+Doc to register/unregister handler into OSGi and Pur Java context

I have attached a zip, where you will can find some projects and documentation about my idea to manage handler for CSS engine into OSGi context and Pur Java context. Please read POC-CSS.odt or POC-CSS.rtf documentation. 

In this doc, you will see screen which explained each projects and the different samples (like register/unregister handlers by start/stop OSGi bundles handler config). You will find several launch to test samples.

Hope my idea will please you. My code is not commented but I hope documentation will be enough. Welcome for any suggestions!

Thank a lot.

Regards Angelo
Comment 9 Thomas Schindl CLA 2010-08-12 09:41:21 EDT
If I understand Olegs comment right. One can use plugin.xml in a none OSGi-Env so there's no need for an extra implementation. 

My current position is like the one from Oleg. Our Primary Target are OSGi-Environments and if the overhead/complexity we need to introduce to support none OSGi-Envs is justifyable I'm +1
Comment 10 Angelo ZERR CLA 2010-08-12 09:48:24 EDT
(In reply to comment #9)
> If I understand Olegs comment right. One can use plugin.xml in a none OSGi-Env
> so there's no need for an extra implementation. 
> 
> My current position is like the one from Oleg. Our Primary Target are
> OSGi-Environments and if the overhead/complexity we need to introduce to
> support none OSGi-Envs is justifyable I'm +1

Tom I had tried to study tu use plugin.xml into no OSGi context. Problem with plugin.xml is : 

* the bundle must be a singleton (how manage several versions of the same bundles?)
* I'm not sure that the stop bundles which register extension with plugin.xml can unregister the extension. Not sure with that.

Have you seen my proposition? It use OSGi services. By default you can my class CSSEngineConfigurationBundleActivator, but you could use another thing to register the services like DS or Spring DM. Config is declared into XML file cssengine-config, but you could create Java code to create the handler if you wish.
Comment 11 Angelo ZERR CLA 2010-08-13 06:40:12 EDT
(In reply to comment #9)
> If I understand Olegs comment right. One can use plugin.xml in a none OSGi-Env
> so there's no need for an extra implementation. 
> 
> My current position is like the one from Oleg. Our Primary Target are
> OSGi-Environments and if the overhead/complexity we need to introduce to
> support none OSGi-Envs is justifyable I'm +1

Hi Tom, Olegs (and other),

I have investigated time to manage plugin.xml into none OSGi-Envs and it can start work well. I have implemented some org.eclipse.core.registry bundle classes to manage plugin.xml into none OSGi-Envs, and it works!

So now I can use standard API wich manage extension point like : 

-------------------------------------------------
IExtensionPoint extPoint = registry					.getExtensionPoint("org.eclipse.core.contenttype.contentTypes");
-------------------------------------------------

However there are restrictions about classpatch definition : 

* you must add into the classpath project (the launch) plugin.xml and META-INF/MANIFEST.MF at hand. 
* you must explicitly define into classpath (with Required-Bundle or with Project ClassPath) the bundle which define and add extension-point. For instance in my case I had to add org.eclipse.core.contenttype bundles with Required-Bundle in order to use this extension point into none OSGi-Envs.

So with this solution, I think E4 CSSEngine will not change a lot. Just call my class which manage Extension Point which works with none OSGi-Envs.

I clean my work and send you a patch with my work.

Regards Angelo
Comment 12 Angelo ZERR CLA 2010-08-13 09:40:50 EDT
(In reply to comment #11)
> (In reply to comment #9)
> > If I understand Olegs comment right. One can use plugin.xml in a none OSGi-Env
> > so there's no need for an extra implementation. 
> > 
> > My current position is like the one from Oleg. Our Primary Target are
> > OSGi-Environments and if the overhead/complexity we need to introduce to
> > support none OSGi-Envs is justifyable I'm +1
> 
> Hi Tom, Olegs (and other),
> 
> I have investigated time to manage plugin.xml into none OSGi-Envs and it can
> start work well. I have implemented some org.eclipse.core.registry bundle
> classes to manage plugin.xml into none OSGi-Envs, and it works!
> 
> So now I can use standard API wich manage extension point like : 
> 
> -------------------------------------------------
> IExtensionPoint extPoint = registry                   
> .getExtensionPoint("org.eclipse.core.contenttype.contentTypes");
> -------------------------------------------------
> 
> However there are restrictions about classpatch definition : 
> 
> * you must add into the classpath project (the launch) plugin.xml and
> META-INF/MANIFEST.MF at hand. 
> * you must explicitly define into classpath (with Required-Bundle or with
> Project ClassPath) the bundle which define and add extension-point. For
> instance in my case I had to add org.eclipse.core.contenttype bundles with
> Required-Bundle in order to use this extension point into none OSGi-Envs.
> 
> So with this solution, I think E4 CSSEngine will not change a lot. Just call my
> class which manage Extension Point which works with none OSGi-Envs.
> 
> I clean my work and send you a patch with my work.
> 
> Regards Angelo

Ok I have  done some tests with CSS engine, and now I can apply styles into None OSGi env. The only thing I had changed into CSS engine is (CSSEngineImpl constructor) : 

Instead to do this : 

-------------------------------------
IExtensionRegistry registry = RegistryFactory.getRegistry();
-------------------------------------

I do that : 

-------------------------------------
IExtensionRegistry registry = org.eclipse.equinox.nonosgi.registry.RegistryFactoryHelper.getRegistry();
-------------------------------------

Where org.eclipse.equinox.nonosgi.registry.RegistryFactoryHelper is my Helper which manage into OSGi and none OSGi env.

But there are some restrictions because of classpath : 

* I need to add "org.eclipse.e4.ui.widgets" into my classpath.
* I need to add the folder "org.eclipse.e4.ui.css.core" into my classpath to load plugin.xml and MANIFEST.MF of the org.eclipse.e4.ui.css.core. If org.eclipse.e4.ui.css.core is a bundles stored into plugins, I have not this problem (because it is into my classpath).

I will send you my work soon.

Regards Angelo
Comment 13 Angelo ZERR CLA 2010-08-16 03:00:31 EDT
Created attachment 176652 [details]
Manage plugin.xml in NO OSGi-env (Projects + Tests + Samples with E4 CSSEngine + Docs)

Hi,

I have attached a org.eclipse.equinox.nonosgi.registry_100816.zip with my work which manage plugin.xml in NO OSGi-env (and OSGI env too). org.eclipse.equinox.nonosgi.registry project is the bundle which manage in NO-OSGi-env plugin.xml files.  You will find a CVS patch for E4 CSSEngine to use it in NO OSGI-env and one sample (TestCSS) which use CSS engine in NO OSGi-env.

Zip contains a doc folder where you can find a documentation about org.eclipse.equinox.nonosgi.registry (samples are explained too). So please read "Extension Point Registry - NO OSGi-env.odt" or "Extension Point Registry - NO OSGi-env.rtf" for more information.

Hope you will like my work.

Regards Angelo
Comment 14 Angelo ZERR CLA 2010-09-14 11:04:58 EDT
Hi, 

For your information, I have written an article "Eclipse Extension Points and Extensions without OSGi" at http://angelozerr.wordpress.com/2010/09/14/eclipse-extension-points-and-extensions-without-osgi/

where I explain how use "org.eclipse.equinox.nonosgi.registry" by using the sample coming from the Lars Vogel tutorial http://www.vogella.de/articles/EclipseExtensionPoint/article.html

Regards Angelo
Comment 15 Wendell Beckwith CLA 2010-11-12 13:36:12 EST
This would be fantastic to have.  Essentially Platform.getExtensionRegistry() could delegate to RegistryFactoryHelper.getRegistry() (or something like it) and be transparent to registry users.  As for whether it would be used, we have a multi-million dollar product suite that we want to move to the eclipse platform, but would honestly need to be rewritten nearly from scrath.  Instead I have spent the last couple months working through the issues to remove the circular dependencies and wiring things together using the Eclipse Registry which will be used outside of OSGi.  See Oleg, your work does have users. :)  Since we can't halt all development for months the plan is to iteratively update pieces to get their contributions etc from the registry and not the homegrown extension mechanism.  Then we should be in much better shape to adopt the eclipse platform completely.
Comment 16 Angelo ZERR CLA 2010-11-13 07:06:08 EST
(In reply to comment #15)
> This would be fantastic to have.  Essentially Platform.getExtensionRegistry()
> could delegate to RegistryFactoryHelper.getRegistry() (or something like it)
> and be transparent to registry users.  As for whether it would be used, we have
> a multi-million dollar product suite that we want to move to the eclipse
> platform, but would honestly need to be rewritten nearly from scrath.  Instead
> I have spent the last couple months working through the issues to remove the
> circular dependencies and wiring things together using the Eclipse Registry
> which will be used outside of OSGi.  See Oleg, your work does have users. :) 
> Since we can't halt all development for months the plan is to iteratively
> update pieces to get their contributions etc from the registry and not the
> homegrown extension mechanism.  Then we should be in much better shape to adopt
> the eclipse platform completely.

Hi Binyan,

I will be very happy if my work could be integrate in the Eclipse Platform. It should be very fantastic. Just for your information you can use today Platform.getExtensionRegistry() in your Plug-In and use in NO OSGi env by initializing in your Java main  RegistryFactoryHelper.getRegistry(). Please read http://angelozerr.wordpress.com/2010/09/14/eclipse-extension-points-and-extensions-without-osgi/#SingleSourcing

Regards Angelo
Comment 17 Lars Vogel CLA 2014-03-18 17:06:36 EDT
Marking as WONTFIX, as there are currently no plans to implement that.