cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike M Pestorich (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAY-1559) Use Lifecycle Annotations as markers on PersistentObject methods
Date Thu, 24 Sep 2015 03:26:05 GMT

    [ https://issues.apache.org/jira/browse/CAY-1559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14905767#comment-14905767
] 

Mike M Pestorich commented on CAY-1559:
---------------------------------------

I'd like to pick this back up and begin working through the speed issues you've identified.
It should be trivial to introduce 'opt-in' behavior. But beyond that, I've recently made some
other changes on my end and come up with a few other ideas that might address the slow startup
times when opting into this functionality. I'd like to run some benchmarks to prove it all
out. I was hoping that you might have some suggestions on how to go about that and was also
wondering what you felt were acceptable startup times... Or other metrics that I should be
targeting?

> Use Lifecycle Annotations as markers on PersistentObject methods
> ----------------------------------------------------------------
>
>                 Key: CAY-1559
>                 URL: https://issues.apache.org/jira/browse/CAY-1559
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Core Library
>    Affects Versions: 3.1M3, 3.1, Short term future, Undefined future
>            Reporter: Mike M Pestorich
>            Assignee: Andrus Adamchik
>              Labels: annotations, listener
>             Fix For: 4.0.M3
>
>         Attachments: 0001-x.patch, LifecycleAnnotationMarker.patch
>
>
> In my current project I have various abstract classes that my persistent objects inherit
from. While experimenting with various new ways of using lifecycle listeners and their corresponding
annotations available in 3.1, I found myself wanting to annotate a method on one of those
abstract classes (say with @PostAdd) and have it act as a callback on all of its subclasses.
Out of the box, I could get this to work the way I wanted by doing something like:
> public class SomeAbstractPersistantObject {
>     ...
>     @PostAdd(SomeAbstractPersistantObject.class)
>     public void onPostAdd(Object object)
>     {
>         object.getObjectId() ... 
>     }
> }
> And then later on registering the listener by doing something like:
> serverRuntime.getDataDomain().getEntityResolver().getCallbackRegistry().addListener(new
SomePersistentObject());
> The problem was that I didn't what to have to instantiate an object just to register
it, or for that matter even have to register the listener in the first place. My callback
is already part of the PersistentObject that it applies to and as such should "just work"
for that object or anything that extends it. I wanted to be able to do something like:
> public class SomeAbstractPersistantObject {
>     ...
>     @PostAdd
>     public void onPostAdd()
>     {
>         this.getObjectId() ... 
>     }
> }
> And that's it. Listeners/Callbacks defined in this manner are registered when lazy initialization
of the callback registry occurs within the EntityResolver. All I have to do now is annotate
a method within the persistent object that I want it to act on and don't have to worry about
anything else.
> I don't know if this sort of thing would be useful to anyone but I have attached a patch
that I believe does just that. I have been using it for a couple of days now and it seems
to be working as intended without breaking the other available means of using lifecycle listeners.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message