How to create a Singleton Class in C#?

Recently i had to work in a .NET project (not usual, mainly because i haven’t developed in C# since a couple of years) using C# of a multithread application executing the same process through various threads (at the end i used Parallel Tasks) and i wanted to handle Oracle Database connections properly. I’m going to write some posts about my experience and what i’ve learned.

Right now i just wanna share this simple but useful article about how to create Singleton classes in C#. In my case i created a ConnectionManager Singleton class to serve connections to all the running Tasks. The article covers the scenario of a single thread application and a multithread application. Enjoy it.

https://msdn.microsoft.com/en-us/library/ff650316.aspx

Change beans.xml filename in Spring MVC

Spring Framework logo

If you start using Spring MVC to develop Web Applications and you declare the DispatcherServlet in web.xml, it’s a little bit annoying to rename the Spring beans file to xxxx-servlet.xml, for example, if you declare DispatcherServlet like this:

Your beans.xml file has to be renamed to springservlet-servlet.xml to let DispatcherServlet find the configuration file. But, we can change this behavior by specifying to DispatcherServlet the name of our Spring Beans file in the next way:

Continue reading