Java Development, Recruitment and Consultancy

Proteus 2.0

Java without the Palaver

There are many frameworks which try to hide the complexity and consequential cost of a J2EE application. Our experience has been that most applications simply do not need the complex infrastructure provided by J2EE. Instead of hiding the complexity of J2EE we have developed our own light-weight scalable framework called Proteus2 that we have used successfully in several projects.

Proteus2 does not run in an application server. All it requires is a Java 5+ JVM, a Servlet Engine (our preferred choice is Caucho's resin) and a Web Server like Apache.

As a case-study we have described an interesting application of the Proteus framework here

Architecture

The Proteus2 architecture is similar to Apache's Struts in so far as, at the heart of it, there is a Controller Servlet that routes requests to objects that then service the request. Within Proteus2 these objects are known as Apapters. Each page of an application's interface is associated with a particular 'method' on an Adapter. To provide for background asynchronous processing and distributed computing Proteus2 also supports the concept of Services. A Service is simply a java object running in a dedcicated thread that is managed by a container that can be configured to be in the same JVM as the Controller or can run in a seperate JVM on another box. The Services receive data and processing instructions via a very efficient light-weight XML protocol.

Configuration

The proliferation of configuration files can be a big problem with large J2EE projects. Proteus2 has been designed to keep these to a minimum. Below is an example of the main configuration file for a small web application. A few points to notice are:
  • how the application's menu is defined here
  • the contact page is mapped to the Adaptor 'Message' and its method 'contact' through the page plan definition.
  • how some pages are only visible if logged in
<config>

  <!-- path to controller servlet -->
  
  <controller domain='http://www.mysite.com' securedomain='https://secure.mysite.com' path='/pub' />
 
  <!-- path definitions -->

  <xslroot   path="{rootdir}/xsl/" />
  
  <!-- Definition of page plans and the associated tasks:
    plan - The name maps directly to the page name invoked (ie ?pg=test ).
           It defines the set of tasks that are needed to service the page.
           Each task is called sequentially and in the order specified.
    task - Defines an adaptor object and method to call with optional parameters.
           Task names should be unique.
  -->
  
  <plans>

    <plan name='msg.contact' enabled='yes'>
       <task name='' use='com.mysite.adaptors.Message contact' enabled='yes' />
    </plan>
  
  </plans>
  
  <!-- Definition of pages and site navigation
       Note: pageids should be unique and map to the xsl file used to render page -->

<pagesets>
  <pageset id='main' accesslevel='0' >
    <page id='logout' xsl='home'   title='logout'        plan='logout'        desc='' hidden='o' />
    <page id='home_'       title='Home'                  plan=''              desc='' goto='home' >
      <page id='home'      title='Home'                  plan=''              desc='' />
    </page>
    <page id='login'       title=''                      plan='login'         desc='' hidden='y' />
    
    <page id='about_'           title='About'            plan=''              desc='' goto='about' >
      <page id='about'          title='About'            plan=''              desc='' />
      <page id='testimonials'   title='Testimonials'     plan=''              desc='' />
      <page id='partners'       title='Partners'         plan=''              desc=''  loggedin='y' />
    </page>
    <page id='jt'               title='Travel'           plan=''              desc=''  goto='jt_history'>
      <page id='jt_history'     title='By Aircraft'      plan=''              desc='' />
      <page id='jt_standard'    title='By Ship'          plan=''              desc='' />
      <page id='jt_enterprise'  title='By Train'         plan=''              desc='' />
    </page>
    <page id='contact_'         title='Contact Us'       plan=''          desc='' goto='contact' >
      <page id='contact'        title='Contact Us'       plan='msg.contact'  desc='' />
    </page>
   </pageset>
</pagesets>
  
</config>