Access by type

This commit is contained in:
Fabio Sinibaldi 2022-05-02 17:55:48 +02:00
parent a7280b0b1d
commit 8ff0cee95a
2 changed files with 22 additions and 3 deletions

View File

@ -175,7 +175,7 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
log.trace("Looking for Indexers for {}",request);
ArrayList<IndexerPluginInterface> toReturn=new ArrayList<>();
UseCaseDescriptor desc = request.getUseCaseDescriptor();
List<HandlerDeclaration> indexers = desc.getHandlersMapByType().get(IndexerPluginDescriptor.INDEXER);
List<HandlerDeclaration> indexers = desc.getHandlersByType(IndexerPluginDescriptor.INDEXER);
log.debug("Found UCD [{}] Indexers : {}",desc.getId(),indexers.size());
for (HandlerDeclaration handlerDeclaration : indexers)
toReturn.add((IndexerPluginInterface) pluginManager.getById(handlerDeclaration.getId()));
@ -186,7 +186,7 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
log.trace("Looking for materializers for {}",request);
ArrayList<MaterializationPlugin> toReturn=new ArrayList<>();
UseCaseDescriptor desc = request.getUseCaseDescriptor();
List<HandlerDeclaration> materializers = desc.getHandlersMapByType().get(MaterializerPluginDescriptor.MATERIALIZER);
List<HandlerDeclaration> materializers = desc.getHandlersByType(MaterializerPluginDescriptor.MATERIALIZER);
log.debug("Found UCD [{}] Materializers : {}",desc.getId(),materializers.size());
for (HandlerDeclaration handlerDeclaration : materializers) {
toReturn.add((MaterializationPlugin) pluginManager.getById(handlerDeclaration.getId()));

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.xml.bind.annotation.XmlRootElement;
@ -76,11 +77,29 @@ public class UseCaseDescriptor {
}catch (Throwable t){
log.error("Invalid useCaseDescriptor : unable to get Handler Map by Type with {} in useCaseDescriptor [ID {}]",h,this.getId(),t);}
});
if(log.isTraceEnabled()) {
toReturn.forEach((s, handlerDeclarations) -> log.trace("UCD {} : Found N {} handlers of type {}",this.getId(),handlerDeclarations.size(),s));
}
return toReturn;
}
/**
* Returns map Type -> Handler Declaration
* Returns List of Handler Declaration by type
*
* @param type
* @return
*/
@JsonIgnore
public List<HandlerDeclaration> getHandlersByType(String type){
List<HandlerDeclaration> toReturn=
handlers.stream().sequential().
filter(handlerDeclaration -> handlerDeclaration.getType().equals(type)).collect(Collectors.toList());
log.debug("UCD {} : Found {} Handlers for {}",getId(),toReturn.size(),type);
return toReturn;
}
/**
* Returns map ID -> Handler Declaration
* @return
*/
@JsonIgnore