Registering modules with the application

Registering a module with the application means adding the module's functionality into the application. What this module registration performs depends on the application's requirements. For example, if the application includes a main menu, then a possible registration action for a module is to add menu items to the main menu. If the application is based on tabs, a possible registration action can be adding tabs to the main screen. All these actions need to be performed through a shared API. Take the example of adding a menu item. In this case, a possible interface could be something like the following:

public interface MenuItemRegistration {
void addMenuItem(MenuBar menu);
}

Modules can implement this interface to add menu items into the existing application's main menu.

Because we already have an ApplicationLayout interface, which defines methods to manipulate the layout, the following interface is good enough:

public interface AppModule {
void register(ApplicationLayout layout);
}
The AppModule interface is located in the Data-centric-Applications-with-Vaadin-8chapter-02api Maven project of the source code that accompanies this book.

This interface can be packaged in a separate JAR file so it can be distributed to any third-party developers. This JAR should contain all the classes and interfaces that could be needed by module implementations. This is the reason we previously created the api Maven module. There also is another advantage: The api JAR can be distributed to third-party developers to allow them to create new functionality for the application without distributing the whole compiled code of your web application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset