Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Scout/Tutorial/3.8/webservices/DatabaseLogHandler

< Scout‎ | Tutorial‎ | 3.8
Revision as of 14:07, 10 November 2011 by Unnamed Poltroon (Talk) (New page: <source> @ScoutTransaction public class DatabaseLogHandler extends LogHandler { private static final IScoutLogger LOG = ScoutLogManager.getLogger(DatabaseLogHandler.class); /** * ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, otj, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


@ScoutTransaction
public class DatabaseLogHandler extends LogHandler {

  private static final IScoutLogger LOG = ScoutLogManager.getLogger(DatabaseLogHandler.class);

  /**
   * Property to access the primary key of the log entry in the message context.
   */
  public static final String PROP_WS_LOG_NR = UUID.randomUUID().toString();

  @Override
  protected void handleLogMessage(DirectionType directionType, String soapMessage, SOAPMessageContext context) {
    try {
      /*
       * If this handler is invoked to post-process the SOAP-response, the SOAP-request was already logged and
       * the log's primary key put into the message context. In consequence, the log entry is updated with the SOAP response.
       */
      Long wsLogNr = (Long) context.get(PROP_WS_LOG_NR);
      if (wsLogNr == null) {
        // SOAP request
        wsLogNr = SQL.getSequenceNextval("GLOBAL_SEQ");
        context.put(PROP_WS_LOG_NR, wsLogNr);

        SQL.insert("" +
            "INSERT INTO   WS_LOG " +
            "             (WS_LOG_NR, " +
            "              EVT_DATE, " +
            "              SERVICE, " +
            "              PORT, " +
            "              OPERATION, " +
            "              REQUEST) " +
            "VALUES       (:wsLogNr, " +
            "              :evtDate, " +
            "              :service, " +
            "              :port, " +
            "              :operation, " +
            "              :request)"
            , new NVPair("wsLogNr", wsLogNr)
            , new NVPair("service", StringUtility.nvl(context.get(SOAPMessageContext.WSDL_SERVICE), "?"))
            , new NVPair("port", StringUtility.nvl(context.get(SOAPMessageContext.WSDL_PORT), "?"))
            , new NVPair("operation", StringUtility.nvl(context.get(SOAPMessageContext.WSDL_OPERATION), "?"))
            , new NVPair("request", soapMessage)
            , new NVPair("evtDate", new Date())
            );
      }
      else {
        // SOAP response
        SQL.update("" +
            "UPDATE   WS_LOG " +
            "SET      RESPONSE = :response " +
            "WHERE    WS_LOG_NR = :wsLogNr"
            , new NVPair("wsLogNr", wsLogNr)
            , new NVPair("response", soapMessage)
            );
      }
    }
    catch (ProcessingException e) {
      LOG.error("failed to persist webservice-log", e);
    }
  }
}

Back to the top