Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# Considerations when Defining the Functions

Java methods defining the functions can have primitive data types, or Concept, Event and Object. They can return any primitive data types or Concept, Event and Object.

If the custom functions have primitive data types only, it is also visible and usable in the mapper. In that case, the category attributes of the @BEPackage annotation is used as the folder for your custom functions.

Note: The interface has some limitations as it does not allow static methods. Do not use annotations when using interfaces. Create an interface as a normal java interface without any annotations and implement it in a class without any annotations. To see these interface methods under the custom catalog function, create a static overloading method with annotations.

For example:

Copy

    public interface InterfaceProjectLibTest
    {
            public abstract String[] getAllDestinations();

               public abstract String getClusterName();
    }

    public class interfImpl implements InterfaceProjectLibTest
    {
            static int count=0;
            @Override
            public String[] getAllDestinations()
            {
                    Object[] ars= null;
                    RuleSession rs = RuleSessionManager.getCurrentRuleSession();
                    String[] activdest=(String[])rs.invokeCatalog("Channel.getAllDestinations", ars);
                    count = activdest.length;
                    return activdest;
            }

            @Override
            public String getClusterName() {
                   // TODO Auto-generated method stub
                   Object[] ars= null;
                   RuleSession rs = RuleSessionManager.getCurrentRuleSession();
                   String clustername;
                   clustername=(rs.invokeCatalog("Cluster.getClusterName", ars)).toString();
                   return clustername;
            }

            @BEFunction(name = "getNoOfDests", signature= "getNoOfDests", description="Returns Number of destinations of the current rulesession")
            //@BEFunction
            public static int getNoOfDests()
            {
                   interfImpl im = new interfImpl();
                   im.getAllDestinations();
               +    System.out.println("count: " + count);
                   return count;
            }

            @BEFunction(name = "ReturnAllDestinations", signature= "getAllDest", description="Returns all destinations of the current rulesession")
            public static String[] getAllDest()
            {
                   interfImpl im = new interfImpl();
                   String[] activedests = im.getAllDestinations();

                   return activedests;

            }

            @BEFunction(name = "ReturnClusterName", signature= "getClusName()", description="Returns the clustername")
            public static String getClusName()
            {
                   interfImpl im = new interfImpl();
                   String clustername=im.getClusterName();
                   System.out.println("ClusterName is: " + clustername);
                   return clustername;
            }
    }

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.