|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.service.GeneralService
adriani.jws.template.service.ServiceLogic
public class ServiceLogic
The "interface" class, implementing the high level behavior of the service.
Preparation of the parameters for the DAO layer should not be handled here, but should be
delegated to the ServiceMacro
instead.
Using this class it should be possible to implement the service's skeleton just adding a code-block
like this:
ServiceLogic logic = new ServiceLogic() ;
WrapperXXXIn input = new WrapperXXXIn(adbBean) ;
WrapperXXXOut output = (WrapperXXXOut) logic.getOutput(input) ;
ADBBean element = output.getElement() ;
ServiceLogic
method reflecting a SOAP method should return the proper
WrapperXXXOut
, i.e. a custom subclass of the WrapperOut
class.
Field Summary | |
---|---|
protected static java.lang.String |
command_pwd
The hard-coded pattern used to recognize remote manager commands (i.e. "000000"). |
protected static int |
ERROR
The static value used to identify the ERROR empty response. |
static int |
FORMAT_DATE
Static value identifying the 2nd web service method. |
static int |
GET_INFORMATION
Static value identifying the 1st web service method. |
protected java.lang.String |
header_value
The header value as retrieved from the SOAP's request (depending by the project). |
protected static int |
INFO
The static value used to identify the INFO empty response. |
protected static java.lang.String |
leadingName
Beginning of each logging message produced by this class. |
protected static WSLogger |
logger
Retrieving the logger instance to be used for this class (static). |
protected ServiceMacro |
serviceMacro
A reference to the ServiceMacro managing all the calls the necessary DAO's. |
protected static int |
SILENT
The static value used to identify the INFO empty response. |
protected static int |
WARN
The static value used to identify the WARNING empty response. |
Fields inherited from class adriani.jws.template.service.GeneralService |
---|
benchLogger, serviceAnalyzer |
Constructor Summary | |
---|---|
ServiceLogic()
Constructor, creating also the ServiceMacro object and storing it as class attribute. |
|
ServiceLogic(boolean macro)
Constructor, creating also the ServiceMacro object and storing it as class attribute. |
|
ServiceLogic(java.lang.String value)
Constructor, creating also the ServiceMacro object and storing it as class attribute. |
Method Summary | |
---|---|
WrapperOut |
checkAuthentication(int method)
Checking for authentication, comparing authentication from the SOAP's header with authentication data from the properties file. |
protected WrapperOut |
getEmptyResponse(int method,
int level,
int state)
Prepare a valid WrapperOut object when it's not possible to produce a valid result. |
WrapperDateOut |
getFormatDate(WrapperDateIn input)
This is main business logic for the web service. |
WrapperInformationOut |
getInformation(WrapperInformationIn input)
This is main business logic for the web service. |
ServiceMacro |
getServiceMacro()
Return the instance of the serviceMacro used by this class. |
static WrapperOut |
getWrapperOut(int method)
The factory creating the proper WrapperXXXOut object that will be returned
by the corresponding getOutputXXX() method. |
protected WrapperOut |
handleMacroError(int method,
java.lang.Exception exception,
boolean last)
Prepare a valid WrapperOut subclass when the exception comes from a lower level, like the
ServiceMacro class or the ServiceDBA class. |
protected WrapperOut |
handleNoValidation(WrapperOut wrapper,
java.lang.Exception e)
Prepare a valid WrapperOut subclass when we fail validation of the original
WrapperOut object produced by the main logic. |
WrapperOut |
invokeMethod(int method,
WrapperIn input)
General purpose service layer for all the web service's methods. |
protected boolean |
manageService(WrapperIn input)
Allow to configure the service dynamically, without reloading the AAR package on the application server. |
protected void |
showConfiguration()
Prints in the LOG file some information about the service configuration. |
Methods inherited from class adriani.jws.template.service.GeneralService |
---|
compareSB, delay, finalize, getCommandsList, getServiceAnalyzer, loadBundle, 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 |
---|
protected ServiceMacro serviceMacro
ServiceMacro
managing all the calls the necessary DAO's.
protected java.lang.String header_value
public static final int GET_INFORMATION
public static final int FORMAT_DATE
protected static final int SILENT
protected static final int INFO
protected static final int WARN
protected static final int ERROR
protected static final java.lang.String command_pwd
protected static java.lang.String leadingName
protected static WSLogger logger
Constructor Detail |
---|
public ServiceLogic()
ServiceMacro
object and storing it as class attribute.
public ServiceLogic(java.lang.String value)
ServiceMacro
object and storing it as class attribute.
This constructor should be used when we need to retrieve (and store here) some data from the
SOAP's header.
value
- the value retrieved from the SOAP's headerpublic ServiceLogic(boolean macro)
ServiceMacro
object and storing it as class attribute.
macro
- the ServiceMacro
it's instantiated only if this parameter is true
Method Detail |
---|
public WrapperOut checkAuthentication(int method)
<tns:psk xmlns:tns="http://adriani.altervista.org/namespaces/template">foo</tns:psk>
For further details see the "how2use.txt" file.
SoapHandler
,
SoapElements
public WrapperOut invokeMethod(int method, WrapperIn input)
invokeBusinessLogic()
method of the XXXMessageReceiverInOut
class forwards the action to
XXXSkeleton.operation()
, which can call this method.
return (WrapperXXXOut) invokeMethod(METHOD_NAME, input) ;
method
- the static integer reference to the method to be invokedinput
- the input ADBBean
wrapped by the WrapperIn
class
WrapperOut
classpublic WrapperInformationOut getInformation(WrapperInformationIn input)
invokeBusinessLogic()
method of the XXXMessageReceiverInOut
class forwards the action to
XXXSkeleton.operation()
, which should just calls this method.
input
- the input ADBBean
wrapped by the WrapperInformationIn
class
WrapperInformationOut
classpublic WrapperDateOut getFormatDate(WrapperDateIn input)
invokeBusinessLogic()
method of the XXXMessageReceiverInOut
class forwards the action to
XXXSkeleton.operation()
, which should just calls this method.
input
- the input ADBBean
wrapped by the WrapperDateIn
class
WrapperDateOut
classpublic static WrapperOut getWrapperOut(int method)
WrapperXXXOut
object that will be returned
by the corresponding getOutputXXX()
method. Every possible WrapperXXXOut
class
must extend the parent WrapperOut
class.WrapperXXXOut
object corresponding to the input
method parameter, which describes one of the operations offered by the skeleton
(listed using static integer values defined as class fields).getEmptyResponse()
method.
method
- the logic method that invoked this method (see class fields)
WrapperOut
object for the corresponding logic methodprotected WrapperOut handleMacroError(int method, java.lang.Exception exception, boolean last)
WrapperOut
subclass when the exception comes from a lower level, like the
ServiceMacro
class or the ServiceDBA
class. In this case the error message is
obtained by reading the necessary StackTraceElement
objects.WrapperOut
wrapper to ensure a correct SOAP output response, containing
a message like "Java Macro Error".
method
- the logic method that invoked this method (see class fields)exception
- the Exception
thrown from a lower level (null
otherwise)last
- if true
the getEmptyResponse()
method is invoked
WrapperOut
subclass with a message describing this situationprotected WrapperOut handleNoValidation(WrapperOut wrapper, java.lang.Exception e)
WrapperOut
subclass when we fail validation of the original
WrapperOut
object produced by the main logic. The output message will contain a message
with a reference to all the ADBBean
objects responsible for the validation error.
wrapper
- the instance of the WrapperOut
subclass wrapping the output datae
- the Exception
thrown when validating the WrapperOut
element
WrapperOut
subclass with a message describing all the validation errorsprotected WrapperOut getEmptyResponse(int method, int level, int state)
WrapperOut
object when it's not possible to produce a valid result.
This method can be called in many different situations, each situation corresponding to a different
message to be logged while producing the empty response. These situations are identified using the
state
param, which should be one of the integer values mapped by the
ErrorMessage
class. In current implementation this method is called in following
situations: COMMAND, NO_DB, NO_RESULT, ERROR_LOGIC, ERROR_MACRO.level
parameter can be: SILENT, INFO, WARN or ERROR.getWrapperOut()
,
to produce the proper WrapperOut
method for the current method.
method
- a reference to one the SOAP methods exposed in the WSDL (see class fields)level
- the integer value defining the level of the logged messagestate
- the code of the message as described by the ErrorMessage
class
WrapperOut
object with a message describing this situationgetWrapperOut(int method)
public ServiceMacro getServiceMacro()
serviceMacro
used by this class.
serviceMacro
used by this classprotected boolean manageService(WrapperIn input)
command_pwd
class field,
while the field containing the command is defined by the WrapperSearchIn
class.
input
- an instance of the WrapperSearchIn
wrapper containing the input data
true
if the input number have been recognized as valid command codecommand_pwd
,
WrapperInformationIn.getCommand()
protected void showConfiguration()
GeneralService
class MUST implement this method.
Hence, in order to save coding this method forwards action to the showConfiguration()
method
of the ServiceMacro
class.
showConfiguration
in class GeneralService
ServiceMacro.showConfiguration()
|
Build 19/03/2014 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |