Tapestry
  1. Tapestry
  2. TAPESTRY-1924

Allow for templates coming from stream

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.6
    • Fix Version/s: 5.0.12
    • Component/s: tapestry-core, tapestry-ioc
    • Labels:
      None

      Description

      In the current version Tapestry parses templates coming from java.net.URL. If the template is not in the filesystem (for example coming from database), it is more easier to implement this if Tapestry can parse the template coming from stream.
      My suggestion is to extend the org.apache.tapestry.ioc.Resource interface with one more method:

      InputStream toStream();

      which will be called insted of calling toURL().openStream() when parsing the template.

      If this interface is extended in this way, Tapestry should expect org.apache.tapestry.ioc.Resource.toURL() to return null even when the resource exists(but does not have an URL).

        Activity

        Kalin Krustev created issue -
        Hide
        Howard M. Lewis Ship added a comment -

        Probably should add an exists() method to determine whether the file exists, rather than trusting toURL() or toStream() to return non-null. Those methods can then change to return a non-null object or throw an exception. Possibly toURL() will not be needed.

        Show
        Howard M. Lewis Ship added a comment - Probably should add an exists() method to determine whether the file exists, rather than trusting toURL() or toStream() to return non-null. Those methods can then change to return a non-null object or throw an exception. Possibly toURL() will not be needed.
        Hide
        Kalin Krustev added a comment -

        Yes, throwing an exception also seems good and removing toURL from org.apache.tapestry.ioc.Resource is also going to make interface simpler. But when I looked the source it seemed simpler to keep toURL. Howard, it's your decision if it will be kept, my issue was for supporting resources coming from stream.

        Show
        Kalin Krustev added a comment - Yes, throwing an exception also seems good and removing toURL from org.apache.tapestry.ioc.Resource is also going to make interface simpler. But when I looked the source it seemed simpler to keep toURL. Howard, it's your decision if it will be kept, my issue was for supporting resources coming from stream.
        Howard M. Lewis Ship made changes -
        Field Original Value New Value
        Assignee Howard M. Lewis Ship [ hlship ]
        Howard M. Lewis Ship made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Howard M. Lewis Ship added a comment -

        Added two methods to Resource: exists() and openStream().

        Resources that can open a stream but not provide a URL should work fine throughout the framework. The built-in implementations of Resource base exists() and openStream() on toURL(), but other implementations of Resource may work quite differently.

        Show
        Howard M. Lewis Ship added a comment - Added two methods to Resource: exists() and openStream(). Resources that can open a stream but not provide a URL should work fine throughout the framework. The built-in implementations of Resource base exists() and openStream() on toURL(), but other implementations of Resource may work quite differently.
        Howard M. Lewis Ship made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 5.0.12 [ 12313048 ]
        Status In Progress [ 3 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12417544 ] Default workflow, editable Closed status [ 12568628 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12568628 ] jira [ 12590100 ]

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Kalin Krustev
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development