Archive

Archive for the ‘Java’ Category

Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting [step3]

avril 10, 2012 3 commentaires

In [step2] we have seen how to use Spring DM to load/unload in OSGi context Spring file (stored in META-INF/spring folder) from an OSGi bundle. In this article we will see how to:

  • publish service to OSGi services registry with declaration mean with Spring DM <osgi:service.
  • >S

  • consume service from OSGi services registry with declaration mean (to avoid using OSGi ServiceTracker) with Spring DM <osgi:reference .

We will modify our thread client FindAllUsersThread to consume a UserService which returns a list of User :

public interface UserService {

	Collection<User> findAll();

}

and displays on console this User list.

  • On consumer side (Simple Client), The UserService will be retrieved from the OSGi services registry with <osgi:reference:
    <osgi:reference id="userService" interface="fr.opensagres.services.UserService"
      cardinality="0..1" timeout="1000" />
    

    This service instance will be injected (Dependency Injection) in the FindAllUsersThread :

    <bean id="FindAllUsersThread" class="fr.opensagres.simpleclient.FindAllUsersThread"
      init-method="start" destroy-method="interrupt">
      <property name="userService" ref="userService"></property>
    </bean>
    

    and UserService will be used in the thread :

    public class FindAllUsersThread extends Thread {
    
    	private UserService userService;
    
    	public void setUserService(UserService userService) {
    		this.userService = userService;
    	}
            
            @Override
    	public void run() {
              // Consume UserService and display user list here...
            }
    }
    
  • On publish side (Services Implementation), the UserService implementation instance will be declared in Spring file as bean:
    <bean id="userService" class="fr.opensagres.services.impl.UserServiceImpl" />
    

    and this bean will be registered in the OSGi references with Spring DM <osgi:service:

    <osgi:service ref="userService" interface="fr.opensagres.services.UserService" />
    

Lire la suite…

Catégories :Spring, Spring DM

Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting [step2]

avril 6, 2012 10 commentaires

In [step1], we have initialized Spring DM. At this step we can start using Spring DM features. One of goal of Spring DM is to give the capability to any OSGi bundles, to declare Spring bean in XML Spring file stored in their META-INF/spring folder. Spring DM provides a Spring Extender bundle which :

  1. load XML Spring file for each OSGi bundles which starts. We will check that in the Start Simple Client bundle section.
  2. unload XML Spring file for each OSGi bundles which stops.We will check that in the Stop Simple Client bundle section.

We will check this feature in this article by developing a Simple OSGi Bundle which uses Spring fr.opensagres.simpleclient to create an instance of a Thread :

  • the bundle hosts a Thread class which display in the System Out console a message :
    public class FindAllUsersThread extends Thread {	
    	
      @Override
      public void run() {
        while (!super.isInterrupted()) {				
          System.out.println("Call FindAllUsersThread#run()");				
        }
      }
    }
  • this Thread class will be declared in a Spring bean in the META-INF/spring/module-context.xml Spring file of the bundle. The start/interrupt of the Thread will be managed by the Spring:
    <bean id="FindAllUsersThread" class="fr.opensagres.simpleclient.FindAllUsersThread"
    	init-method="start" destroy-method="interrupt" />
    

Lire la suite…

Catégories :Spring DM

Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting [step1]

avril 6, 2012 16 commentaires

In [step0] we have seen that I will explain step by step how to develop « Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting ». In my articles, I will use Spring DM instead of using Eclipse Gemini Blueprint because today CXF DOSGi supports only Spring DM. However I have created the patch DOSGI-115 to support Eclipse Gemini Blueprint with DOSGi.

In this article we will just initialize Spring DM :

But what is Spring DM? Spring DM gives you the capability to use Spring on OSGi context:

  1. any OSGi bundles can declare Spring bean in XML Spring file stored in their META-INF/spring folder. Spring DM provides a Spring Extender bundle which :
    1. load XML Spring file for each OSGi bundles which starts.
    2. unload XML Spring file for each OSGi bundles which stops.
  2. it’s possible to declare in Spring bean, services to publish/consume in the OSGi registry services.

Lire la suite…

Catégories :Spring, Spring DM Étiquettes :

Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting [step0]

avril 5, 2012 3 commentaires

XDocReport project provides a modular Eclipse RCP/RAP XDocReport application where you can develop your own module with Eclipse Plugin to manage your domain with CRUD Form and generates some reporting. The online RAP demo provides for instance a Resume module to manage resume (create/update/search resume and generate report resume):

This application is based on :

  • Eclipse RCP to provide Fat Rich Client.
  • Eclipse RAP to provide the same application in WEB mode
  • Eclipse Gemini Blueprint to use Spring on OSGi context. This project is the donation of the Spring DM project to Eclipse
  • Spring Data JPA is used to implement our DAO with JPA. This Spring project is very impressive because you need not code your JPA Query. You must just follow some convention name with your methode DAO interface and that’s all! Spring Data JPA implements (at runtime) for you the JPA DAO.
  • Eclipselink used as JPA Implementation.

You can find sources from this Eclipse RCP/RAP application on Git.

Our 2 next goals is :

  • manage remoting to provide too Client (RCP Client) and Server (Services on server side) architecture. To do that we have several solutions like :
  • use Eclipse E4 instead of Eclipse RCP as soon as Eclipse RAP will support Eclipse E4.

We spent much time to study how to manage those technologies together but today we like this architecture. Goal of my « Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting » articles is to explain step by step how to develop a simple Eclipse RCP/RAP with those Spring technologies, shares several rules that we have discovered with Spring on OSGi context, and manages 2 architectures :

To follow those articles, you must know OSGi, Eclipse RCP:

You can read the next article [step1] which explains how to initialize Spring DM.

Eclipse Nebula Pagination Control

janvier 6, 2012 13 commentaires

In business application with large data, display data in a table with navigation page can be really helpful. In our XDocReport project, we need this feature in our Eclipse RCP/RAP XDocReport application for instance to select resumes to open in the Search Resume Dialog :

This last screenshot is the resume search dialog in WEB context (Eclipse RAP). Here a screenshot in fat client context (Eclipse RCP) :

After several search, it seems that there is no project which provides a SWT pagination control, which works with Eclipse RCP and RAP. So we decided to develop this control and give our code to Eclipse Nebula Project. Today Nebula Team are voting if the project will be accepted or not. Pagination control was accepted by Nebula and today it is stored on Eclipse Nebula Git.

If you are intersted you can read the original bug 367064.

Lire la suite…

Eclipse Nebula Picture Control

janvier 6, 2012 5 commentaires

In some business application, your model (domain) contains sometimes image byte array (ex : photo for person model, logo for project model, etc). In our XDocReport project, we need to manage photo byte array with SWT control for the person model in our Eclipse RCP/RAP XDocReport, in the resume editor :

This last screenshot is the resume editor in WEB context (Eclipse RAP). Here a screenshot in fat client context (Eclipse RCP) :

After several search, it seems that there is no project which provides a SWT picture control, which works with Eclipse RCP and RAP. So we decided to develop SWT PictureControl and give our code to Eclipse Nebula Project.Today Nebula Team are voting if the project will be accepted or not. Pictur control was accepted by Nebula and today it is stored on Eclipse Nebula Git.

If you are intersted you can read the original bug 365948.

Lire la suite…

JAX-WS with Apache CXF and Eclipse [step2]

août 24, 2011 69 commentaires

In [step1], we have configured CXF Eclipse Plugin to use CXF 2.4.2 and created an empty Dynamic Web project with Tomcat 7.

In this article we will create a sample Java class HelloServiceImpl and publish it as WebService by using CXF Eclipse wizard. Basicly, this wizard will :

Lire la suite…

Catégories :Apache CXF, JAX-WS

JAX-WS with Apache CXF and Eclipse [step1]

août 23, 2011 14 commentaires

Few months ago, I had to migrate WebServices from my professional project based on Axis to JAX-WS which is the Java API for XML Web Services supported by the Java Platform, Standard Edition 6 (Java SE 6).

There are several implementations of JAX-WS like :

In my case, my professional project doesn’t use Spring. We have chosen Apache CXF which use Spring by default but you can manage CXF without Spring.

I have discovered and learned CXF with Eclipse JEE Indigo (works too with Eclipse JEE Helios) which provides Wizard to generate JAX-WS annotation and initialize CXF application. I think that playing with the CXF Eclipse Wizard is a good start point to learn CXF, so I decided to write some articles called JAX-WS with Apache CXF and Eclipse (this link is the plan of articles) which explains step by step how to generate WebService and Consumer of WebService with CXF Eclipse Wizard.

In my articles I will use :

  • the last version 2.4.2 of CXF.
  • Tomcat 7 as server.
  • Eclipse JEE Indigo.

But you can do the same thing with another version of CXF and another server. In this article I will explain how to

  1. initialize the CXF Plugin
  2. and create an empty Eclipse Dynamic Web Project with Tomcat 7.

Lire la suite…

Catégories :Apache CXF, JAX-WS

My first steps with Eclipse RAP [step7]

août 8, 2011 13 commentaires

In [step6] we have seen how to manage UI with SWT Java code (no need to code Javascript). When I started « My first steps with Eclipse RAP » articles, I used Eclipse Helios which provides RAP 1.3. Since June 2011 Eclipse Indigo has been released and provides RAP (runtime and tooling) 1.4 which improves RAP. So, I decided to start over my articles with Eclipse Indigo to benefit from New & Noteworthy of RAP 1.4. In this article we will :

At the end of this article we will compare the two generated RAP and RCP Application code to see the differences between RCP and RAP Application. We will use this comparison in the [step8] to manage RAP (WEB Application) and RCP (Fat client) application with the same code (Single Sourcing).

Lire la suite…

Catégories :Eclipse RAP, Eclipse RCP

My first steps with Eclipse RAP [step6]

Mai 31, 2011 3 commentaires

In step5, we have explained the generated code of the RAP Hello World Application. In this step we will improve our RAP Application to add basic user-interface (UI). At the end of this article, our RAP Application will look like this :

In RAP/RCP Application, UI is managed with SWT (Standard Widget Toolkit) :

SWT is an open source widget toolkit for Java designed to provide efficient, portable access to the user-interface facilities of the operating systems on which it is implemented.

SWT is an API to manage UI. There are several implementation of SWT :

  • for RCP Application, the basic idea of SWT is to use the operating systems (OS) native widget to render UI. There is an implementation of SWT for each OS (Windows, Linux…). Swing for instance emulates the UI widgets, that’s why the look and feel of Swing Application are the same for any OS, although look and feel of SWT Application change according to the OS (a button in SWT Application use Windows button look and feel if the SWT Application runs on Windows, use Linux button look and feel if the SWT Application runs on Linux..)..
  • for RAP Application, SWT is implemented with Qooxdoo Javascript widgets. The SWT implementation in RAP Application is called RWT (Rich Widget Toolkit). We will study it in the next article.

Lire la suite…

Catégories :Eclipse RAP
Concevoir un site comme celui-ci avec WordPress.com
Commencer