Uploaded image for project: '[Read Only] - Hippo Site Toolkit 2'
  1. [Read Only] - Hippo Site Toolkit 2
  2. HSTTWO-1965

@Persistable annotation support which enables using a writable session during the annotated method call

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • High
    • Resolution: Fixed
    • None
    • 2.24.02, 2.25.00-alpha
    • None
    • None

    Description

      My short-term goal is to avoid #refresh() invocation on the default
      session by using only writable session in the annotated operation (@Persistable).

      If an operation of JAX-RS Service is annotated by @Persistable, then HstRequestContext#getSession() will return a writable session by default.
      This lets us use writable session only during the method invocation.

      Of course we still have to re-fetch beans, but my idea can improve a
      little by avoiding another #refresh() call. See the examples below.

      Regarding "how can you know what other code was already executed and
      fetched virtual nodes?":

      • This is not my short-term improvement goal yet. So, the
        architectural enhancements could save this situation in the end.
      • My solution is about the short-term improvement only.

      Let me explain my small improvement again here with examples.

      Currently, I have to write this, for instance:

      public void updateDocument(...) {
      scopeBean = getMountContentBaseBean();
      document = findDocument(scopeBean);
      wpm.update(document);
      requestContext.getSession().refresh(false); // This is needed
      // because document is from default session
      // while wpm is from writable session
      scopeBean = getMountContentBaseBean();
      document = findDocument(scopeBean);
      }

      I'd like to write like the following instead:

      @Persistable
      public void updateDocument(...) {
      scopeBean = getMountContentBaseBean();
      document = findDocument(scopeBean);
      wpm.update(document);
      document = findDocument(scopeBean);
      }

      If the document is retrieved from #getContentBean(), then the examples
      will get shorter.

      My small improvement idea is just about removing another #refresh() call
      as you may see. And, scopeBean doesn't need to be re-fetched.

      My idea is just about a small improvement in the short term, looking
      less important.
      But, I think this can improve the following:

      • Removes error-prone steps with #refresh(), which is caused by using
        two different jcr sessions. One session for fetching/updating with
        annotation.
      • Code readability. Much simpler.

      Attachments

        Issue Links

          Activity

            People

              svoortman Simon Voortman (Inactive)
              wko Woonsan Ko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: