Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Pluggable modules

    I'm working with SmartGWT and OSGi in an existing application. The Server/UI we have can be extended based on "features" installed. To do this, the idea is to have a pluggable framework where the UI can be extended by having UI plugins installed on disk and loaded via OSGi. The plugins are a fragment bundle of the base UI module.

    To get to this point, I separated the base UI module out into two SmartGWT modules -- one that contains the pieces of the UI that only the base UI module cares about, and a "common" UI module that can be compiled into the base UI module and the plugins so they can be shared.

    When running the code, I can see all modules get loaded, and the entry points get called. The idea was to have the plugin modules register for events in the base UI module in order to extend the UI. For example: if the base module were about to show a menu, it could signal on the event to all plugins that it is about to display a menu and pass the menu object when it fires the event. The plugins could then modify the menu by adding any extra options to it and register for events when the menu item gets selected.

    This is where I've hit a roadblock - the events don't seem to be getting received by the plugin modules. I think what is happening is that with it being separate modules, they each have their own copies of the "common" code in which the HandlerManager resides for registering and firing events. Therefore, the plugin registers for the event with its copy of the HandlerManager and the main UI doesn't have any listeners in its copy of the HandlerManager. What I need is a way to share this object.

    I found this thread in which they are talking about this exact idea with GWT:
    https://groups.google.com/forum/#!topic/Google-Web-Toolkit/cZrMJK8E4Hk

    Before I go any further with this:
    1. Is it possible to use this mechanism to "export" an API in order to have plugins call it with SmartGWT? Is there something built into SmartGWT to do this easily?
    2. Is there some other mechanism to do this?
    3. Is this idea possible at all with the SmartGWT framework?

    #2
    GWT's compilation model does make this kind of thing very complicated.

    Consider, first, some completely different approaches, which may or may not fit your requirements:

    1) Don't bundle these "plugins" as separate modules. Decide that everything must be compiled together and set up processes for doing so.

    2) Redefine the nature of a UI plugin to make it narrower. For example, allow only Component XML to be declared for the plugin's UI. You could extend Component XML to allow certain rudimentary event handling steps to be declared in XML, if that's enough to meet the needs of plugin developers.

    3) use SmartClient. No compilation, no issue.

    You may be stuck with GWT and modules that must be separately compiled. As far as your guess of what's going wrong, it doesn't sound correct, but then we're not sure what approach you've even taken to loading the multiple separately compiled modules, so we don't have enough information to speculate.

    As far as the feasibility of creating interop between two separately compiled modules using gwt-exporter, yes this will work, and SmartGWT makes this a much, much more effective strategy than it normally is, because the entire SmartClient API is already there in JavaScript.

    Any way you end up approaching this, we'd recommend using the JumpStart program to get an Isomorphic engineer to help with analyzing your requirements, picking the right approach, and implementing a first cut.

    Comment

    Working...
    X