Sign In : Sign Up : Blog : Search: Language : Help :
This website is now frozen, please migrate your content to BotLibre.com or BotLibre.biz
Java Persistence Performance

dynamic weaving without persistence unit (jrebel)

by pranahata posted Apr 1 2015, 0:54

We have a client server app and we send the eclipselink entities from the server to the client using eclipselink copygroups. It is terribly great in the sense that we don't have to create DTOs as we can decide what parts of the object graph get serialized and we can keep all the business logic and validation in the domain model (entities).

One downside of it is that in order for this to work we need to statically weave the classes as the client side doesn't have a persistence unit and the weaving doesn't  seem to happen unless a pu containing the entities is initialized.

We are also using jrebel so at the moment every time we make a change to an entity we have to weave the entire jar statically which causes jrebel to reload every class in the jar.

Is it possible to programmatically (or statically) weave a single class? 



by jamesssss posted Apr 1 2015, 9:32
If your only sending objects one-way, you probably don't need to weave the client, the weaved fields will just disappear on the client. If you are sending objects both ways, then the weaving is required so the server know the difference between a field being null vs not instantiated.

If you include your persistence unit and eclipselink on the client (with meta-inf persistence.xml) then dynamic weaving should work on the client too. You may need a special or dummy persistence.xml that does not connect to the database.

Trying to weave one class at a time is probably a bad idea, as classes reference other classes, and you have to weave the class before it is loaded, otherwise it is too late.

Here is the JavaDoc for the static weaver,


and source code,


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1735, today: 3, week: 7, month: 19

Id: 330252
Posted: Apr 1 2015, 0:54
Replies: 1
Views: 1748, today: 3, week: 6, month: 16
I'm sure
Flag graphic as offensive, or in violation of site rules