Amar3tto opened a new pull request #17051:
URL: https://github.com/apache/beam/pull/17051


   CDAP plugins use their own configuration classes (ex. 
`SalesforceSourceConfig`, `SalesforceStreamingSourceConfig`) to set the 
required parameters to prepare and run pipeline in Source or Sink classes. All 
these config classes are extended from the base 
`io.cdap.cdap.api.plugin.PluginConfig` class.
   As a first step in integration of **_CDAP plugins_** and _**Apache Beam**_, 
there should be implemented a mechanism to create an instance of the specific 
`PluginConfig` implementation.
   
   ![Untitled Diagram 
drawio(1)](https://user-images.githubusercontent.com/17278361/147752088-5ffa6117-16aa-4ddd-af83-edb2f770963b.png)
   
   For this purpose, suggested solution provides a `ConfigWrapper<T>` class. 
Apache Beam user creates an instance of this class by passing the 
`PluginConfig` specific class as a `T` parameter. 
   `ConfigWrapper<T>` object provides simple methods to instantiate the 
corresponding `T` object:
   1. `fromJsonFile(File file)`
   2. `withParams(Map<String, Object> params)`
   3. `setParam(String paramName, Object value)`
   4. `build()`
   
   Apache Beam user could set required parameters for the CDAP plugin by 
passing the Map/JSON file or by manually setting each parameter.
   After that, when the `build()` method was called, the `ConfigWrapper<T>` 
uses `InstantiationUtils`, which in turn uses Reflection API. 
`InstantiationUtils` class provides mechanisms for:
   1. Creating an empty `PluginConfig` object bypassing the limitations of 
private constructors or the absence of no-args constructor.
   2. Going over all `Field`s with the `cdap.Name` annotation and setting the 
appropriate parameter values for them. 
   As a result `ConfigWrapper<T>` returns `PluginConfig` object which can be 
further used when integrating with the corresponding plugin.
   
   
   ![Untitled Diagram 
drawio](https://user-images.githubusercontent.com/17278361/147752102-79457cce-1b4c-4a87-8404-ca9068915d9b.png)
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
    - [ ] [**Choose 
reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and 
mention them in a comment (`R: @username`).
    - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA 
issue, if applicable. This will automatically link the pull request to the 
issue.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit 
[https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   
------------------------------------------------------------------------------------------------
   [![Build python source distribution and 
wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python 
tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java 
tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more 
information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to