soap tutorial

adriani.jws.template.service
Class ServiceMacro

java.lang.Object
  extended by adriani.jws.template.service.GeneralService
      extended by adriani.jws.template.service.ServiceMacro

public class ServiceMacro
extends GeneralService

This class provides all the logic used to prepare the calls to the necessary DAO, hence it's an intermediate layer between the upper main business logic (the ServiceLogic class) and the underlying datasource layer (the ServiceDAO class).
The "interface policy" of this class is the following:

EXCEPTION : an unexpected exception is thrown, hence nothing is returned
DATA OK : the method return an ArrayList containing a set of Wrapper objects
NO DATA : the method return an ArrayList containing a set of Wrapper objects (could be empty)
NO DATABASE : the method return a null object (database not available)
NO CUSTOMER : the method return a null object (customer not found in the database)

The specific case can be acknowledged by calling the getStatus() method after execution, which contains a text message only after a NO DATABASE case or a NO DATA case.

Implementation guidelines:

Architecture: to grant loose coupling to the WSDL document and to the database, all the database issues should be handled by the ServiceDAO class, and all the ADBBean data conversion issues should be handled by the related wrapper in the messages package.


Field Summary
static java.lang.String BLANK
          Static final String value stored as class field to improve performances.
static java.lang.String EMPTY
          Static final String value stored as class field to improve performances.
static java.lang.String HYPHEN
          Static final String value stored as class field to improve performances.
protected static java.lang.String leadingName
          Beginning of each logging message printed on the STDOUT .
protected static WSLogger logger
          Retrieving the logger instance to be used for this class (static).
protected static int NO_CUSTOMER
          A static code describing the status of this macro after the last operation.
protected static int NO_DATA
          A static code describing the status of this macro after the last operation.
protected static int NO_DATABASE
          A static code describing the status of this macro after the last operation.
protected static int OK
          A static code describing the status of this macro after the last operation.
static java.lang.String QUOTE
          Static final String value stored as class field to improve performances.
protected  ServiceDAO serviceDAO
          A reference to the ServiceDAO class accessing the necessary database's.
protected  int status
          An integer code describing the status of this macro after the last operation.
static java.lang.String UNDER
          Static final String value stored as class field to improve performances.
static java.lang.StringBuffer ZERO
          Static final StringBuffer value stored as class field to improve performances.
 
Fields inherited from class adriani.jws.template.service.GeneralService
benchLogger, serviceAnalyzer
 
Constructor Summary
ServiceMacro()
          Constructor, creating also the ServiceDAO object and storing it as class attribute.
 
Method Summary
 java.util.ArrayList dummyFormatDate(WrapperDateIn input)
          Return an ArrayList emulating the actual macro response, but filled with dummy data.
 java.util.ArrayList formatDate(WrapperDateIn input)
          Example method, to be replaced with actual business logic for your web service.
 java.util.ArrayList getDummyInformation(WrapperInformationIn input)
          Return an ArrayList emulating the actual macro response, but filled with dummy data.
 java.util.ArrayList getInformation(WrapperInformationIn input)
          Example method, to be replaced with actual business logic for your web service.
 ServiceDAO getServiceDAO()
          Accessor method.
 int getStatus()
          Accessor method.
protected  java.util.ArrayList handleNoDatabase(int database)
          Prepare a null ArrayList object when the service logic fails because there is no connection to one of the required databases.
protected  java.util.ArrayList handleNoRecord(WrapperIn input, int error)
          Prepare an empty ArrayList object when the service logic fails because was not Possible to find data from the DAO layer (assuming the business logic needs to find it in the database).
 void setStatus(int value)
          Accessor method.
protected  void showConfiguration()
          Prints in the LOG file some information about the service configuration.
protected  int valueOfBuffer(java.lang.StringBuffer buffer, int no_value)
          Parse the string value of the input StringBuffer buffer into an integer value.
 
Methods inherited from class adriani.jws.template.service.GeneralService
compareSB, delay, finalize, getCommandsList, getServiceAnalyzer, loadBundle, loadProperties, logIntrospection, manageService, showJavaProperties, showRuntime, valueOfString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceDAO

protected ServiceDAO serviceDAO
A reference to the ServiceDAO class accessing the necessary database's.


status

protected int status
An integer code describing the status of this macro after the last operation.


EMPTY

public static final java.lang.String EMPTY
Static final String value stored as class field to improve performances.

See Also:
Constant Field Values

BLANK

public static final java.lang.String BLANK
Static final String value stored as class field to improve performances.

See Also:
Constant Field Values

UNDER

public static final java.lang.String UNDER
Static final String value stored as class field to improve performances.

See Also:
Constant Field Values

HYPHEN

public static final java.lang.String HYPHEN
Static final String value stored as class field to improve performances.

See Also:
Constant Field Values

QUOTE

public static final java.lang.String QUOTE
Static final String value stored as class field to improve performances.

See Also:
Constant Field Values

ZERO

public static final java.lang.StringBuffer ZERO
Static final StringBuffer value stored as class field to improve performances.


OK

protected static final int OK
A static code describing the status of this macro after the last operation.

See Also:
Constant Field Values

NO_DATA

protected static final int NO_DATA
A static code describing the status of this macro after the last operation.

See Also:
Constant Field Values

NO_DATABASE

protected static final int NO_DATABASE
A static code describing the status of this macro after the last operation.

See Also:
Constant Field Values

NO_CUSTOMER

protected static final int NO_CUSTOMER
A static code describing the status of this macro after the last operation.

See Also:
Constant Field Values

leadingName

protected static java.lang.String leadingName
Beginning of each logging message printed on the STDOUT .


logger

protected static WSLogger logger
Retrieving the logger instance to be used for this class (static).

Constructor Detail

ServiceMacro

public ServiceMacro()
Constructor, creating also the ServiceDAO object and storing it as class attribute.

Method Detail

getInformation

public java.util.ArrayList getInformation(WrapperInformationIn input)
Example method, to be replaced with actual business logic for your web service.

Remark: if this method opens connection to a database, you should make sure to not return from this method before closing the connection!

Parameters:
input - the input parameters wrapped by the WrapperIn class
Returns:
an array list containing all the found records

formatDate

public java.util.ArrayList formatDate(WrapperDateIn input)
Example method, to be replaced with actual business logic for your web service.

Remark: if this method opens connection to a database, you should make sure to not return from this method before closing the connection!

In this example the SOAP response depends by the input SOAP request as follows:

1. If we have only an input date --> we return the same date plus 24 hours
2. If we have also an input pattern --> we format the input date with respect of the input pattern
3. If we have also an input ID --> we return the entity_time matching the input entity_ID
4. If we have both pattern and ID --> we return the entity_time matching the input entity_ID, formatted using the input pattern string

Parameters:
input - the input parameters wrapped by the WrapperIn class
Returns:
an array list containing all the found records

handleNoDatabase

protected java.util.ArrayList handleNoDatabase(int database)
Prepare a null ArrayList object when the service logic fails because there is no connection to one of the required databases. The output message will contain a message like "No connection to the database".

Parameters:
database - a reference to the code number of the missing database
Returns:
a null ArrayList object with a message describing this situation
See Also:
Database

handleNoRecord

protected java.util.ArrayList handleNoRecord(WrapperIn input,
                                             int error)
Prepare an empty ArrayList object when the service logic fails because was not Possible to find data from the DAO layer (assuming the business logic needs to find it in the database). The output message will contain a message like "missing/wrong database data".

Parameters:
input - the input parameters wrapped by the WrapperIn class
Returns:
a null ArrayList object

setStatus

public void setStatus(int value)
Accessor method.


getStatus

public int getStatus()
Accessor method.


getServiceDAO

public ServiceDAO getServiceDAO()
Accessor method.


showConfiguration

protected void showConfiguration()
Prints in the LOG file some information about the service configuration. This method should be used only for testing or debug.

Specified by:
showConfiguration in class GeneralService

getDummyInformation

public java.util.ArrayList getDummyInformation(WrapperInformationIn input)
Return an ArrayList emulating the actual macro response, but filled with dummy data. This method is called by the business logic when the FAKE configuration flag is set to true, this means that the actual macro call (getInformation()) it's not executed and no database connections are opened.

Just to provide a more dynamic example, in current implementation the second parameter of the input wrapper specifies how many dummy records will be produced: see ServiceDAO.getDummyQuery(StringBuffer[] param, int howMany, int cols) for details.
Such behavior allows to test the "no data found" feature, simply passing 0 (zero) as second parameter in the input wrapper.

Parameters:
input - the input parameters wrapped by the WrapperIn class
Returns:
an array list containing some dummy records
See Also:
ServiceDAO.getDummyQuery(StringBuffer[] param, int howMany, int cols)

dummyFormatDate

public java.util.ArrayList dummyFormatDate(WrapperDateIn input)
Return an ArrayList emulating the actual macro response, but filled with dummy data. This method is called by the business logic when the FAKE configuration flag is set to true, this means that the actual macro call (getFormatDate()) it's not executed and no database connections are opened.

Parameters:
input - the input parameters wrapped by the WrapperIn class
Returns:
an array list containing some dummy records

valueOfBuffer

protected int valueOfBuffer(java.lang.StringBuffer buffer,
                            int no_value)
Parse the string value of the input StringBuffer buffer into an integer value. The no_value parameter represent the default integer value to be returned if the parsing is not successful.

Parameters:
buffer - the input string object
no_value - the integer value to be returned if conversion fails
Returns:
the integer value of the input string (or the no_value number)

Build 18/09/2012

Morpheus Quality Technologies - Making the Zion software
Copyright © 2009-2013 Morpheus Quality Technologies. All Rights Reserved