我一直在关注了Talend 教程中的“如何创建自定义组件”。 如果我效法一字不差,与我的文件命名如下,并放置在文件夹内tTutorialRow
,本教程的工作原理:
tTutorialRow_java.xml
tTutorialRow_messages.properties
tTutorialRow_begin.javajet
tTutorialRow_main.javajet
tTutorialRow_end.javajet
这是使用下面的代码:
tTutorialRow_java.xml:
<COMPONENT>
<HEADER
PLATEFORM="ALL"
SERIAL=""
VERSION="2.0"
STATUS="ALPHA"
COMPATIBILITY="ALL"
AUTHOR="Talend"
RELEASE_DATE="20070525A"
STARTABLE="false"
>
<SIGNATURE/>
</HEADER>
<FAMILIES>
<FAMILY>Helium</FAMILY>
</FAMILIES>
<DOCUMENTATION>
<URL/>
</DOCUMENTATION>
<CONNECTORS>
<CONNECTOR CTYPE="FLOW" MAX_INPUT="1"/>
<CONNECTOR CTYPE="ITERATE" MAX_OUTPUT="1" MAX_INPUT="1"/>
<CONNECTOR CTYPE="SUBJOB_OK" MAX_INPUT="1" />
<CONNECTOR CTYPE="SUBJOB_ERROR" MAX_INPUT="1" />
<CONNECTOR CTYPE="COMPONENT_OK" />
<CONNECTOR CTYPE="COMPONENT_ERROR" />
<CONNECTOR CTYPE="RUN_IF" />
</CONNECTORS>
<PARAMETERS>
<PARAMETER NAME="ADDRESSES" FIELD="TABLE" REQUIRED="true" NUM_ROW="3" NB_LINES="5" SHOW="true">
<ITEMS BASED_ON_SCHEMA="false">
<ITEM NAME="USERNAME" />
<ITEM NAME="DOMAIN" />
</ITEMS>
</PARAMETER>
</PARAMETERS>
<CODEGENERATION/>
<RETURNS>
<RETURN NAME="NB_LINE" TYPE="id_Integer" AVAILABILITY="AFTER"/>
</RETURNS>
</COMPONENT>
tTutorialRow_messages.properties:
LONG_NAME=Tutorial component
HELP=org.talend.help.TutorialRow
NB_LINE.NAME=Number of lines
ADDRESSES.ITEM.USERNAME=Username
ADDRESSES.ITEM.DOMAIN=Domain
ADDRESSES.NAME=Addresses
tTutorialRow_begin.javajet:
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.process.IConnection
org.talend.core.model.process.IConnectionCategory
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
java.util.List
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
List<Map<String, String>> lines = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__ADDRESSES__");
%>
java.util.List<String> addresses_<%=cid %> = new java.util.ArrayList<String>();
<%
for (int i=0; i<lines.size(); i++) {
Map<String, String> line = lines.get(i);
%>
addresses_<%=cid %>.add(<%= line.get("USERNAME") %> + "@" + <%= line.get("DOMAIN") %>);
<%
}
%>
int nb_line_<%=cid %> = 0;
tTutorialRow_main.javajet:
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.process.IConnection
org.talend.core.model.process.IConnectionCategory
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
java.util.List
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
%>
String[] adresses_<%=cid %> = addresses_<%=cid %>.toArray(new String[] {});
System.out.print(nb_line_<%=cid %>++ + ": ");
for (int i_<%=cid %> = 0; i_<%=cid %> < adresses_<%=cid %>.length; i_<%=cid %>++ )
{
System.out.print(adresses_<%=cid %>[i_<%=cid %>]);
if (i_<%=cid %> < adresses_<%=cid %>.length-1) System.out.print(",");
}
System.out.println();
tTutorialRow_end.javajet:
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.process.IConnection
org.talend.core.model.process.IConnectionCategory
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
java.util.List
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
%>
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid %>);
如果我更改文件名来自:
tTutorialRow_java.xml
tTutorialRow_messages.properties
tTutorialRow_begin.javajet
tTutorialRow_main.javajet
tTutorialRow_end.javajet
至:
myProject_java.xml
myProject_messages.properties
myProject_begin.javajet
myProject_main.javajet
myProject_end.javajet
并更新文件夹名称myProject的,添加成分不再起作用。 我怎样才能用新名称添加的组件?
谢谢!