org.jaffa.components.voucher
Class SimpleVoucherGenerator

java.lang.Object
  extended byorg.jaffa.components.voucher.AbstractVoucherGenerator
      extended byorg.jaffa.components.voucher.SimpleVoucherGenerator
All Implemented Interfaces:
IVoucherGenerator

public class SimpleVoucherGenerator
extends AbstractVoucherGenerator

This is a very simple implementation of the IVoucherGenerator interface. It has 2 additional properties which need to be set before invoking the generate method 1- DomainClassName: A fully qualified classname for the domain class 2- FieldName: A fieldname This implementation will merely perform the following query: 'SELECT [fieldname] FROM [domainclassname] ORDER BY [fieldname] DESC' It will then generate the voucher by 1- Incrementing the number portion from the value retrieved 2- Appending the number to the prefix with appropriate padding NOTE: This implementation suffers from a very serious drawback - 2 THREADS CAN OBTAIN THE SAME VOUCHER This class is intended for demo purposes only. It SHOULD NOT be used in a production environment.

Author:
GautamJ

Constructor Summary
SimpleVoucherGenerator()
           
 
Method Summary
 String generate()
          The client will invoke this method to generate a voucher.
 String getDomainClassName()
          Getter for the property domainClassName.
 String getFieldName()
          Getter for the property fieldName.
 void setDomainClassName(String domainClassName)
          Setter for property domainClassName.
 void setFieldName(String fieldName)
          Setter for property fieldName.
 
Methods inherited from class org.jaffa.components.voucher.AbstractVoucherGenerator
cleanup, getLabelToken, getLength, getPrefix, getUow, init, setLabelToken, setLength, setPrefix, setUow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleVoucherGenerator

public SimpleVoucherGenerator()
Method Detail

getDomainClassName

public String getDomainClassName()
Getter for the property domainClassName.

Returns:
Value of property domainClassName.

setDomainClassName

public void setDomainClassName(String domainClassName)
Setter for property domainClassName.

Parameters:
domainClassName - New value of property domainClassName.

getFieldName

public String getFieldName()
Getter for the property fieldName.

Returns:
Value of property fieldName.

setFieldName

public void setFieldName(String fieldName)
Setter for property fieldName.

Parameters:
fieldName - New value of property fieldName.

generate

public String generate()
                throws FrameworkException,
                       ApplicationExceptions
The client will invoke this method to generate a voucher.

Specified by:
generate in interface IVoucherGenerator
Specified by:
generate in class AbstractVoucherGenerator
Returns:
a unique voucher.
Throws:
FrameworkException - if any framework error occurs.
ApplicationExceptions - if any application error occurs.


Copyright © 2002-2004 JAFFA Project.