Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-1236

Scala Scripting: Make all types of the script arguments visible on the Scala side

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • Scripting
    • None

    Description

      Currently the Scala scripting engine inserts a preamble for the bindings passed to a Script. The preamble contains a declaration of the following form for each value in the Bindings instance:

      val request: SlingHttpServletRequest = bindings.get("request").asInstanceOf[SlingHttpServletRequest]

      The types are hard coded in the ScalaScriptEngine.TypeHints class. For unknown types a declaration of type AnyRef is inserted into the preamble.

      I suggest to implement a run time type discovery algorithm which discovers the accessible type from a given instance and inserts the respective declarations into the preamble. That way the static coupling between the known values in Bindings and its types would go away. Furthermore the values would be of a type appearing to be of all the visible types on the Scala side.

      Attachments

        1. SLING-1236.patch
          25 kB
          Michael Dürig

        Activity

          People

            cziegeler Carsten Ziegeler
            mduerig Michael Dürig
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: