Adding custom remote functions

You can create a custom bundle to export your own remote functions for use inside expressions. The exm.service=true entry instructs Expression manager, that the service contains remote functions suitable for use in expressions. The <service_id> value must be a valid Java identifier (alphanumeric,$, _ with no other special characters). This value, prefixed with the REMOTE_ keyword, forms the prefix which is used inside expressions. For example, an interface with an annotated method bar() and the service ID foo in the BluePrint service properties, can be referenced inside expressions using REMOTE_foo:bar(). To create a custom bundle to export your own remote functions, perform the following tasks:
  1. Ensure that the Expression Manager classes, specifically the com.adobe.exm.expeval package, are imported in the bundle's manifest.

  2. Define an interface for the OSGi service containing methods which are being exported for use by Expression Manager.

  3. Declare methods on the interface A and annotate them with the @ServiceMethod annotation (com.adobe.exm.expeval.ServiceMethod). Expression Manager ignores any unannotated methods. The ServiceMethod annotation has the following optional attributes which can also be specified:

    • enabled: Determines if this method is enabled. Expression Manager ignores disabled methods.

    • familyId: Specifies the method’s family (group). If empty, Expression Manager assumes that the method belongs to the default family. There is no registry of families (except for the default one) from which functions are chosen. Expression Manager dynamically creates the registry by taking a union of all family IDs specified by all the functions exported by the various bundles. Ensure that the ID they specify here is reasonably readable, since it displays in the expression authoring user interface as well.

    • displayName: A human-readable name for the function. This name is used for display purposes in the authoring user interface. If empty, Expression Manager constructs a default name using the function's prefix and local-name.

    • description: A verbose description for the function. This description is used for display purposes in the authoring user interface. If empty, Expression Manager constructs a default description using the function's prefix and local-name.

The parameters of the methods can also be optionally annotated using the @ServiceMethodParameter annotation (com.adobe.exm.expeval.ServiceMethodParameter). This annotation is only used for specifying human-readable names and descriptions of method parameters for use in the authoring user interface.
  1. Ensure that the parameters and return-values of the interface methods belong to one of the following types:

    • java.lang.String

    • java.lang.Character

    • char

    • java.lang.Boolean

    • boolean

    • java.lang.Integer

    • int

    • java.lang.Short

    • short

    • java.lang.Byte

    • byte

    • java.lang.Double

    • double

    • java.lang.Long

    • long

    • java.lang.Float

    • float

    • java.util.Calendar

    • java.util.Date

  2. Define the implementation of the interface, configure it as a Spring bean and export it as an OSGi service via BluePrint with the following special properties:
    <bp:service interface="A" ref="<bean_id_of_Impl_of_Interface_A> "> 
        <bp:service-properties> 
           <entry key="connectors.httpinvoker" value="true" /> 
           <entry key="connectors.httpinvoker.alias" value="/<service_id> " /> 
           <entry key="connectors.remoting" value="true" /> 
           <entry key="connectors.remoting.id" value="<service_id>" /> 
           <entry key="exm.service" value="true" /> 
        </bp:service-properties> 
    </bp:service>

// Ethnio survey code removed