From Persistency Questions To EMF …


This week I finally decided to step in EMF. 2 years after starting Eclipse development …. French people will say here “Mieux vaut tard que jamais

Here is the story …

In a custom view built on top of Draw2D  providing embedded C profiling informations to the user we decided to add filtering capabilities. Thus we added a filtering button opening a dialog letting the user choose the elements he wants to filter.

Quickly we got the following interfaces and associated implementation:

public interface Filter {

public String getName();

public boolean isFiltered(Object element);
}

public interface TypeFilter extends Filter {

public void addType(String type);

public boolean removeType(String type);
}

We easily implemented filtering management using these interfaces . Then came the need to save user defined filters across Eclipse launches.

Saving these filters in our plugin directory inside the workspace (/workspace/.metadata/plugins/my.plugin.id) came immediately in our minds but HOW …. ????

  1. Using Eclipse preferences store ?? Impossible our filters are composed of a name attribute (type String) and a liste of types attribute (type List<String>)  and preferences store can only stor informations of type “key=value”.
  2. Using XML ?? Nice solution but …. needs to reinvent the wheel in order to convert our filter data structure into XML and to get back our data structure from this XML.
  3. Using EMF ?? Yes of course, among a lot features it’s here for that !!!!

I took up my sleeves and less than 1 hour after our filters was persisted across Eclipse instances !!!!

Here is the way I proceeded (mainly following EMF book) :

  1. Annotation of previously described Java interfaces
  2. Generation of model classes
  3. Persistence of these generated classes using EMF API (Ressource)
  4. Well done EMF !!!

This experience introduced me smoothly to EMF and avoided me to waste time on XML parsing/writing with in Java. I certainly should have used EMF before … I’ll try to use it more in the future in order to really understand all the benefits it can bring.

Advertisements
This entry was posted in Uncategorized by Manuel. Bookmark the permalink.

3 thoughts on “From Persistency Questions To EMF …

    • Hi Ed,

      Why do you think you owe me something ? Because i said thanks EMF ?
      Christmas day is coming soon, so for this time it’ll be free :)

      More over I forgo to mention that now I’ll better understand all the nice pictures you post about modeling

      Manu

  1. Pingback: From Persistency Questions To EMF … Part 2 « Manuel Selva’s Eclipse blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s