Search in sources :

Example 1 with ComponentDao

use of org.talend.sdk.component.server.dao.ComponentDao in project component-runtime by Talend.

the class ComponentManagerService method init.

@PostConstruct
private void init() {
    ofNullable(configuration.mavenRepository()).ifPresent(repo -> System.setProperty("talend.component.manager.m2.repository", repo));
    mvnCoordinateToFileConverter = new MvnCoordinateToFileConverter();
    instance = ComponentManager.instance();
    deploymentListener = new DeploymentListener(componentDao, componentFamilyDao, actionDao, configurationDao);
    instance.getContainer().registerListener(deploymentListener);
    // note: we don't want to download anything from the manager, if we need to download any artifact we need
    // to ensure it is controlled (secured) and allowed so don't make it implicit but enforce a first phase
    // where it is cached locally (provisioning solution)
    ofNullable(configuration.componentCoordinates()).orElse(emptyList()).forEach(this::deploy);
    ofNullable(configuration.componentRegistry()).map(File::new).filter(File::exists).ifPresent(registry -> {
        final Properties properties = new Properties();
        try (final InputStream is = new FileInputStream(registry)) {
            properties.load(is);
        } catch (final IOException e) {
            throw new IllegalArgumentException(e);
        }
        properties.stringPropertyNames().stream().map(properties::getProperty).filter(gav -> !configuration.componentCoordinates().contains(gav)).forEach(this::deploy);
    });
}
Also used : Stream.empty(java.util.stream.Stream.empty) MvnCoordinateToFileConverter(org.talend.sdk.component.dependencies.maven.MvnCoordinateToFileConverter) Produces(javax.enterprise.inject.Produces) ComponentFamilyMeta(org.talend.sdk.component.runtime.manager.ComponentFamilyMeta) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ComponentServerConfiguration(org.talend.sdk.component.server.configuration.ComponentServerConfiguration) ConfigurationDao(org.talend.sdk.component.server.dao.ConfigurationDao) Observes(javax.enterprise.event.Observes) Config(org.talend.sdk.component.design.extension.repository.Config) Collectors.toSet(java.util.stream.Collectors.toSet) ComponentFamilyDao(org.talend.sdk.component.server.dao.ComponentFamilyDao) Properties(java.util.Properties) ContainerListener(org.talend.sdk.component.container.ContainerListener) ContainerComponentRegistry(org.talend.sdk.component.runtime.manager.ContainerComponentRegistry) Container(org.talend.sdk.component.container.Container) Collections.emptyList(java.util.Collections.emptyList) Optional.ofNullable(java.util.Optional.ofNullable) Artifact(org.talend.sdk.component.dependencies.maven.Artifact) Collection(java.util.Collection) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) File(java.io.File) RepositoryModel(org.talend.sdk.component.design.extension.RepositoryModel) ComponentActionDao(org.talend.sdk.component.server.dao.ComponentActionDao) Collectors.toList(java.util.stream.Collectors.toList) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) ComponentDao(org.talend.sdk.component.server.dao.ComponentDao) PostConstruct(javax.annotation.PostConstruct) Data(lombok.Data) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ComponentManager(org.talend.sdk.component.runtime.manager.ComponentManager) AllArgsConstructor(lombok.AllArgsConstructor) InputStream(java.io.InputStream) Initialized(javax.enterprise.context.Initialized) MvnCoordinateToFileConverter(org.talend.sdk.component.dependencies.maven.MvnCoordinateToFileConverter) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) PostConstruct(javax.annotation.PostConstruct)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Properties (java.util.Properties)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 Stream.empty (java.util.stream.Stream.empty)1 PostConstruct (javax.annotation.PostConstruct)1 PreDestroy (javax.annotation.PreDestroy)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Initialized (javax.enterprise.context.Initialized)1 Observes (javax.enterprise.event.Observes)1 Produces (javax.enterprise.inject.Produces)1 Inject (javax.inject.Inject)1 AllArgsConstructor (lombok.AllArgsConstructor)1