You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Laurent Perez <ha...@gmail.com> on 2006/09/07 14:05:27 UTC

Accessing a cocoon SourceResolver from another servlet ?

Hi

I would like to access the Cocoon servlet from another running
servlet, basically all I want is to query a sitemap pattern and get a
SAX result out of it. I believe I should use a SourceResolver for
that, I don't want to "fake" some HTTP request to hit that sitemap
pattern.

I think I know how to lookup another servlet under my webapp, but I
don't know what to do once I lookup
org.apache.cocoon.servlet.CocoonServlet. Also, o.a.c.Cocoon has a
createSourceResolver() method, but I'm not sure if this is the right
way.

Could anyone point me in the right direction ?

thanks!


-- 
<a href="http://in-pocket.blogspot.com">http://in-pocket.blogspot.com
- Mobile world, technology and more</a>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Accessing a cocoon SourceResolver from another servlet ?

Posted by Laurent Perez <ha...@gmail.com>.
> If you would like to use cocoon-trunk that is very easy:
> ApplicationContext context =
> WebApplicationContextUtils.getRequiredWebApplicationContext(
> servletContext );
> SourceResolver resolver = context.getBean( SourceResolver.ROLE );

wow. great. I'm already using Spring behind Cocoon, I guess I should
give the trunk a try.. any up-to-date docs on how to build it,
especially with the required maven configuration ?

> I do not know if there is a possibility to get an internal cocoon
> component in 2.1.x.

well, under 2.1.9 I found the CocoonBean helper class, which is what
cocoon-client seems to use. so far so good, its processURI(pattern,
outputstream) method works as expected, but processURI(pattern,
contenthandler) (I need to receive that pattern result thru SAX) does
not, throwing an NPE on every attempt.

I tracked the exception down to
o.a.c.environment.AbstractEnvironment#initComponents() :

this.sourceResolver =
(org.apache.excalibur.source.SourceResolver)this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);

does CocoonBean really support writing to a SAX ContentHandler, or is
my ContentHandler object "badly" initialized ? there's really no
documentation about this helper class :(

thanks,
laurent

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Accessing a cocoon SourceResolver from another servlet ?

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Laurent Perez wrote:
> Hi
> 
> I would like to access the Cocoon servlet from another running
> servlet, basically all I want is to query a sitemap pattern and get a
> SAX result out of it. I believe I should use a SourceResolver for
> that, I don't want to "fake" some HTTP request to hit that sitemap
> pattern.
> 
> I think I know how to lookup another servlet under my webapp, but I
> don't know what to do once I lookup
> org.apache.cocoon.servlet.CocoonServlet. Also, o.a.c.Cocoon has a
> createSourceResolver() method, but I'm not sure if this is the right
> way.
> 
> Could anyone point me in the right direction ?

If you would like to use cocoon-trunk that is very easy:

ApplicationContext context = 
WebApplicationContextUtils.getRequiredWebApplicationContext( 
servletContext );

SourceResolver resolver = context.getBean( SourceResolver.ROLE );

that's it.

I do not know if there is a possibility to get an internal cocoon 
component in 2.1.x.



-- 
Leszek Gawron, 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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org