Singleton - Constructor needs a parameter :(

Hello,
i have a Problem with the Singleton Pattern.
Following situation:
I have a class (Commander) which starts all the dialogs of my Swing Application. For this it starts first the BPs and they start the dialogs.
The BPs need my mainprocess class in the construtor to set the its parent. So, my commander-class needs to keep an instance of the mainprocess-class as a member.
At the moment the constructor of my commander class gets the mainprocess instance, but i want to make the commander singleton.
When i do that i am not able to use the constructor to publish the mainprocess class. I dont want to use the getInstance-method to give my the commander, the mainprocess.
It seems impossible to make the commander singleton as long as it needs the mainprocess for each other operation. Is that right or do you have a solution for my problem?
thanks and regards
Toni

Does something like this work?
public final class Commander {
    private static Commander instance;
    private MainProcess main;
    private Commander(MainProcess p) {
        main = p;
    public static synchronized Commander createInstance(MainProcess p) {
        if (instance == null) {
            instance = new Commander(p);
        } else {
            throw new UnsupportedOperationException("Instance already created!");
    public static synchronized Commander getInstance() {
        if (instance != null) {
            return instance;
        } else {
            throw new UnsupportedOperationException("Instance not created!");
}

Similar Messages

  • Please..how to instal libero mail on mi Ipad. I need the parameter for send and receive mail..Thanks

    Please..how to instal "libero" mail on my Ipad. I need the parameter for send and receive mail..Thanks

    FYI: POP will by default, delete messages from the server after downloading them (This applies to most pop clients, computer or mobile). POP is old tech and is not recommended if IMAP or Exchange are available. The default when setting up a g-mail type account is IMAP. Full synchronization with the server. You may also be able to set it up as an Exchange account, allowing for push e-mail and sync of calendars and contacts as well. See the Gmail help pages for instructions.

  • NEED SET PARAMETER ID for  maintain Activity (BUS2000126)

    Hi all,
             i am working in CRM 5.0, i have created one Z Activity Report wit interaction,
    i need Set parameter id for maintain Activity (BUS2000126) for geting the partcular Transaction Activity,
    it is not working :
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    data:index type i.
      CASE R_UCOMM.
        WHEN '&IC1'.
            read table it_data  index rs_selfield-tabindex.
           SET PARAMETER ID    'CRM_CURR_OBJECT_ID'
               FIELD it_data-object_id.
           call transaction 'CRMD_BUS2000126' ."and skip first screen.
      ENDCASE.
    ENDFORM.                    "user_command
    this 'CRM_CURR_OBJECT_ID' parameter is not working ,
    Can any one tell me parameter ID for t-code 'CRMD_BUS2000126' ,
    Thanks,
    Ganesh R

    Hi Pratik Patel,
                           i have tryed  Parameter ID: CRM_OBJECT_ID,
    but it is not working ..
    see my coding :
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    data:index type i.
      CASE R_UCOMM.
        WHEN '&IC1'.
            read table it_data  index rs_selfield-tabindex.
           SET PARAMETER ID 'CRM_OBJECT_ID' FIELD it_data-object_id.
           call transaction 'CRMD_BUS2000126' and skip first screen.
      ENDCASE.
    ENDFORM.                    "user_command
    here is any problem?,
    i have checked clicked object id is comming properly ,
    can u tell what is the problem?
    regards
    ganesh

  • Window constructor needs another Window obj then how the Frame obj created

    hi all
    Window constructor needs another window obj as owner
    then when we create the Frame obj, surely the Window constructor gets called
    so where from this window get the owner of it self
    thanx

    Window, Frame, and Dialog all have native implementations (obviously), so the simple answer is "it just does"
    More formally, since a frame is a first-class window (ie shows up in the windows taskbar) it is not dependant on another frame.

  • Dynamiclaly determine the need of parameter prompt? (CR8.5)

    Hi,
    I'm wondering if it's possible to have cr8 decide if a parameter is needed.
    I have a report, its an invoice template that has some graphics that display depending on a selected parameter.
    The graphics are generally only used when a copy invoice or credit is needed - otherwise the user selects 'plain' and the invoice prints with no graphics.
    The document type is determined by the database field DOC_TYPE which would be 'CIV' for copy invoice or 'CCR' for copy credit - otherwise 'INV' or 'CRN'
    Is it possible to specify that, if the doc_type is 'CIV' or 'CCR' then prompt for graphics if not, no parameter prompt - show/print the plain report.
    The reason for this is that, when invoices are raised, they are raised in batches and it would be inpracticle to stop and choose a parameter for each invoice - these invoices are all printed on headed paper, therefor - graphics are supressed.
    The graphics are only shown when a customer requests a copy invoice and we then send out a pdf generated from the report with graphics shown

    Please re-post if this is still an issue or purchase a case and have a dedicated support
    engineer work with your directly

  • Need of parameter id's...?

    Hey gurus,
    In PBO event why do we need parameter ID's..and are the parameter ID already defined or do we create one..
    Please help...
    Cheers:Jim

    hi,
    parameter id's are useful in having data values from one session to another for from internal session to external session. useful in situations when we have to cal standard screens with some default values.
    if helpful reward some points.
    with regards,
    suresh.

  • I need one parameter value to return all values in SSRS

    when clicking on last label , I need data associated with all counties to retrieved , it is working fine when clicking on particular country but I can't figure it out how to do this is with multiple value  
    in my SQL code I am trying to do this 
    where country in(@country)

    There is no need to specify "All countries" in SSRS if you want to select all the countries if you want to render the report. Just pass all the available values and in the "General" tab select
    Allow multiple values which gives you the option to choose all the countries or also one or more countries... Don't forget to specify the "IN" operator in your query... it's a must...
    Good luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles..

  • Error 1136: expects 0 arguments but constructor needs 2

    Hi. In my project I have a Box class that extends MovieClip, and Box has instances of the Egg class. The Egg class receives two arguments on instantiation, month (a string) and size (an int).
    Here's my code:
    package com.stuff {
    import flash.display.MovieClip;
    import com.stuff.Egg;
    public class Box extends MovieClip {
         private var Egg1:Egg = new Egg("jan", 2);
         private var Egg2:Egg = new Egg("feb", 5);
         public function Box():void {
    package com.stuff {
    public class Egg {
         public function Egg(m:String, s:int):void {
    When I test the movie I get the following error: 1136: Incorrect number of arguments. Expected 0.
    What am I doing wrong? Thank you.

    I would still remove the :void on the constructors - it's not really a standard and makes the constructor stand out.
    That said, maybe the error isn't with your constructor? Are you calling any functions inside of the Egg constructor in your actual code? I would watch for that. Try commenting lines out and adding them back 1 by 1 until you get the error.

  • Why I need this parameter file ? initTSH1.ora

    I have installed oracle10g on RHEL5, did not get any error message, after the installer finished , I startup the database , but got this msg:
    ORA-01078: failure in processing system parameters
    LRM-00109: could not open parameter file '/u01/oracle/product/1020/db_1/dbs/initTSH1.ora'
    and the parameter directory has these files:
    [oracle@localhost dbs]$ pwd
    /u01/oracle/product/1020/db_1/dbs
    [oracle@localhost dbs]$ ls
    hc_datacent.dat init.ora lkDATACENTER spfiledatacent.ora
    initdw.ora lkDATACENT orapwdatacent
    [oracle@localhost dbs]$
    I can not search anything about the file initTSH1.ora , please help me, thanks .

    Your ORACLE_SID environment variable is set as TSH1, which is not your DB name. As oracle user try this :
    $ export ORACLE_SID=datacent
    $ sqlplus / as sysdba
    If you get "Connected to an idle instance.", then try
    SQL> startup

  • Hopefully easy, passed object to constructor, need for event

    Ok, the current scope of my program is currently two frames, in two files, Login.java and Select.java (if you have not been following my neverending question saga)
    I create an instance of Select from within the Login file, and i pass to the constructor of select, the Login object created, so Select can have access to what was entered in the text field of Login via a getName function, that works.
    Now i want to have the "Back" button in Select close the select frame, and re-open the Login frame ie setVisible(false) and setVisible(true) respectivly...
    Now once before, i noticed if i tried to make the visibility false of Login, from within the file that i created that Login object, i would get odd errors. So i figure if i want Select to close itself, i would pass it the object that Login created of Select.
    But, the event code for the button has no idea what i passed to the constructor of Select (the event code for the button IN select)
    So how would i go about letting my lil button know what i passed to the constructor of the class that it is in?
    I assume this is an easy question, at least i hope so
    Here is some relevent code:
    // from Login.java, within the event for pressing "next" after validating the name within the text field.
    selectframe = new Select(loginframe, selectframe);
    selectframe.setSize(500, 350);
    selectframe.setTitle("Select the midget");
    selectframe.setVisible(true);
    // Select.java
    public Select(Login passed, Select selectpass)
              passed.setVisible(false);  //works fine...
              // GUI code
    public void actionPerformed(ActionEvent f)
          if (f.getSource() == jbtBack)
               System.out.println("Back pressed");
               selectpass.setVisible(false);  //Error: selectpass is undefined
               passed.setVisible(true);  //Error. passed is undefined

    import java.awt.*;
    import java.awt.event.*;
    public class ClassA extends Frame implements ActionListener
         public ClassA() {
              setTitle("ClassA");
              addWindowListener(new WindowAdapter()     {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              clb = new ClassB(this);
              createFrame();
         private void createFrame() {
              setSize(300, 200);
              Button b = new Button("OK");
              b.addActionListener(this);
              add(b);
              show();
         public void actionPerformed(ActionEvent ae) {
              clb.frame2();
         public static void main(String args[]) {
              new ClassA();
         private ClassB clb;
    class ClassB extends Frame implements ActionListener
         ClassA cla;
         public ClassB(ClassA passed) {
              cla = passed;
         void frame2() {
              setTitle("ClassB");
              setSize(300, 200);
              setLocation(300, 200);
              cla.setVisible(false);
              Button b = new Button("OK");
              b.addActionListener(this);
              add(b);
              show();
         public void actionPerformed(ActionEvent ae) {
              setVisible(false);
              cla.setVisible(true);
              return;
    }These two classes each display a single button. When one is clicked, its frame becomes invisible and the other frame appears.
    Mark

  • BSP needs Portal Parameter

    Hi to all,
    I'm not very familar with Business Server Pages but I have the requirement to provide a BSP with parameter from the SAP NetWeaver Enterprise Portal (like username, language, iView-Id....). I'm not allowed to use Application Parameter or URL-parameter to send the data to the BSP.
    So my question is: How can I provide the BSP with parameter from the portal?
    Can I use Customer Exits for 'ParameterProvider' and put there some values into the current component or http session but how can I then read the values in the BSP?
    Or shall I use cookies? Other ideas?
    Thanks for your help!
    Best regards
    Katharina

    Hi,
    You can use below steps...
    1.  Application Parameters for BSP iview in portal like below
    Application Parameters =
    userid=<User.LogonUid>&fname=<User.firstname>&lname=<User.lastname>&email=<User.email>
    And  
    <User.displayname>
    <User.salutation>
    <User.firstname>
    <User.lastname>
    <User.jobtitle>
    <User.department>
    <User.telephone>
    <User.fax>
    <User.streetaddress>
    <User.zip>
    <User.city>
    <User.country>
    <User.timezone>
    <User.mobile>
    2. BSP application in R/3
      DATA: l_url_parameters        TYPE tihttpnvp,
                 l_url_userparameter    TYPE ihttpnvp.
      READ TABLE l_url_parameters WITH KEY name = 'USERID'
                                  INTO l_url_userparameter.
    Thnx!
    Suriya

  • Enhancement request: Stop marking private singleton constructor as not used

    Example:
    public class Singleton
      private static Singleton instance = new Singleton();
      private Singleton()
    }Thanks,
    ~ Simon

    I tried this in JDev 11g tech preview two and no errors or warnings are flagged:
    package x;
    public class Singleton {
      private static Singleton instance = new Singleton();
      private Singleton()
      public static Singleton getInstance() {
          return instance;
    }

  • Need make Parameter i/p field invisible

    Hi,
    Below is my sample program. I am trying to make MG1 invisible on output screen.
    But PT1_From still visible where as other comments are invisble.
    Please help me on changing the visibility of PT1_From to invisible.
    Thanks
    Vimalraj
    REPORT  ZQUERYSCREEN.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (20) PT1 FOR FIELD PT1_From MODIF ID MG1 .
    SELECTION-SCREEN COMMENT (20) text-013 MODIF ID MG1 .
    PARAMETERS: PT1_From type i  MODIF ID MG1 .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (20) text-014 .
    PARAMETERS: PT1_To type i.
    SELECTION-SCREEN END OF LINE.
    at selection-screen OUTPUT.
    PT1 = ' Flight Date ' .
    PT2 = ' '' Comma escape '' ' .
      LOOP AT SCREEN.
        IF screen-group1 = 'MG1'.
           screen-intensified = '1'.
           screen-INVISIBLE = '1'.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.

    Hi,
    try this:
      LOOP AT SCREEN.
        IF screen-group1 = 'MG1'.
          screen-active = 0.
          screen-input = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    Reward points please,
    Regards,
    George
    Edited by: George Lioumis on Jan 9, 2008 11:23 AM

  • Assistance Class and Constructor

    Hi,
    I've created an assistance class + a constructor for it. This constructor needs a parameter to initialize the Assistance Class.
    However I'm unable to pass it on since the instantiation of WD_ASSIST is done by the framework.
    How can I achieve this?
    Thanks

    Yes Thomas. I totally agree with you. ideally an assistance class is always instantiated by the WD framework. But I just talked about the technical possibility of having a constructor for an assistance class.
    Apart from the embedded component usage one more possibility which comes to my mind is coverting a normal class ( being used elese where in normal report programs where constructor is necessary for instantiating parameters) into an assistance class. Although the class may be copied into a new class and then by deleting the constructor and creating a method for the purpose which constructor used to do.
    I welcome your thoughts on this scenario.

  • Need to use DocNum as parameter in Crystal report

    Dear All,
    I am developing a report for our customer now. It is a invoice report. We need 2 parameters
    1) Customer code (drop-down list. can only choose one each time)
    Here is my token
    Customer@ SELECT CardCode, CardName FROM OCRD WHERE CardType = 'C' ORDER BY CardCode
    2) Then we need another parameter to display all invoice number for the specific customer. How can I create the parameter here?
    Thanks in advance.
    Regards,
    Yuka

    You create two parameters in Crystal Reports. Try these
    One for Cusomer (Customer@Select CardName from OCRD where CardType='C')  - This would be String, Dynamic
    One for DocNum - Type :Number , Static
    Import the crystal report using Report Layout Manager to the app menu.
    Then navigate to the patch and click on the report, when the report loads you should see a dropdown list for Customer Name and the DocNum will be blank.
    Click on View-->System Information and findout field info
    create a query : Select DocNum,CardCode,CardName,DocTotal,DocDueDate from OINV where CardCode=$[TableName.Field]

Maybe you are looking for

  • I need to download a c6500-fpd-pkg.151-1.SY.pkg patch

    I need to download a c6500-fpd-pkg.151-1.SY.pkg patch, but I do not have this permission, no sales staff and Cisco contract number. Which friends can send a copy to me, thank you! My mail is [email protected] [email protected]-----------------

  • OAS 4.0.8.1 (wrksf and Listener Admin)

    Installed OAS 4.0.8.1 onto SUSE 6.4. Install fine but I am unable to start the wrksf process either through the OAS admin or directly with owsctl. It appears to start then stops ????. Also when I try to administer the Listeners the wladmin call fails

  • How to sync contacts

    i m using nokia 500.. How s sync my contacts from nokia sync? I was sync my all contacts to ovi sync.. Bt now i updated nokia sync.. It doesnt sync my contacts.. Plz reply me..

  • Downward compatibility express 4.0 to Pro 5.1.4

    I have final cut express 4.0 and I need to be able to save the files so they are compatible with final cut pro 5.1.4 which is a lower version. can anyone help? thanks

  • Catalog association to user through scenario in 10.2

    Hi Guys, I used to the ssociate the catalog to user through scenario in ATG 9.0 below like this.. session starts(event) -> (action)Change - person's - catalog - xxcatalog but when i am trying to create the same scenario in ATG 10.2, I don't see the o