cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thorsten.scherler....@juntadeandalucia.es>
Subject Re: How to get spring beans with Cocoon Template 1.0?
Date Fri, 21 Nov 2008 08:51:57 GMT
On Fri, 2008-11-21 at 00:04 +0100, Grzegorz Kossakowski wrote:
> Thorsten Scherler pisze:
> > On Thu, 2008-11-20 at 09:31 +0100, Thorsten Scherler wrote:
> >> On Wed, 2008-11-19 at 22:06 +0800, 黄海冬公司邮箱 wrote:
> >>> codes:
> >>> 	<jx:set var="appctx"
> >>> value="${cocoon.context.getAttribute(Packages.org.springframework.web.contex
> >>> t.WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)}"/>
> >>> 	<jx:set var="bean" value="${appctx.getBean('bean')}"/>
> >>>
> >>> Roy Huang
> >> Thanks very much Roy, will it try now.
> > 
> > Works like a charm, thanks again Roy!
> 
> There is one problem with this solution: it's ugly.

hmm, saw uglier solutions. ;) ...but you are right.

> 
> It introduces a dependency on very specific implementation that may change in the future.

That is true. Like I wrote in the first mail, would be awesome to have
cocoon.spring.getBean('NameOfBean').

> 
> Thorsten and Roy, if you really need to access some beans from expressions I suggest
to add them to
> ObjectModel by implementing ObjectModelProvider interface. 

Hmm, is there any documentation about how to this. I mean how can I
create a cocoon.spring.getBean('NameOfBean') factory?

> This way you can easily control what
> exactly the template can access and you remove dependency on specific implementation.

IMO a template should be able to access all beans from cocoon. If we
want to limit the access one can think about adding security to
cocoon.spring.getBean('NameOfBean') which checks whether the template is
allow to access the bean. Wee bit like using
http://www.acegisecurity.org/ for that part.

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





Mime
View raw message