I've been a zone leader with DZone since 2008, and I'm crazy about community. Every day I get to work with the best that JavaScript, HTML5, Android and iOS has to offer, creating apps that truly make at difference, as principal front-end architect at Avego. James is a DZone Zone Leader and has posted 639 posts at DZone. You can read more from them at their website. View Full User Profile

Enterprise Applications Made Easy With JVx

01.19.2011
| 6500 views |
  • submit to reddit

JVx is an enterprise application framework allowing developers to create database applications using a single sourcing approach. Taking the convention over configuration approach, made popular by Spring, the framework claims to speed up enterprise application development. With a small team,  René Jahn has provided a useful framework that allows you to complete your projects with fewer lines of code. Even so, the single source aspect may be the most appealling, with the ability to have Swing, web, and soon Android, clients for your application quite easily. I took the time to speak to René to find out more about this project.

 

DZone: Can you introduce yourself and your development background?

René Jahn: At the moment I am Community Manager and Head of Research & Development at SIB Visions. In the last 10 years I worked on different software projects as Software Architect, Developer and Team Manager. My focus was and is on (Rich) Internet and Intranet Applications  for business processes. That are classical multi tier applications with or without databases, sometimes browser based but also Desktop applications.
I have a lot of practical (project) experience with databases, especially with Oracle and MySql, developed backend and frontend systems with different technologies and frameworks. To be more concrete – worked with GWT, extGWT, Tapestry, Hibernate, Flex, Axis2, Swing, AWT, QT Jambi and a lot of other frameworks, tools and technologies like POI, Oracle Forms, JDT compiler. Much of my experience is now bundled in JVX.

DZone: So what exactly is JVx?

René Jahn: The Enterprise Application Framework – JVx, is a Full-Stack Application Framework for the Java platform. It facilitates the development of professional and efficient Database applications, in a short time and using little source code. The framework's architecture is based on the Multi-tier architecture model for the development of software systems and provides full support for all tiers. That were the facts, and in detail that means:

JVx defines an abstract User Interface which is technology independent. That are simple Java Interfaces which defines the requirements of UI Components and Controls. The technology depenent implementation has to use those Interfaces to be a valid UI technology for JVx. We have already implemented Swing, GWT with extGWT and QT Jambi.

Write an application and start it, without source code modification, as Desktop, RIA or Ajax/Html application.
On the server side, JVx offers session management (even for desktop applications), security managers for flexible authentication, an object provider for accessing business logic and a generic persistence API to access any kind of datasource, e.g. databases, twitter, xml. The persistence API offers CRUD operations out of the box without implementing additional classes.

JVx defines the communication between client and server and has implementations for http(s) and in process (same VM). The communication supports RPC and uses a generic serialization mechanism which works independent of the JVM version. The same communication was already implemented with .NET, to show the flexibility.

DZone: How long has it been in development? Is there a big team working on it?

René Jahn: We started development in October, 2008 – but had not choosen a license. The first official release, version 0.6 was in October 2009 under Apache License 2.0. We used this version for a software project which is still in production, with this version. We had a feature list for 1.0 very soon, so we decided against version number 1.0 because not all features were implemented.

The team…  Currently, we are 3 developers. We have almost the same experience with business applications but different point of views and different technology knowledge which helps a lot. We look forward to any interested person because every helping hand is needed.

DZone: Could you share some coding samples, or what's involved in creating an application using JVX?

René Jahn: This is a welcome challenge. Lets create an application with user login and simple CRUD operations for an existing database table.

We need an application class and extend the predefined Application. This is a MDI application with frames:

public class FirstApplication extends Application {

public FirstApplication(UILauncher pLauncher) {
super(pLauncher);
}

@Override
protected IConnection createConnection() throws Exception {
return new DirectServerConnection();
}

@Override
protected String getApplicationName() {
return "dzone";
}
}

Now we add a button to the toolbar for opening our new screen:

    @Override
protected void afterLogin() {
super.afterLogin();

UIToolBar tbMasterData = new UIToolBar();
UIButton butDBEdit = createToolBarButton
("doEdit", null, "Editor",
UIImage.getImage(UIImage.SEARCH_LARGE));

tbMasterData.add(butDBEdit);

getLauncher().addToolBar(tbMasterData);
}

and now we create the action for the button click:

    public void doEdit() throws Throwable {
DBEditFrame frame = new DBEditFrame(this);
frame.setVisible(true);
}

Maybe you're wondering about the action declaration. The framework supports standard listener handling and dynamic listeners, because we wanted to reduce source code.

If you look at the action declaration, you see the Throwable clause. The framework has a central exception handling and shows a standard error dialog if an exception occurs. It is not a problem to change the default behaviour.

Now we need our CRUD screen:

public class EditFrame extends UIInternalFrame
{
private Application application;
private AbstractConnection connection;
private RemoteDataSource dataSource = new RemoteDataSource();
private RemoteDataBook rdbContacts = new RemoteDataBook();

public EditFrame(Application pApp) throws Throwable {
super(pApp.getDesktopPane());

application = pApp;

initializeModel();
initializeUI();
}

private void initializeModel() throws Throwable {
//we use a new "session" for the screen
connection = ((MasterConnection)application.getConnection()).
createSubConnection("app.dzone.Edit");
connection.open();

//data connection
dataSource.setConnection(connection);
dataSource.open();

//table
rdbContacts.setDataSource(dataSource);
rdbContacts.setName("contacts");
rdbContacts.open();
}

private void initializeUI() throws Exception {
UIGroupPanel group = new UIGroupPanel();
group.setText("Available Contacts");

UITable table = new UITable();
table.setDataBook(rdbContacts);

group.setLayout(new UIBorderLayout());
group.add(table);

//same behaviour as centered component in BorderLayout
setLayout(new UIBorderLayout());
add(group);

setTitle("Contacts");
setSize(new UIDimension(600, 500));
}
}

We created the connection to our server (server and client runs in same process), an object for accessing data and a table for displaying data. Our layout is not rocket science.

The client-side is now ready. Lets configure our server to access the database:

public class Edit extends Session {

public DBStorage getContacts() throws Exception {
DBStorage dbsContacts = (DBStorage)get("contacts");

if (dbsContacts == null)
{
dbsContacts = new DBStorage();
dbsContacts.setDBAccess(getDBAccess());
dbsContacts.setWritebackTable("CONTACTS");
dbsContacts.open();

put("contacts", dbsContacts);
}

return dbsContacts;
}
}

We create a storage which reads and writes from the CONTACTS table from our existing database. The last missing thing is our database connection. We use the hard coded variant:

Thats it.

    public DBAccess getDBAccess() throws Exception {
DBAccess dba = (DBAccess)get("dBAccess");

if (dba == null)
{
dba = DBAccess.getDBAccess(
"jdbc:hsqldb:hsql://localhost/dzone");

dba.setUsername("sa");
dba.setPassword("");
dba.open();

put("dBAccess", dba);
}

return dba;
}


Our application started as Swing Desktop and Ajax/html web application:





DZone: What similar frameworks exist, and how does JVx set itself apart from those?

René Jahn: There are not so many similar Java frameworks available, but of course there are some. Similar open source frameworks are Eclipse RIENA with Eclipse RAP, Jspresso, Eclipse Scout and some parts of XDev. I know one commercial framework which is called qafe, but don’t have detailed information about it.

JVx has all features combined in one framework and all works together without problems. That is not always the case if you mix up frameworks. Some of above frameworks have very powerful features but misses other ones from the other frameworks. But I will not say that JVx is perfect, of course we have many ideas.

Some advantages of JVx compared to above frameworks, but not all points are relevant for every  framework:

  • very small source base and low complexity
  • no external dependencies - only commons-fileupload if you use an unsigned  RIA
  • does not need a lot of configuration files (one single xml with 15 lines)
  • one client model for all UI controls
  • master/detail relations for an unlimited number of tables or binding editors to model data (without additional implementation effort)
  • UI is technology independent
  • Single Sourcing
  • complete source documentation
  • Runs without changes on Android devices
  • replaceable client/server communication and serialize mechanism
  • develop local without application server and be sure that it works on application server

If you know other comparable frameworks, please let me know.

DZone: Has mobile been the most popular use of the framework?

René Jahn: The main goal of JVx is to develop data driven applications with or without database. It is not focused on mobile development, but we designed JVx that mobile development is absolutely possible. Because Android is a fan of Java, our framework works on that platform. We don’t have an UI implementation right now, but it is a pleasure to use exactly the same business logic for mobile devices as for the RIA or web application without implementing/defining additional services.

We created a native Android client for our football betting game. Different client, same framework, same business logic, without additional services.

To support easy UI integration, we have Android AddOns for JVx - some simple adapter implementations for List.

DZone: It's still in beta, so what features will you be adding before it reaches general release?

René Jahn: JVx has not reached version 1.0, but the last GA release was 0.8. It was available in October 2010. We have following release schedule:

  • GA release cycles of 6 months
  • Beta versions every month (no fixed intervals). The first beta version of the next release will be available 1 month after the last GA release.
  • 0.9 is planned for March/April 2011
  • 1.0 is planned for August 2011 (maybe earlier)

The original feature list for 1.0 will be reached with version 0.9, but we extended the list in the last two years with a lot of requests from users.
The actual roadmap is available at http://support.sibvisions.com.

Some cool features will be:

Request grouping
(Now the client requests data on demand, but every controller requests itself. With request grouping, we reduce requests significantly and increase performance)

Automatic link storage management optimization
(We detect database relations on demand and send the information to the client. The client automatically configures drop-down list boxes. But we don’t cache the information, and that increases memory. The optimization reduces memory usage on client and server)

Server Side Storage Triggers
(We implement storage triggers (before insert, before update, …) for server side storages. The feature is comparable to database triggers)

Other cool features: Autofilter for table control, Configuration encryption, CallBackListener for remote communication, Chart integration

DZone: What are you plans for the longer term future of the framework?

René Jahn: Java has a problem with its User Interface – JVx hopefully not ;-) because the UI doesn’t matter.
We look forward to the new JavaFX and maybe it is a fresh UI technology for JVx. But there is another alternative already available - Apache Pivot. We think about the integration, but have no concrete plan.

In summary, we look for alternative UIs.

Other topics are cloud storages, scalability, monitoring support and tools, test recording, headless UI Testing, HTML 5 websocket support as option for our current callback mechanism.

And last but not least - build a community and celebrate many release parties.