JeeWiz Home

 
  
 
Contents  >   3.  Tutorial
 


3.5 Adding Business Logic

Ok - so now you have to add the business logic code.

It will help to understand how the business logic should be added and how JeeWiz ensures that the business logic is preserved during subsequent regenerations. The answer to these is explained in the following sections: What is Generated and Adding Business Logic

Eclipse should compile the business logic as it is added. Once all the business logic is added the application is ready to run. To add the business logic, open out the project and edit the implementation files outlined in red:

For CongestionZoneLifecycleEvent.java, method logVehicle(), the code is:
if ( bean == null ) {
    log.info( "****** WARNING VEHICLE ENTERING SPACE IS NULL ******");
}
log.info( "------ logging vehicle in the space - " + bean.getLicencePlate());
For CongestionZoneLifecycleEvent.java, method removeOldCars(), the code is:
if ( entry.getYearBuilt().intValue() < 1970)
{
    log.info( "------ Removed Car - " + entry.getYearBuilt());
}
else 
{
    log.info( "------ Vehicle is liable for charge - " + entry.getYearBuilt());
}
For Processor_Actions.java, method processVehicle(), the code is:
log.info( " ------- processVehicle() A VEHICLE IS IN THE SPACE - " + vehicle);
Boolean isItValid = GsbProxies.LicenceService.isLicenceValid( vehicle.getLicencePlate() );
log.info( " ------- processVehicle() isItValid = " + isItValid );
if ( !isItValid.booleanValue() )
{
    log.info( " ------- processVehicle() The Vehicle " + vehicle.getLicencePlate() + 
              " is not a valid vehicle - call the police ");
}
// Now we need to determine if a congestion charge has been paid for this vehicle. 
// If not we should issue a fine.
this.numberOfVehicles++;
return null;
For Processor_Actions.java, method vehicleDrivesIntoZone(), the code is:
processVehicle( bean, GsbSpaces.getLocalCongestionZone(), null );
For Processor_Actions.java, Additional Code (at the end), the code is:
private int numberOfVehicles;
public int getNumberOfVehicles() 
{
    log.info( " *** - COUNT OF VEHICLES - " + this.numberOfVehicles + " ***");
    return this.numberOfVehicles;
}
For LicenceService.java, isLicenceValid(), the code is:
log.info("isLicenceValid() ------ isLicenceValid() called with " + licence);
if ( licence.endsWith("0"))
    return new Boolean(false);
else
    return new Boolean(true);
(which we admit doesn't win any prizes for elegance).

For RoadUsers_Actions.java, method createVehicle(), the code is:
log.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ");
log.info("-- Generator - the gsb = "+ hashCode());
log.info("<<<<<<<< " +  Thread.currentThread() + 
         " about to create vehicle - using GsbSpaces.CongestionZone " );
driveVehicleIntoZone(genVehicle(), GsbSpaces.getRemoteCongestionZone(), null);
For RoadUsers_Actions.java, method driveVehicleIntoZone(), the code is:
log.info( "Driving Vehicle into the zone - " + vehicle);
gigaSpace.write(vehicle);
For RoadUsers_Actions.java, Additional Code (at the end), the code is:
private Vehicle genVehicle()
{
    Vehicle vehicle = new Vehicle();
    vehicle.setLicencePlate( Integer.toString( randomCarGen.nextInt() ) );
    vehicle.setMake("Vauxhall");
    vehicle.setModel("Astra");
    vehicle.setYearBuilt(new Integer("2001"));
    return vehicle;
}
private static Random randomCarGen = new Random();


Copyright (c) 2001-2009 New Technology/enterprise Ltd.