Simplify the initialization of and application (currently done with singletons)

Say I have two startup classes:
class A extends Parent {
    public void startUp() {
        Foo.getInstance().init();
        Moo.getInstance().init();
        // and 25 more of the same kind
class B extends Parent {
    public void startUp() {
        Foo.getInstance().init();
        AnotherMoo.getInstance().init();
        // and 25 more of the same kind
}As you can see both classes inherit from one parent.
Singleton init() methods are called in a specific sequence and it is important to maintain that sequence.
Problem: I'd like to simplify startUp() methods. Ideally i'd like to keep information on all singleton dependencies at one place, perhaps I will end up pushing them up into the Parent class, perhaps it can be resolved using Spring or some other application framework...? Anyway what would be your advice on how to get rid of initialization in two separate classes?

I can't see how this would help... I'm trying to move duplicated code from two places into one place. Let me illustrate the problem on a different example, say you have:
// A.java
Foo1.getInstance().init();
Foo2.getInstance().init();
Foo3.getInstance().init();
Foo4.getInstance().init();
XXX.getInstance().init(); /* It is important this particular call has happened after Foo4.getInstance().init(); and before Foo5.getInstance().init(); */
Foo5.getInstance().init();
Foo6.getInstance().init();
// B.java
Foo1.getInstance().init();
Foo2.getInstance().init();
Foo3.getInstance().init();
Foo4.getInstance().init();
YYY.getInstance().init(); /* It is important this particular call has happened after Foo4.getInstance().init(); and before Foo5.getInstance().init(); */
Foo5.getInstance().init();
Foo6.getInstance().init();
// ...So what i'm trying to do is - consolidate code and make it run (or get configured) at one place, and I explore every available opportunity not just core Java functionality

Similar Messages

  • My husband and I share one computer.  We want to be able to share the same music on our iPhones, but we don't want to share the same contacts and applications.  How can I set this up so we still share music, but everything else is separate on our iPhones?

    My husband and I share one computer.  We want to be able to share the same music on our iPhones, but we don't want to share the same contacts and applications.  How can I set this up so we still share music, but everything else is separate on our iPhones?

    Welcome to the Apple Community.
    iTunes and iCloud are different accounts. You can both use the same ID for the store login and share your music etc., and use different ID's to log in to iCloud, thereby keeping your calendars etc separate.

  • HT4914 My wife and I both have iPhones and iPads. Can we both have access to the same iTunes Match library or do we have to have separate subscriptions?  Our devices are synced to the same computer and we currently download titles from the same library.

    My wife and I both have iPhones and iPads. Can we both have access to the same iTunes Match library or do we have to have separate subscriptions?  Our devices are synced to the same computer and we currently download titles from the same library.  We both use separate apple id's on our devices.

    You need to reconfigure your phone for use with your Apple ID. I suggest you restore yours as new then reconfigure it with your information and Apple ID. Be sure to disable Find My Phone, if it's enabled, before proceeding.
    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device: Several Alternative Solutions
    A
    1. iOS- Forgotten passcode or device disabled after entering wrong passcode
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. Restoring iPod touch after forgotten passcode
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. iOS- Understanding passcodes
    6. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    7. iOS - Unable to update or restore
    Forgotten Restrictions Passcode Help
                iPad,iPod,iPod Touch Recovery Mode
    You will need to restore your device as New to remove a Restrictions passcode. Go through the normal process to restore your device, but when you see the options to restore as New or from a backup, be sure to choose New.
    You can restore from a backup if you have one from BEFORE you set the restrictions passcode.
    Also, see iTunes- Restoring iOS software.

  • I have continuous problems with my iPad Mini, and it is getting worse!  Newstand application keep pausing or crashing, websites keep hanging first time in but then open fine the second time, and I have problems with applictions crashing.

    I have continuous problems with my iPad Mini, and it is getting worse!  Newstand application keep pausing or crashing, websites keep hanging first time in but then open fine the second time, and I have problems with applictions crashing.  Has anyone experienced similar problems and any suggestions?

    Has the device always behaved this way? Did this start as a result of an update to the iOS software? If the problem is that bad, you should probably restore the iOS software and then restore from a backup. If that fails, restore as new and rebuild the device. If that fails, it's time for a trip to an Apple Store to let them have a look at the iPad.
    Use iTunes to restore your iOS device to factory settings

  • HT4993 i have an i phone 5 and want to down load a free ap from the app store and it comes up with 54 pages of a terms agreement but won't let me agree to it so i can move on?

    i am trying to down load an app from the app store and it comes up with new terms and conditions agreement but it wont let me agree to it so i can move on

    Hi, Aviation01. 
    I would recommend closing all applications in multitasking and power cycling the device.  Once you have done this attempt to download the application and accept the terms again. 
    If an app is unresponsive but the system seems to respond to button presses, you can force the app to close:
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    iOS: Force an app to close
    If you are still experiencing issues, you can always download the application through iTunes on the computer.  This will allow you to accept the terms through the computer. 
    Cheers,
    Jason. 

  • I forgot the passcode to turn off restrictions. I have restored my iPad back to the factory settings and then synced it with the latest backup. The restrictions are still on and it is asking for the passcode. Can someone tell me how to get that off.

    I forgot the passcode to turn off restrictions. I have restored my iPad back to the factory settings and then synced it with the latest backup. The restrictions are still on and it is asking for the passcode. Can someone tell me how to get that off.

    The only option is to wipe the device clean and restore it to factory settings.  Hope you have a backup.
    Follow the instructions in  iOS: How to back up your data and set up your device as a new device http://support.apple.com/kb/HT4137 to restore the device to factory settings.
    Once you have setup the device as a new one, you can then sync it back with your iTunes account and all your music, apps, contacts and any other content sync'ed with iTunes will be loaded on the device. Any content that is stored only on the device and not sync'ed with iTunes, like app logins or data, will be lost during this process. Be forewarned that this is a long process and can take a couple of hours or more to complete. This can be painful, but it is necessarily so to prevent users from working around the security settings. After the restore is complete, you can setup a new Restrictions passcode. Make a note of the passcode to avoid this situation in future.
     Cheers, Tom

  • HT4528 I installed the new update and it is frozen with a picture of the charger head, an arrow pointing to a iTunes image. How do I get my phone to work properly?

    I installed the new update and it is frozen with a picture of the charger head, and an arrow pointing to a iTunes icon. How do I get my phone to work properly?

    What happened when you tried to restore and update the iPod?

  • I Try to update the playstation app and it comes up with "tthe item is no longer available"

    I Try to update the playstation app and it comes up with "tthe item is no longer available" how do I solve this problem
    <Re-Titled By Host>

    more than likely that app was downloaded using that apple id.. unless you know the password, you will not be able to update.. delete the app and re-download using your new apple id

  • Is it possible to render the clips individually and relink- such as with Color/fcp?

    I'm fairly new to Ae/ PP, and am trying to figure out a good workflow for grading (using resolve lite) Basically, I need to denoise my footage first (neat video) and then send that footage to Resolve, then back to pp. Now, this works fine with Resolve's scene detector as it can cut up the footage, but if there are any dissolves, etc, then I need to do this via xml instead.
    What I would like to do is: Edit in PP. Send to AE to denoise, render (the denoise need to happen before grading) and replace the original files with the new denoised clips in pp. Then send the xml to Resolve. So far this would work if it wasn't for AE rendering everything into one clip, eliminating the cuts/layers.
    Is it possible to render the clips individually and relink- such as with Color/fcp? If not, any other workflow that could work for me?
    Hope someone can help- dynamic link is driving me up the wall.

    Simply use Dynamic Link to send your whole timeline to AE or use AE's Premiere project import. Then once you have a working AE project, you can use scripts like rdPreCompose to create separate sub-comps for each clip which in turn you then can render separately. Still, the limitation will always be the kind of transitions you use. Essentialyl you should avoid anything that isn't a hard cut or simple cross dissolve 'cos there's no way to recreate it in AE without eating up the handle of your footage. You'd essentialyl be shooting yourself in teh foot if you jump ahead too far in Premiere and already add too much finishing there.
    Mylenium

  • HT201343 My Mac book pro all of a sudden doesn't have the airplay icon and doesn't work with my Apple TV . Why  ?

    My Mac book pro all of a sudden doesn't have the airplay icon and doesn't work with my Apple TV . Why  ?

    The Airplay icon will not display if the OS is unable to locate any Airplay devices.
    I would check that both devices are connected to the same network and maybe even power cycle the network devices - eg router etc
    Maybe even try to connect both devices to another network like an iPhone personal Hotspot and see if that helps to isolate the problem

  • I have a fairly elderly I Mac 7.1 (2.47 Ghz Intel Core Duo) operating OSX v 10.9.5. At the core level I find two Library folders, one within the System Folder and one by itself with the other core level folders - mostly same content. Is this right?

    iMac 7.1 (2.47 Ghz Intel Core Duo w/2GB memory) operating OSX v 10.9.5. At the core level I find two Library folders, one within the System Folder and one by itself with the other core level folders - mostly same content. Is this right or do I have a duplication problem?
    The system is slow.

  • HT1552 Im setting up a server with the port 25565 and im doing it with Port Map but the problwem is i cant seem to get it to work with my router. it goes through my macmini to the router and the expansion hardrive

    Im setting up a server with the port 25565 and im doing it with Port Map but the problwem is i cant seem to get it to work with my router. it goes through my macmini to the router and the expansion hardrive

    Im setting up a server with the port 25565 and im doing it with Port Map but the problwem is i cant seem to get it to work with my router. it goes through my macmini to the router and the expansion hardrive

  • Will the airport devices and time capsule work with telstras mobile hotspot (Sierra Wireless AirCard 753S Mobile Hotspot)??

    will the airport devices and time capsule work with telstras mobile hotspot (Sierra Wireless AirCard® 753S Mobile Hotspot)??

    Yes. There are 2 ways you could use these devices:
    Wirelessly 'join' the network. This would be slower and doesn't offer extending functionality.
    Use an Ethernet cable (through Powerline if you can't run a cable). This is faster and offers extending functionality. I would recommend using Bridge Mode if possible.

  • Is it possible to create the adhoc network and get it work with WLAN APIs (WlanConnect) instead of netsh commands...?

    Hi All,
    I am facing issues in creating  adhoc network in Windows 8.1. After searching in internet, I found that adhoc works with 
    netsh commands.
    1. I have tried neths commands and able to get it work on windows 8.1, 
     but I want to do it through the WLAN APIs ie. WlanConnect ,
    2. I am able to initiate the adhoc network(on Windows 8.1) by using WlanConnect API and other device are also able to connect to the Windows8.1 initiated adhoc  network  but the DHCP is not working.
    -> clients are not able to get the IP address.
    Is it possible to create the adhoc network and get it work with WLAN APIs (WlanConnect) instead of netsh commands...?
    Thanks
    akhil

    Hi,
    Did you mean to write a program to implement that creating adhoc via UI? This should be development issue.
    But this is Windows 8.1 client forum and there is no professional on develop.
    To help you better, I suggest you submit a new case on MSDN forum to help to check your code as they will be more professional on your issue:
    This is the MSDN forum link.
    http://social.msdn.microsoft.com/Forums/ 
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.  Thank you for your understanding.
    Kate Li
    TechNet Community Support

  • When creating events my calendar has the GMT default and I've done everything to fix it. I need help. It's driving me crazy.a

    Time Zone issue in the calendar.

    ChurchGurl,
    I had the same problem on my newly acquired iPhone 6 as well as my slightly older iPad Mini (2), but the problem did not start until after I set up my iPhone 6 recently. The link (iOS: Troubleshooting issues with date and time - Apple Support) in Jason's response above is good advice and should fix the problem, but then your phone will not automatically adjust time zones if you go from one time zone to another. That may not be a problem much, or at all depending on how much you travel. Something else I noticed is that you are specifically referring to using the Calendar App. Be sure to check Settings > Mail, Contacts, Calendars > Time Zone Override (near the bottom under the "Calendars" section). If Time Zone Override is turned off, "events will display according to the time zone of your current location." I don't know for sure if the "location" it's talking about is determined by the "Time & Date" settings mentioned in Jason's response or some other calculation (GPS, Cell Signal, etc.). I'm thinking that if you turn off the feature to automatically set your time zone, it may affect your calendar as well.
    Possible Alternative Solution...
    My iPhone and iPad calenders sync with my Google Calendar, so this may be a whole different circumstance, although I encountered the same problem you're having where any appointments I created on my iPhone 6 (and suddenly on my iPad Mini as well, which created events properly before) listed the GMT Time Zone instead of my own. I checked the settings mentioned above, and checked the Calendar Time Zone settings directly in my Google account and all was correct... except for the iOS Time Zone issue displayed on the iOS Calendar. So, I created a new event in the iOS Calendar, and when I set the time for the event I made sure to change the Time Zone setting to my current/correct Time Zone, and then hit Done. After doing this a couple of times and changing/correcting the Time Zone each time I created the new appointment, it now uses the correct Time Zone for new events on both my iPhone 6 and on the iPad Mini as well, as if it synchronized the two back to the correct Calendar Time Zone settings. I suspect it had something to do with the fact that I set up a new iPhone on my account recently, but I don't know for sure. One question for you is whether you set up, restored, or added any new iOS devices to your account recently. It may or may not make a difference, but it's worth checking into. Good luck!

Maybe you are looking for

  • How do insert files into one song in Auditions?

    I have six edited music files and I want to place them all into one file to run in PowerPoint. How do I do that? Thanks.

  • Goldengate setup

    Hi I am setting up goldengate. I am fairly new to oracle. On th einstallation guide step 4.8.1 it is referring to extract user name, i do not recall making such user or is this the goldengate user? also what are the 4 other user names in the db for g

  • Redo log files are not applying to standby database

    Hi everyone!! I have created standby database on same server ( windows XP) and using oracle 11g . I want to synchronize my standby database with primary database . So I tried to apply redo logs from primary to standby database as follow . My standby

  • Table names to find Program names and Table names

    Hi All, I want to find Program names and Tables names where Transaction codes are not been created. If TCodes are created I can find from TSTC. But programs and tables which does not have tcodes. How can I find them?

  • Signature électronique Adobe READER

    Bonjour, J'ai lu attentivement le didacticiel concernant l'utilisation de la signature électronique d'Abobe Reader (j'ai la version XI) mais je n'ai pas compris comment m'en servir pour mon utilisation. Dans l'entreprise où je travaille je souhaite u