cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Webservice and Cayenne
Date Fri, 26 Aug 2011 17:29:51 GMT
Attaching DataContext to a session is just one possible way of accessing Cayenne. And ServletUtils
is just an example of how access to DataContext can be performed. You are most certainly not
limited by that.

So to answer your question let's start from this - what kind of service are you writing? 

1. Does it only read from the db , or does it perform read and write? 
2. Is there any server-side state that needs to be preserved for a given user between requests?


Andrus

On Aug 26, 2011, at 7:13 PM, Tony Giaccone wrote:

> Ok, so I'm using apache CXF to manager my web service and have that all set
> up, but the restult is that each request is unique and there is no session.
> 
> Given that the suggestion is made with web apps to call
> 
> ServletUtils.getSessionContext(session)
> 
> Not having a session is going to make that difficult.  So what do I do?
> 
> Creating a context on each incoming request seems pretty heavy and
> laborious.
> 
> Is there another path through this?
> 
> My first thought, is to open a DataContext when the service starts, and then
> for each request that comes in create a nested editing context, and then
> commit changes in the nested context when the service method is exits.
> 
> Is that the path I should consider?
> 
> 
> Tony
> 
> 
> 
> 
> 
> 
> 
> On Thu, Aug 25, 2011 at 8:01 AM, Andrus Adamchik <andrus@objectstyle.org>wrote:
> 
>> Services container and injection (same as Spring, Guice, etc)
>> 
>> In this case it is T5, cause in addition to REST frontend, I have HTML
>> frontend in the same set of apps, so T5 provides the same set of services to
>> both.
>> 
>> Andrus
>> 
>> On Aug 25, 2011, at 2:57 PM, Tony Giaccone wrote:
>> 
>>> Andrus,
>>> 
>>> I'm curious why you are using the tapestry IoC container. What purpose
>> does it serve?
>>> 
>>> Tony Giaccone
>>> 
>>> Life is what you live today.
>>> 
>>> On Aug 24, 2011, at 5:07 PM, Andrus Adamchik <andrus@objectstyle.org>
>> wrote:
>>> 
>>>> I am using Cayenne with Jersey frontend (http://jersey.java.net/ )  and
>> a Tapestry 5 IoC container in between. Jersey is a JAX RS implementation and
>> can serialize objects based on standard JAXB annotations, generating either
>> XML or JSON.
>>>> 
>>>> While there's no direct JAXB bindings for Cayenne DataObjects, I'd use
>> very simple annotated DTO's converting between Cayenne and DTO in each
>> Jersey resource class.
>>>> 
>>>> What I find interesting is that the DTO conversion is not simply a
>> workaround for the lack of direct serialization. It actually allows to
>> bridge the mismatch between the DB schema and the desired end user format of
>> the output.
>>>> 
>>>> Like the above stack a lot - very simple and clean frontend code, ties
>> nicely to fairly abstract backend business logic, very little configuration.
>>>> 
>>>> Andrus
>>>> 
>>>> 
>>>> On Aug 24, 2011, at 7:51 PM, Tony Giaccone wrote:
>>>>> I'm interested in implementing a Restful web service using Cayenne as
>> the
>>>>> backing ORM. My guess is that there are some people on this list who
>> may
>>>>> have opinions on how might best be implemented. My intent is to vend
>> json to
>>>>> the clients.  I know that ROP and the hessian protocol are actively
>> being
>>>>> used, but I don't think those have a place in what I want to build (no
>> jvm
>>>>> on client side).
>>>>> 
>>>>> In particular there I've seen some discussions about using DTO's and
>> custom
>>>>> template generation. I'm especially interested in how this is
>> accomplished.
>>>>> 
>>>>> Anyone care to comment?
>>>>> 
>>>>> 
>>>>> Tony Giaccone
>>>> 
>>> 
>> 
>> 


Mime
View raw message