edu.princeton.wordnet.orm.hibernate
Class SessionBroker

java.lang.Object
  extended by edu.princeton.wordnet.orm.hibernate.SessionBroker

public class SessionBroker
extends java.lang.Object

Session Manager

Author:
Bernard Bou

Field Summary
private static org.apache.log4j.Logger LOG
          Logger
private static java.lang.String theConnectionSettings
          Hibernate config
private static org.hibernate.SessionFactory theSessionFactory
          The single instance of Hibernate SessionFactory
 
Constructor Summary
private SessionBroker()
          Disable constructor to guarantee a single instance
 
Method Summary
static void closeSession(org.hibernate.Session thisSession)
          Close session
static java.lang.String getConnectionData()
          Get connection data
private static java.util.Properties getConnectionProperties()
          Get connection configuration
(package private) static org.hibernate.SessionFactory getInstance()
          Get singleton instance
static org.hibernate.Session getSession()
          Returns a session
private static org.hibernate.Session openSession()
          Open session
static void setup()
          Setup
static void setup(java.lang.String theseConnectionSettings)
          Setup
static void shutdown()
          Closes the session factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG
Logger


theConnectionSettings

private static java.lang.String theConnectionSettings
Hibernate config


theSessionFactory

private static org.hibernate.SessionFactory theSessionFactory
The single instance of Hibernate SessionFactory

Constructor Detail

SessionBroker

private SessionBroker()
Disable constructor to guarantee a single instance

Method Detail

getInstance

static org.hibernate.SessionFactory getInstance()
                                         throws org.hibernate.HibernateException,
                                                java.io.FileNotFoundException
Get singleton instance

Returns:
singleton instance
Throws:
org.hibernate.HibernateException
java.io.FileNotFoundException

setup

public static void setup(java.lang.String theseConnectionSettings)
Setup

Parameters:
theseConnectionSettings - command line arguments

setup

public static void setup()
                  throws org.hibernate.HibernateException,
                         java.io.FileNotFoundException
Setup

Throws:
java.sql.SQLException
org.hibernate.HibernateException
java.io.FileNotFoundException

getConnectionProperties

private static java.util.Properties getConnectionProperties()
                                                     throws java.io.FileNotFoundException
Get connection configuration

Returns:
connection properties
Throws:
java.io.FileNotFoundException

getConnectionData

public static java.lang.String getConnectionData()
                                          throws java.io.FileNotFoundException
Get connection data

Throws:
java.io.FileNotFoundException

shutdown

public static void shutdown()
Closes the session factory


openSession

private static org.hibernate.Session openSession()
                                          throws org.hibernate.HibernateException,
                                                 java.io.FileNotFoundException
Open session

Returns:
session
Throws:
org.hibernate.HibernateException
java.io.FileNotFoundException
java.sql.SQLException

getSession

public static org.hibernate.Session getSession()
                                        throws org.hibernate.HibernateException,
                                               java.io.FileNotFoundException
Returns a session

Returns:
session
Throws:
java.sql.SQLException
org.hibernate.HibernateException
java.io.FileNotFoundException

closeSession

public static void closeSession(org.hibernate.Session thisSession)
                         throws org.hibernate.HibernateException
Close session

Parameters:
thisSession - session
Throws:
org.hibernate.HibernateException