Custom Java Functions may be shared using an EventFlow project on which your projects depend. The project with the function group jar file must be present and open in your workspace to use the functions. Unlike Java Operators and Adapters, since Functions require HOCON declarations to be seen and used, Java Functions cannot be shared from a Maven dependency from either a fragment ZIP file or a jar file.
Steps
In the EventFlow fragment project to be shared, use the
New > StreamBase Java Functions wizard to create the function group class and define the set of functions it contains. Edit the created .java file normally to add functionality. Then in the user EventFlow (EF) or Live Datamart (LDM) project, add the dependency to the
pom.xml in the <dependencies> section (example):
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>myfunctions</artifactId>
<type>ep-eventflow-fragment</type>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
The wizard creates a
CustomFunctionGroup (
com.tibco.ep.streambase.configuration.sbengine) HOCON
.conf file in the function project's
src/main/configurations folder which declares each function. It is the
CustomFunctionGroup configuration which allows these functions to be used in Map operators, Aggregate operators, and other EventFlow expression contexts.
For the functions to remain available for typechecking, the project in which they are defined must be present and open in each workspace where they are used by dependent projects.
HOCON configuration in the function project is available from an EventFlow fragment. Care must be taken to make sure shared projects which supply HOCON have their HOCON "
name" and "
version" properties set uniquely from HOCON which may be present in the dependent projects. If two HOCON files are found across all projects and their dependencies with the same "
name" and "
version" then this is a conflict which will prevent the node from being installed.
Troubleshooting
If in Studio the custom Java function does not typecheck or the class is not found, doublecheck the EventFlow project's
pom.xml dependency and that the supplying project is referenced correctly in the dependent project's
pom.xml dependencies.
Use the right-click action on the EventFlow project:
Maven > Update Project, with "
Force Update of Snapshots/Releases" enabled to clear stale error status and attempt to resolve all dependencies.
Monitor build actions using the Eclipse "
Progress" view to ensure all build and typechecking actions have completed before trying to correct an error.
If you suspect the function declaration in the
CustomFunctionGroup configuration does not match the implementation of the function in the class, use the
New > StreamBase Java Functions wizard to create the stub function again in a new class to use as a syntax reference for comparison to see if there are any differences which would explain the problem. Have the wizard generate into a new
.java and HOCON file so that once you are satisfied you have checked them completely, these reference files may be deleted without impacting the implementation you intend to keep.