[Hippo-cms7-user] How can i get an instance of "javax.jcr.Repository" in hst-assembly hippo 7.7

Woonsan Ko w.ko at onehippo.com
Sat Apr 7 04:14:06 CEST 2012


One more thing is that you'd better get references of the component 
manager and components whenever you want to use because the component 
manager and its components can be re-initialized at runtime by default 
whenever hst configuration is changed. See [1] for detail.
In other words, if your bean has had a reference to the repository bean, 
then it should be improved to get the reference as local variable in 
operations because the repository bean can be closed and a new bean has 
been re-initialized at runtime.

[1] https://issues.onehippo.com/browse/HSTTWO-1611

On 4/7/12 10:08 AM, Woonsan Ko wrote:
> Hi,
>
> I don't think there has been any significant changes affecting the API
> usages.
>
> HstServices#getComponentManager() returns a valid instance only when the
> HST container has been successfully initialized.
> And, the HST container is initialized by HstSiteConfigServlet which is
> configured in the web.xml.
> If hst-config.properties has "check.repositories.running = false", then
> the servlet initializes the container right during the initialization of
> the servlet itself. If the configuration has "check.repositories.running
> = true", the servlet waits until hippo repository starts".
> Therefore, if you have a spring application context configuration
> somewhere through either context level or servlet level, then you have
> to consider this initialization order.
>
> If you don't want to be bothered by this initialization order, they you
> might consider invoking HstServices.getComponentManager() in your
> component code just before using it lazily.
>
> Regards,
>
> Woonsan
>
> On 4/6/12 10:34 PM, Ebrahim wrote:
>> Hi
>> I am trying to port an old plugin to Hippo 7.7, in an older version of
>> hippo
>> i used to use the following snippet to get an instance of the jcr
>> Repository
>>
>> <bean id="containerComponentManager"
>> class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
>>
>> <property name="targetClass" value="org.hippoecm.hst.site.HstServices"
>> />
>> <property name="targetMethod" value="getComponentManager" />
>> </bean>
>>
>> <bean id="javax.jcr.Repository"
>> class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
>>
>> <property name="targetObject" ref="containerComponentManager" />
>> <property name="targetMethod" value="getComponent" />
>> <property name="arguments">
>> <list>
>> <value>javax.jcr.Repository</value>
>> </list>
>> </property>
>> </bean>
>>
>> but it no longer works, because
>> "org.hippoecm.hst.site.HstServices.getComponentManager()" returns null.
>> Any idea on why is that and how to get and instance of "jcr repository"?
>>
>> --
>> View this message in context:
>> http://hippo.2275632.n2.nabble.com/How-can-i-get-an-instance-of-javax-jcr-Repository-in-hst-assembly-hippo-7-7-tp7443042p7443042.html
>>
>> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
>
>


-- 
w.ko at onehippo.com     www.onehippo.com
Boston - 1 Broadway, Cambridge, MA 02142
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466



More information about the Hippo-cms7-user mailing list