[Hippo-cms7-user] Direct JCR Access...where is UserSession class?

Ard Schrijvers a.schrijvers at onehippo.com
Thu Sep 30 11:26:21 CEST 2010


On Thu, Sep 30, 2010 at 3:49 AM, Woonsan Ko <w.ko at onehippo.com> wrote:
>  Hi Matt,
>
> UserSession (org.hippoecm.frontend.session.UserSession) is in
> hippo-ecm-frontend-engine jar.
> Here's dependency information as an example. Version may be different.
>
> <dependency>
> <groupId>org.hippoecm</groupId>
> <artifactId>hippo-ecm-frontend-engine</artifactId>
> <version>2.12.20</version>
> </dependency>
>
> By the way, the guide in the documentation is only for CMS Plugin
> development, not for normal HST component development.
> So, if you intend to develop a custom CMS plugin, then you can use
> org.apache.wicket.Component#getSession() method and cast it to UserSession
> as documented.
> Or, if you just want to access JCR session in a HST component, you can
> directly get jcr session simply by HstRequestContext#getSession() in a
> component.

for completeness, mostly repeating what Woonsan already says:

Matt, I think you are referring to getting a jcr session in a site
application, for example in one of your HstComponent's.

A *lot* of convenience methods are exposed by the HstRequestContext.
For example getting a jcr session. If you want to access the
HstRequestContext in your component, just use:

@Override
    public void doBeforeRender(HstRequest request, HstResponse
response) throws HstComponentException {
         HstRequestContext reqContext =  request.getRequestContext();
    }

Note that during processing a single http request we have:

1) One single shared HstRequestContext for the entire request
2) A new instance of HstRequest *per* HstComponent that is used for
the specific request.

As a site-note I want to mention that HstComponent's are not
thread-safe and used by multiple requests concurrently,

Hope this helps,

Regards Ard

>
> Regards,
>
> Woonsan
>
>
> On 09/29/2010 06:17 PM, mvanbergen wrote:
>>
>> Hello,
>>
>> I am looking through the documentation the JCR examples at:
>>
>>
>> http://www.onehippo.org/cms7/documentation/development/content+repository/jcr/examples.html
>>
>> Specifically:
>>
>> Session session = ((UserSession) request.getSession()).getJcrSession();
>>
>> Looks straightforward, but I can't seem to figure out what library the
>> UserSession class resides.  Is there a Maven dependency that should be
>> added
>> to the Site pom to enable me to import this class into my component class
>> (org.hippoecm.frontend.session.UserSession)?
>>
>> Thanks!
>> Matt
>
>
> --
> w.ko at onehippo.com     www.onehippo.com
> NORTH AMERICA • SAN FRANCISCO - Hippo USA Inc. 185 H Street, Suite B
> Petaluma CA 94952 +1 (707) 773-4646
> EUROPE • AMSTERDAM - Hippo B.V. Oosteinde 11 1017 WT Amsterdam
> +31(0)20-5224466
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html
>



-- 
Hippo
Europe  •  Amsterdam  Oosteinde 11  •  1017 WT Amsterdam  •  +31 (0)20 522 4466
USA  • San Francisco  185 H Street Suite B  •  Petaluma CA 94952-5100
•  +1 (707) 773 4646
Canada    •   Montréal  5369 Boulevard St-Laurent  •  Montréal QC H2T
1S5  •  +1 (514) 316 8966
www.onehippo.com  •  www.onehippo.org  •  info at onehippo.com



More information about the Hippo-cms7-user mailing list