protected static DesignModel getDesignModel(final ComponentFamilyMeta.ProcessorMeta processor) { return ofNullable(processor.get(DesignModel.class)) .orElseThrow(() -> new IllegalArgumentException("Processor doesn't contain DesignModel")); } }
public Optional<org.talend.sdk.component.runtime.output.Processor> findProcessor(final String plugin, final String name, final int version, final Map<String, String> configuration) { return find(pluginContainer -> Stream .of(pluginContainer .get(ContainerComponentRegistry.class) .getComponents() .get(container.buildAutoIdFromName(plugin)))) .filter(Objects::nonNull) .map(component -> ofNullable(component.getProcessors().get(name)) .map(proc -> proc .getInstantiator() .apply(configuration == null ? null : proc.getMigrationHandler().migrate(version, configuration))) .map(org.talend.sdk.component.runtime.output.Processor.class::cast)) .findFirst() .flatMap(identity()); }
/** * Returns {@link Processor} class method annotated with {@link ElementListener} * * @return listener method */ public Method getListener() { return Stream .of(getType().getMethods()) .filter(m -> m.isAnnotationPresent(ElementListener.class)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("No @ElementListener method in " + getType())); } }
p.getIcon(), emptyList(), singletonList("MAIN"))), c.getProcessors().values().stream().map(p -> { final Method listener = p.getListener(); return new Component(p.getParent().getCategories(), p.getParent().getName(), p.getName(), .findBundle(container.getLoader(), Locale.ENGLISH) .displayName() .orElse(p.getName()), p.getIcon(), getDesignModel(p).getInputFlows(), getDesignModel(p).getOutputFlows()); })))
.getProcessors() .put(name, new ComponentFamilyMeta.ProcessorMeta(component, name, findIcon(type), findVersion(type), type, parameterMetas, instantiator, migrationHandlerFactory.findMigrationHandler(parameterMetas, type, services),
@Override protected void doExecute() throws MojoExecutionException, MojoFailureException { if (!classes.exists()) { throw new MojoExecutionException("No " + classes); } try (final ComponentManager manager = new ComponentManager(repository, "TALEND-INF/dependencies.txt", "org.talend.sdk.component:type=component,value=%s") { { addPlugin(artifactId, classes.getAbsolutePath()); } }) { final Container container = manager.findPlugin(artifactId).get(); final ContainerComponentRegistry registry = container.get(ContainerComponentRegistry.class); registry.getComponents().values().forEach(c -> { c .getPartitionMappers() .forEach((k, p) -> getLog().info("Found component " + c.getName() + "#" + p.getName())); c .getProcessors() .forEach((k, p) -> getLog().info("Found component " + c.getName() + "#" + p.getName())); }); doWork(manager, container, registry); } }