Search in sources :

Example 1 with JarRuntimeInfo

use of org.talend.components.api.component.runtime.JarRuntimeInfo in project tdi-studio-se by Talend.

the class Component method getModulesNeeded.

@Override
public List<ModuleNeeded> getModulesNeeded(INode node) {
    List<ModuleNeeded> componentImportNeedsList = new ArrayList<>();
    ConnectorTopology topology = null;
    if (node != null) {
        boolean hasInput = !NodeUtil.getIncomingConnections(node, IConnectionCategory.DATA).isEmpty();
        boolean hasOutput = !NodeUtil.getOutgoingConnections(node, IConnectionCategory.DATA).isEmpty();
        if (hasInput && hasOutput) {
            topology = ConnectorTopology.INCOMING_AND_OUTGOING;
        } else if (hasInput) {
            topology = ConnectorTopology.INCOMING;
        } else if (hasOutput) {
            topology = ConnectorTopology.OUTGOING;
        } else {
            topology = ConnectorTopology.NONE;
        }
    } else {
        Set<ConnectorTopology> topologies = componentDefinition.getSupportedConnectorTopologies();
        if (!topologies.isEmpty()) {
            topology = topologies.iterator().next();
        }
    }
    RuntimeInfo runtimeInfo = null;
    try {
        runtimeInfo = componentDefinition.getRuntimeInfo(ExecutionEngine.DI, node == null ? null : node.getComponentProperties(), topology);
    } catch (Exception e) {
        if (node == null) {
        // not handled, must because the runtime info must have a node configuration (properties are null)
        } else {
            ExceptionHandler.process(e);
        }
    }
    if (runtimeInfo != null) {
        if (runtimeInfo instanceof JarRuntimeInfo) {
            JarRuntimeInfo currentRuntimeInfo = (JarRuntimeInfo) runtimeInfo;
            JarRuntimeInfo localRuntimeInfo = new JarRuntimeInfo(//$NON-NLS-1$
            currentRuntimeInfo.getJarUrl().toString().replace(//$NON-NLS-1$
            "mvn:", //$NON-NLS-1$ //$NON-NLS-2$
            "mvn:" + MavenConstants.LOCAL_RESOLUTION_URL + "!"), currentRuntimeInfo.getDepTxtPath(), currentRuntimeInfo.getRuntimeClassName());
            runtimeInfo = localRuntimeInfo;
        }
        final Bundle bundle = FrameworkUtil.getBundle(componentDefinition.getClass());
        for (URL mvnUri : runtimeInfo.getMavenUrlDependencies()) {
            //$NON-NLS-1$
            ModuleNeeded moduleNeeded = new ModuleNeeded(getName(), "", true, mvnUri.toString());
            componentImportNeedsList.add(moduleNeeded);
            if (bundle != null) {
                // update module location
                try {
                    final MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(moduleNeeded.getMavenUri());
                    final String moduleFileName = artifact.getFileName();
                    final File bundleFile = BundleFileUtil.getBundleFile(bundle, moduleFileName);
                    if (bundleFile != null && bundleFile.exists()) {
                        // FIXME, better install the embed jars from bundle directly in this way.
                        moduleNeeded.setModuleLocaion(ExtensionModuleManager.URIPATH_PREFIX + bundle.getSymbolicName() + '/' + moduleFileName);
                    }
                } catch (IOException e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
    ModuleNeeded moduleNeeded = new ModuleNeeded(getName(), "", true, "mvn:org.talend.libraries/slf4j-log4j12-1.7.2/6.0.0");
    componentImportNeedsList.add(moduleNeeded);
    moduleNeeded = new ModuleNeeded(getName(), "", true, "mvn:org.talend.libraries/talend-codegen-utils/0.17.0-SNAPSHOT");
    componentImportNeedsList.add(moduleNeeded);
    return componentImportNeedsList;
}
Also used : JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) IOException(java.io.IOException) BusinessException(org.talend.commons.exception.BusinessException) IOException(java.io.IOException) URL(java.net.URL) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) MavenArtifact(org.talend.core.runtime.maven.MavenArtifact) File(java.io.File) ConnectorTopology(org.talend.components.api.component.ConnectorTopology)

Example 2 with JarRuntimeInfo

use of org.talend.components.api.component.runtime.JarRuntimeInfo in project components by Talend.

the class KinesisInputDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology topology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(topology);
    try {
        return new JarRuntimeInfo(new URL("mvn:org.talend.components/kinesis-runtime"), DependenciesReader.computeDependenciesFilePath("org.talend.components", "kinesis-runtime"), RUNTIME);
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Example 3 with JarRuntimeInfo

use of org.talend.components.api.component.runtime.JarRuntimeInfo in project components by Talend.

the class KinesisOutputDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology topology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(topology);
    try {
        return new JarRuntimeInfo(new URL("mvn:org.talend.components/kinesis-runtime"), DependenciesReader.computeDependenciesFilePath("org.talend.components", "kinesis-runtime"), RUNTIME);
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Example 4 with JarRuntimeInfo

use of org.talend.components.api.component.runtime.JarRuntimeInfo in project components by Talend.

the class DevNullOutputDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(connectorTopology);
    try {
        return new JarRuntimeInfo(new URL(LocalIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(LocalIOComponentFamilyDefinition.MAVEN_GROUP_ID, LocalIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_ARTIFACT_ID), RUNTIME);
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Example 5 with JarRuntimeInfo

use of org.talend.components.api.component.runtime.JarRuntimeInfo in project components by Talend.

the class RowGeneratorDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(connectorTopology);
    try {
        return new JarRuntimeInfo(new URL(LocalIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(LocalIOComponentFamilyDefinition.MAVEN_GROUP_ID, LocalIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_ARTIFACT_ID), RUNTIME);
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Aggregations

JarRuntimeInfo (org.talend.components.api.component.runtime.JarRuntimeInfo)44 URL (java.net.URL)28 MalformedURLException (java.net.MalformedURLException)27 ComponentException (org.talend.components.api.exception.ComponentException)27 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)7 Test (org.junit.Test)5 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Bundle (org.osgi.framework.Bundle)1 BusinessException (org.talend.commons.exception.BusinessException)1 ConnectorTopology (org.talend.components.api.component.ConnectorTopology)1 NetSuiteConnectionProperties (org.talend.components.netsuite.connection.NetSuiteConnectionProperties)1 ModuleNeeded (org.talend.core.model.general.ModuleNeeded)1 MavenArtifact (org.talend.core.runtime.maven.MavenArtifact)1