Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [wtp-incubator-dev] EMF2DOMSSE

This doesn't sound like a wrapper model that I was describing, but rather a different way of doing bi-directional synchronization between two models. 

In the wrapper solution that I implemented, a wrapper object only holds a reference to a DOM Element. There is not other model state in the wrapper. When a getter is called, it reaches directly into the DOM Element. There are no events to process. The more complicated case is a when a model element has to retrieve sub-elements. The method first retrieves all candidate DOM elements. It then consults a map kept in the wrapper that maps DOM elements to wrapper instances. Existing wrappers are re-used. New wrappers are created as necessary. Old wrappers are disposed. This all happens in the getter call. The caller always gets the state as represented in DOM, but wrapped in model API.

Oracle
Konstantin Komissarchik | Consulting Member of Technical Staff
Phone: +1 425 201 1795 | Mobile: +1 206 898 0611 
Oracle Eclipse Tooling
411 108th Ave NE, Suite 2100 | Bellevue, WA 98004 
 

-----Original Message-----
From: David Carver [mailto:d_a_carver@xxxxxxxxx] 
Sent: Tuesday, November 11, 2008 1:47 PM
To: konstantin.komissarchik@xxxxxxxxxx
Cc: WTP Incubator Dev list
Subject: Re: [wtp-incubator-dev] EMF2DOMSSE

Konstantin Komissarchik wrote:
> I would be interested in hearing more about implementing the wrapper solution using EMF. Do you end up letting EMF generate the model and then hand-replacing the implementations of various methods with calls to DOM?
>
Yes and no. The approach that the XSD EMF model takes is the have a
place holder field for the DOM related element that it corresponds to.
I.e. if an an EMF Class is an element, it holds an org.w3c.dom.Element
field that gets populated. If you have a an EMF class that would map to
an attribute, then it has an org.w3c.dom.Attribute field. When ever a
set or update is called on the EMF model it fires off an an ENotifier
event to do any correspond synchronization. At least that is my
understanding so far. The root element in Emf gets the
org.w3c.dom.Document field.

So you can load up and create the entire EMF model by setting
emfRootElementClass.setDocument(document) which would take the WTP DOM
as the document to be set, and the necessary objects are created for the
rest of the model.

I'm still going through the code, but it allows for using EMF to model
and generate the code, and then adding the necessary synchronization
code with out having to use Adapters.





Back to the top