JBeans

JBeans Introduction

The code that is currently generated to the JBeans standard. JBeans embraces the Java Beans and EJB standards and makes them available in an intuitive and application friendly manner. The JBeans standard is based on many years experience porting beans to different platforms and architectures. JBeans has 3 principal classes.

  • Beans
  • Sessions
  • Homes

These principal classes are based on interfaces. Access to these classes is done through a ClassContext object, which acts as a Factory for the creation of these classes. The specific implementations are hidden below this interface layer, making them a flexible way to deploy the different architectures, as well as provide a thin layer to perform optimization.

Beans from different Class Contexts can be made link to one another. This means that beans from one ClassContext can use beans from other Classes Contexts.

The diagram below illustrates the interfaces (gray) and implementations (clear) for JBeans.

A full description of JBeans, complete with White Paper and Downloads can be found in the JBeans Web Page.

JBeans Classes

JBeans has the following types of classes: -

JBean Type   Purpose
ClassContext   Factory class for creating Beans.
Bean Classes   Bean Interfaces, Classes and Lazy Classes
Enumerated Types   For holding fixed types (e.g. Marital Status)
Validator Classes   For Validating properties and beans before setting and storing.
Session Classes   For managing saving, removing, finding across dependent beans.
Home Classes   For managing creating, updating, removing, finding for a bean type.

The JBeans are designed to easily map down to a object/relational mapping, but can handle other sources such as JNDI or properties files. We have successfully handled a wide variety of relational databases from the simple petstore to ecommerce models, neurological modeling, Microsoft Northwind, multi-instrument trading and complex financial derivatives models..

JBeans has been designed to operate across the Enterprise. JBeans has been designed to operate across multiple databases, and multiple projects. Whether it's a single Bean receiving real-time data in a 1-tier environment or several hundred Beans being saved across multiple databases in a 3-tier environment the JBeans interfaces will stay the same and keep the application code easy to use.

Implementation Transparency

JBeans beans transparently acts as 1, 2 or 3 tier layer. JBeans is a proven design. JBeans is a complete Beans layer. JBeans embraces Beans, JDBC, EJB and Web Services. JBeans is future proofed and allows your architects to retarget application code at different technologies as they change and evolve.

We can currently handle the following architectures: -

  • 1 Tier - (In-Memory)
  • 2 Tier - (JDBC, EJB Local)
  • 3 Tier - (EJB Remote/WebServices)

Orthogonal to this JBeans have been designed to act friendly in either a standalone application, a client-server or in a server-side engine.

Developers need no JDBC or EJB skills to use JBeans. JBeans can be used by your existing application developers, without employing expensive consultants. JBeans has been used successfully by COBOL developers to build market-leading products. Using a development environment's code completion developers have told us that the code almost write itself.

Example Code

The code fragment below shows how easy JBeans is to use. There is no sign of Beans, JDBC, EJB or Web Services.

public House createNewHouse() throws Exception
{

House house = furnitureContext.newHouseBean();
house.setHouseType( HouseType.DETATCHED );

Address address = furnitureContext.newAddressBean();
address.setLine1( "28 Old Avenue" );
address.setLine2( "Weybridge" );
address.setLine3( "Surrey" );
address.setLine4( "England" );
address.setPostCode( "KT12 4AX" );

house.setAddress( address );

Room hall = addRoom( house, RoomType.HALL, 12, 6 );
Room lounge = addRoom( house, RoomType.LOUNGE, 20, 20);

furnitureContext.getHouseSession().save( house );

//Correction
house.getAddress().setLine1( "28 The Avenue" );
Room dining = addRoom( house, RoomType.KITCHEN, 15, 19 );

furnitureContext.getHouseSession().save( house );

RoomSession roomSession = furnitureContext.getRoomSession();
roomSession.remove( lounge );

return house;

}

public Room addRoom( House house, RoomType roomType, double length, double width ) throws Exception
{

Room room = furnitureContext.newRoomBean();
room.setRoomType( roomType );
room.setLength( new Double( length ) );
room.setWidth( new Double( width ) );

house.addRoom( room );

return room;

}

public House printHouses( HouseType houseType ) throws Exception
{

HouseSession houseSession = furnitureContext.newHouseSession();
for( Iterator iter = houseSession.findByHouseType( houseType ); iter.hasNext(); )
{

House house = (House)iter.next();
System.out.println( house );
System.out.println( house.getAddress() );
System.out.println( StringUtil.toString( house.getRooms() ) );

}

System.out.println( "Total=" + houseSession.countByHouseType( houseType ) );

}

Code Annotation

As an application developer it is easy to see how easy and natural they are to program in. If your interested have a look at the list of features below, and try to understand some of the features.

  • There is no importing of anything technical.
  • All the Beans and Sessions are created via the <Project>Context.
  • There is a Bean and Session for each Entity.
  • Developers only deal with interfaces, and not the implementation.
  • The House is created as a normal Bean.
  • The HouseType.DETACHED is an Enumerated Type.
  • Beans are assembled as normal Beans before being saved.
  • The Address is set on the House (one-one).
  • Rooms are added to the House (many-one).
  • The Room dimensions can be null, so Doubles are used.
  • The Houseonly is saved (No create or store).
  • The Address and Room beans are automatically saved, with the
    House, in a single transaction, because they were dependents.
  • The Address is amended and a second Room is added.
  • The House is saved, only the Address is stored because it has
    changed and the new Room is created, again in a single transaction.
  • The lounge is removed directly from the RoomSession.
  • The Session lets Houses be found by a variety of means.
  • Once a House is found the Address and Rooms are retrieved transparently.
  • Sessions let you count as well as find.