Package it.rol

Class DBManager

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
it.rol.DBManager
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class DBManager extends javax.servlet.http.HttpServlet

DBManager è la classe utilizzata per stabilire su quale database deve insistere un'istanza della web-application Rischi on Line (rol) esponendo le relative informazioni attraverso metodi accessori.

Pensata per evitare riferimenti circolari tra il ConfigManager ed il DBWrapper, questa classe supporta Request e Response e può essere utilizzata per calcolare ulteriori variabili, se necessario.

Mon 30 Sep 2024 01:40:03 PM CEST

Author:
Giovanroberto Torre
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Restituisce la stringa necessaria al connettore del database.
    void
    init(javax.servlet.ServletConfig config)
    Inizializza (staticamente) le variabili globali che saranno utilizzate anche dalle altre classi: connessione al database: db tabella hash di tutte le classi richiamabili dall'applicazione nome del parametro identificante la command corrente pagina di errore etc...

    Methods inherited from class javax.servlet.http.HttpServlet

    doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service

    Methods inherited from class javax.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DBManager

      public DBManager()
  • Method Details

    • init

      public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
      Inizializza (staticamente) le variabili globali che saranno utilizzate anche dalle altre classi:
      • connessione al database: db
      • tabella hash di tutte le classi richiamabili dall'applicazione
      • nome del parametro identificante la command corrente
      • pagina di errore
      • etc...
      Specified by:
      init in interface javax.servlet.Servlet
      Overrides:
      init in class javax.servlet.GenericServlet
      Parameters:
      config - la configurazione usata dal servlet container per passare informazioni alla servlet durante l'inizializzazione
      Throws:
      javax.servlet.ServletException - una eccezione che puo' essere sollevata quando la servlet incontra difficolta'
    • getDbName

      public static String getDbName()

      Restituisce la stringa necessaria al connettore del database.

      java:comp/env is the node in the JNDI tree where you can find properties for the current Java EE component (a webapp, or an EJB).
      Context envContext = (Context)initContext.lookup("java:comp/env"); allows defining a variable pointing directly to this node. It allows doing SomeBean s = (SomeBean) envContext.lookup("ejb/someBean"); DataSource ds = (DataSource) envContext.lookup("jdbc/dataSource"); rather than SomeBean s = (SomeBean) initContext.lookup("java:comp/env/ejb/someBean"); DataSource ds = (DataSource) initContext.lookup("java:comp/env/jdbc/dataSource"); Relative paths instead of absolute paths. That's what it's used for.
      It's an in-memory global hashtable where you can store global variables by name. The "java:" url scheme causes JNDI to look for a javaURLContextFactory class, which is usually provided by your app container, e.g. here is Tomcat's implementation javadoc.

      Metodo getter sulla variabile di classe.

      Returns:
      String - il nome usato dal DbWrapper per realizzare il puntamento jdbc