Extension mechanism / Groups Management APIs#620
Conversation
…echanism # Conflicts: # symphony-bdk-http/symphony-bdk-http-api/src/main/java/com/symphony/bdk/http/api/ApiClient.java # symphony-bdk-http/symphony-bdk-http-api/src/main/java/com/symphony/bdk/http/api/auth/Authentication.java # symphony-bdk-http/symphony-bdk-http-jersey2/src/main/java/com/symphony/bdk/http/jersey2/ApiClientJersey2.java # symphony-bdk-http/symphony-bdk-http-webclient/src/main/java/com/symphony/bdk/http/webclient/ApiClientWebClient.java
|
|
||
| private final ApiClient loginClient; | ||
|
|
||
| public String retrieveBearerToken(@Nonnull final AuthSession session) throws ApiException { |
There was a problem hiding this comment.
do we handle the token's refresh for now?
There was a problem hiding this comment.
Yes that's not done yes 👍 I was actually thinking of implementing the Groups API as part of a separate PR to make this one clearer and with a single purpose. WDYT?
| @API(status = API.Status.EXPERIMENTAL) | ||
| public interface BdkAuthenticationAware { | ||
|
|
||
| void setAuthSession(AuthSession session); |
There was a problem hiding this comment.
so I guess breaking the dependency on core means moving AuthSession, ApiFactory, Retry to interfaces and in the extension-api module?
There was a problem hiding this comment.
Correct, I actually started to move the Retry logic to a separate module but it would bring quite a lot of additional changes that will make this PR bigger. I'd prefer to do it as part of another PR once this one merged
| * TODO javadoc | ||
| */ | ||
| @API(status = API.Status.EXPERIMENTAL) | ||
| public interface BdkApiClientFactoryAware { |
There was a problem hiding this comment.
something we have not thought of maybe is how do i inject my own things in the extension? given I don't manage the creation of it
We should also perhaps implement the spring boot support too to see if it fits in
There was a problem hiding this comment.
well right now we create what we need in the SymphonyGroupService constructor (for instance the oauth client)
but what if I want an existing object?
There was a problem hiding this comment.
What to you mean by existing object?
There was a problem hiding this comment.
something that the extension would need but that would not be managed by the BDK itself, let's say that the extension needs to encrypt data before sending it via the generated api classes
so it needs an Encryptor object but also want to share it across multiple extensions so we would like to inject it in different places (like the ApiFactory that we inject in the extension but for an object not created/managed by the BDK)
(yes I'm making this up and maybe this is too complex for now)
There was a problem hiding this comment.
This would be possible if the extension provides a service, this service could expose an init() methods that takes external objects not necessary managed by the BDK. Something like:
MyExtensionService service = bdk.extensions().service(MyExtension.class);
service.configure(encryptionModule);
// then
String encryptedData = service.encrypt("Hello, World!");…ocumentation, improved Groups Extension example
Not sharing it with the core as the configuration is a bit more specific.
| @@ -0,0 +1,61 @@ | |||
| # Symphony Group Extension | |||
There was a problem hiding this comment.
maybe just a generic extension documentation as part of docs/ is enough?
| public class GroupExtensionConfig { | ||
|
|
||
| @Bean | ||
| public SymphonyGroupService groupService(BdkConfig config, ApiClientFactory apiClientFactory, AuthSession session) { |
There was a problem hiding this comment.
can we do more magic and pick it up at runtime just because it is in the classpath? like spring bot does when add a dependency?
…o feature/extension-mechanism
| @RequestMapping("/api") | ||
| public class ApiController { | ||
|
|
||
| @Lazy // required, otherwise Spring Boot application startup will fail |
There was a problem hiding this comment.
can't we put the lazy on the bean instead?
There was a problem hiding this comment.
We can't actually, since the extension service bean is dynamically registered in the application content.
| ``` | ||
|
|
||
| ### Access your Extension's service in Spring Boot | ||
| In Spring Boot, your extension's service is _lazily_ initialized. It means that you must annotate your injected extension's service |
There was a problem hiding this comment.
We could do it with https://www.baeldung.com/spring-boot-custom-auto-configuration too
But that would probably forces us to have a spring boot group extension module
There was a problem hiding this comment.
or maybe even simpler with https://www.baeldung.com/spring-componentscan-filter-type#filtertypeassignabletype ?
5b2344c to
eea68f4
Compare
55ad660 to
b968e41
Compare
…cally loaded when the extension is declared as a bean (requires `@Lazy`). However, the SymphonyGroupService can directly be added as a bean (no need to register the extension in this case)
…echanism # Conflicts: # symphony-bdk-http/symphony-bdk-http-api/src/main/java/com/symphony/bdk/http/api/auth/Authentication.java # symphony-bdk-http/symphony-bdk-http-jersey2/src/main/java/com/symphony/bdk/http/jersey2/ApiClientJersey2.java # symphony-bdk-http/symphony-bdk-http-webclient/src/main/java/com/symphony/bdk/http/webclient/ApiClientWebClient.java
The BDK extension mechanism aims to allow developers to provide additional features without necessary having to contribute in the finos/symphony-bdk-java repository.
All extensions must implement the
BdkExtensionmarker interface, and can optionally implement extension point interfaces such as:BdkExtensionServiceProviderBdkApiClientFactoryAwareBdkAuthenticationAwareBdkRetryBuilderAwareAs a first use-case, this PR also brings the Symphony's Groups API support as an extension.
Todo list
Closes #479