Martin Taal's Blog

About EMF, Teneo, CDO, Texo, Hibernate, Open-Source ERP and other topics

Taking EMF to the third tier: the Texo JSON Resource

leave a comment »

Hi!

After supporting a 2-tier architecture it is now time to make the step to a full 3-tier application architecture for EMF based RCP’s connected to  a standard JPA web server. The server side of this 3-tier architecture was already done earlier: the Texo JSON web service layer. The only remaining topic was implementing the client side: an EMF resource which talks JSON with the server.

Well a first version is available now: the JSONTexoResource. This resource uses JSON to communicate with a server with JPA entities generated from ecore models using Texo.

The nice thing is that the JSONTexoResource transparently works with EMF Proxies. So EMF proxies are automatically resolved by sending a HTTP request to the server and getting the content of the object.

It is easy to override Texo code to add authentication support to the HTTP communication layer. An additional nice feature is that the server side can change/update objects when they are being persisted. Server-side changes are send back to the client (executing the persist action) and merged with the client side objects.

The Texo Resource also support loading objects using queries, counting, retrieving and refreshing individual objects (from the server) and cross-reference queries.

For more information:

  • specifics on the JSONTexoResource can be found here
  • for setting up the server side is check out this wiki page or see this video.

Thanks for reading and I hope this blog post helps to give Texo a try. Visit the Texo wiki for more information. Let me know if you have any questions or remarks on the EMFT newsgroup or forum!

gr. Martin

Advertisements

Written by martintaal

August 30, 2012 at 12:21 am

Posted in Texo

EMF CDO HibernateStore: Upgraded to Teneo 2.0, JPA 2.0 and Hibernate 4.1

leave a comment »

In a previous post I talked about Teneo 2.0 and its JPA 2.0 and Hibernate 4.1 support. With these new developments it was time to upgrade the CDO Hibernate store also. So here it is: the CDO Hibernate Store in the CDO 4.1 release/build now also supports JPA 2.0 and Hibernate 4.1. This new functionality is available from CDO 4.1 RC1 or any nightly build from the 21th of May 2012.

Hibernate 4.1 is a major release and it is not binary compatible with 3.6.0. This means that when getting the latest CDO Hibernate store 4.1 version you also need to upgrade Hibernate to 4.1, and if you are testing using hsqldb then make sure to also upgrade that one.

To help you out, the newer hibernate and hsqldb versions are available through this update site:

http://www.elver.org/eclipse/2.0.0/update

The CDO Hibernate Store 4.1 depends on Teneo 2.0 which you can find on this update site:

http://download.eclipse.org/modeling/emf/teneo/updates/2.0.0/interim/

I hope this post is useful for you, thanks for reading and if you are interested feel free to give feedback or ask questions on the EMF newsgroup or forum.

gr. Martin

Written by martintaal

May 23, 2012 at 4:54 am

Posted in CDO

EMF Teneo 2.0: JPA 2.0 and Hibernate 4.*!

with 3 comments

The time has come to up the version number of Teneo from 1.2.0 to 2.0.0. The ‘technical’ reason is support for Hibernate 4.* which has a different internal api than previous versions. At the same time it is nice to announce another new feature: JPA 2.0 annotation support (see the JPA 2.0 spec). Teneo already supported the JPA 1.0 specification and the JPA EntityManager api.

The JPA 2.0 annotation development has been made possible by the sponsorship of an active Teneo user-company. It is great to see that there are companies out there who appreciate what we do at the Eclipse Modeling group and specifically ofcourse Teneo!

JPA 2.0 annotations can be defined in-the-model as well as in a separate xml file.

To summarize Teneo is now available in 2 actively maintained versions:

1.2.0:

  • JPA 2.0
  • Hibernate 3.6/EclipseLink 2
  • EMF 2.6 and 2.7
  • Eclipse Helios

2.0.0:

  • JPA 2.0
  • Hibernate 4.1
  • EMF 2.7 – 2.8
  • Eclipse 3.7 and further

Note the JPA 2.0 support is available in the latest build of both versions of Teneo, the main difference between the 2 versions is the supported Hibernate version.

Active development of new features is done in the 2.0.0 version, but bugs/issues will be actively fixed in 1.2.0 for the foreseeable future.

I am currently upgrading CDO Hibernate Store to Teneo 2.0.0, that should be finished soon to!

For more information on dependencies and how to get these new versions, visit the Teneo wiki download & install page. This page also lists the update site with the latest Hibernate and hsqldb plugins.

I hope this post is useful for you, thanks for reading and if you are interested feel free to give feedback or ask questions on the EMF newsgroup or forum.

gr. Martin

Written by martintaal

May 21, 2012 at 3:54 am

Posted in CDO, Teneo

EMFT Texo: Auto-generate Java model code on model file changes

leave a comment »

Hi!

Next to the work I am doing on an EMF JSON resource, and solving some bugs, I was very motivated to get a nice new feature into Texo: automatic code generation on model file changes.

After each model change you have to go through the somewhat cumbersome right click on a project file and finding the Texo menu to generate your code.

This has now become a lot easier! In the Texo project properties you can now define, that code should be automatically generated when a model file changes. This includes changes to xsd’s and annotation model files.

The project properties allow you to set different things like if only certain model files should trigger a regenerate, or if JPA or DAO classes need to be generated. It is all described here.

So just check the correct flag in the project properties and your code is generated on-the-fly and more importantly: automatic.

Thanks for reading and I hope this blog post helps to give Texo a try. Visit the Texo wiki for more information. Let me know if you have any questions or remarks on the EMFT newsgroup or forum!

gr. Martin

Written by martintaal

May 18, 2012 at 12:54 am

Posted in Texo

EMFT Texo: EMF – RCP persistence using Texo generated JPA entities

with 6 comments

Hi!

After working on Texo JSON Rest, the next step for me has been to implement an EMF Resource which persists its data using JPA annotated entities in a standard ORM.

This makes it possible to use Texo in a RCP environment with an EMF generated front-end and a Texo generated JPA backend.

The first implementation of the TexoResource supports a 2-tier architecture: the JPA TexoResource communicates directly with the database through the JPA/ORM layer.

EMF RCP - Texo - 2-tier architecture

My next step will be to implement a Texo JSON Resource which communicates using JSON with a server running Texo. The server side of this 3 tier architecture is already done: the Texo JSON web service layer. For an example project running Texo in Tomcat/web container check out this wiki page or see this video.

For this new development I am developing EMF JSON converters, these could be useful also in other solutions, you can find the relevant plugin here in git.

I am cooperating with others to develop an example RCP using Texo. My goal is to provide more example projects. If you are interested in cooperating on this, ping me on the Texo forum.

Thanks for reading and I hope this blog post helps to give Texo a try. Visit the Texo wiki for more information. Let me know if you have any questions or remarks on the EMFT newsgroup or forum!

gr. Martin

Written by martintaal

May 9, 2012 at 8:38 am

Posted in Texo

EMF Texo: JSON REST web service support, connecting your client to an EMF supporting web-server!

with one comment

Hi!

As always, Eclipsecon was an inspiration to finally implement those features which I always wanted to do. This time it was implementing JSON REST web service support in Texo. This new feature is based on my experience implementing RIA user interfaces for business web apps.

Texo automatically provides the JSON REST web service support using the ecore/xsd domain model. So with just a few lines of code your domain model is accessible from browser/mobile web UIs.

Why would it be a good idea to try out and use the Texo JSON functionality? Well first it is quite feature complete, supporting full CRUD, querying in multiple ways, individual update/inserts, mass delete/update/insert, proxying, etc. The second good reason is that it is based on real application experience, this explains why attention has been paid to details as querying for multiple values to fill a grid, record counting and object titles. The third good reason: the combination of JSON REST with the other Texo features (JPA entity generation, runtime layer, etc.) makes it possible to have a running feature-complete JSON REST function within a few minutes, generated from an ecore/xsd model.

Texo JSON runs typically in a web container like Tomcat. The example project illustrates how to set this up. After installing/running the solution in a web container, you can for example do these type of uris/queries to retrieve information:

The first example will retrieve a single object in JSON format, the second all Writer objects and the third example shows how a free-format query can be passed. Security and SQL injection prevention are important topics here to.

Insert/update are supported through POST http methods, deletion is done through the DELETE http method.

Other features of the Texo JSON REST support:

  • Paging parameters to support efficient scrolling through a large grid of data
  • Setting the number of levels in the containment tree which should be returned
  • The proxy concept, references are sent back with a proxy uri, to prevent reading the complete database
  • Several ways of doing insert/update
  • Combining multiple insert/update/delete actions in one request

As a next step I am considering implementing a few example web apps using client side UI technology as provided by sencha or even try to connect a RCP with an EMF UI to the Texo JSON layer.

Thanks for reading and I hope this blog post helps to give Texo a try. Visit the Texo wiki for more information. Let me know if you have any questions or remarks on the EMFT newsgroup or forum.

gr. Martin

Written by martintaal

April 5, 2012 at 6:10 am

Posted in Texo

Texo: easy (custom) code generation with EMF merging, code formatting and import resolving

leave a comment »

Texo provides code/JPA entity generation from ecore/xsd models specific for web server/service environments. In this post I will discuss how easy it is to extend/override Texo code generation with your own templates. You can even replace the complete Texo code generation with your own templates. Using Texo for your own code generation has some distinctive advantages.

Texo uses XPand as the templating language, the first question is why use Texo and not use XPand directly, well here are several good reasons:

  • EMF merging: Texo supports the same merging of manual code as EMF, you can manually change the generated code, manual changes will be retained when regenerating, so if you generate your code with the @generated javadoc tag you will get EMF merging for free (incl. support of merging of annotations etc.)
  • Code formatting: Texo makes sure that your code is formatted according to the development project code formatting standards
  • Import resolving: an important/difficult topic to solve yourselve, just generate all your code with fully-qualified class names, Texo will do automatic import resolving for you.
  • Efficient/Effective: a source file is only touched if it is actually changed by Texo, so your code will not show unneeded diffs, source files which are not needed anymore are automatically removed

All this is available out-of-the box and will work for all your generated code! Now how to extend/override code generation?

Let’s first see how to generate Texo standard code, it is very easy… After installing Texo, right-click any ecore/model and in the Texo submenu choose one of the generate code options.

Texo Entity Generation

Now the next step is to add/override Texo templates, it is a just few steps:

  • add the Texo nature to the project

Add Texo nature

  • create a folder structure inside your development project, the folder structure must match the template path in Texo
  • place your own templates in the folder structur

    Texo

Now let’s see an example of a template, here is one which generates a simple subclass of a generic DAO:

«IMPORT org::eclipse::emf::texo::modelgenerator::modelannotations»
«IMPORT org::eclipse::emf::texo::annotations::annotationsmodel»
«IMPORT org::eclipse::emf::ecore»
«IMPORT org::eclipse::emf::texo::generator»

«EXTENSION org::eclipse::emf::texo::modelgenerator::templates::util»

«DEFINE root(ModelController modelController) FOR EClassModelGenAnnotation-»

«LET ((EPackageModelGenAnnotation)this.ownerEPackageAnnotation) AS ePackageAnnotation»

«FILE "org/eclipse/emf/texo/example" + toLowerCase(ePackageAnnotation.name) + "/" + this.simpleClassName + "HbDaoImpl.java" java-»
package org.eclipse.emf.texo.example.daoimpl.«toLowerCase(ePackageAnnotation.name)»;

/**
 * The Dao implementation for the {@link «this.qualifiedClassName»} entity.
 * @generated
*/
public class «this.simpleClassName-»HbDaoImpl extends org.eclipse.emf.texo.example.GenericDaoHbImpl<«this.qualifiedClassName», Long> implements org.eclipse.emf.texo.example.dao.«toLowerCase(ePackageAnnotation.name)».«this.simpleClassName-»Dao
{

/**
 * @generated
 */
 public «this.simpleClassName-»HbDaoImpl(org.eclipse.emf.texo.example.HbSessionProvider sp, org.eclipse.emf.texo.example.dao.DaoFactory df) {
 super(«this.qualifiedClassName».class, sp);
 }

}
«ENDFILE-»
«ENDLET»
«ENDDEFINE»

See that the @generated doc tag is used, this makes it possible to manually change the generated code, and re-generate without loosing your changes.

This was basically it, so it is not more than adding your own templates and tell Texo where to find them.

Thanks for reading! Visit the Texo wiki for more information. Let me know if you have any questions or remarks on the EMFT newsgroup or forum.

gr. Martin

Written by martintaal

February 23, 2012 at 12:24 pm

Posted in Texo