The Business Application Module

The Bargainer

The Bargainer demo application

The Business Application Framework

The Business Application Framework provides the means for specification and realisation of the Business Application Service Handlers.

A Business Application may be the grouping of a set of handlers like authentication, payment etc. for a specific company or for a specific process of a company. A company (Service Provider) may provide a Business Application that will be used to encapsulate a set of service handlers.

Each application service handler is distributed on two sites. The client site and the server site. This means that in order a request to be served, the specific for the request service handler is called on both sites. The handler that runs on the server site will provide the handler that runs on the client site through the SEMPER Commerce layer, with all the necessary information for the service like product description, prices etc.

Currently there is a general Business Application built (semper.BApp.FrmWrkClnt.BApp, semper.BApp.FrmWrkSrv.BApp) that will fit most of the needs of an average company. As mentioned above it is distributed on client and server site. The application service handlers that are provided are for:

Before the user starts performing any transactions of the above services a secure session must be established between the client and the server. This is done by the Session_Start handler.

If the user does not want to perform any other transactions, must end the secure session between the client and the server by sending a Session_End request.

Thus the first request served must be a Session_Start request and the last one a Session_End.

Session Start

Used as the first request of a new Business Application object. It causes the creation of this new BApp object by the system. This same object is used for performing all the subsequent requests sent to the SEMPER Client until the user has sent a Session_End request. The secure connection (CLConnection object) established by the Semper Client/Server modules and passed to the BApp object is used throughout the session for communication between the client and the server.

Session End

Used as the last request of a Business Application object. Deactivates the BApp object and removes it from the BAppSessionManager. The secure connection assigned to this BApp object is destroyed.

Authentication

The customer authenticates the identity of the Business. Checks the authenticity of the server by asking for certificates.

Payment

The customer pays online using one of the provider online payment systems and receives the goods/services. Confirmation is asked from the customer before the actual payment transaction is performed. The underlying CLOrderPayConfirm service provided from the Commerce Layer module is used.

Offer

The customer checks the availability of certain products/services. The underlying CLOffer service provided from the Commerce Layer module is used.

Per time of use based Payment

The customer pays online using one of the provider online payment systems and receives the goods/services. The amount of money that will be retrieved from the account of the user is based on the time of use of the system.

Confirmation is asked from the customer before the actual payment transaction is performed. The underlying CLOrderPayConfirm service provided from the Commerce Layer module is used.

Customisation of a Business Application

Any company that wants to create a new Business Application and integrate it in the SEMPER software must create a pair of new classes, one for the client site and one for the server site. These classes extend the general classes of the Business Application Framework (semper.BApp.FrmWrkClnt.BApp, semper.BApp.FrmWrkSrv.BApp). In order to provide the service handlers that fit to company's needs they can either use any of the already implemented services of the parent classes or create on their own the different implementation of the services they want to provide, by overriding the existing ones.

In the case that they want to provide services that do not have any implementation or specification for their handlers in the parent classes it is the responsibility of the company to create and implement them in these company specific classes.

Case Study

For example let say that a company XXX wants to create a Business Application and the services that wants to provide have the same handlers with the general one, except the pay service handler.

In a case like that, as mentioned above, a pair of new classes must be created - one for the client and one for the server.

The client class named BAppXXX is implemented as follows:


package semper.BApp.BusinessClnt;



import java.lang.*;

import java.util.*;

import java.io.*;

import semper.BApp.FrmWrk.*;

import semper.BApp.FrmWrkClnt.*;

import semper.commlayer.*;

import semper.transfer.*;

This class defines the behaviour of the company XXX Business Application in the client side. This class implements the method (handler) required to perform payments as well as the methods for activation and deactivation. The other handlers are inherited from the parent class.


public class BAppXXX extends BApp implements BusinessApp

{

	static private int sid = 0;



	private final String _enterSession = new String("<HTML><BODY bgcolor=white><CENTER><B>"

 				+"<A HREF= http://www.xxx.com/>"

				+"Click to Start the SEMPER Session" + id()

				+ " for "

				+ name()

				+"</a></B></CENTER></BODY></HTML>");



	private final String _exitSession = new String("<HTML><BODY bgcolor=white><CENTER><B>" 				

				+ "<A HREF= http://www.xxx.com/>"

				+ "Click to End the SEMPER Session "

				+ id()

				+ " for "

				+ name()

				+"</a></B></CENTER></BODY></HTML>");

Constructs a client BApp object for company XXX.


public BAppEurocom()

{

		super(sid++, "COMPANY XXX");

}

Gets product configuration entry send by the equivalent BApp in the server site.


	public BAppCfgEntry configEntryGet(String entryId) throws BAExcept

	{





		CLData cl = new CLData();

        	StringBufferInputStream stringInputStream ;

       		InputStream input;

       		DataInputStream inputStream=null;



		try

		{

			stringInputStream = new StringBufferInputStream(cl.receive(this.getCL()).get_data());

			input = stringInputStream;

            		inputStream = new DataInputStream(input);

		}

		catch (Exception e)

      		{

      		}

		if (inputStream != null)

		{

			try

			{

				entryId = new String(inputStream.readLine().trim());

	  			String succRespURL = new String(inputStream.readLine().trim());

	  			String failRespURL = new String(inputStream.readLine().trim());

	  			String prodName = new String(inputStream.readLine().trim());

	  			String prodPrice = new String(inputStream.readLine().trim());

				String prodDur = new String(inputStream.readLine().trim());

	  			String prodXPrice = new String(inputStream.readLine().trim());

				String prodXtime = new String(inputStream.readLine().trim());

				String currency = new String(inputStream.readLine().trim());



 				return new BAppCfgEntryEurocom(entryId,

	  							 succRespURL,

	  							 failRespURL,

	  							 prodName,

	  							 prodPrice, prodDur,

	  							 prodXPrice, prodXtime,

								 currency);

			}

			catch (Exception e)

      			{

				throw new BAExcept(this.getClass().getName()

						+ ": Cannot Get Configuration Entry ("

						+ e

						+ ")");

			}

		}

	}

The next methods use the implementation of the class BApp which they inherit. They are showed here, because they are declared in the interface BusinessApp which they implement as well.


	/**

	 * Returns the type of the Business Application.

	 *

	 */

	public String getType()

	{

		return super.getType();

	}



	/**

	 * Returns the CLConnection object associated with the BApp object

	 *

	 */

	public CLConnection getCL()

	{

		return super.getCL();

	}



	/**

	 * Sets the CLConnection object associated with the BApp object

	 *

	 */

      	public void setCL(CLConnection connection)

	{

		 super.setCL(connection);

	}



	/**

	 * True is the Business Application is active else false.

	 *

	 */

	public boolean isActive()

	{

		return super.isActive();

	}



	/**

	 * Performs a Business Application Request.

	 *

	 * Dispatches the Business Application request invoked

	 * on a specific Business Application.

	  */

	public String  request(BAReq req) throws BAExcept

	{

		return super.request(req);

	}

The next methods implement the different behaviour of this specific business application compared with the general one.


	/**

	 * Activates the BApp object.

	 *

	 * Used as the first request of a new BApp object. It causes the creation of

	 * a new BApp object by the system.

	 *

	  */

	protected String activate(BAReq request)

	{

		return _enterSession;

	}



	/**

	 * Deactivates the BApp object.	Removes the BApp from the BAppSessionManager.

	 *

	 */

	protected String deactivate(BAReq request)

	{

		return _exitSession ;

	}



	/**

	 * Performs a complete payment indicated in the request.

	 *

	 */

	protected String pay(BAReq request) throws BAExcept

	{

		BAppCfgEntry cfgEnt = null;

		String paymentMethod = null;



	

		cfgEnt = configEntryGet(request.getParam("PRODUCTID"));

		paymentMethod = request.getParam("PAYMENTMEANS");



		String data = new String(cfgEnt.prodName() + " \n" );

		CLContentData cldata =new CLContentData (data,'\n');



		Security security = new Security();

		cldata.set_currency(cfgEnt.currency());

		cldata.set_value(new Float(cfgEnt.prodPrice()).floatValue());

		cldata.set_payment_method(paymentMethod);

		CLOrderPayConfirm cl = new CLOrderPayConfirm();



		int accepted, sent ;



		try

		{

			accepted = cl.send(this.getCL(),name(),cldata,security);



		}

		catch(CLException e)

		{

			throw new BAExcept(this.getClass().getName()

						+ "Cannot Send Order Pay Confirm("

						+ e

						+ ")");

		}







		if (accepted == CLServices.CL_ACCEPTED) // Accepted Payment

		{

			 return new String(

				"<HTML><TITLE>Success You May Proceed</TITLE>"				

				+ "<BODY bgcolor=white><CENTER>"

				+ "<A HREF=\"http://www.xxx.com/cgi-bin/response1.cgi?"

				+ "name1=" +  request.getParam("name1")

				+ "& name2=" +  request.getParam("name2")

				+ "& name3=" +  request.getParam("name3")

				+ "& nameN =" +  request.getParam("nameN") + "\">"

				+ "<FONT size+=2>Success Click here to Proceed </FONT>"

				+ "</A>"

				+ "</CENTER></BODY>" 

				+ "</HTML>"); 

		}

		else          // Not Accepted or Canceled Payment

		{

		    	CLData answer = new CLData();

		    	CLContentData answerData =new CLContentData (new String("Request Canceled" + "\n"),'\n');

		    	try

		    	{

			    	sent = answer.send(this.getCL(),null,answerData,security);



		    	}

            			catch(CLException e)

		    	{

			}

			return new String("<HTML><TITLE>Failure Go </TITLE>"				

				+ "<BODY bgcolor=white><CENTER>"

				+ "<A HREF=\"http://www.xxx.com/cgi-bin/response1.cgi?"

				+ "name1=" +  request.getParam("name1")

				+ "& name2=" +  request.getParam("name2")

				+ "& nameN =" +  request.getParam("nameN") + "\">"

				+ "<FONT size+=2>Failure Click here to Go Back </FONT>"

				+ "</A>"

				+ "</CENTER></BODY>" 

				+ "</HTML>"); 



		}

	}

}

The server class named BAppXXX is implemented as follows:


package semper.BApp.BusinessSrv;



import java.lang.*;

import java.util.*;

import java.io.*;

import semper.BApp.FrmWrk.*;

import semper.BApp.FrmWrkSrv.*;

import semper.commlayer.*;

import semper.transfer.*;

This class defines the behaviour of the company XXX Business Application in the server side. This class implements the method (handler) required to perform payments as well as the methods for activation and deactivation. The other handlers are inherited from the parent class.


public class BAppXXX extends BApp implements BusinessApp

{

	static private int sid = 0;

	static private BAppConfigTable config = null;

Contstructs a server BApp object for company XXX.

 

	public BAppEurocom() throws BAExcept

	{

		super(sid++,"EUROCOM EXPERTISE S.A.");

	

		if (config == null)

		{

			config = new BAppConfigTable("semper/BApp/BusinessSrv/BAppEurocom.config");

		}

	}

Gets product configuration entry from the configuration table and send it to equivalent BApp in the client.

 

	public BAppCfgEntry configEntryGet(String entryId,BAReq request)

	{



		int sent;





		BAppCfgEntry cfgEntry = (BAppCfgEntry)config.getEntry(entryId);



		String dataToSend = new String(cfgEntry.entryId() + "\n"

					+ cfgEntry.succRespURL()

					+ "\n"

					+ " "

					+ "\n"

					+ cfgEntry.prodName()

					+ "\n"

					+ cfgEntry.prodPrice()

					+ "\n"

					+ cfgEntry.prodDur()

					+ "\n"

					+ cfgEntry.prodXPrice()

					+ "\n"

					+ cfgEntry.prodXtime()

					+ "\n"

					+ cfgEntry.currency()

					+ "\n");

    		CLContentData cldata =new CLContentData (dataToSend,'\n');

		Security security = new Security();

		CLData cl = new CLData();



		try

		{

			sent = cl.send(this.getCL(),null,cldata,security);

		}

        		catch(CLException e)

		{

		}



		return null;

	}

The next methods use the implementation of the class BApp which they inherit. They are showed here, because they are declared in the interface BusinessApp which they implement as well.

 

	/**

	 * Returns the type of the Business Application.

	 *

	 */

	public String getType()

	{

		return super.getType();

	}



	/**

	 * Returns the CLConnection object associated with the BApp object

	 *

	 */

	public CLConnection getCL()

	{

		return super.getCL();

	}



	/**

	 * Sets the CLConnection object associated with the BApp object

	 *

	 */

     	 public void setCL(CLConnection connection)

	{

		super.setCL(connection);

	}



	/**

	 * True is the Business Application is acctive else false.

	 *

	 */

	public boolean isActive()

	{

		return super.isActive();

	}



	/**

	 * Performs a Business Application Request.

	 *

	 * Dispatches the Business Application request invoked

	 * on a specific Business Application.

	 *

	 */

	public String  request(BAReq req) throws BAExcept

	{

		return super.request(req);

	}

The next methods implement the different behaviour of this specific business application compared with the general one.


	/**

	 * Activates the BApp object.

	 *

	 * Used as the first request of a new BApp object. It causes the creation of

	 * a new BApp object by the system.

	 *

	 */

	protected String activate(BAReq request)

	{

		return null;

	}



	/**

	 * Deactivates the BApp object.	Removes the BApp from the BAppSessionManager.

	 *

	  */

	protected String deactivate(BAReq request)

	{

		return null;

	}



	/**

	 * Performs a complete payment indicated in the request.

	 *

	 */

	protected String pay(BAReq request)

	{

		BAppCfgEntry cfgEnt = null;



	

	    	cfgEnt = configEntryGet(request.getParam("PRODUCTID"), request);



		CLGeneral cl = new CLGeneral();



		CLContentData received ;



		try

		{

			received = cl.receive(connection);

		}

		catch(CLException e)

		{

		}



		return null;



	}

}

This infrastructure allows companies to customise the Business Application Service Handlers to their needs.

Helper Classes

  • BAReq
  • BAppCfgEntry
  • BAppConfigTable
  • BAppSessionManager
  • Exceptions

  • BAExcept