All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generator.component.Source.mustache Maven / Gradle / Ivy

Go to download

Web application allowing to generate maven or gradle project skeleton to speed up component development.

There is a newer version: 10.57.0
Show newest version
package {{package}};

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.talend.sdk.component.api.configuration.Option;
import org.talend.sdk.component.api.input.Producer;
import org.talend.sdk.component.api.meta.Documentation;
{{#generic}}
import org.talend.sdk.component.api.record.Record;
import org.talend.sdk.component.api.service.record.RecordBuilderFactory;

{{/generic}}

import {{servicePackage}}.{{serviceName}};

@Documentation("TODO fill the documentation for this source")
public class {{className}} implements Serializable {
    private final {{configurationName}} configuration;
    private final {{serviceName}} service;
{{#generic}}
    private final RecordBuilderFactory builderFactory;
{{/generic}}

    public {{className}}(@Option("configuration") final {{configurationName}} configuration,
                        final {{serviceName}} service{{#generic}},
                        final RecordBuilderFactory builderFactory{{/generic}}) {
        this.configuration = configuration;
        this.service = service;
{{#generic}}
        this.builderFactory = builderFactory;
{{/generic}}
    }

    @PostConstruct
    public void init() {
        // this method will be executed once for the whole component execution,
        // this is where you can establish a connection for instance
    }

    @Producer
    public {{#generic}}Record{{/generic}}{{^generic}}{{modelName}}{{/generic}} next() {
        // this is the method allowing you to go through the dataset associated
        // to the component configuration
        //
        // return null means the dataset has no more data to go through
{{#generic}}        // you can use the builderFactory to create a new Record.{{/generic}}
        return null;
    }

    @PreDestroy
    public void release() {
        // this is the symmetric method of the init() one,
        // release potential connections you created or data you cached
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy