How to stop a singleton class being clonable ?

Do we have any way to stop clone method being invoked on a singleton class.
One way I guess is to implement clone method and throw an exception inside the method.

jwenting wrote:
georgemc wrote:
Why bother, though? Don't you trust your fellow developers not to do stupid things?why should I trust them to not do stupid things when I don't even trust myself to not do stupid things? >:=)Because trusting them not to do stupid things would actually be a stupid thing :)

Similar Messages

  • How to stop the Dialog from being dragged

    I was hoping that someone could tell me when calling a Dialog from Jframe, a how to stop the Dialog from being dragged
    while a dialog is showing.
    When it is visible I can still click and drag the Dialog
    I want to set it so you can not drag it until the dialog has be closed.

    If you don't have access to the parent frame, a "hack" that usually works:
    Frame frame = Frame.getFrames()[0];
    if (null != frame && frame instanceof JFrame){
    JFrame jf = (JFrame)frame;
    JDialog jd = new JDialog(jf, "title");
    ... code here ...
    As each JFrame (or Frame) is opened, its stored in the array of Frames that you can get. Same thing with Dialog.getDialogs(). Almost always, at least so far for me I've never had this problem, the [0] index is the main window opened, or the parent/top frame. I'd put the check in there to be safe and make sure its a JFrame and usually you'll only have the one JFrame.

  • How to stop volume icon from being displayed randomly

    How to stop volume icon from being displayed randomly

    Thanks for the quick response.
    I have a number of slides which act as a training module. The quiz follows this. All the answers to the quiz are in the module slides. I'd like the user to be able to see which questions they're failing on, but not be shown the answers, as, if they are failing the quiz, the whole module needs to be reviewed and the test retaken.
    If this isn't possible, I'll probably just remove the review option, thereby meaning my retake button can stay, and the user can just go back and re-read the module slides to learn the answers.
    Thanks

  • How to stop an email from being sent after I hit send?

    How can I immediately stop an email from being sent after clicking "send"?
    I can't seem to find any info on this. I am assuming that it is impossible. Correct?

    When sending the emails with larger attachments that take a little time to actually upload and get out, you can open the activity viewer by pressing command-0 (or is it command-o?--)--it may also be under the window menu at the top--I'm not at my Mac right now to check. The activity viewer has a stop button on it. After you stop it, you should be able to either delete the email from the outgoing mail folder or drag that email to another folder, such as the drafts folder. I've done this a few times without a problem.

  • How to stop an idoc from being processed further

    Hi Experts,
    I have a requirement where i have to stop the idoc from being processed in an user exit.
    I have to stop the idoc and give a suitable status message over there.
    It would be highly helpful if anybody tells me how to stop the idoc abruptly and giv the status messsage.
    Thanks in advance.
    Praveen.

    Hi,
    Check the below link
    https://forums.sdn.sap.com/click.jspa?searchID=11810720&messageID=3032674
    You need to find aproper EXIT.
    The avaliable options for you in the exit is
    IDOC_DATA
    Now if i pick the segment having shiped qty from the data record and check the same with the delivery qty your objective is half done.
    When the condition fails you need to update the IDOC with Error 51 saying that this is not possible .
    for that you need to bring your logic as
    LOOP AT IDOC_CONTROL.
    PERFORM LOGIC...
    ENDLOOP.
    FOR LOGIC .
    All the criteria and then update the status of the IDOC then error is generated and updated to the IDOc.
    PERFORM updatestatusidoc.
    endform logic.
    like this in
    form updatestatusidoc.
    IF subrc = 0 .
    t_idoc_status-docnum = f_idoc_contrl-docnum.
    t_idoc_status-status = c_idoc_status_ok.
    t_idoc_status-msgty = 'S'. -
    >denotes success
    t_idoc_status-msgid = 'ZXXX'.
    t_idoc_status-msgno = '000'. "
    t_idoc_status-msgv1 = itab-field.
    APPEND t_idoc_status.
    ELSEIF subrc = 1.
    t_idoc_status-docnum = f_idoc_contrl-docnum.
    t_idoc_status-status = c_idoc_status_error.
    t_idoc_status-msgty = 'E'. "denotes --->error
    t_idoc_status-msgid = 'ZXXX'.
    t_idoc_status-msgno = '001'. "
    t_idoc_status-msgv1 = itab-field.
    APPEND t_idoc_status.
    endif.
    endform.
    this has to be done to make the idoc to trigger error mode.
    Regards,
    Raj.

  • 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.

  • How to stop copied files from being automatically trashed

    so this has only been happening recently, in the last 2-3 weeks.
    if i choose a file, say "example.txt" and duplicate it, adding "example copy.txt" to the desktop, within a couple seconds, it gets automatically placed in the trash.
    if i rename the copy to "example.2.txt" and move it back to the desktop, it'll stay. so it's not an issue of identical files being trashed. if i take it and name it back to "example copy.txt" it gets placed in the trash again automatically.
    how do i stop this? it's driving me mental because i have to go retrieve everything i copy from the trash bin. i'm sure i haven't downloaded any automators or anything, so any kind of input would be beneficial.
    thanks!

    whats the type n contents of this files.it is text only pipe seperated.
    have u specified the bad or log file path while creating the external file.no I do not. I use simple UTL_FILE for writing to these files but it does generate .log all the time and sometimes .bad whenever there is some problem.
    the sample script used for create external table is mentioned below.
    CREATE TABLE "XX"."E_ERROR_LOG"
    (     "SERVER_ID" VARCHAR2(24),
         "MONITOR_ID" VARCHAR2(24),
         "XXX_ID" VARCHAR2(8),
         "XXX_SUBTYPE_ID" VARCHAR2(8),
         "ERROR_CODE" VARCHAR2(6),
         "LOG_TIMESTAMP" VARCHAR2(19),
         "ERROR_MESSAGE_BODY" VARCHAR2(1024),
         "XXXX_MESSAGE" NVARCHAR2(1024)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY "XXXX"
    ACCESS PARAMETERS
    ( records delimited by newline
         fields terminated by '|'
         missing field VALUES are NULL
    LOCATION
    ( 'DF_XXXX_ERRORLOG_DATA01.dbf'
    REJECT LIMIT UNLIMITED;
    ----------------------------------------------------------------------------------------------------------

  • How to stop an iPhone from being hacked

    Can an iPhone be hacked through your iCloud account or email account (meaning your Apple ID). I have found disturbing things on the internet to monitor phones such as auto-forward.com. For about $70 you can monitor everything on a smart phone. Of course they're disclaimer is that being a parent, you want to make sure what your kids are up to and it says "not to be used for illegal purposes". But I am an adult and someone is monitoring me. My Apple ID password only works when this person wants it to work. My email and texts disappear.
    HOW DO I STOP THIS??  I have already traded my phone in changed apple IDs, the techs at the apple store found strange software diagnostics.
    Law enforcement is not very tech savvy. Can data forensics trace the person doing this? About $2000, but worth it to catch the stalker.

    Your Apple ID can be compromised. That would allow a miscreant to buy things using your account, access your iCloud information and potentially wipe the phone remotely. If your concerned about that, make sure that you use a complex password and 2 step verification. Make sure your recovery email account is also secure.
    http://support.apple.com/kb/HT5570
    You should also put a password on your phone to prevent people from gaining physical access to it.
    Don't believe everything you read on the internet. In order to use such software on an iPhone, someone would need to have access to your phone in order to jailbreak it. If you restore the phone as new and follow the advice above, no one will be monitoring your phone (except possibly the government and they are not going to be deleting your texts and emails).
    Best of luck.

  • How to stop control characters from being tokenized?

    In Oracle 11.2.0.3
    I have documents which has embeded Arabic and so there is a control character \u202b to indicate right-to-left string. How do I stop these kinds of control characters from being tokenized. Doing a search with CONTAINS(search_string,' \u202b')>0 finds documents. Do I just add the '\u202b' as a stopword?

    What lexer are you using, Amin?
    I assume from what you say that the characters are getting indexed as whole tokens?  If so, adding them as stopwords should work, but I'm surprised they're getting indexed at all - sounds like a fault in the "alphanumeric indentification" code to me.
    I'm going to take a guess this is the World Lexer.  Am I right?

  • How to stop table row from being split onto two pages

    How do I stop a row of output from being split between two
    pages. When the CFDocument loads, sometimes, the last row on a page
    "spills" over onto the next. I'd like to figure out who to prevent
    these "orphans" from happening, and force the row onto one page or
    the other.
    Here's my code for the doc... I have a sp that querys the sql
    db. Using CFDocument - CF Version 7.02

    If you know roughly how many lines of output will fit on a
    page (you can test to find out), then you can count result lines
    (you should be able to use RecordCount and do some math) and cfif
    against your counter and force a page break beforehand if the next
    table will be too much to fit on the page. Then just reset the
    counter after you page break.

  • How to stop just one item being reset when sumbit is pressed?

    How can i keep the value of just one item when the submit button is pressed. This field will always be the user id of the user logged on so i dont want it to be reset. I have tired doing a simple query to select the id everytime the page loads but the value then appears null when i do an insert statement to create a particular record for the user in a table.
    Anyone any ideas?

    Right I could see how the APP_USER would work but it wouldn’t work in this situation.
    To be more specific I want the id of the user which is called student id to stay the same all the way through the application as there id refers to them. What I have is that when a user logs on it takes them to their details and a menu part. One of the options is to enter some documents relevant to them. So when they click this option a new page opens showing a report of all the current documents as well as a form where you can update, insert new and delete documents.
    When you load the page the report and form work fine with the correct student id being passed form the pervious page. If however you create a document all the fields in the form get reset. I therefore want a way of stopping the student id from being reset when you create or delete a document. Basically if the page refreshes.
    I can run an sql query that gets the correct student id if the field is null and displays it correctly in the form but for some reasons (im guessing cos its a result of a query) when it tries to process this when I submit the field is null.
    Any ideas as this one has got me

  • How to stop music folder from being created when changing media folder

    When I try to change the media folder location, a new "music" folder is created - how do I stop this from happening (I already have a music folder that I want it to default to, but when I try to select it, it creates another music sub folder)
    This is a new issue - I have been using itunes for years without ever having this problem...

    That's how itunes 9 works, now. The top-level folder is considered the "Media" folder and there are music, podcast, movie, audiobook, etc subfolders.
    Which is better in a way, since before itunes 9, everything was dumped in a music folder, even audiobooks that weren't music.
    http://support.apple.com/kb/ht3847

  • How to stop the same frame being played twice.

    Hi,
    I am creating a quiz in flash using AS 3.0
    I need the order of the questions to be in a random order which I have worked out how to do.
    I now need to make it so the questions are shown only one, I've tried looking on the internet but I've not been able to find anything that a: helps and b: I understand.
    stop();
    BTcorrect.addEventListener(MouseEvent.CLICK, nextQuestion);
    function nextQuestion(evt:MouseEvent):void {
      var q_number :  Number = 3;
      var randomFrame:Number = Math.ceil(Math.random() * q_number);
      trace(randomFrame);
      gotoAndStop(randomFrame);
    here is my code so far, I dont know where to go from here.
    Thank you in advance.
    Matt.

    you can use the shuffle function to randomize any array and then loop through the randomized array to ensure you're accessing no duplicates:
    function shuffle(a:Array) {
        var p:int;
        var t:*;
        var ivar:int;
        for (ivar = a.length-1; ivar>=0; ivar--) {
            p=Math.floor((ivar+1)*Math.random());
            t = a[ivar];
            a[ivar] = a[p];
            a[p] = t;

  • How to stop email addresses from being added to contacts

    hofw do you stop email addresses from sent emails from being added automatically to contacts?

    No. They are not being created by the phone. They are being created by your mail system, whether that is Exchange, Yahoo, Google, etc. They all have settings to automatically create contacts from people you correspond with. There is no setting on the phone to control this. Check the settings for your mail account with or talk to your IT department.

  • How to stop mouse pointer from being included on screenshots

    Hey guys I was hoping someone could help me with this problem.
    I am creating a software simulation and have decided to use Captivate 6.  When capturing the appropriate screenshots i have noticed that the mouse pointer is being included with these. I DO NOT want the mouse pointer to be included within the screenshot.
    I know how to disable the mouse pointer when setting my preferences before creaing the simulation, however, the mouse pointer is still being included in the screenshots. Here is an example below.. Can anyone help me?
    Thanks,
    Garrett
    Example: I orginally wanted to show the user's log in menu, but once I clicked "Login" the mouse pointer stuck to the screenshot. I don't want this mouse pointer to be there

    I actually chose Demo and assessment.  The mouse is not what I want to see in the slides. The timeline does not show a mouse at all because I have that functionality disabled. What I really want is to essentially replicate an application. I want the user to be able to start this captivate project from a flash drive and actually have the applications GUI with limited functionality (for training purposes). I am starting to think there is a problem with the application I am trying to replicate. I have a software product that I must start on a virtual machine. Once the virtual machine is up and running then can I actually start the application. I have already done two of these with different applications and had no problem at all with the mouse pointer disappearing. This one, however, is being very difficult. Maybe its because im using QNX?

Maybe you are looking for

  • How do I use my gift card balance on Apple TV to rent movies

    I have balance on my I tunes gift card that I entered on my apple account. When I try to purchase a movie on Apple TV it wants to charge my credit card. How do I add gift card to Apple TV ?

  • Use of EXISTS clause in Interface

    I want to build an interface from one table but using an exist clause to check the data change in the same table. In SQL statement it can be expressed as follows   SELECT PB.PROJECT_KEY, COUNT (DISTINCT DW_PROJECT_BUILDING_KEY)     FROM DW_PROJECT_BU

  • Text box AppendText

    Its late in the afternoon and I am refreshing my myself in PowerShell GUI.  I have my GUI built and sort of functioning getting ready to add the meat of the script in.  I am attempting to use AppendText  and cannot figure out the format for the escap

  • Macbook Air and Aperture SSD storage space?

    I recently purchased the new Macbook Air 13" i5 with 128 GB SSD and 4GB of Ram. I have 50Gb of photos. 1.) Can I store these photos on a Time Machien and file share? 2.) Should I purchased a gigabit ethernet NAS drive like a DROBO? 3.) Should I go wi

  • Adding buttons on toolbar

    On occerance of certain ActionEvent i need to add dynamic JButtons & JLabels on the JToolBar. Initially JToolBar will be empty. Code below is not working properly... It is creating buttons dynamiclly but i cant set any property for that one. class De