Page tree
Skip to end of metadata
Go to start of metadata

The problem

The info.magnolia.ui.vaadin.integration.datasorce.DataSource has to be an easily configurable part of a sub-app. Currently its definition is stored in the ContentSubAppDescriptor:

SubAppDescriptor
public interface ContentSubAppDescriptor extends SubAppDescriptor {
    ...
    DataSourceManagerDefinition getDataSourceManager();
}

As long as datasource is something that many components of sub app might be requiring (e.g. BrowserPresenter, WorkbenchPresenter, ImageProvider etc) it would be highly convenient if we could inject the DataSource directly in those components. However, we should not configure the DataSource on the module level as one module (or even one app) should be able to support several sub apps with different  data sources. 

Proposals

  • One way to solve the problem would be to refactor AppInstanceControllerImpl and allow for overriding the AppInstanceControllerImpl#createSubAppComponentProvider method in such a way that one can get access the Guice configuration and allow for adding custom mappings.
    • Such way would require a possibility to use different AppInstanceControllers for different apps.
    • Would lead to quite substantial refactoring
    • Reveal the Guice nature of our IoC mechanism to the extenders.
  • Another approach would be to introduce a new annotation (e.g. @InjectableComponent) . By annotating methods of the SubAppDescriptor we could let the AppInstanceController know that the properties that correspond to annotated methods should be mapped within a component provider.

    public interface ContentSubAppDescriptor extends SubAppDescriptor {
        ...
    	@InjectableComponent
        DataSourceManagerDefinition getDataSourceManager();
    }
    • Then we would assume that such a definition would have a property with some conventional name (e.g. Class<? extends DataSource> implementationClass).

    • We would extract the interface/abstract class type form the property type (in our case it's DataSource) and map the actual value stored in descriptor instance to it.
  • No labels