Skip to main content



      Home
Home » Modeling » EMF » [CDO] Is it possible to implement ReadAccess and WriteAccess handlers in one class?
[CDO] Is it possible to implement ReadAccess and WriteAccess handlers in one class? [message #631170] Wed, 06 October 2010 09:03 Go to next message
Eclipse UserFriend
Hello,
while experimenting with my experimental CDO server I've found interesting thing. I'm using CDO code provided by Eclipse 3.6 Helios release. I'm trying to attempt implementing one access handler class for both read and write access handlers functionality. So my access handler class implements both IRepository.WriteAccessHandler, IRepository.ReadAccessHandler interfaces. What's strange is that WriteAccess handler methods are not called on my handler, although it's correctly registered and I work with transactions on the repository (it's reader functionality is well called). I also see debug output written into log from my debug write access handler which is registered before this handler. Even the more funny thing is that once I modify the handler in a way it does not implement IRepository.ReadAccessHandler interfaces then suddenly the CDO core upcalls its WriteAccess handler methods well. My guess is that this is an issue somewhere in CDO core, but still I'd like to be sure I have not made mistake anywhere nor made a bad assumption that I'm allowed to implement one access handler class for both reader and writer access handlers.
Thanks,
Karel
Re: [CDO] Is it possible to implement ReadAccess and WriteAccess handlers in one class? [message #631231 is a reply to message #631170] Wed, 06 October 2010 11:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi Karel,

We have not thought of this special sceanrio and the handler registration code clearly acts like XOR:

public void addHandler(Handler handler)
{
if (handler instanceof ReadAccessHandler)
{
synchronized (readAccessHandlers)
{
if (!readAccessHandlers.contains(handler))
{
readAccessHandlers.add((ReadAccessHandler)handler);
}
}
}
*else* if (handler instanceof WriteAccessHandler)
{
synchronized (writeAccessHandlers)
{
if (!writeAccessHandlers.contains(handler))
{
writeAccessHandlers.add((WriteAccessHandler)handler);
}
}
}
else
{
throw new IllegalArgumentException("Invalid handler: " + handler); //$NON-NLS-1$
}
}

If you file an enhancement request we can certainly help you ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 06.10.2010 15:03, schrieb Karel Gardas:
> Hello,
> while experimenting with my experimental CDO server I've found interesting thing. I'm using CDO code provided by Eclipse 3.6 Helios release.
> I'm trying to attempt implementing one access handler class for both read and write access handlers functionality.
> So my access handler class implements both IRepository.WriteAccessHandler, IRepository.ReadAccessHandler interfaces.
> What's strange is that WriteAccess handler methods are not called on my handler, although it's correctly registered and I work with transactions
> on the repository (it's reader functionality is well called). I also see debug output written into log from my debug write access handler which is
> registered before this handler. Even the more funny thing is that once I modify the handler in a way it does not implement IRepository.ReadAccessHandler
> interfaces then suddenly the CDO core upcalls its WriteAccess handler methods well. My guess is that this is an issue somewhere in CDO core,
> but still I'd like to be sure I have not made mistake anywhere nor made a bad assumption that I'm allowed to implement one access handler class
> for both reader and writer access handlers.

> Thanks,
> Karel
Re: [CDO] Is it possible to implement ReadAccess and WriteAccess handlers in one class? [message #631254 is a reply to message #631231] Wed, 06 October 2010 13:15 Go to previous messageGo to next message
Eclipse UserFriend
Hi Eike,
hehe, this was exactly what I had in mind seeing the behavior. Anyway, as you requested, PR#327140 is inserted for you. Smile
Thanks,
Karel
PS: in the meantime the solution is to use handler's proxies (one read and one write) both delegating to my complex handler.
Re: [CDO] Is it possible to implement ReadAccess and WriteAccess handlers in one class? [message #631262 is a reply to message #631254] Wed, 06 October 2010 13:49 Go to previous messageGo to next message
Eclipse UserFriend
Am 06.10.2010 19:15, schrieb Karel Gardas:
> Hi Eike,
> hehe, this was exactly what I had in mind seeing the behavior. Anyway, as you requested, PR#327140 is inserted for you. :)

I fixed it in HEAD and R3_0_maintenance ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


> Thanks,
> Karel
> PS: in the meantime the solution is to use handler's proxies (one read and one write) both delegating to my complex handler.
Re: [CDO] Is it possible to implement ReadAccess and WriteAccess handlers in one class? [message #631265 is a reply to message #631262] Wed, 06 October 2010 14:13 Go to previous message
Eclipse UserFriend
I've seen your fix! You are really super-fast! I've also wondered why you have removed section throwing "wrong handler" exception, but then well, thanks to the method signature I guess nobody is really able to sent there anything other than read/write read+write handler.
Thanks!
Karel
Previous Topic:Uniqueness not enforced by Validate
Next Topic:[CDO]Are derived features supported ?
Goto Forum:
  


Current Time: Wed Jul 23 08:30:00 EDT 2025

Powered by FUDForum. Page generated in 0.03304 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top