开发者

Split a GWT-Platform application on more than one project

I'm currently developing a GWTP application that is growing, so I want to develop it so that I can decide to split it in two or more parts in the future.

Consider that I'm working on a project P that can be conceptually divided into two 开发者_运维问答projects P1 and P2 on which people from two different teams are working. P1 and P2 would then share come common stuff, for example extensions of standard presenter classes, common presenters and views, configs, and so on. I would like to create an application that is the sum of P1, P2 and a common project Px that would be a dependency of the other two projects and a GWTP project as well.

I don't know if is possible to do this, but I think that the main problem would be that I would need three Ginjectors, a common one, and two extensions, one for each project.

Is there an example that copes a situation like this? Or should I try a different approach?


If I understood your comment right, I would suggest, you do not need a wrapper, rather a library which provides the functionality via GWT modules (please see here). Each of this module can use GWTP and DI but without a Ginjector. You rather provide gin modules where you configurate your module dependencies. In your application where your ginjector is created, you just install the gin modules of your library.

!!!Don't forget: When using GWTP, you also have DI on the server side, which functions exact the same way.

Example for the client side. Consider we have two let's say components which are compound of some pages etc. P1 and P2. Then create two GWT modules with module configs like P1.gwt.xml and P2.gwt.xml. Each of these modules have a GinModule e.g.

public class P1GinModule extends AbstractGinModule {

    @Override
    protected void configure() {
        // bind your presenters, views, etc..
    }
}

In your application A1 you create your gin configuration where you install the modules you want, in this case P1GinModule and P2GinModule

public class A1GinModule extends AbstractGinModule {

    @Override
    protected void configure() {
        install(new P1GinModule());
        install(new P2GinModule());
    }
}

Your ginjector should then look like this:

@GinModules(A1GinModule.class)
public interface AppInjector extends Ginjector {
    // what ever you need ...
}

Note: in you appliations config, let's say A1.gwt.xml, don't forget to inherit the two GWT modules.

With this approach you have all the dependency injection working for different modules that are rolled out in libraries and provided via GWT Modules.

Hope that helped.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜