How do Soplets support inheritance?

16 views
Skip to first unread message

Dan Haywood

unread,
Aug 3, 2011, 5:58:43 AM8/3/11
to sop...@googlegroups.com
This post is just based solely on viewing the Prezo demo... so I may have misunderstood something.  That said...

In Apache Isis (naked objects) we use Java classes to build its metamodel, whereas Soplets uses enums.  The first question that occurred to me was, how does Soplets support inheritance, both class- and interface based?  For example, if in a library I want to say that a Book is a Loanable thing (public class Book implements Loanable), how would I express this in Soplets?

The other question - which is more about the intended scope of Soplets - is whether it is solely about building a metamodel to be consumed in various ways, or whether it provides any runtime object management support (cf JPA/Hibernate)?

Thanks
Dan

Chris May

unread,
Aug 3, 2011, 6:44:23 PM8/3/11
to sop...@googlegroups.com
Hi Dan,

representing the class hierarchy is not really the focus of Soplets for now, especially since enums do not support inheritance (much to my dismay...); but doing that with regular Java objects (as you do with Naked Objects) is just fine, often there is no need to replicate this semantic information in an additional metamodel.

For representing a relation between two classes, I just name the classname of the target type (interface or actual class), as an example see the customer field in SopOrder (I'm aware that this is not entirely type safe, but that is the best what you get with the current language spec):

https://github.com/sopletmaster/org.soplets.petstore/blob/master/src/org/petstore/soplets/SopOrder.java

Regarding your second question: Soplets do not provide a runtime object management on its own, they are conceived solely for the purpose of representing (static) semantic information. However, you can combine them with existing solutions like Hibernate. Just have a look at the SopOrder class mentioned above: there is a regular Hibernate annotation next to the Soplet annotation, which will be woven (via byte-code) into the getter method of the target entity, and acts just as you would expect it.
@ManyToOne( //this annotation will be woven into the MOrder class
targetEntity=MCustomer.class)

Of course, the information "targetEntity=MCustomer" is a duplicate of the "javaType=MCustomer.class" attribute of the regular Soplet annotation below. In that sense I'm envisioning an run-time adapter which would translate the Soplet metadata to Hibernate semantics, so the additional Hibernate annotations could be dispensed of eventually.
Did that answer your questions?

regards, Chris




Reply all
Reply to author
Forward
0 new messages