soap tutorial

adriani.jws.template.service
Class GeneralService

java.lang.Object
  extended by adriani.jws.template.service.GeneralService
Direct Known Subclasses:
ServiceLogic, ServiceMacro

public abstract class GeneralService
extends java.lang.Object

The parent class for all the classes implementing the service business logic: ServiceLogic and ServiceMacro. At the moment this class offers following features for a general web service class:

  1. Loads the general configuration from the properties file.
  2. Static configuration (on start time) of the required logger objects.
  3. Load keywords from the corresponding properties file (if required).
  4. Implementation of the remote command manager feature.


Field Summary
protected static LoggerManager benchLogger
          Reference to the benchLogger created in the static code block.
protected static java.lang.String leadingName
          Beginning of each logging message produced by this class.
protected static WSLogger logger
          Logger instance for this class (static): must be set after WSLogger initialization.
protected static GeneralAnalyzer serviceAnalyzer
          Reference to the serviceAnalyzer created in the static code block.
 
Constructor Summary
GeneralService()
          Stateless constructor.
 
Method Summary
 boolean compareSB(java.lang.StringBuffer first, java.lang.StringBuffer second)
          Helper method.
 void delay(long time)
          Stops this thread for few milliseconds.
 void finalize()
          Method useful for debug and testing, the verify the scope of the web service objects.
static java.lang.StringBuffer getCommandsList()
          Produce a short description list for remote manager commands accepted by the web service when the MANAGER feature is activated.
 GeneralAnalyzer getServiceAnalyzer()
          Return the GeneralAnalyzer object, used during development or benchmark testing to collect statistical data about the service's performances.
static java.util.ResourceBundle loadBundle()
          Load configuration from the template_config.properties file and store them into this class attributes.
static java.util.ResourceBundle loadBundle(java.lang.String name, boolean verbose)
          Load the resource bundle identified by input string parameter.
static void loadProperties()
          Load data from the resource bundle into the proper static fields.
 void logIntrospection()
          PLACE HOLDER: not used at the moment (sample code).
protected  void manageService(int key)
          Allow to configure the service dynamically, without reloading the AAR package on the application server.
protected abstract  void showConfiguration()
          Prints in the LOG file some information about the service configuration.
protected  void showJavaProperties()
          Prints in the LOG file (or on STDOUT, if enable) all the Java properties set at run time.
protected  void showRuntime()
          Deprecated. use the showJavaProperties() method instead, because it return the list of all Java properties
protected  int valueOfString(java.lang.String string, int no_value)
          Parse the string value of the input String into an integer value.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceAnalyzer

protected static GeneralAnalyzer serviceAnalyzer
Reference to the serviceAnalyzer created in the static code block. This object MUST BE static to ensure that all the subclasses of the GeneralService class do refer to the same analyzer.


benchLogger

protected static LoggerManager benchLogger
Reference to the benchLogger created in the static code block. The benchLogger logs on file single detailed information about the SQL execution times, this is different from the serviceAnalyzer object, which collects only global and statistical data.

Remark: this logger is always an instance of the SystemLogger class.


logger

protected static WSLogger logger
Logger instance for this class (static): must be set after WSLogger initialization. For this reason this logger is set in the static code-bloc below.


leadingName

protected static java.lang.String leadingName
Beginning of each logging message produced by this class.

Constructor Detail

GeneralService

public GeneralService()
Stateless constructor.

Method Detail

finalize

public void finalize()
Method useful for debug and testing, the verify the scope of the web service objects.

Overrides:
finalize in class java.lang.Object

loadProperties

public static void loadProperties()
Load data from the resource bundle into the proper static fields. This method is executed when this class is loaded, since it's invoked by a static code-block defined in this very class.

Actual implementation of the get bundle mechanism is implemented by the delegated getBundle() method: in this way we allow all other classes to load the bundle exactly with the same criteria.


loadBundle

public static java.util.ResourceBundle loadBundle()
Load configuration from the template_config.properties file and store them into this class attributes. This method searches such file in two different ways:

First the configuration file is found in the CLASSPATH, i.e. "externally" with respect of the AAR file. To easy file naming and location, such "external" configuration file is not qualified, but it's named simply template_config.properties.
If such research fails, the configuration file is searched "internally", i.e. witht the AAR file. For legacy reason, such "internal" file is fully qualified, i.e. it's named as adriani.jws.template.resources.template_config.properties.

Since such configuration is redundant, detailed error message are printed only if the last search fails (in this case the search for the internal file).

Returns:
the instance of the ResourceBundle matching the Settings.CONFIG static field (if found), null otherwise
See Also:
#loadBundle(String name)

loadBundle

public static java.util.ResourceBundle loadBundle(java.lang.String name,
                                                  boolean verbose)
Load the resource bundle identified by input string parameter.
If an error occurs we can not log the error on the log system, since we failed to acknowledge the logger configuration (which is depicted in the configuration file we failed to load).

Parameters:
name - the name of the ResourceBundle or properties file to be loaded
verbose - if true detailed error messages are printed on STDOUT
Returns:
the instance of the ResourceBundle matching input parameter(if found), null otherwise

getServiceAnalyzer

public GeneralAnalyzer getServiceAnalyzer()
Return the GeneralAnalyzer object, used during development or benchmark testing to collect statistical data about the service's performances.

Returns:
a reference to the GeneralAnalyzer object

showConfiguration

protected abstract void showConfiguration()
Prints in the LOG file some information about the service configuration.
Generally speaking, the service configuration depends by the service actual duties, hence it's not possible to implement the method at this level, since this is a general purposes class. It's up to the ServiceLogic or ServiceMacro subclass to implement this method in order to show the actual service configuration.


manageService

protected void manageService(int key)
Allow to configure the service dynamically, without reloading the AAR package on the application server.
Following commands are available:



Remark: this method can be invoked only when the service in the MANAGER mode. Hence, when this method is called using the option number 9 the MANAGER mode is turned off and this method can not be invoked again! This behavior can be used to "close" this access when security issues are required.

Parameters:
key - the integer command code as described above
See Also:
ServiceLogic.command_pwd, ServiceLogic.manageService(WrapperIn input), WrapperInformationIn.getCommand()

showJavaProperties

protected void showJavaProperties()
Prints in the LOG file (or on STDOUT, if enable) all the Java properties set at run time. This method should be used only for testing or debug.


getCommandsList

public static java.lang.StringBuffer getCommandsList()
Produce a short description list for remote manager commands accepted by the web service when the MANAGER feature is activated. This information are produced in text format, and are ready to be printed on a OutputStream object (usually STDOUT).

Returns:
a printable string containing the list of available remote commands

delay

public void delay(long time)
Stops this thread for few milliseconds.

Parameters:
time - the time (in milliseconds) that this thread must be stopped

valueOfString

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

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

compareSB

public boolean compareSB(java.lang.StringBuffer first,
                         java.lang.StringBuffer second)
Helper method.

Parameters:
first - a StringBuffer object
second - another StringBuffer object
Returns:
true if the two string object contains the same text

logIntrospection

public void logIntrospection()
PLACE HOLDER: not used at the moment (sample code).


showRuntime

protected void showRuntime()
Deprecated. use the showJavaProperties() method instead, because it return the list of all Java properties

Prints in the LOG file some information about the system run time. This method should be used only for testing or debug.


Build 19/03/2014

Morpheus Technologies - making the Zion software
Copyright © 2009-2014 Morpheus Technologies. All Rights Reserved