Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement bytecode enhancement for zooActivateRead()/zooActivateWrite() and the rest #62

Open
tzaeschke opened this issue Apr 16, 2015 · 4 comments

Comments

@tzaeschke
Copy link
Owner

tzaeschke commented Apr 16, 2015

Could be done manually (!??!), with ASM, or with a high level library such as
CGLIB (https://github.com/cglib/cglib) or javassist (http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/).

See also http://mydailyjava.blogspot.no/2013/11/cglib-missing-manual.html

  • Consider using proxy classes (like Hibernate/JPA). They have some overhead (memory etc), but they are DBMS-controlled and may simplify features such as detach/reattach...
@mojo2012
Copy link

I just created a classfiletransformer for that exact purpose using javassist. It could probabely be done with bytebuddy too quite easily.
I will keep you posted

@tzaeschke
Copy link
Owner Author

Sorry for the late reply, I'm quite with other stuff at the moment. Your classfile transformer looks very useful. I suppose it could also be used to insert the super-class ZooPC or PersistenceCapableImpl? I think javassist has a setSuperclass() method. The getter/setter could also be fine-tuned to load/mark-dirty the objects only if the an attribute is actually accessed/modified.
If you don't mind me asking, what is your plan? Would you like to contribute to ZooDB, or provide an external byte-code enhancer, or demonstrate something of your spot-framework (I admit I haven't fully grasped what it does), or are you just giving me some friendly pointers? :-)

@mojo2012
Copy link

The current implementation is not yet complete. I plan to implement the super class injection as well.
Currently I'm working on a bi-directional relation update mechanism, although directly in my models - to be independent of the underlying persistence framework.

Basically you can inject whatever functionality you want into the bytecode - except lambdas!

The goal behind spOt is to implement a rapid-application-development framework - similar to the SAP hybris stack (I'm a professional hybris dev). The framework provides a rich domain model (including the possibility to extend or modify existing models), services to connect to various 3rd party systems, convenience functionality (l10m, i18n, solr integration, generic entity management interface) and a (more or less) fully implemented shop interface).
Unfortunately it is a huge monolithic monster.
I want spOt to offer similar functionality as open source and based on a micro-service approach.

Currently spOt provides some domain models including the functionailty to alter them and add new ones. This is done using xml notation (https://raw.githubusercontent.com/mojo2012/spot-framework/master/spot-core/src/main/resources/core-itemtypes.xml).
Also some lower-level functionality is already implemented as well (generic REST service to access the models, l10n, basic service infrastructure).

Unfortunately none of the major ORM mappers (I tried hibernate, eclipselink, datanucleus, ebean) work as reliable and as functional as Hybris. All of them have some downsides, like relying a lot on manually written code, are not threadsafe etc.

So I was looking for better suited alternatives and landed here ;-) Currently ebean and zoodb are my two favorite frameworks to use for persistence.
So I'm trying to implement the missing parts and of course I also plan to contribute to zoodb in one or another way.
*But I will most likely do it my way :-D But as spOt is open source you're free to use whatever you need. *

If your requirements are not too far from what I need, I will try to implement them of course.

@tzaeschke
Copy link
Owner Author

Thanks for the explanation, that sounds very cool (even though I never used SAP hybris or SAP in general).
I also didn't know of ebean, their session-less approach sound really useful, I suppose something similar could be done via JDO's non-transactional write.
Well, I'll keep following spOt, the bytecodeenhancer may become handy sooner or later. The current approach of going simply after getter/setter to inject zooActivate calls may be just fine if you are following a simple bean approach with no complexity inside the data classes.
Let me know if you require specific enhancements in ZooDB to make spOt work, I may be able to squeeze them in between my other tasks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants