Listener in cocoon 2.2

View: New views
4 Messages — Rating Filter:   Alert me  

Listener in cocoon 2.2

by Thorsten Scherler-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

what is the best way to implement a Listener in cocoon 2.2?

I our use case we have a "listener" uri that got dispatched by an
external application to notify that some resources have changed and
invalid our cache for that resource.

The thing is that the uri do not have to/will not return anything in the
body only in the request header.

The current solution which was presented to us uses a custom generator
which will not output anything. That just does not feel right.

I did a small test with
<map:match pattern="notify">
 <map:act type="notify"/>
 <map:generate src="notify.xml"/>
 <map:serialize/>
</map:match>

but that is just to make it work the normal cocoon way. The notify.xml
is a dummy and I am not really thrilled about that neither.

Using flow seems to be as well too much since we just want a simple
listener that returns only http header.

TIA for any feedback.

salu
--
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)





Re: Listener in cocoon 2.2

by Dominic Mitchell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Sep 29, 2009 at 10:38 AM, Thorsten Scherler <thorsten.scherler.ext@...> wrote:
Hi all,

what is the best way to implement a Listener in cocoon 2.2?

I our use case we have a "listener" uri that got dispatched by an
external application to notify that some resources have changed and
invalid our cache for that resource.

The thing is that the uri do not have to/will not return anything in the
body only in the request header.

The current solution which was presented to us uses a custom generator
which will not output anything. That just does not feel right.

I did a small test with
<map:match pattern="notify">
 <map:act type="notify"/>
 <map:generate src="notify.xml"/>
 <map:serialize/>
</map:match>

but that is just to make it work the normal cocoon way. The notify.xml
is a dummy and I am not really thrilled about that neither.

Using flow seems to be as well too much since we just want a simple
listener that returns only http header.

Last time I needed something like this I used the "empty:" source.  Combined with a reader, that should do the track.

  <map:match pattern="notify">
    <map:read src="empty:" />
  </map:match>

This is untested — I can't remember if there are any quirks.

-Dom 

Re: Listener in cocoon 2.2

by Thorsten Scherler-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2009-09-29 at 20:27 +0100, Dominic Mitchell wrote:

> On Tue, Sep 29, 2009 at 10:38 AM, Thorsten Scherler
> <thorsten.scherler.ext@...> wrote:
>         Hi all,
>        
>         what is the best way to implement a Listener in cocoon 2.2?
>        
>         I our use case we have a "listener" uri that got dispatched by
>         an
>         external application to notify that some resources have
>         changed and
>         invalid our cache for that resource.
>        
>         The thing is that the uri do not have to/will not return
>         anything in the
>         body only in the request header.
>        
>         The current solution which was presented to us uses a custom
>         generator
>         which will not output anything. That just does not feel right.
>        
>         I did a small test with
>         <map:match pattern="notify">
>          <map:act type="notify"/>
>          <map:generate src="notify.xml"/>
>          <map:serialize/>
>         </map:match>
>        
>         but that is just to make it work the normal cocoon way. The
>         notify.xml
>         is a dummy and I am not really thrilled about that neither.
>        
>         Using flow seems to be as well too much since we just want a
>         simple
>         listener that returns only http header.
>
>
> Last time I needed something like this I used the "empty:" source.

That is a custom input module, right?

>   Combined with a reader, that should do the track.
>
>
>   <map:match pattern="notify">
>     <map:read src="empty:" />
>   </map:match>
>
>
> This is untested — I can't remember if there are any quirks.
>


Yeah will reduce the match nicely. Thanks Dom.

salu2

>
> -Dom
--
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)





Re: Listener in cocoon 2.2

by Sylvain Wallez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dominic Mitchell wrote:

> On Tue, Sep 29, 2009 at 10:38 AM, Thorsten Scherler
> <thorsten.scherler.ext@...
> <mailto:thorsten.scherler.ext@...>> wrote:
>
>     Hi all,
>
>     what is the best way to implement a Listener in cocoon 2.2?
>
>     I our use case we have a "listener" uri that got dispatched by an
>     external application to notify that some resources have changed and
>     invalid our cache for that resource.
>
>     The thing is that the uri do not have to/will not return anything
>     in the
>     body only in the request header.
>
>     The current solution which was presented to us uses a custom generator
>     which will not output anything. That just does not feel right.
>
>     I did a small test with
>     <map:match pattern="notify">
>      <map:act type="notify"/>
>      <map:generate src="notify.xml"/>
>      <map:serialize/>
>     </map:match>
>
>     but that is just to make it work the normal cocoon way. The notify.xml
>     is a dummy and I am not really thrilled about that neither.
>
>     Using flow seems to be as well too much since we just want a simple
>     listener that returns only http header.
>
>
> Last time I needed something like this I used the "empty:" source.
>  Combined with a reader, that should do the track.
>
>   <map:match pattern="notify">
>     <map:read src="empty:" />
>   </map:match>
>
> This is untested — I can't remember if there are any quirks.

Good trick. Now more than a source, which involves the SourceResolver
machinery, a very simple stupid Reader can also do the trick. Or does
the "empty" source already exist?

<map:match pattern="notify">
  <map:act type="notify">
    <map:read type="empty" status-code="200"/>
  </map:act>
</map:match>

Sylvain

--
Sylvain Wallez - http://bluxte.net