[ 
https://issues.apache.org/jira/browse/EAGLE-442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hao Chen updated EAGLE-442:
---------------------------
    Description: 
## Module Registry Interfaces

* ApplicationProvider
```
ApplicationProvider{ 
   void register(ModuleRegistry) 
}
```

* ModuleRegistry
```
ModuleRegistry { 
    void register(ModuleScope scope,Module module);
    default void register(Module moduel) {
        register(GlobalScope.class, module)
    }
}
```

* 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)

```
ModuleScope
    |- GlobalScope
    |- MetadataStore
        |- MySQLMetadataStore
        |- MongodbMetadataStore
        |- MemoryMetadataStore
```

## Example

* Registry: in `HBaseAuditLogAppProvider`

```
@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);
            }
        });
    }
```
* 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)

```
@Inject
    public HbaseMetadataBrowseWebResource(ApplicationEntityService 
entityService, ISecurityMetadataDAO metadataDAO){
        this.entityService = entityService;
        this.dao = metadataDAO;
    }
```

## More Use Cases
* ExampleResource
* ExampleService
* ExampleApplicationProviderTest#testApplicationExtensions

## JIRA
* https://issues.apache.org/jira/browse/EAGLE-442
* https://issues.apache.org/jira/browse/EAGLE-431



  was:
Module Registry Interfaces

ApplicationProvider
ApplicationProvider{ 
   void register(ModuleRegistry) 
}
ModuleRegistry
ModuleRegistry { 
    void register(ModuleScope scope,Module module);
    default void register(Module moduel) {
        register(GlobalScope.class, module)
    }
}
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)
ModuleScope
    |- GlobalScope
    |- MetadataStore
        |- MySQLMetadataStore
        |- MongodbMetadataStore
        |- MemoryMetadataStore
Example

Registry: in HBaseAuditLogAppProvider
@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);
            }
        });
    }
Inject: For example, HbaseMetadataBrowseWebResource could get current 
ISecurityMetadataDAO with @Inject ISecurityMetadataDAO metadataDAO as 
following, instead of using MetadataDaoFactory
@Inject
    public HbaseMetadataBrowseWebResource(ApplicationEntityService 
entityService, ISecurityMetadataDAO metadataDAO){
        this.entityService = entityService;
        this.dao = metadataDAO;
    }
More Use Cases

ExampleResource
ExampleService
ExampleApplicationProviderTest#testApplicationExtensions


> 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
>
>
> ## Module Registry Interfaces
> * ApplicationProvider
> ```
> ApplicationProvider{ 
>    void register(ModuleRegistry) 
> }
> ```
> * ModuleRegistry
> ```
> ModuleRegistry { 
>     void register(ModuleScope scope,Module module);
>     default void register(Module moduel) {
>         register(GlobalScope.class, module)
>     }
> }
> ```
> * 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)
> ```
> ModuleScope
>     |- GlobalScope
>     |- MetadataStore
>         |- MySQLMetadataStore
>         |- MongodbMetadataStore
>         |- MemoryMetadataStore
> ```
> ## Example
> * Registry: in `HBaseAuditLogAppProvider`
> ```
> @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);
>             }
>         });
>     }
> ```
> * 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)
> ```
> @Inject
>     public HbaseMetadataBrowseWebResource(ApplicationEntityService 
> entityService, ISecurityMetadataDAO metadataDAO){
>         this.entityService = entityService;
>         this.dao = metadataDAO;
>     }
> ```
> ## More Use Cases
> * ExampleResource
> * ExampleService
> * ExampleApplicationProviderTest#testApplicationExtensions
> ## JIRA
> * https://issues.apache.org/jira/browse/EAGLE-442
> * https://issues.apache.org/jira/browse/EAGLE-431



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

Reply via email to