io.bootique.linkmove.LinkMoveFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bootique-linkmove Show documentation
Show all versions of bootique-linkmove Show documentation
Provides LinkMove integration with Bootique.
package io.bootique.linkmove;
import com.google.inject.Injector;
import com.nhl.link.move.connect.Connector;
import com.nhl.link.move.runtime.LmRuntime;
import com.nhl.link.move.runtime.LmRuntimeBuilder;
import io.bootique.linkmove.connector.IConnectorFactoryFactory;
import io.bootique.linkmove.connector.JdbcConnectorFactoryFactory;
import io.bootique.linkmove.connector.URIConnectorFactoryFactory;
import org.apache.cayenne.configuration.server.ServerRuntime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class LinkMoveFactory {
private String extractorsDir;
private List> connectorFactories;
public LinkMoveFactory() {
this.extractorsDir = ".";
this.connectorFactories = new ArrayList<>();
// add default factories
connectorFactories.add(new JdbcConnectorFactoryFactory());
connectorFactories.add(new URIConnectorFactoryFactory());
}
public LmRuntime createLinkMove(Injector injector, ServerRuntime targetRuntime,
Set builderCallbacks) {
Objects.requireNonNull(extractorsDir);
LmRuntimeBuilder builder = new LmRuntimeBuilder().withTargetRuntime(targetRuntime).extractorModelsRoot(extractorsDir);
connectorFactories.forEach(factory -> addToBuilder(builder, factory, injector));
builderCallbacks.forEach(c -> c.build(builder));
return builder.build();
}
protected void addToBuilder(LmRuntimeBuilder builder, IConnectorFactoryFactory factoryFactory, Injector injector) {
builder.withConnectorFactory(factoryFactory.getConnectorType(), factoryFactory.getConnectorFactory(injector));
}
public List> getConnectorFactories() {
return connectorFactories;
}
public void setConnectorFactories(List> connectorFactories) {
this.connectorFactories = connectorFactories;
}
public String getExtractorsDir() {
return extractorsDir;
}
public void setExtractorsDir(String extractorsDir) {
this.extractorsDir = extractorsDir;
}
}