singleton

Is this a memory leak?

I have a ListActivity containing an object I've defined called a MessageItem. I want to pass the data in this MessageItem off to a Service to do some stuff, but I don't want the Activity to be data bound to the Service such that Android can't reclaim the Activity if it needs to (ergo memory leak). What I'm doing is passing the MessageI...

Singleton in my C++ program

I wrote 2 classes, Agent and Timing. The third class will contain the main() function and manage it all. The goal is to create n instances of Agent and a SINGLE instance of Timing. It's important to mention that Agent uses Timing fields and Timing uses Agent functions. How can I turn Timing to singleton? //Agent.h #ifndef Timing_h #defi...

clear singleton pattern concept please

Hi I want to make connection with sql server DB and maintain in singleton pattern. So is this functionality inbuilt in dot net ? or we mannually have to write the code for this scenario? ...

Pattern for lazy thread-safe singleton instantiation in java

Hello guys, the lazy thread-safe singleton instantion is kinda not easy to understand to every coder, so i wanted to create a class in our enterprise framework that would do the job. What do you think about it? Do you see something bad about it? Is there something similar like in Apache Commons? How can i make it better? Supplier.java...

Best practices for moving objects to a separate thread

We have an implementation for an Ultrasound machine application current where the Ultrasound object is created on the UI's thread. A Singleton implementation would have been good here, but regardless, isn't. Recently, the set methods changed such that they automatically stop and restart the ultrasound machine, which can take between 10-...

can I make alias to singletone function?

I would like to make somekind of alias in c++ to single tone calling so instead of calling each time to MYCLASS::GetInstance()->someFunction(); I could call just someFunctionAlias(); in my code . ...

PHP singleton class structure - Am I doing it right ?

I have a really big script. It has a database class, a base class, a user authentication class, a resellers authentication class, paypal ipn class, a downloads class, and a plugins class The Base class extends database class like this: class Base extends database { var $userid; var $root; var $config function Base...

Which is the recommended way as a client to get handle to the scheduler?

I'm using Quartz Scheduler v1.8.3 and is integrated into Apache Tomcat v6.0.10, and hence scheduler is initialized from within servlet container. Jobs are also added/scheduled to scheduler from within Apache Tomcat. I'm designing a JSP web front end page (quartzAdmin.jsp) from where I only want to see scheduler information like meta-da...

Can I use singleton class in a static library for iPhone?

Hello everyone, Is possible make a static library with a singleton class inside? Because I try it but without success. ...

Is the singleton in ASP.NET per session or per machine?

I have an web application written in ASP.NET (FW 3.5) (along with some VBScript, this is a legacy app) that uses a utility class in the backend that logs error. I need to log several values that a user has entered in the front-end. Since the utility class has no access to the front end (or any HTTP services), i created a singleton cl...

Static Object in Jboss using EJB3

hi all, is it possible to create something like static object using EJB3 in Jboss. in other words i need to create something like a static object using singleton pattern or something like that, that is because i need to preload a configuration from database and i want that every bean that jboss creates uses this class to read this config...

J2EE: Singleton vs keeping things in session

When should an object (i.e. an application-wide properties file) be kept in the session, as opposed to creating a singleton to keep it? When should each of these approaches be used? Note: I am working on a clustered environment, if that makes any difference. ...

Creating a good registry class in PHP for important classes

I have a webapplication where I use a registry class. The registry class holds important classes that I need troughout my application. I have made the registry class a Singleton class and this class is static. The content of the registry class is here: <?php class registry { private static $objects = array(); private static $i...

MIDlet as singleton

Is it safe to implement a MIDlet class as a singleton? That is, after all, the Display class is acting like a singleton for each and every midlet so is the midlet itself a singleton by behaviour so that implementing it as such wouldn't break something? In other words, it is not possible to have two instances of an app running, is it? I ...

changing the same singleton array form all classes ?

Hi just made my firs singleton and i am trying to figure out something. i have a categories array that is stored in the singleton. when i need it i use : Mannager *sharedManager = [Mannager sharedManager]; categories = [[NSMutableArray alloc] initWithArray:sharedManager.categories]; [sharedManager release]; now i understand that ...

What's the difference between design pattern and enterprise design pattern?

Hi, I want to know the difference between design pattern and enterprise design pattern. For example, some books call ActiveRecord an enterprise design pattern, while, singleton is a design pattern. Thanks ...

Wrapping a complex linq query with a Try-Catch block and catching the correct Exceptions

The below code is a factory class that is delivers objects of type IGraph that have the GraphTypeAttribute implemented. Inside the static constructor of the GraphFactory, a list is built by using Linq to collect the appropriate classes to be delivered by the Factory. Normally without Linq I had a buch of loops and if-then's that could be...

Difference between singleton class and static class?

Possible Duplicates: Difference between static class and singleton pattern? What is the difference between a Singleton pattern and a static class in Java? HI I am not clearly getting What’s the difference between a singleton class and a static class? Can anybody elaborate this with example? ...

PHP Singleton PDO

from http://www.php.net/manual/en/class.pdo.php ###### config.ini ###### db_driver=mysql db_user=root db_password=924892xp [dsn] host=localhost port=3306 dbname=localhost [db_options] PDO::MYSQL_ATTR_INIT_COMMAND=set names utf8 [db_attributes] ATTR_ERRMODE=ERRMODE_EXCEPTION ############ <?php class Database { private static $lin...

Call to undefined method Database::prepare()

from http://www.php.net/manual/en/class.pdo.php ###### config.ini ###### db_driver=mysql db_user=root db_password=924892xp [dsn] host=localhost port=3306 dbname=localhost [db_options] PDO::MYSQL_ATTR_INIT_COMMAND=set names utf8 [db_attributes] ATTR_ERRMODE=ERRMODE_EXCEPTION ############ <?php class Database { private static $lin...