Archived

This forum has been archived. Please start a new discussion on GitHub.

Singleton object for services in an IceBox

Hi.
According to the MVC paradigm I have decided to establish a special IceBox responsible for hosting services dealing with database operations. Lets name it DataBaseBox.

Other services, when they will manipulate data in a database, communicate with their counterparts hosted in the DataBaseBox.

E.g.: lets assume we are to create an Logger service. The service should be able to store log entries in a database. I suggest creating actually two services:
1. Logger service which is accessible to clients;
2. LoggerDAL service which is accessible to only other services and which resides in the DataBaseBox.

When a client invokes the Logger.write(log_entry) operation the Logger service sends the log_entry to the LoggerDAL service.

The LoggerDAL service uses the NHibernate to actually access the underlying database for data manipulations.

The problem: I need to establish the NHibernate as a singleton object accessible to all the services hosted by the DataBaseBox. Having this in hand is a must when it is required to issue JOIN operations in the underlying database.

Any thoughts?

Regards,
Dmitry.

Comments

  • matthew
    matthew NL, Canada
    The problem: I need to establish the NHibernate as a singleton object accessible to all the services hosted by the DataBaseBox. Having this in hand is a must when it is required to issue JOIN operations in the underlying database.

    I would have some static singleton, lazy initialized by the first caller. You can put this in some shared library linked by all the services.