Pages

Friday, May 31, 2013

EJB-GWT and Netbeans IDE

Accessing EJB from GWT using the Netbeans IDE

I was curious to see how does it work the GWT(google web toolkit) technology, together with EJB-session beans, moreover how the Netbeans development environment uses it's wizards, to ease the development.
I created a MySql table with a simple architecture to demonstrate the functionality, having an ID and a Name field:

My short demonstration is about to visualize the content of the “Name” field by a given record ID.
Netbeans gives us some useful wizards to create entity and session beans to achieve the MySql table's content. Entity beans are a type of Enterprise JavaBean(EJB), a server-side J2EE component, that represents persistent data maintained in a database. Session Beans implements a business task using entity beans. Both are hosted by an EJB container, like the Glassfish server.
To access EJB from a GWT web application, we must create remote session beans. Using the Netbeans Ide, we can achieve this, in following way:
  • first I created a java class library project, remote.jar. This jar file will contain the necessary entity bean for the session bean. Right clicking on this project I added an entity bean with a wizard connecting to the above mentioned MySql table. Additional packages to this project were the EclipseLink JPA 2.1 and Java EE 6 Api Library.
  • in the next step, I created a new project an EJB module. The remote.jar was added to this module as an additional library. Right clicking also on this project, we can call a wizard to create a remote session bean for the entity class. This step, is also generates automatically the remote session bean into the remote.jar file
  • I built both projects and deployed the EJB module using Glassfish 4.
  • To create a GWT web application with Netbeans it is necessary to add the GWT plugin to the IDE from it's menu: Tools-Plugins-Available Plugins or Downloaded Plugins if you have downloaded this plugin from Netbeans' official site. After this, you can create the java web application adding to it the GWT framework, at the end of the wizard.

How to configure the GWT web application to use enterprise java beans

We can do this by the remote.jar package created in the steps above mentioned. After the GWT web application was created, I added the remote.jar package to this web project, with the entity and remote session bean created in it. I don't want to enter in too much details, I suppose that you are familiar with GTW-RPC technology, because this is necessary to reach server-side data. So, after creating the necessary java files to the GWT-RPC(you can use here, also wizards), my server-side implementation of a simple ejb call, looks like the following:


GWT-RPC sends server-side data across the network through serialized objects, therefore one important thing I would like to mention here, that we must create a wrapper class, to send ejb data, across the wire, to the client. An entity record with a given id, is found by the session bean finder method.
The wrapper class implements the Serializable object, gets the entity data as input data into it's constructor, and associates their value to it's local fields, accessed by getter and setter methods.

Thursday, May 9, 2013

DIA - Engineering diagrams

1. Dia is an application for creating technical diagrams. Its interface and features are loosely patterned after the Windows program Visio. Features of Dia include multiple-page printing, export to many formats (EPS, SVG, CGM and PNG), and the ability to use custom shapes created by the user as simple XML descriptions for generating the desired code. Dia is useful for drawing UML diagrams, flowcharts, database diagrams, network maps, electrical circuits and many others. 
You can download for free:
http://projects.gnome.org/dia/




2. BlueJ is an integrated Java environment specifically designed for introductory teaching. BlueJ supports:
  • fully integrated environment
  • graphical class structure display
  • graphical and textual editing
  • built-in editor, compiler, virtual machine, debugger, etc.
  • easy-to-use interface, ideal for beginners
  • interactive object creation
  • interactive object calls
  • interactive testing
  • incremental application development 
Downloadable from:
http://www.bluej.org/download/download.html 

Saturday, May 4, 2013

GWT-MGWT from a single source code

   I just write a simple web page rpc-application, that recognizes the platform on which it is run, and has a different UI for mobile and for desktop.
Gwt stands for browsers and Mgwt for m. webkit, and I tried to use a proper arhitecture to load the right GUI.
If you test this on a desktop machine use firefox for desktop and google chrome to emulate mobile appearance(with http://ipad-emulator.org/).

So, this is:
http://lehelsipos-gwt4.appspot.com/

And if you would like to download the source code:
http://siposlehel.atw.hu/