Class DBLogTracer

All Implemented Interfaces:
IOLogTracer, Identified

public class DBLogTracer extends AbstractIOLogTracer
Tracer utilizzato per salvare i log all'interno della tabella SLOG del database. Attenzione! Il salvataggio è sincrono e quindi è necessario attendere che los tatement di salvataggio sia stato completato prima di poter proseguire con le elaborazioni seguenti. Pertanto un elevata mole di richieste a questo tracer potrebbe comportare un rallentamento generale. Per questo motivo si consiglia di wrappare il tracer all'interno di un AsyncIOLogTracer.
  • Field Details

    • _input

      protected ByteArrayOutputStream _input
    • _output

      protected ByteArrayOutputStream _output
    • _error

      protected ByteArrayOutputStream _error
    • _id

      protected long _id
    • _status

      protected int _status
    • _duration

      protected long _duration
    • _date

      protected String _date
    • _url

      protected String _url
    • requestHeaders

      protected String requestHeaders
    • responseHeaders

      protected String responseHeaders
    • _inputAttachments

      protected int _inputAttachments
    • _outputAttachments

      protected int _outputAttachments
    • _start

      protected long _start
    • _method

      protected String _method
    • _statusCode

      protected int _statusCode
    • _sdf

      protected final SimpleDateFormat _sdf
  • Constructor Details

  • Method Details

    • isLogActive

      protected boolean isLogActive()
      Description copied from class: AbstractIOLogTracer
      Check whether the log should be traced or not
      Specified by:
      isLogActive in class AbstractIOLogTracer
      Returns:
      true if the log is active, false otherwise
    • getOutputStreamInput

      public OutputStream getOutputStreamInput()
      Returns:
      lo stream su cui scrivere il contenuto della richiesta.
    • getOutputStreamOutput

      public OutputStream getOutputStreamOutput()
      Returns:
      lo stream su cui scrivere il contenuto della risposta nel caso la richiesta sia stata processata con successo.
    • getOutputStreamError

      public OutputStream getOutputStreamError()
      Returns:
      lo stream su cui scrivere il contenuto della risposta nel caso di errori.
    • save

      public void save()
      Description copied from interface: IOLogTracer
      Memorizza le informazioni inviate/ricevute in modo persistente.
    • completed

      public boolean completed()
      Description copied from interface: IOLogTracer
      returns true if the tracer has all the necessary information and can proceed with saving the log. false otherwise
      Returns:
      true if the tracer has all the necessary information and can proceed with saving the log. false otherwise
    • getValues

      protected HashGetter getValues()
    • setStart

      public void setStart(long start)
      Description copied from interface: IOLogTracer
      Utilizzato per impostare l'istante in cui l'elaborazione della richiesta ha inizio. Questo metodo dev'essere invocato IMMEDIATAMENTE PRIMA del invio della richiesta al WS.
      Parameters:
      start - timestamp di inizio chiamata
    • setEnd

      public void setEnd(long end)
      Description copied from interface: IOLogTracer
      Utilizzato per impostare l'istante in cui la richiesta è stata elaborata. Questo metodo dev'essere invocato SOLO una volta che la richiesta è stata ricevuta ed elaborata.
      Parameters:
      end - timestamp di fine chiamata
    • setDuration

      public void setDuration(long l)
      Description copied from interface: IOLogTracer
      Utilizzato per impostare la durata complessiva della richiesta. Questo metodo dev'essere invocato SOLO una volta che la richiesta è stata ricevuta ed elaborata.
      Parameters:
      l - millisecondi trascorsi dal momento di invio all'effettiva ricezione.
    • setService

      public void setService(String service, String url)
      Description copied from interface: IOLogTracer
      Imposta il nome e l'url del servizio, inizializzando il nome del log nel caso sia abilitata la funzionalità di logging. Questo metodo dev'essere invocato prima di iniziare la scrittura del log.
      Parameters:
      service - nome del servizio
      url - url del servizio
    • setRequestHeaders

      public void setRequestHeaders(String headers)
      Description copied from interface: IOLogTracer
      Imposta gli headers della richiesta.
      Parameters:
      headers - headers della richiesta.
    • setResponseHeaders

      public void setResponseHeaders(String headers)
      Description copied from interface: IOLogTracer
      Imposta gli headers della risposta.
      Parameters:
      headers - headers della risposta.
    • setStatus

      public void setStatus(int s)
      Description copied from interface: IOLogTracer
      Viene utilizzato per impostare lo stato del tracer; solitamente questo metodo viene invocato più volte in modo da mantenere allineato lo stato con l'avanzamento della richiesta.
      Parameters:
      s - si possono specificare i seguenti valori:
    • setInputAttachments

      public void setInputAttachments(int count)
      Parameters:
      count - il numero di allegati inviati
    • setOutputAttachments

      public void setOutputAttachments(int count)
      Parameters:
      count - il numero di allegati ricevuti
    • getReference

      public Object getReference(String serviceName)
      Description copied from interface: IOLogTracer
      Get the reference that can be used later to retrieve the log. If the DB log has been activated, this method will return a Long number indicating the ID of the database record. If the FS log has been activated, this method will return an array of string whose contains 4 elements:
      1. path of the master document
      2. path of the Input raw document
      3. path of the Outputput raw document (in case of successfully response)
      4. path of the Error raw document (in case of unsuccessfully response)
      Parameters:
      serviceName - string containing the name of the service. If you have an instance of Message you can extract the service's name in this way:
      message.getExchange().get(Message.WSDL_INTERFACE).toString()
      Returns:
      The reference that can be used later to retrieve the log
    • flush

      public void flush()
      Description copied from interface: IOLogTracer
      method used to clean any variables once the log has been saved
    • setMethod

      public void setMethod(String method)
      Description copied from interface: IOLogTracer
      Imposta il metodo d chiamata di un servizio.
      Parameters:
      method - verbo con cui viene chiamato il servizio
    • setStatusCode

      public void setStatusCode(int code)
      Description copied from interface: IOLogTracer
      Imposta il codice di risposta relativo ad una chiamata ad un WS
      Parameters:
      code - codice di risposta