Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Texo/EMFResource"

(Introduction)
 
(7 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
== Introduction ==
 
== Introduction ==
  
Texo also supports you in when developing a RCP solution. The solution architecture has 2 parts:
+
Texo is also very usefull when developing a RCP solution. The solution architecture has 2 parts:
 
* an EMF generated user interface which uses EObjects
 
* an EMF generated user interface which uses EObjects
* a Texo generated persistence layer, using standard JPA/ORM
+
* a Texo generated persistence layer on the server, using standard JPA/ORM
  
To support this architecture Texo has implemented a new resource: the [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/TexoResource.java TexoResource]. This implementation has 2 subclasses implementing different scenarios:
+
To support this architecture Texo provides a new EMF resource (to be used in the RCP client): the [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/TexoResource.java TexoResource]. This implementation has 2 subclasses implementing different scenarios:
 
* [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/runtime/org.eclipse.emf.texo.server/src/org/eclipse/emf/texo/server/store/EPersistenceTexoResource.java EPersistenceTexoResource]: for direct integration in the same systems layer with the ORM, the 2-tier architecture.
 
* [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/runtime/org.eclipse.emf.texo.server/src/org/eclipse/emf/texo/server/store/EPersistenceTexoResource.java EPersistenceTexoResource]: for direct integration in the same systems layer with the ORM, the 2-tier architecture.
* JSONTexoResource (under development): this resource allows you to implement a 3-tier architecture.
+
* [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/core/org.eclipse.emf.texo.json/src/org/eclipse/emf/texo/json/JSONTexoResource.java JSONTexoResource]: for a full 3-tier architecture with EObjects on the client, JPA on the server and JSON for the communication.
  
 
== Architecture ==
 
== Architecture ==
 
=== 2-Tier Architecture ===
 
=== 2-Tier Architecture ===
  
Currently (build 9th May 2012) a 2-tier architecture is supported through the [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/runtime/org.eclipse.emf.texo.server/src/org/eclipse/emf/texo/server/store/EPersistenceTexoResource.java EPersistenceTexoResource] which is located in the org.eclipse.emf.texo.server plugin. This resource implementation makes use of the Texo [[Texo/EntityManagerHandling|EntityManager]] integration to have access to an EntityManager to retrieve and read information.  
+
The 2-tier architecture is supported through the [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/runtime/org.eclipse.emf.texo.server/src/org/eclipse/emf/texo/server/store/EPersistenceTexoResource.java EPersistenceTexoResource] which is located in the org.eclipse.emf.texo.server plugin. This resource implementation makes use of the Texo [[Texo/EntityManagerHandling|EntityManager]] integration to have access to an EntityManager to retrieve and read information.  
  
 
In this 2-tier architecture the EMF Resource talks directly (through Texo) with the ORM layer and the database.  
 
In this 2-tier architecture the EMF Resource talks directly (through Texo) with the ORM layer and the database.  
Line 25: Line 25:
 
=== 3-Tier Architecture ===
 
=== 3-Tier Architecture ===
  
In the near future also a 3-tier architecture will be supported. A new type of EMF resource: TexoJSONResource is being implemented (May 2012) which allows you to have a 3 tier architecture:
+
Texo also supports a 3-tier architecture using the JSONTexoResource:
* front-end: the user interface - client using standard EMF generated code
+
* Front-end: the user interface - client using standard EMF generated code
* middle-tier: the web server layer provides a [[Texo/JSON_REST_Web_Services|CRUD JSON]] web service function and the JPA/ORM persistence
+
* Middle-tier: the web server layer provides a [[Texo/JSON_REST_Web_Services|CRUD JSON]] web service function and the JPA/ORM persistence
* database
+
* Database
  
  
Line 39: Line 39:
 
* by setting the types URI parameter in the URI of the resource, the types parameter should be a comma delimited list of JPA entity names, normally the EClass name is used. For example: http:/localhost:8080/texo?types=Library,Book
 
* by setting the types URI parameter in the URI of the resource, the types parameter should be a comma delimited list of JPA entity names, normally the EClass name is used. For example: http:/localhost:8080/texo?types=Library,Book
 
* by directly calling the query method on the TexoResource, the query method allows free format HQL/JPQL queries with named parameters.
 
* by directly calling the query method on the TexoResource, the query method allows free format HQL/JPQL queries with named parameters.
 +
 +
The TexoResource internally uses an instance of  [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/EObjectStore.java EObjectStore]. You can get this object through the getEObjectStore method on the TexoResource. The EObjectStore provides additional methods which can be very usefull:
 +
** cross-referencing: find all the objects that refer to a specific target object
 +
** counting using a query
 +
** refreshing an object from the server
  
 
Persisting your changes can be done by calling the save method (the one without the outputstream parameter) on the resource. Updates, new objects and deletions are persisted.
 
Persisting your changes can be done by calling the save method (the one without the outputstream parameter) on the resource. Updates, new objects and deletions are persisted.
 +
 +
=== The JSONTexoResource - setting up a server side ===
 +
 +
The Texo JSON Resource has some additional specific points to take into account.
 +
 +
First it needs a running server, see [[Texo/JSON_REST_Web_Services#Video.2FDemo_.26_Example_project|here]] for an example project and video for such a server side.
 +
 +
Then next, the URI for creating the resource must be a valid web address pointing to the Texo server environment. For example the following web address is used in the test environment of Texo: http://localhost:8080/texo/jsonws
 +
 +
The JSONTexoResource resolves proxies by doing HTTP requests to the server side to load the proxied objects. EMF proxies only work correctly if the EMF resource is created through a ResourceSet.
 +
 +
When sending objects from the client to the server (when saving a resource) the server side is allowed to change objects before persisting. The changes are send back to the client and merged into the client-side objects.
 +
 +
If the client needs to authenticate against the server then you need to create your own subclass of the [http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/core/org.eclipse.emf.texo.json/src/org/eclipse/emf/texo/json/JSONEObjectStore.java JSONEObjectStore]. This class has several overriding points for changing the URL or adding authentication to the HttpUrlConnection. See [[Texo/Components|here]] on how to tell Texo to use your specific subclass of the JSONEObjectStore.
 +
 +
The JSONTexoResource is specifically targeted for usage in a RCP. For the RCP environment/client side you need 2 plugins:
 +
* org.eclipse.emf.texo
 +
* org.eclipse.emf.texo.json
 +
 +
And in addition the EMF plugins ofcourse. You can find these plugins through the Texo [[Texo/Download_and_Install#Update_Manager_Locations|update site]].
 +
 +
=== The EPersistenceTexoResource ===
 +
 +
The EPersistenceTexoResource uses the [[Texo/EntityManagerHandling|Texo EntityManager]] integration to have access to an EntityManager, please check out the [[Texo/EntityManagerHandling|Texo EntityManager]] wiki page for more information.

Latest revision as of 05:58, 14 December 2013

Introduction

Texo is also very usefull when developing a RCP solution. The solution architecture has 2 parts:

  • an EMF generated user interface which uses EObjects
  • a Texo generated persistence layer on the server, using standard JPA/ORM

To support this architecture Texo provides a new EMF resource (to be used in the RCP client): the TexoResource. This implementation has 2 subclasses implementing different scenarios:

  • EPersistenceTexoResource: for direct integration in the same systems layer with the ORM, the 2-tier architecture.
  • JSONTexoResource: for a full 3-tier architecture with EObjects on the client, JPA on the server and JSON for the communication.

Architecture

2-Tier Architecture

The 2-tier architecture is supported through the EPersistenceTexoResource which is located in the org.eclipse.emf.texo.server plugin. This resource implementation makes use of the Texo EntityManager integration to have access to an EntityManager to retrieve and read information.

In this 2-tier architecture the EMF Resource talks directly (through Texo) with the ORM layer and the database.


Org.eclipse.emf.texo.resource.2tier.png


3-Tier Architecture

Texo also supports a 3-tier architecture using the JSONTexoResource:

  • Front-end: the user interface - client using standard EMF generated code
  • Middle-tier: the web server layer provides a CRUD JSON web service function and the JPA/ORM persistence
  • Database


Org.eclipse.emf.texo.resource.3tier.png


Using the Texo Resource

Information can be loaded in the Texo resource in 2 ways:

  • by setting the types URI parameter in the URI of the resource, the types parameter should be a comma delimited list of JPA entity names, normally the EClass name is used. For example: http:/localhost:8080/texo?types=Library,Book
  • by directly calling the query method on the TexoResource, the query method allows free format HQL/JPQL queries with named parameters.

The TexoResource internally uses an instance of EObjectStore. You can get this object through the getEObjectStore method on the TexoResource. The EObjectStore provides additional methods which can be very usefull:

    • cross-referencing: find all the objects that refer to a specific target object
    • counting using a query
    • refreshing an object from the server

Persisting your changes can be done by calling the save method (the one without the outputstream parameter) on the resource. Updates, new objects and deletions are persisted.

The JSONTexoResource - setting up a server side

The Texo JSON Resource has some additional specific points to take into account.

First it needs a running server, see here for an example project and video for such a server side.

Then next, the URI for creating the resource must be a valid web address pointing to the Texo server environment. For example the following web address is used in the test environment of Texo: http://localhost:8080/texo/jsonws

The JSONTexoResource resolves proxies by doing HTTP requests to the server side to load the proxied objects. EMF proxies only work correctly if the EMF resource is created through a ResourceSet.

When sending objects from the client to the server (when saving a resource) the server side is allowed to change objects before persisting. The changes are send back to the client and merged into the client-side objects.

If the client needs to authenticate against the server then you need to create your own subclass of the JSONEObjectStore. This class has several overriding points for changing the URL or adding authentication to the HttpUrlConnection. See here on how to tell Texo to use your specific subclass of the JSONEObjectStore.

The JSONTexoResource is specifically targeted for usage in a RCP. For the RCP environment/client side you need 2 plugins:

  • org.eclipse.emf.texo
  • org.eclipse.emf.texo.json

And in addition the EMF plugins ofcourse. You can find these plugins through the Texo update site.

The EPersistenceTexoResource

The EPersistenceTexoResource uses the Texo EntityManager integration to have access to an EntityManager, please check out the Texo EntityManager wiki page for more information.

Back to the top