Employee demo

This section shows small demo - employee application. You will find sample demo in downloaded zip file or at least see screnshots screenshots . This demo is reference demo application that is directly contained in vpda repository

Case study

We want to develop sample application that can collect organization departments, its employees and realized projects. We have these domains in our application:

  • Department
  • Employee belonging to Department
  • Project realized by Department
  • Task executed by Employee

Really simply, multiuser application. We would suppose both application will have 3 tier architucture. Application will use relational database to store data, have application logic on server and presentation logic implememted as web or desktop application. We will start with database layer.

Database layer

Application is really simply, we can suppose we will need no stored procedures, just tables to store data.

  • Non-vpda application will need to create and manage database script (also for various target DBMS)
  • VPDA provides small modeling library to model database tables like java classes. This is very simply modeling using which we get DB vendor independence and compilation check when mapping to JPA entities. Look at usage to see example.
  • Both vpda,non-vpda can use JPA to persist data. Vpda adds transaction service regardless of server platform.

Application layer

In this tier we need to create services using which we can make basic CRUD operation upon domain objects and add advanced business logic. These services will be used mainly by view tier, but coul be used also as integration services with other systems. Typically these services should be realized like session beans.

  • Non-vpda application can create session beans to implement basic CRUD services. These services will operate directly with domain entities, so also caller of this layer must use domain objects. We will need JEE application server , which although provides many services , it is not so easy to develop application effective way.
  • VPDA will also use business services to implement basic CRUD operation, but this business services can run in J2SE using Spring or on application server . Application code is always same. So we can very quickly change application and run again in our favorite IDE without any special plugins or tools like (MyEclipse, Eclipse WTP, RAD).

Presentation layer

This tier somehow presents data and provides application flow. It can be implemented like web or desktop application. Here we will see power of vpda.

  • Non-vpda application can create web application and use JSP,JSF,Wicket,GWT or any web framework. For all of these framework it is not so easy to develop large, well maintainable application. For each 'frame' we need to define view (columns, detail fields, action) and provide communication with application layer. Imagine realy big application like ERP system, CRM with many developers, it is big challenge to develop such consistent and easily scallable tier. Web application will be deployed probably to web server and communicates with Application layer using EJB local or Remote calls.
  • Non-vpda can create desktop application using Swing or SWT. These means hard work to define all frames and actions and to 'map' user interface to appllication layer. This way client is also controller and there is always some very important bussiness logic ( like at least filtering, business validation) there. Also client must communicate with server using EJB remote calls, which means having vendor libraries on client.
  • VPDA divides presentation client between client and server machine. Client is always only presenter of data regardless it is swing client or web client. We do not write new client code for new application. We define client views and controller using view providers components on server. These components provides view and controller for client. So we develop one application with two client target platforms. We do not need to do hard work to define view and implement communication to server

Installation and demo application

Download release from releasesAndDownloads and unzip demo application. Seee readme/README.TXT , there you can find description for folders in zip archive. Now u can try the employee demo aplication running as plain server with spring or on JEE server. Application will have swing client and web client.

  • Running as plain server with Spring :
    1. Run employee server : INSTALL_DIR/vpda-samples/emp/bin/runEmpPlain , ensure you use jdk 6 or JAVA_HOME is set to point to valid java 6.0 install directory
    2. Run swing client : INSTALL_DIR/vpda-swingClient/bin/run , ensure you use jdk 6.0 or JAVA_HOME is set to point to valid java 6.0 install directory. You can use RMI or HTTP protocol to connect.
    3. Run swing application using webstart technology. Open browser at http://localhost:8082/vpda-webstart and launch webstart
    4. Open browser at http://localhost:8082/vpda/ and use web application.
    5. When finished, kill server with CTRL+C

    Now u can play with application, update data, use master detail (department - employee,projects), create new records. In usage you will see there was not much code to write for all of this.

  • Running on Glassfish. Same as running application in J2EE with Spring , we can run application on JEE server without Spring. We will use h2 database with data in memory. So no database installation will be needed.
    1. Install GlassFish. We have last tested with glassfish-installer-v2.1-b25 build.
    2. Create Connection Pool with name : vpdaH2MemPool and DataSource class name : org.h2.jdbcx.JdbcDataSource. Add properties to pool :
      • url = jdbc:h2:mem:vpda;DB_CLOSE_DELAY=-1
      • user = sa
      • password = ""
    3. Create new jdbc resource for above created pool with jndiName = jdbc/vpdaH2Mem
    4. Deploy sample ear file to Glassfish server : INSTALL_DIR/vpda-samples/samples-emp/ear/samples-emp-server-ear-version.ear using GlassFish web console or command line
    5. Start Swing client and use RMI/HTTP protocol
    6. Open browser at http://localhost:8080/vpda/

      Now you can again play with application running on GlassFish. You see application is same regardless running as J2SE application or JEE.