You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Michael Alderton-Smith <mi...@onexys.com> on 2009/08/05 23:49:08 UTC

Online/Offline

Here's something I just can't figure.  I'm writing a rich client based
on the Netbeans plaftorm that must be able to run in online and offline
mode.

I have got Cayenne to run successfully remotely connected to my
glassfish server and everything works great.

What I do is wrap getting the data context so I can control whether to
use the remote one or a local derby based context depending on whether
the client application is in on or offline mode.

The problem I see, is that any references to classes in my code are to
the client classes generated by Cayenne for the server objects, but
would need to be the actual full server classes to work with the derby
database, so I see no way of making all my code generic.

Has anyone come across this idea before, and is there perhaps a way to
use the client classes, but without a remote connection as such.  That
way my code won't care whether it's talking to the server or the local
derby database, except when it comes to the datacontext itself.
otherwise I'll have to integrate the online/offline code throughout the
system, which is going to be a lot of work.

Simple question at the end of the day.... can you use the lighter client
classes locally somehow?

Any help would really be appreciated.  I haven't been working with
Cayenne for long, but it's been good enough for me to give up on
hibernate, jpa and all the other alternatives due to it's remoting
capability.


Re: Online/Offline

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Aug 6, 2009, at 12:49 AM, Michael Alderton-Smith wrote:

> Simple question at the end of the day.... can you use the lighter  
> client
> classes locally somehow?

Yes. Try using org.apache.cayenne.remote.service.LocalConnection for  
your local work. It still incurs the overhead of two layers of  
objects, but at least it all happens in the same JVM and there's no  
extra network communication, so it should be bearable in most cases.

Andrus

Re: Online/Offline

Posted by Andrus Adamchik <an...@objectstyle.org>.
This is not fully on topic (see my other email in this thread which  
was more to the point), still... there's one cool feature that I've  
discussed with somebody offline some time ago. Often you need to work  
offline and then synchronize the data saved offline back to the server  
when the client goes online, and pull the changes made by other  
clients back to your client. Not unlike the way git or other DSCM  
operate, to give an analogy.

Cayenne object graph change tracking "protocol" is basically ready for  
such scenario, as each individual object change is recorded  
internally, and can be replayed later. The challenge is to implement  
the actual flow, data merging and conflict resolution algorithms. I've  
made some back-of-the-napkin design for that, but didn't have time to  
write the code as a side project, and didn't have any ongoing paying  
projects which would require this feature and could've covered the  
implementation costs.

So mentioning this here just in case someone in the community would  
like to step in. IMO this could become a killer feature of the ROP.

Andrus


On Aug 8, 2009, at 9:51 PM, Aristedes Maniatis wrote:
> On 6/08/09 7:49 AM, Michael Alderton-Smith wrote:
>> The problem I see, is that any references to classes in my code are  
>> to
>> the client classes generated by Cayenne for the server objects, but
>> would need to be the actual full server classes to work with the  
>> derby
>> database, so I see no way of making all my code generic.
>
> There has been some talk of merging the client and server classes,  
> however it is considerable work and I would not count on it any time  
> soon.
>
>
>> Any help would really be appreciated.  I haven't been working with
>> Cayenne for long, but it's been good enough for me to give up on
>> hibernate, jpa and all the other alternatives due to it's remoting
>> capability.
>
> Yes, it is very good for that. But unfortunately I don't see a quick  
> solution for your needs, even though I'd love to implement the same  
> thing myself in one on my applications.
>
> Ari Maniatis
>
>
>
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>


Re: Online/Offline

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 6/08/09 7:49 AM, Michael Alderton-Smith wrote:
> The problem I see, is that any references to classes in my code are to
> the client classes generated by Cayenne for the server objects, but
> would need to be the actual full server classes to work with the derby
> database, so I see no way of making all my code generic.

There has been some talk of merging the client and server classes, however it is considerable work and I would not count on it any time soon.


> Any help would really be appreciated.  I haven't been working with
> Cayenne for long, but it's been good enough for me to give up on
> hibernate, jpa and all the other alternatives due to it's remoting
> capability.

Yes, it is very good for that. But unfortunately I don't see a quick solution for your needs, even though I'd love to implement the same thing myself in one on my applications.

Ari Maniatis



-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A