Home Tutorials Training Consulting Products Books Company Donate Contact us









NOW Hiring

Quick links

Share

Eclipse server integration This tutorial describes options how to integration a server with Eclipse. A 2-tier and 3-tier layer is described.

1. Eclipse server integration

1.1. Presentation and the persistence layer

In an application you typically have a layer which persists the data and another layer which represents the data. In an Eclipse RCP application you have the RCP part for the representation. The persistence layer can be a data base, the file system or a storage system handled by a remote server.

1.2. 1-tier Architecture

A 1-tier layer for an Eclipse RCP application is if the data of the RCP application is stored locally. This can be, for example, via the file system or an embedded database.

1.3. 2-tier Architecture

A 2-tier layer for an Eclipse RCP application is if the data is stored in a database and the Eclipse RCP application communications directly with the database server. In this scenario, typically JDBC or JPA with a SQL database is used. Alternately no SQL based database, like MongoDB, can be used.

Updates in the storage layer require an update in the RCP application.

1.4. 3-tier Architecture

In an 3-tier architecture the RCP application communications with a server application. This server application handles the storage of the data and the communication with the storage layer.

2. Using the JPA in an OSGi environment

The usage of JPA to access a database, either embedded or standalone, requires a special setup, as you must configure JPA to run in an OSGi runtime.

In case JPA should be used within an OSGi environment, e.g., an Eclipse RCP application, some rules have to be considered.

  • Tell the PersistenceProvider, which classloader should be used

  • Place the persistence.xml in the META-INF folder of the bundle, where the EntityManager is created

import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.jpa.PersistenceProvider;

public class JPADataBaseService {

    Map<String,Object> properties = new HashMap<>();
    // pass the bundles classloader as property
    map.put( PersistenceUnitProperties.CLASSLOADER, getClass().getClassLoader() );

    PersistenceProvider persistenceProvider = new PersistenceProvider();
    EntityManagerFactory entityManagerFactory
     = persistenceProvider.createEntityManagerFactory( "vogella-entitiy-manager", properties );
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    // do database transactions with the entityManager
}

You find an example for this on Github.

3. Server integration

To communicate wit a server, typically Eclipse RCP clients uses one of the following technologies to communicate.

  • REST based services

  • SOAP based services

  • RMI

  • HTTPRemoteInvoker (Spring)

As REST is a de-facto standard based on web technologies, it is recommend to this approach. A very efficient library for accessing REST based services is the Retrofit library.

4. About this website

5. Eclipse product and export resources

5.1. vogella GmbH training and consulting support

TRAINING SERVICE & SUPPORT

The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.

The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.

Copyright © 2012-2017 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.

See Licence.