[ 
https://issues.apache.org/jira/browse/EAGLE-442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15416509#comment-15416509
 ] 

ASF GitHub Bot commented on EAGLE-442:
--------------------------------------

Github user haoch commented on the issue:

    https://github.com/apache/incubator-eagle/pull/323
  
    I think ApplicationProvider is just for providing a package of static 
application process/metadata/extensions but not for runtime.
    
    As following typical example, for different scope of memory/mysql, 
`ISecurityMetadataDAO` should bind to different implementation 
`InMemMetadataDaoImpl`/ `JDBCSecurityMetadataDAO`, and caller just need to 
inject with `@Inject ISecurityMetadataDAO dao`.
    
    ~~~
       @Override
        public void register(ModuleRegistry registry) {
            registry.register(MemoryMetadataStore.class, new AbstractModule() {
                @Override
                protected void configure() {
                    
bind(ISecurityMetadataDAO.class).to(InMemMetadataDaoImpl.class);
                }
            });
    
            registry.register(MySQLMetadataStore.class, new AbstractModule() {
                @Override
                protected void configure() {
                    
bind(ISecurityMetadataDAO.class).to(JDBCSecurityMetadataDAO.class);
                }
            });
        }
    ~~~
    
    While if register with current metadata store instance, then the code have 
to be as following, it will bind the register interface with MetadataStore and 
not extensible enough.
    
    ~~~
    @Override
        public void register(MetadataStore store, ModuleRegistry registry) {
           if(store instance of MemoryMetadataStore){
                registry.register(MemoryMetadataStore.class, new 
AbstractModule() {
                   @Override
                   protected void configure() {
                     
bind(ISecurityMetadataDAO.class).to(InMemMetadataDaoImpl.class);
                  }
            });
           } else if (store instance of MySQLMetadataStore){
            registry.register(new AbstractModule() {
                @Override
                protected void configure() {
                    
bind(ISecurityMetadataDAO.class).to(JDBCSecurityMetadataDAO.class);
                }
            });
           }
       }
    ~~~
    
    I think both maybe ok, and have similar implementation code, but the first 
implementation should be more flexible, especially in future we may be able to 
extend more than MetadataStore.



> Support to extend metastore DAO modules in SPI
> ----------------------------------------------
>
>                 Key: EAGLE-442
>                 URL: https://issues.apache.org/jira/browse/EAGLE-442
>             Project: Eagle
>          Issue Type: Sub-task
>    Affects Versions: v0.5.0
>            Reporter: Hao Chen
>            Assignee: Hao Chen
>              Labels: app-framework, extensibility
>             Fix For: v0.5.0
>
>
> h1. Module Registry Interfaces
> * ApplicationProvider
> {code}
> ApplicationProvider{ 
>    void register(ModuleRegistry) 
> }
> {code}
> * ModuleRegistry
> {code}
> ModuleRegistry { 
>     void register(ModuleScope scope,Module module);
>     default void register(Module moduel) {
>         register(GlobalScope.class, module)
>     }
> }
> {code}
> * ModuleScope
> - Modules registered in scope of `GlobalScope` will be visible globally
> - Modules registered in 
> `MySQLMetadataStore`/`MongodbMetadataStore`/`MemoryMetadataStore` will only 
> be visible when selected MetadataStore is active (set in configuration file)
> {code}
> ModuleScope
>     |- GlobalScope
>     |- MetadataStore
>         |- MySQLMetadataStore
>         |- MongodbMetadataStore
>         |- MemoryMetadataStore
> {code}
> h1. Example
> * Registry: in `HBaseAuditLogAppProvider`
> {code}
> @Override
>     public void register(ModuleRegistry registry) {
>         registry.register(MemoryMetadataStore.class, new AbstractModule() {
>             @Override
>             protected void configure() {
>                 
> bind(ISecurityMetadataDAO.class).to(InMemMetadataDaoImpl.class);
>             }
>         });
>         registry.register(MySQLMetadataStore.class, new AbstractModule() {
>             @Override
>             protected void configure() {
>                 
> bind(ISecurityMetadataDAO.class).to(JDBCSecurityMetadataDAO.class);
>             }
>         });
>     }
> {code}
> * Inject: For example, `HbaseMetadataBrowseWebResource` could get current 
> `ISecurityMetadataDAO` with `@Inject ISecurityMetadataDAO metadataDAO` as 
> following, instead of using 
> [`MetadataDaoFactory`](https://github.com/apache/incubator-eagle/blob/9b10f22221b60f0f6451e71ac3396b326f9565ef/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/service/MetadataDaoFactory.java)
> {code}
> @Inject
>     public HbaseMetadataBrowseWebResource(ApplicationEntityService 
> entityService, ISecurityMetadataDAO metadataDAO){
>         this.entityService = entityService;
>         this.dao = metadataDAO;
>     }
> {code}
> h1. More Use Cases
> * ExampleResource
> * ExampleService
> * ExampleApplicationProviderTest#testApplicationExtensions



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to