You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2010/06/22 10:31:54 UTC

[jira] Created: (SLING-1566) Add ResourceResolver.isLive() method

Add ResourceResolver.isLive() method
------------------------------------

                 Key: SLING-1566
                 URL: https://issues.apache.org/jira/browse/SLING-1566
             Project: Sling
          Issue Type: Improvement
          Components: API, JCR
    Affects Versions: JCR Prefs 1.0.0
            Reporter: Felix Meschberger
            Assignee: Felix Meschberger
             Fix For: JCR Resource 2.0.8, API 2.1.0


SLING-1262 added a close() method to the ResourceResolver declaring that an exception will be thrown if the ResourceResolver is used after it has been closed.

To be able to check a ResourceResolver in application code, an isLive method should be added.

In addition, the actual exception being thrown if the ResourceResolver has been closed should also be logged.

Finally, in the JcrResourceReslver, the live-check is mainly implemented in the checkClosed() method. Probably this method should not only check the close state of itself but also, whether the underlying primary session is still alive. If the ResourceResolver has not been closed yet, but the session has already been logged out, the JcrResourceResolver may choose to close itself too (as a side effect). This is to be discussed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Created: (SLING-1566) Add ResourceResolver.isLive() method

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,


On 22.06.2010 10:31, Felix Meschberger (JIRA) wrote:
> Add ResourceResolver.isLive() method
> ------------------------------------
>                  URL: https://issues.apache.org/jira/browse/SLING-1566
>
> Finally, in the JcrResourceReslver, the live-check is mainly implemented
> in the checkClosed() method. Probably this method should not only check
> the close state of itself but also, whether the underlying primary
> session is still alive. If the ResourceResolver has not been closed
> yet, but the session has already been logged out, the JcrResourceResolver
> may choose to close itself too (as a side effect). This is to be discussed.

My idea is to modify the JcrResourceResolver.isLive() and .checkClosed()
methods as follows:

   public boolean isLive() {
       if (closed) {
           return false;
       }

       if (getSession().isLive()) {
           return true;
       }

       this.close();
       return false;
   }

   private void checkClosed() {
       if (!isLive()) {
           throw new IllegalStateException(...);
       }
   }

The nice thing here is, that the ResourceResolver live state also in
reality depends on the Session live state. This makes sense, because
Jackrabbit 2 will close sessions automatically if it recognizes a
session to be used by multiple threads concurrently for writing.

The disadvantage is, that a ResourceResolver will be closed as a side
effect of checking whether it is still alive.

WDYT ?

Regards
Felix

[jira] Resolved: (SLING-1566) Add ResourceResolver.isLive() method

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved SLING-1566.
--------------------------------------

    Resolution: Fixed

This issue can be resolved because the implementation is complete.

> Add ResourceResolver.isLive() method
> ------------------------------------
>
>                 Key: SLING-1566
>                 URL: https://issues.apache.org/jira/browse/SLING-1566
>             Project: Sling
>          Issue Type: Improvement
>          Components: API, JCR
>    Affects Versions: JCR Prefs 1.0.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: JCR Resource 2.0.8, API 2.1.0
>
>
> SLING-1262 added a close() method to the ResourceResolver declaring that an exception will be thrown if the ResourceResolver is used after it has been closed.
> To be able to check a ResourceResolver in application code, an isLive method should be added.
> In addition, the actual exception -- IllegalStateException -- being thrown if the ResourceResolver has been closed should also be documented.
> Finally, in the JcrResourceReslver, the live-check is mainly implemented in the checkClosed() method. Probably this method should not only check the close state of itself but also, whether the underlying primary session is still alive. If the ResourceResolver has not been closed yet, but the session has already been logged out, the JcrResourceResolver may choose to close itself too (as a side effect). This is to be discussed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1566) Add ResourceResolver.isLive() method

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12881129#action_12881129 ] 

Felix Meschberger commented on SLING-1566:
------------------------------------------

Added isLive method to ResourceResolver interface and implementations in the JCR Resource bundle in Rev. 956813.

Also documented the IllegalStateException being thrown on methods if ResourceResolver is closed and added a close-check to the JcrResourceResolver.getUserID() method.

> Add ResourceResolver.isLive() method
> ------------------------------------
>
>                 Key: SLING-1566
>                 URL: https://issues.apache.org/jira/browse/SLING-1566
>             Project: Sling
>          Issue Type: Improvement
>          Components: API, JCR
>    Affects Versions: JCR Prefs 1.0.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: JCR Resource 2.0.8, API 2.1.0
>
>
> SLING-1262 added a close() method to the ResourceResolver declaring that an exception will be thrown if the ResourceResolver is used after it has been closed.
> To be able to check a ResourceResolver in application code, an isLive method should be added.
> In addition, the actual exception -- IllegalStateException -- being thrown if the ResourceResolver has been closed should also be documented.
> Finally, in the JcrResourceReslver, the live-check is mainly implemented in the checkClosed() method. Probably this method should not only check the close state of itself but also, whether the underlying primary session is still alive. If the ResourceResolver has not been closed yet, but the session has already been logged out, the JcrResourceResolver may choose to close itself too (as a side effect). This is to be discussed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SLING-1566) Add ResourceResolver.isLive() method

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated SLING-1566:
-------------------------------------

    Description: 
SLING-1262 added a close() method to the ResourceResolver declaring that an exception will be thrown if the ResourceResolver is used after it has been closed.

To be able to check a ResourceResolver in application code, an isLive method should be added.

In addition, the actual exception -- IllegalStateException -- being thrown if the ResourceResolver has been closed should also be documented.

Finally, in the JcrResourceReslver, the live-check is mainly implemented in the checkClosed() method. Probably this method should not only check the close state of itself but also, whether the underlying primary session is still alive. If the ResourceResolver has not been closed yet, but the session has already been logged out, the JcrResourceResolver may choose to close itself too (as a side effect). This is to be discussed.

  was:
SLING-1262 added a close() method to the ResourceResolver declaring that an exception will be thrown if the ResourceResolver is used after it has been closed.

To be able to check a ResourceResolver in application code, an isLive method should be added.

In addition, the actual exception being thrown if the ResourceResolver has been closed should also be logged.

Finally, in the JcrResourceReslver, the live-check is mainly implemented in the checkClosed() method. Probably this method should not only check the close state of itself but also, whether the underlying primary session is still alive. If the ResourceResolver has not been closed yet, but the session has already been logged out, the JcrResourceResolver may choose to close itself too (as a side effect). This is to be discussed.


> Add ResourceResolver.isLive() method
> ------------------------------------
>
>                 Key: SLING-1566
>                 URL: https://issues.apache.org/jira/browse/SLING-1566
>             Project: Sling
>          Issue Type: Improvement
>          Components: API, JCR
>    Affects Versions: JCR Prefs 1.0.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: JCR Resource 2.0.8, API 2.1.0
>
>
> SLING-1262 added a close() method to the ResourceResolver declaring that an exception will be thrown if the ResourceResolver is used after it has been closed.
> To be able to check a ResourceResolver in application code, an isLive method should be added.
> In addition, the actual exception -- IllegalStateException -- being thrown if the ResourceResolver has been closed should also be documented.
> Finally, in the JcrResourceReslver, the live-check is mainly implemented in the checkClosed() method. Probably this method should not only check the close state of itself but also, whether the underlying primary session is still alive. If the ResourceResolver has not been closed yet, but the session has already been logged out, the JcrResourceResolver may choose to close itself too (as a side effect). This is to be discussed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.