Skip to content

Commit

Permalink
just passing the array of classes instead of whole annotation class
Browse files Browse the repository at this point in the history
Signed-off-by: Santhosh Gandhe <[email protected]>
  • Loading branch information
san81 committed Oct 1, 2024
1 parent 144be2f commit 075d260
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ private <T> ComponentPluginArgumentsContext getConstructionContext(final PluginS
.createDefaultPluginConfigObservable(pluginConfigurationConverter, pluginConfigurationType, pluginSetting);

BeanFactory beanFactory;
if(pluginAnnotation.packagesToScanForDI().length>0) {
Class[] scanForDIMarkers = pluginAnnotation.packagesToScanForDI();
if(scanForDIMarkers.length>0) {
// If packages to scan is provided in this plugin annotation, which indicates
// that this plugin is interested in using Dependency Injection isolated for its module
beanFactory = pluginBeanFactoryProvider.initializePluginSpecificIsolatedContext(pluginAnnotation);
beanFactory = pluginBeanFactoryProvider.initializePluginSpecificIsolatedContext(scanForDIMarkers);
}else{
beanFactory = pluginBeanFactoryProvider.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.opensearch.dataprepper.plugin;

import org.opensearch.dataprepper.model.annotations.DataPrepperPlugin;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
Expand Down Expand Up @@ -65,13 +64,12 @@ public BeanFactory get() {
return isolatedPluginApplicationContext.getBeanFactory();
}


public BeanFactory initializePluginSpecificIsolatedContext(DataPrepperPlugin pluginAnnotation) {
public BeanFactory initializePluginSpecificIsolatedContext(Class[] scanForDIMarkers) {
AnnotationConfigApplicationContext pluginDIContext = new AnnotationConfigApplicationContext();
if(pluginAnnotation.packagesToScanForDI().length>0) {
if(scanForDIMarkers.length>0) {
// If packages to scan is provided in this plugin annotation, which indicates
// that this plugin is interested in using Dependency Injection isolated for its module
Arrays.stream(pluginAnnotation.packagesToScanForDI())
Arrays.stream(scanForDIMarkers)
.map(Class::getPackageName)
.forEach(pluginDIContext::scan);
pluginDIContext.refresh();
Expand Down

0 comments on commit 075d260

Please sign in to comment.