Hello everyone,
I am trying to write a custom FME transformer using the FME Plug-in SDK with Java.
I installed the FME Plug-in SDK and successfully followed the steps of the Java tutorial document (after installing the SDK, the tutorial document is located at '<FME>\pluginbuilder\samples\doc\FMEPlugInSDK_Java.pdf'; I attached it to this posting; especially section 4 "Installing and Testing a Transformer" is relevant to my question; ). In section 4 of this document
- the custom transfomer defined in file 'CenterOfMassCalculator_Java.fmx' is installed
- after installing, the FME workspace '..\java\test\function_test.fmw' is run which contains the 'CenterOfMassCalculator_Java' transformer as second element in the translation flow
Eventually, running 'function_test.fmw' in the FME workbench results in that the method 'execute(.)' of the Java class '<FME>\pluginbuilder\samples\java\com\mycompany\myfunction\center.java' is executed.
I am able to attach with the debugger of my IDE and track the code execution there. Moreover, I can also
- change the code in this method,
- build a new JAR with the changed code,
- replace '<FME>\plugins\tfs.jar' with this new JAR,
- and observe the effects of my changes in FME:
So all good with regard to the tutorial itself.
However, what I do not understand is how the connection between the transformer definition in the 'CenterOfMassCalculator_Java.fmx' file and the 'center.java' class is achieved.
Can anyone explain how FME "knows" that
- - the 'execute(.)' method
- - of class 'com.mycompany.myfunction.center.java'
- - in the JAR '<FME>\plugins\tfs.jar'
shall be executed?
Moreover, imagine I have a class 'com.mycompany.myfunction.Center2.java' which---just like 'com.mycompany.myfunction.center.java'---implements the interface IFMEFunction. How can I tell the transformer to jump into the class 'Center2.java' instead of jumping into class 'center.java'?
The 'CenterOfMassCalculator_Java.fmx' file definition is understandable to me up to the point when the template definition is reached (I attached the entire .fmx file to this posting):
...
TEMPLATE_START
FACTORY_DEF * TeeFactory
FACTORY_NAME $(XFORMER_NAME)
$(INPUT_LINES)
OUTPUT FEATURE_TYPE $(OUTPUT_OUTPUT_FTYPE)
@JavaCenter($(X_ATTR),$(Y_ATTR),$(Z_ATTR))
$(OUTPUT_OUTPUT_FUNCS)
TEMPLATE_END
I found some documentation on the definition of .fmx files and the so-called TeeFactory which is used in the template:
- - https://docs.safe.com/fme/html/FME_Transformer_Definition/index.html
- - https://docs.safe.com/fme/html/FME_FactFunc/doc_pages/teefactory.txt
However, from these documents, I could not deviate how the connection from .fmx definitions to concrete Java code is achieved. I think the key part is the '@JavaCenter' annotation.
Is anyone able to help? Or is the only way to contact Safe Software for an integration project (as suggested here in step 4: https://community.safe.com/s/article/developing-a-new-transformer-using-the-fme-plug-in)?
(I also compiled the posting into a PDF which might be easier to read than the posting here in the forum, please see attachments.)
Any help would be greatly appreciated!