cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Kossakowski <gkossakow...@apache.org>
Subject Re: Servlets, Sitemaps, and Spring in trunk
Date Sun, 08 Apr 2007 22:52:09 GMT
Max Pfingsthorn napisaƂ(a):
> Hi everyone,
> 
> I've been looking at trunk to find out how things work these days and
> it looks great, but I am a bit confused. It seems like the blocks can
> register their own servlet to handle requests, is that true? There is
> a suspicious xml file in META-INF/cocoon/spring in each sample. But
> how does spring, or is it avalon, know that this servlet should be
> used at all? Through DispatcherServlet? It doesn't seem to work right
> now though, at least not if I use the cocoon-webapp. Is there an easy
> way to make it work? I'm trying to do some json stuff, so a "detour"
> through cocoon would not be so great.
> 

Yes, it's already great and will be even more appealing. :-)
First of all, forgot about Avalon, all new stuff is Spring-based.
Configuration at META-INF/cocoon/spring contains mount-path property
which is the most important at the beginning. It tells DispatcherServlet
the prefix on which servlet is registered.
For example, if mount path is "/cocoon-forms-sample" all request that
would be matched by "/cocoon-forms-sample/**" will get dispatched to the
registered servlet.
Next important thing is making connections to other blocks (servlets).
It is needed if you want to call pipelines in other block. They can
provide access for static resources (no more use of resource://
protocol!) and dynamic ones.
This configuration snippet:
<servlet:connections>
  <entry key="ajax" value-ref="org.apache.cocoon.ajax.impl.servlet"/>
</servlet:connections>
tells that we want to reference ajax servlet under short 'ajax'
identifier. Now you can do something like this:
<map:generate src="servlet:ajax:/some/resource.xml"/>
and request for "/some/resource.xml" will be processed by ajax servlet.

I think it's enough to start playing. If you want example of heavy usage
of servlet-service-fw stuff take a look on refactored forms and ajax
blocks in whiteboard. You have to make a svn switch and rebuild them.

Ahh, and you can try it with cocoon-webapp but you have to use following
pattern for your url:
/blocks-test/[mount-path]/[rest-of-url]
"/blocks-test" part is location where DispatcherServlet is mounted (take
a look on web.xml in cocoon-webapp).

Don't hesitate to ask more questions and make a promise to tell us
success story not only about servlet-service-fw ;-)

-- 
Grzegorz Kossakowski

Mime
View raw message