How to ensure singleton classes no longer exist

hi all not sure if this is the right forum....
I am writting an application that integrates another, I wish to stop and then restart the integrated application but it seems that the singleton classes of which there are quite a few ( each being statically initalised) do not disappear when I try to shut them dowm. (if I am shutting them down that is ...)
is there a way to ensure these instances are terminated so I can restart the integrated application inside my application?
is there a way to see what instances exist so I can see if in fact I am disposing of any?
thanks for ur help

is there a way to ensure these instances are
terminated so I can restart the integrated application
inside my application?
is there a way to see what instances exist so I can
see if in fact I am disposing of any?
What exactly are you trying to achieve?
Do these hold on to resources which you must clean first? Then you must have a clean/dispose method. There is no other option. You can use a registration class to make this easier.
Do you simply want to reinitialize them? Then you could use a class loader but it probably going to take less time to simply do the same as above and add a reinit method to each. Again you can use a registration class to make this easier.

Similar Messages

  • How to make Singleton Class secure

    I have a Singleton class which I instantiate using reflection by a call to a public getInstance method that return the object from a private constructor. I have to use reflection as I dont have any other options since my class instantiation is decided on runtime. How will I secure other form instantiating the same class again by using reflection on my private constructor? Any ideas?

    How much do these different implementations of your singleton have in common? What I'm getting at is, is there some common code you could extract out of them all, and make that a singleton in it's own right? Needing to do this sort of hacking is often a sign you're fudging something together, that could be solved more elegantly. We use the Singleton pattern generally when the state of the object needs to exist exactly once. Can you extract that from the disparate objects?
    The singleton classes that I load do not have anything in common. They are all similar but unique, and independant in their own respect. I will have to decide only on what singleton object I have to load in runtime, based on certain criterion. This is done by reflection, by a call to the public getInstance() method of the respective singleton classes, since I am deciding on runtime. My problem is that can I prevent others from accessing my private constructor from outside the class using reflection, which enables them to create another duplicate object. Can I restrict them to use only my getInstance() method instead?? I know this is hacking to access the private members, but I want to know whether there is any way where I can restrict this hacking???In the above code I dont want these statements to work at any case
    java.lang.reflect.Constructor[] c = cl.getDeclaredConstructors();
    c[0].setAccessible(true);
    A anotherA  = (A) c[0].newInstance(new Object[]{"Duplicate"});

  • How to ensure singleton behavior across cluster and session?

    I need a class that loads up properties from a file and keeps those properties loaded after the first load? The code that will do the loading is being invoked by jsp. I have defined all the methods and variables as static and have a static flag to check if loaded. Is that sufficient?

    You could scope such info to the application scope - some info is provided here: http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html
    "application - You can use the Bean from any JSP page in the same application as the JSP page that created the Bean. The Bean exists across an entire JSP application, and any page in the application can use the Bean."

  • SQL Server Utility - How to Remove Instance that No Longer Exists on Server

    I had a default instance that I had installed for an application.  But then I was told they wanted it as a named instance.  I had added the default instance to the UCP (SQL Server Utility).  I have uninstalled the default instance forgetting
    that I had added it to the UCP.  Now when I try to remove the managed instance I get the following error:
    The action has failed.  Step failed.  The SQL Server connection does not correstpond to this managed instance object.  (Microsoft.Sqlserver.Management.Utility)
    How do I remove the managed instance from the UCP?  Do I need to go into a table in database sysutility_mdw and delete something?
    select * from msdb.dbo.sysutility_ucp_managed_instances
    where instance_id=57
    Maybe delete from table msdb.dbo.sysutility_ucp_managed_instances?
    Or maybe table sysutility_ucp_managed_instances_internal?
    lcerni

    I ran this
    EXEC msdb.dbo.sp_sysutility_ucp_remove_mi @instance_id=57
    And it fixed the issue.
    lcerni

  • SINGLETON CLASSES QUESTIONS

    Hello,
    Could someone please explain what the following code does? How does it work? How can I use it in the real program?
    More importantly, if you are kind enough, please give me some examples how to use singleton class? Why do we have to use this class?
    I spent two days on this topic, Singleton, but my mind still goes blank.....
    thank you.
    public class Singleton
    static public Singleton getInstance()
    if(theInstance == null)
    theInstance = new Singleton();
    return theInstance;
    protected Singleton()
    //initializing instance fields
    //instance fields and methods
    private static Singleton theInstance = null;

    Hello,
    Could someone please explain what the following code
    does? The code defines a class called Singleton. :)
    How does it work? The static method "getInstance()" returns an object of type Singleton. Static methods can be called without having an instance of a class, so you can type:
    Singleton.getInstance();
    How can I use it in the
    real program?This class is pretty useless in a real program. The point of this class is to show you how the Singleton design pattern can be implemented in Java. Any useful Singleton object needs to have additional properties and methods. (Oh I know someone will say that you can still use this class for something, but I'm trying to explain something here...)
    More importantly, if you are kind enough, please give
    me some examples how to use singleton class? Sure, here's an example of a singleton: Suppose you want a debugging class that will simply write text to a file. You want to only have one instance of this class (i.e. you don't want to have multiple log files, you want to provide one single interface point for this):
    class LoggerSingleton
      private static final String LOGFILENAME = "log.txt";
      private BufferedWriter write = null;
      private LoggerSingleton instance;
      synchronized static public LoggerSingleton getInstance()
      { if(instance == null)  instance = new LoggerSingleton(LOGFILENAME);
        return instance;
      protected LoggerSingleton(String filename)
        try {
          write = new BufferedWriter(new FileWriter(filename));
          write.write("Log File Opened");
          write.newLine();
          write.flush();
        catch(IOException ioe)
          System.err.println("Error!  LoggerSingleton could not be initialized");
          ioe.printStackTrace(System.err);
          System.exit(1);
      public log(String text)
        write.write(text);
        write.newLine();
        write.flush();
    }This class will make sure you only have one log file and ensures that all classes are using it:
    class FirstClass {
      SecondClass second = new SecondClass();
      public FirstClass() {
        LoggerSingleton.getInstance().log("Inside FirstClass' constructor");
      public void func1() {
        LoggerSingleton.getInstance().log("Inside FirstClass.func1()");
    class SecondClass {
      public SecondClass() {
        LoggerSingleton.getInstance().log("Inside SecondClass' constructor");
    Why do we have to use this class?You don't have to use this class, but it is one technique to ensure that multiple instances of an object are not instantiated. It is also a technique to ensure that there is only one interface point across the application (you can also use a Singleton object to implement the Bridge and Factory design patterns). The Singleton technique is achieved by making the constructor protected, which means that only methods inside the class (and package) can construct instances of Singleton. The only time an instance of Singleton is constructed is the first time that getInstance() is called.
    I spent two days on this topic, Singleton, but my mind
    still goes blank.....
    Still blank?

  • How to delete the queries in  BW Production which are no longer existing.

    Hi,
    How to  delete the queries in BW production which are no longer existing in DEV.
    1. I tried Using RSZDELETE in Production it is not getting deleted and the below message given.
    Query object 4A7V83T3RB4ABIOKSDJT2HWDL is blocked. Deletion has been cancelled.
    2. I tried creating another query in dev with the same technical name and send a transport with deletion
    it is not working.
    Please advise me on this for any function module or any other method.
    Thanks
    Surya

    Hi,
    If you transported the query from DEV and now you want to delete it, you should open a BEx request (Dev Class under which it was originally transported -- or-- Standard - type) in DEV delete the query and move the transport to Production.
    As far as your error is concerned, usually  when you  can delete a query using the delete option in query designer itself,
    Business Explorer> query-> delete objects , when you press execute the system offers you a list of dependent objects on the query(workbook,views), in case the sysytem is unable to delete them i.e.they being used as a input query for a characteristic variable (replacement path),then system throws this error.You can delete these all depndents under there prescribed roles , fav s & then proceed.
    Hope this will be expedite.
    Thax & regards.
    Vaibhave Sharma

  • How to change protected variants created by users that no longer exist

    There are several older variants for which background jobs are scheduled for daily prcessing.  These variants were created and protected by uses that no longer exist in SAP.
    How to  unprotect and change these variants to reflect new requirements.

    Hi Anam
    1. Execute tcode VARCH and enter the program and variant name and make the changes, if the system allows you to do so.
    2. Check with the basis/security team if they can extend the validity and reset the password for the old ids.
    3. If the above doesnt work, you will need to copy the variants manually
    Moving forward, when you create/change jobs, request the basis/security team to create common ids like OTCADM, P2PADM, etc. Ensure that all the variants and jobs are created/changed using this common id. Basis/Security team can controll by opening and closing the ADM account on request from project team and the usage can be recorded for tracking.
    To check the jobs that use a known variant, use tables TBTCP, TBTCO.
    Best Regards
    Sathees Gopalan

  • How do i access an old user ID if i cant remember the password, the email no longer exists, and the apple wont accept my birth day?

    how do I access an old iTunes account if the email address no longer exists, I can't remember the password, and iTunes won't accept my birth date?

    THe fist does not work as it's asked for a birthdate and will not recognize mine. in reasearching this further,it looks as if iTunes not recognizing the correct answer to a security question is a very common problem and that this is actually a huge issue that has lead to many folks not being able to ever access their purchased music again. Apple support has not even been able to unlock old user ID accounts.  Is their a class action lawsuit in regards to this?

  • How to implement a singleton class across apps in a managed server}

    Hi ,
    I tried implementing a singleton class , and then invoking the same in a filter class.
    Both are then deployed as a web app (war file) in a managed server.
    I created a similar app , deployed the same as another app in the same managed server .
    I have a logger running which logs the singleton instances as well.
    But am getting two instances of the singleton class in the two apps - not the same .
    I was under the impression that , a singleton is loaded in the class loader level , and since all apps under the same managed server used the same JVM , singleton will only get initialized once.
    Am i missing something here ? or did i implement it wrong..?
    public class Test
       private static Test ref ;
       private DataSource X; 
       static int Y;
       long Z ;  
       private Test ()
          // Singleton
           Z= 100 ;
       public static synchronized Test getinstance()  throws NamingException, SQLException
          if(ref == null)
             ref = new Test() ;        
             InitialContext ic = new InitialContext();
             ref.X = (DataSource)ic.lookup ("jdbc/Views");
          return ref ;       
       public Object clone()throws CloneNotSupportedException
           throw new CloneNotSupportedException();
       public int sampleMethod (int X) throws SQLException
    public final class Filter implements Filter
         public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException
              try
                   Test ref = Test.getinstance();
                   log.logNow(ref.toString());
    }Edited by: Tom on Dec 8, 2010 2:45 PM
    Edited by: Tom on Dec 8, 2010 2:46 PM

    Tom wrote:
    Hi ,
    I tried implementing a singleton class , and then invoking the same in a filter class.
    Both are then deployed as a web app (war file) in a managed server.
    I created a similar app , deployed the same as another app in the same managed server .
    I have a logger running which logs the singleton instances as well.
    But am getting two instances of the singleton class in the two apps - not the same .Two apps = two instances.
    Basically by definition.
    >
    I was under the impression that , a singleton is loaded in the class loader level , and since all apps under the same managed server used the same JVM , singleton will only get initialized once. A class is loaded by a class loader.
    Any class loader that loads a class, by definition loads the class.
    A VM can have many class loaders. And far as I know every JEE server in existance that anyone uses, uses class loaders.
    And finally there might be a problem with the architecture/design of a JEE system which has two applications but which is trying to solve it with a singleton. That suggests a there might be concept problem with understanding what an "app" is in the first place.

  • My credit card no longer exists how can the online subscription now be sorted out by my company

    My credit card used for the CC subscription no longer exists - the card was being debited monthly. How can my company sort out the payment and how can I ensure my usage of CC is not stopped in the interim. I have tried the chat helpline several times but although it says there are consultants available the second screen always says there are several customers before me and I never get helped.

    I am stuck with a similar problem. I moved from Ireland to the UK but for some reason, iTunes would not let me change the country in my payment information, it remains Ireland. I do not have any credit to spend and I still cannot change it. I even set up a new iTunes account and the country still remains uncangable. Hence, I cannot add the details of my UK card as iTunes believes it is set in Ireland. Have you managed to solve your problem?

  • TS3249 How can I delete an iMovie file reference to a server that no longer exists?

    I am using iMovie 11 and used to have a NAS that I've removed. Whenever I open iMovie, i get a prompt stating that the NAS server (name) no longer exists.  I thought I had moved all my project files to an external hard drive but I must have missed one.  I've tried deleting the com.apple.iMovieApp.plist file but this didn't stop the prompt.  The prompt happens every 5 seconds or so until I close iMovie. 
    Is there a way to reassociate the missing file to my iMovie project?  When I clip on the "missing source clip" in the preview window, I cannot change the properties of the clip to reassociate it to the correct location.
    I am running OS X lion v 10.7.4, iMovie 9.0.8.

    Yeah, this is quite late. Here's how I think you can do it. Run Show Package Contents on the .rcproject file. Find the file simply called "Project". Make a backup copy, and then open it with TextWrangler or similar program*. Search for the path in the file, fix it, and save. Try it in iMovie again. (The version I have is 9.0.4).
    * TextWrangler allows you to edit binary XML files, which is what Project is. I'm sure there are other programs that can do the same. This one is free.

  • I'm trying to recover my security questions, but my alternate email address on the link does not match the one I have put in my Apple ID, on the link it is has an old one that no longer exists. Has anyone else been through this or knows how to help m

    I've been trying to remember my security questions for ages, and I can't seem to remember them. On my Apple ID I have changed my alternate email address because the previous one was deleted, but when I go on the "Password and Security" page on my Apple ID and there is a link saying "Forgot your answers? Send reset security info email to ************@*******.com" but it is giving me my old email that does not match my current one on my Apple ID and no longer exists. I have been trying for very long to recover my security questions' answers, but Apple is not coping with me.
    Has anyone been through this or knows how to help me?
    Thank you.

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    (122986)

  • I have a long-existing iPhone 4s with one apple id and started a job where I received a macbook with another apple id. how do i get my phone to sync with the Mac Pro and secondly how do i get my music on there?

    i have a long-existing iPhone 4s with one apple id and started a job where I received a macbook with another apple id. how do i get my phone to sync with the Mac Pro and secondly how do i get my music on there?

    No not bothered about sycing apps etc it is all about calendars and maybe notes. IN terms of how its done I just want it the easiest way and preferably so that if an entry is made on one calendar then it populates the other.
    Thgius is beacuse I have my work diary on outlok, which I then link with my ical. I want to make sure that information is then shared with her.
    Chris

  • My old Apple ID is on my iPhone, but this has been transferred to a new Apple ID.  The iCloud on my phone is requesting the password for the old Apple ID, but this no longer exists.  How do I update the iCloud Apple ID on my iPhone?

    My old Apple ID is on my iPhone, but this has been transferred to a new Apple ID.  The iCloud on my phone is requesting the password for the old Apple ID, but this no longer exists.  How do I update the iCloud Apple ID on my iPhone?  When I try to get the old passwork through forgot my password, the reply is that there is no account that exists. 

    Try the following....
    Go to Settings>icloud, scroll to bottom of screen and tap Delete Account.  Then log in using a different ID.

  • I don't know of there is anyone than can fix this age old Apple problem.   Does anyone know how to retrieve things under an old Apple ID when the email used for that account no longer exists? I am trying to update a number of apps that was bought under an

    I don't know of there is anyone than can fix this age old Apple problem.   Does anyone know how to retrieve apps under an old Apple ID when the email used for that account no longer exists & I can't remember the password? After speaking with Apple Acct. Security, I got the security Q right but my birthday was wrong! They wanted the serial number from my phone that was 3 iPhones ago! Seriously??!!
    Any updated way to work around this? No Apple people can correct it.
    Thanks,
    Joe

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    (122986)

Maybe you are looking for

  • Wrong document saved, how can i get it back!

    Hi all, Today I was working with Pages for my study. I was making a large document full of images and shapes. After a while the document got bigger and bigger, so I saved my document every 5-10 minutes. When I was finished, i wanted to quit the progr

  • Account clearing error

    I run F.13 in test run, I selected some GL, but it display following error: Account was selected, but not entered in table TF123, what should I do?

  • Connecting the nexus 5500 with multiple vsans

    Hi, it's my first experience in the fibre channel world and i have a few doubts about the best way to connect the nexus 5500 to a EMC storage. This is my scenario this is my configuration: vsan database vsan 2 vsan 2 interface fc 1/1 vsan 3 vsan 3 in

  • Sensitive auto-type - FIX IT PLEASE!!!

    Hi BB - I'm a dedicated user and have just downloaded the lates OS for the BBZ10 - I can't tell you how many errors are occurring when I'm swiping the keypad. It is WAY TOO SENSITIVE causing numerous errors while I'm creating emails OR texting. PLEAS

  • Clip in 16:9 from VOB to .mov via Mpeg Streamclip gets squished in FCE

    Hello! This is a weird one, but I'm sure there's got to be a way -- any help much appreciated. I've been given a DVD to edit. No raw footage. - I used Mpeg Streamclip 1.9 to open the DVD's VOB files - From Mpeg Streamclip, I exported to Quicktime usi