cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@mobilebox.pl>
Subject Re: ApplesProcessor - a little crazy idea
Date Thu, 13 Oct 2005 17:14:28 GMT
Reinhard Poetz wrote:
> Leszek Gawron wrote:
> 
>> WDYT? If you don't like it I will do 2). only in my codebase.
> 
> 
> I like it. I'm one of the Apples users Sylvain mentioned in his mail. 
> I've also prototyped nearly the same code as you did :-)
> Do you use the spring block or does getSpringContext() refer to a 
> "usual" spring context? I'd prefer using the Spring block as the 
> integration is _much_ more advanced, thanks to Carsten.
I am using a spring context loaded with 
org.springframework.web.context.ContextLoaderListener. I'm fetching it 
then with my own SpringApplicationContextFetcher:

> public class SpringApplicationContextFetcher implements Contextualizable, ThreadSafe
{
> 	public final static String	ROLE	= SpringApplicationContextFetcher.class.getName();
> 	private Context				context;
> 
> 	public void contextualize( Context context ) throws ContextException {
> 		this.context = context;
> 	}
> 
> 	public ApplicationContext fetchContext() {
> 		HttpContext environmentContext;
> 		try {
> 			environmentContext = (HttpContext) context.get( Constants.CONTEXT_ENVIRONMENT_CONTEXT
);
> 		} catch ( ContextException e ) {
> 			throw new IllegalStateException( "Error while accessing cocoon context", e );
> 		}
> 
> 		Object attr = environmentContext.getAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
);
> 
> 		if ( attr == null ) {
> 			throw new IllegalStateException( "Root application context not found in servlet context"
);
> 		}
> 		if ( attr instanceof RuntimeException ) {
> 			throw (RuntimeException) attr;
> 		}
> 		if ( attr instanceof Error ) {
> 			throw (Error) attr;
> 		}
> 		if ( ! ( attr instanceof ApplicationContext ) ) {
> 			throw new IllegalStateException( "Root context attribute is not of type ApplicationContext:
" + attr );
> 		}
> 		return (ApplicationContext) attr;
> 	}
> 
> 	public static ApplicationContext fetchContext( ServiceManager manager ) throws ServiceException
{
> 		SpringApplicationContextFetcher fetcher = null;
> 		try {
> 			return ( (SpringApplicationContextFetcher) manager.lookup( ROLE ) ).fetchContext();
> 		} finally {
> 			if ( fetcher != null )
> 				manager.release( fetcher );
> 		}
> 	}
> }

This is almost a copy paste from standard Spring WebApplicationContextUtils.


Could you summarize the advantages of spring block over "pure" spring 
application context. I know I can use cocoon.getComponent("springBean") 
but that has no added value for me. I prefer to keep spring isolated 
from cocoon. This way I am sure I have my business logic 100% easily 
testable. What I lack the most is a decent xml parser support in spring.

> So please check in and then we can work on it.
Thing is: where should I put it?
apples block - bad idea
spring block - it will introduce dependency on apples

> 
> (NB I hope that I can soon drop Apples in favor of JavaFlow as using a 
> state machine is a PITA. The missing part is serialization support for 
> Javaflow. It is itself already serializeable as Torsten showed me in 
> Amsterdam, but needs some integration work in Cocoon to make use of it.)

To tell you the truth I would start using javaflow in production long 
time ago (all my production sites run quite fresh cocoon trunk) but I am 
a little bit scared with postings on users list (NPEs, loosing session). 
  But if Torsten says it's stable - I am probably going to check it out 
in few days.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Mime
View raw message