singleton

Method for Using PDO in PHP

So I've found a method which looked nice to me: http://www.php.net/manual/en/class.pdo.php#97682 Requires PHP 5.3 but my host only supports 5.2 :( So what method should I use for PDO, where it only connects to the database when needed? And reuses the same connection? ...

Singleton-Pattern ASP.NET C# for each user

Hi all, i'm building a web application with asp.net c# and i have a class that i want to use in multiple pages witouth instantiate it every time. I need to load the data in it and never lose them during the user session time. I thought about the singleton-pattern but it shared the instance of the class beetween browsers. How can i solve ...

Slickest way to use BroadcastReceiver in a singleton and more

I have a singleton which stores some prudent information about the user of my application. At the moment, it stores the user's login and the user's location. 1) The location is found via a Service. At the moment, the Service references my singleton directly to stuff the longitude and latitude into it. I would like to use a BroadcastR...

How to call a method/selector when a variable/object changes value on iPhone

Hi, I'm looking for a way to "monitor/observe" a singleton class I'm using to pass information back from an asynchronous http request. I want to update the UI once I have received and parsed the response. Since iPhone SDK does not have an NSArrayController to monitor my data in the singleton, how can I do an asynchronous UI update? Thi...

Xcode - OpenAL - Getting the current time of a playing sound

Hey everyone, I was wondering if someone could point me in the right direction to creating a function in my openAL singleton class that returns the current time of the sound. Any Ideas? Thanks! (Current time 'while the sound is playing') ...

WPF Databinding Singleton Properties (From Multiple Windows)

Edit 3: TLDR-Version I have a singleton DependencyObject that I'm binding UserControls to. Some of the UserControls are in the main window, some of them appear in a separate window (the settings window). The ones that appear in the settings window do not bind correctly and do not affect the values in the singleton. I have a singleton...

Global Variables in Qt

Hi I want to make a global variable in Qt. So I wrote a singleton class. But I am getting the following errors :: error: symbol(s) not found, :: error: collect2: ld returned 1 exit status I am using the following code : CityBookGlobalVariables.h: class CityBookGlobalVariables { private: CityBookGlobalVariables(); CityBookGlo...

EE 6 (GlassFish): how many containers? How many singletons?

Ok, still trying to understand the basic EE 6 concepts here. I'm hoping someone here can help me out. I'm running GlassFish v3 server Kukla with a single domain. I deploy MyEEApp.ear, which contain MyEEWebApp.war, MyEJBs.jar, and, MyUtilityLibrary.jar. My EJB jar contains a @Singleton bean called MySingleton. I then set up another serv...

Parameterized Factory & product classes that cannot be instantiated without the Factory

I'm working on implementing a Factory class along the lines of what is proposed in this response to a previous question: http://stackoverflow.com/questions/410823/factory-method-implementation-c/534396#534396 It's a Factory that stores a map from strings to object creation functions so I can request different types of objects from the ...

Where is memory leak in JavaScript / jquery ?

Hello! I have two singletons: Search - performs the search functionality Topic - presentation of topics (search results) var Search = new function () { this.GetTopics = function () { var query = $("#globalSearch").val(); $.ajax({ url: 'Search/GetTopics', dataType: 'json', dat...

Help debugging WCF Service performance issues

Scenario: WCF Service call routing to COM+ application. netTCPBinding, throttling set pretty high. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode=ConcurrencyMode.Multiple)] Service has two methods, one simply returns the string was input, the other calls the COM+ component and FOR TESTING returns ...

Unable to serialize an object based on a singleton in PHP

I have an object, based on the Singleton design, that I use for user authentication. Because the object is a per-user object, I want the object to be stored automatically in a session variable at the end of execution. However, any time I try to serialize the object, either internally or externally, I get an empty string. The following i...

Using static in Java singletons?

I am building a singleton service in Java for Android: final class MyService { private static Context context = null; // ... private MyService() { myObj = new MyObj(context); // ... } private static class Singleton { private static final MyService INSTANCE = new ...

android weird onCreate / onDestroy balance

Hi, is there a way to tell Android that I would like subsequent calls to startActivity() all resume the target activity rather than creating it over and over again ? Any workarounds ? Thanks ...

Why to use Singleton patern?

Hey, So.. I can't understand why should I even use the Singleton pattern in ActionScript 3. Can anyone explain me this? Maybe I just don't understand the purpose of it. I mean how it differs from other patterns? How it works? I checked the PureMVC source and it's full of Singletons. Why are they using them in the View, Module, Controlle...

Using Guice without a main method

Hi, I'm creating a library that will be included as a jar, so it won't contain a main method. I'm wondering what is the best practice for bootstrapping Guice in this case. I have one top level singleton. public class TestManager { private TestManager() { } public static TestManager getInstance() { // cons...

How to make my WPF MainWindow a singleton?

I want to make my MainWindow a singleton because I want to make accessing it from all other windows in my app easier. But I couldn't make it run. Here is what I did. As usual, I made the MainWindow contractor private, and created a public static MainWindow Instance property to return a static instance. When I just run it without any oth...

Forcing an interrupt between threads through a singlton object (academic)

So this is a very weird situation, and I'm sure not very pythonic. But I'm not actually using this in any production code, I'm just considering how (if?) this could work. It doesn't have to be python specific, but I'd like a solution that at least WORKS within python framework. Basically, I have a thread safe singleton object that imple...

C++ singleton vs completely static object

Let say we need to have just one instance of some class in our project. There are couple ways of doing it. I want to compare. Please can you review my understanding. 1) Classical Singleton pattern 2) Completely static class (all methods and members are static). As I understand the differences are following: a) The order of initiali...

Can i make my own Singleton Stateless Bean with EJB 3.0 ?

Now, with EJB 3.1, we can find the javax.ejb.Singleton annocation that can ensure that this bean is going to be singleton. Is there a way that i can ensure singleton using stateless beans in EJB 3.0 with some modifications in my code (use of the keyword static, or other way to do that....) ...