cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <scher...@gmail.com>
Subject Re: Cocoon3, JSON, Spring
Date Fri, 02 Sep 2011 10:45:55 GMT
On Fri, 2011-09-02 at 09:58 +0300, Andre Juffer wrote:
> On 09/02/2011 02:46 AM, Thorsten Scherler wrote:
> > Hi Andre,
> >
> > sorry for top posting but I am responding from my mobile device.
> >
> > Regarding 1) the org.apache.cocoon.serialization.TextSerializer migration into c3
is ASAIK not yet done. However that should be pretty straight forward to implement.
> 
> Yes, I was already thinking that I could do this.

Contributions are always welcome. ;) 

If you or somebody else will do the migration please open an issue in
https://issues.apache.org/jira/browse/COCOON3 and attach the diff. We
will apply it ASAP.


> >
> > Actually I did lately work with the RESTController of c3 since the JAX-RS integration
was not needed for my use cases. If you choose the c3 REST way you can use the TextResponse
[1]  to return your json objects to the client. In the same package you will as well find
a BinaryResponse [2] which you can use to return binary data like images from your rest services.
> 
> The TextResponse is a good alternative, and I will certainly look into 
> it. It is apparently not yet part of the current alpha Cocoon 
> 3.0.0-alpha-3 that I downloaded from the cocoon website.

No you would need the HEAD or the latest beta snapshot.

> >
> > I just commited an example [3] of an asyncron processing with REST you may want
to look into. It is based on jquery on the client side but you will get the idea. If you look
at [4] you will see the basic background. The block provides a workig example when starting
with "mvn install jetty:run" and browse to localhost:8888/,
> 
> Great!

Actually I am still thinking on implementing comet
http://en.wikipedia.org/wiki/Comet_(programming) Actually long polling
should not to be too complicate to be implemented with our REST
framework (hopefully I will find some play time for implementing
that). ;) 

However html5 will open some new approaches to the comet technique where
Server-sent events and websockets come into play, but I think there we
need to make some changes to our controller. 

Somebody had worked with streaming message in cocoon yet?

> >
> > Regarding the bean lookup, why not using autowiring in your components (more when
you use the REST part)? See [5].
> 
> Yes, that would do it.
> 
> Thanks for your valuable response.

you are welcome. I am glad if it helps you.

salu2

> André
> 
> >
> > HTH
> >
> > [1] http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/TextResponse.java
> > [2] http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/BinaryResponse.java
> > [3] http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest-optional/
> > [4] https://issues.apache.org/jira/browse/COCOON3-75
> > [5] http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/controller/DemoRESTController.java?view=markup
> >
> > Thorsten Scherler<thorsten.at.apache.org>
> > codeBusters S.L. - web based systems<consulting, training and solutions>
> > http://www.codebusters.es
> >
> > Andre Juffer<ajuffer@cc.oulu.fi>  wrote:
> >
> >> Hi All,
> >>
> >> I have two questions:
> >>
> >> (1)
> >> I want to be to be able to return JSON to the client, typically a
> >> browser. The client is responsible to properly present the response to
> >> the user, typically with the Dojotoolkit. As I would like to move to
> >> cocoon3, I was looking for a JsonSerializer or a simple TextSerializer.
> >>
> >> With cocoon 2.2, one can simply use the TextSerializer to return JSON,
> >> by defining
> >>
> >> <map:serializer name="json" mime-type="application/json; charset=UTF-8"
> >>                  src="org.apache.cocoon.serialization.TextSerializer">
> >>    <encoding>UTF-8</encoding>
> >> </map:serializer>
> >>
> >> Cocoon 3 apparently is restricted to only return XML/HTML [1], as far as
> >> I can see. I did not find in the API any mentioning of other types of
> >> serializers, besides XMLSerializer and FopSerializer.
> >>
> >> If so, this would be a limitation. Especially for designing RIAs [2]
> >> (like Twitter), it would be very useful to be able to return JSON.
> >>
> >> So, is there a particular way to return JSON or Text.
> >>
> >>
> >> (2)
> >> With flowscript in cocoon 2.2, it was very easy to instantiate a Java
> >> bean defined in some appropriate Spring bean configuration file, like
> >>
> >> var someFacade = cocoon.getComponent("someFacade");
> >> someFacade.doSomething(...);
> >>
> >> Is there a recommended way in Cocoon 3 to instantiate beans. One could do
> >>
> >> ApplicationContext context =
> >>    new ClassPathXmlApplicationContext( new String[]
> >> {"beans-spring.cfg.xml");
> >> SomeFacade facade = (SomeFacade)context.getBean("someFacade");
> >> facade.doSomething(...);
> >>
> >> within a JAX-RS resource [3].
> >>
> >> So, is this way to do instantiate beans?
> >>
> >> Thanks,
> >> Andre
> >>
> >>
> >> [1] http://cocoon.apache.org/3.0/features.html
> >> [2] http://en.wikipedia.org/wiki/Rich_Internet_application
> >> [3] http://cocoon.apache.org/3.0/referenc/html/webapps.html#webapps.rest
> >>
> >> --
> >> Andre H. Juffer              | Phone: +358-8-553 1161
> >> Biocenter Oulu and           | Fax: +358-8-553-1141
> >> Department of Biochemistry   | Email: andre.juffer@oulu.fi
> >> University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
> >> StruBioCat                   | WWW: www.strubiocat.oulu.fi
> >> NordProt                     | WWW: www.nordprot.org
> >> Triacle Biocomputing         | WWW: www.triacle-bc.com
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >>
> >
> 
> 

-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


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


Mime
View raw message