Initializing classes when the application starts?

Hi all,
I tried to figure this out myself but after loads of searching I found nothing, perhaps I haven't got the right search terms.
I have a web server written in Java with a BasePage class which is extended for each page in the application. What I would like to do is have each subclass automatically register itself with a static PageProcess class. The PageProcessor keeps a list of all registered pages, and can then check incoming requests against that list to decide which subclass should respond.
The problem is that constructors seem to only run when the class is first accessed, so the PageProcessor is never notified of these other pages. I used to have a hard-coded function that checked the requested url and then manually called a static boolean canHandle( String url ) function per-subclass, but as I get more pages this becomes a chore to update with more else if blocks.
Is there some kind of pattern or something I can apply to get this working? I'd like to avoid having a hard-coded list of pages to use in the application, but if that's the only real solution then I can go back to doing it that way.
Thanks,
Michael

Thanks for the reply. I had a look at doing that (via ClassLoader) as well as just checking for what .class files are present, this seems like a decent way of doing it. I had hoped that there would be a way to force the JVM to initialize classes right away rather than on first-access, but as it is I think the easiest solution will be to go back to having my static PageProcessor class have a list of all pages hard-coded.

Similar Messages

  • [Forum FAQ] Why does Office 2013 cost more network flow when the application starts by default?

    Recently, we’ve heard that our customers encounter high network traffic since they large-scalely deploy Office 365/2013 within the domain/site. Does this behavior relate to the new Office? Or does Office 365/2013 cost more network resources in this case?
    To troubleshoot this, we consider to analyze what happened during the process by Network Monitor tool. 
    Start a new capture first and launch Office Word 2013, get the following things as the screenshots:
    According to the information above,
    in addition to the network authentication flow, we could notice that the Word.exe would download a lot of PNG files from the link “/en-us/templates”. What about those PNG files?
    Let us try to directly visit them via IE:
    http://office.microsoft.com/en-us/templates/TM103463086.png?ts=AOLhIeGIzwg
    Beyond question, they are the thumbnails of the Office template which are downloaded while the Office application starts by default.

    In
    some certain circumstances,
    we might disable it by Office option or Group policy.
    Disable Start Screen by Office 2103 UI:
    Open Office 2013 application, go to File in Ribbon > Options tab > General page > under the section of Start Screen options, uncheck the options "Show the
    Start screen when this application starts"
    Disable Start Screen by Registry key:
    HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\General
    DisableBootToOfficeStart (DWORD): set the value
    to 1
    Disable Start Screen by Group Policy:
    Disable Start Screen by OCT:
    That's all. If you have any questions or concerns about this topic, feel free to post here.
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

  • Adjust Quicktime Volume Control when the application starts

    3Apr07
    I have a problem streaming program. Microsoft stopped supporting Widows Media Player for the Mac.
    Micosoft has a application FLIP4MAC-MWV which will either open a window in Safari or has the option of opening a window in Quicktime.
    My problem is: The volume level in Quicktime is too high when the stream begins. I use Wiretap Pro to record radio streams while I am at work. The default high volume distorts the recording.
    I have tried and tried again to change the default volume level to a middle level, but the stream starts at max volume. How do I change that?
    I also have the same problem with the Safari window level.
    Can anyone tell me how to adjust the default volume in Quicktime and Safari?
    Thank you for reading this post and greater thanks for any recommendations.
    Regards,
    Craig H. Henden

    14Apr07
    Thank you for you help. I actually don't use Quicktime-formated files or steams. I used to use Windows Media Player until the Wiretap Pro custormer support recommended I use Flip4Mac WMV to convert Media Player streams to Quicktime compatible. However, the volume is too high.
    I did try adjusting the Midi Sound controller. It did not have the effect when Quicktime starts-up.
    Most of the time I record using Windows Media Player or Flip4Mac, I am not home to adjust the volume.
    I will try adjusting the Midi control again. I wish Flip4Mac converted Media Player formated streams to Itunes. Wiretap pro works very well with itunes.
    Regards,
    Craig H. Henden

  • How to set the cursor in a text box when the application starts?

    Hi. It's me again. Its seems to me that there isn't any Spanish speaker, so I reformulate my question in English. What I want is to place the cursor in the text box so that the user can enter the text. Could anybody help me? Thanks in advance. MamenFLASH$

    Hi. I have Flash 2004 Professional, as 2. Any idea of how can I do it 
    by means of Java Script or action script 2? Thanks in advance. 
    MamenFLASH$
    El 23/01/2010, a las 21:22, kglad escribió:
    >
    you can do that when your flash has focus.  (how you do it depends 
    on your as version).
    >
    and while flash can't set focus on itself, you may be able to use 
    javascript to set focus on your flash.
    >

  • How to unfold all folders of AdvancedDataGrid when the application start?

    Is there a way to AdvancedDataGrid automatically show all your content?

    It might be worth checking in at the QuickTime-API mailing list about that, Manoj:
    http://lists.apple.com/mailman/listinfo/quicktime-api

  • IMovie '11 - when I open iMovie the application starts, but there is no window, If i plug in my iPhone the window will appear from the top right corner, but disappear again. HELP!?

    iMovie '11 - when I open iMovie the application starts, but there is no window, If i plug in my iPhone the window will appear from the top right corner, but disappear again, even if i use a drop down menu from the top menu bar and select, say 'New Project', it will appear from the top right corner, let me choose a new project, only to disappear again into that same corner.

    Argh I'm having the same problem! I always use imovie, and haven't had this prob before... apprantly imovie 11 is full of bugs like this. Anyone know if theres any way of downgrading?

  • You can't open the application Start.osx because PowerPC applications are no longer supported.

    what does this error message mean? I am trying to use a disc that came along with a book I ordered for studying. However, when I try and run it, this is the error message I receive. "You can't open the application Start.osx because PowerPC applications are no longer supported." Anything I can do to fix this and make it work?????

    Many educational CDs have not been upgraded due to lack of funds in the educational market to pay for such updates. 
    This situation is due primarily to the fact that one of the major political parties in this country favors tax cuts to the rich while cutting federal educational support funding (or eliminating the federal Department of Education altogether).
    However, you can restore Rosetta and run your educational CD if you install Snow Leopard Server ($20) into Parallels (up to $79) for use in Lion/Mt. Lion/Mavericks:
                                  [click on image to enlarge]
    More information here:
    http://forums.macrumors.com/showthread.php?t=1365439

  • Initialising class when J2EE server starts

    Hi,
    I am facing a problem. I wish to instantiate a class when the J2EE/ tomcat server starts. This is similar to the property set in weblogic as
    weblogic.system.startupClass.startup = <name of ur startup class>
    Here we can specifiy the class to be instantiated during startup of server.
    Can i do something similar in tomcat/ j2ee server?
    I do not wish to use a servlet since my webapplication contains jsps and other supporting classes and my own apis.
    Thank you in adv.
    ...supriya.

    if you use ServletContext Listeners you should be ready as far as web app is concerned. Most servers I believe offer JMX integration so that you can listen for server startups. : )

  • Executing a program when the server starts

    I have developed a chat program and to run it I have type "java ChatManager".
    Is there a way where this program can start automatically when I start the tomcat.
    Regards,
    Sharad

    The chat application is a java file. I need to keep it running so that I can use it in my applet. The problem is after I start the tomcat, I have start the chat application and for this I open a new window and type "java ChatManager". Once this is done I can start using the chat applet. Is there a way, where the chat application starts automatically when the tomcat starts. Do I need to add something in the server.xml file for this.
    Regards,
    Sharad

  • The application start is forbidden, because of....... Error

    Hi,
    We are trying to install SP10 but it didn´t work and the portal is not starting, this happened before and got solved but the guy who did it is on vacation :O(, the Error we are geting in the logs is this one:
    The application start is forbidden, because of the server mode and action
    Does any one has a clue on how to solve this?
    Thanx in advanced!

    Hi,
    We found the error, when installing the SP the J2ee engine went to Safe Mode, we set Safe Mode off and it is working again, thanx alot!
    Gerardo J

  • Bluetooth no longer loads automatically when the computer starts

    I have the Bluetooth Stack version 2.01.21.1. It was working fine. When the laptop booted up, the bluetooth mouse was automatically connected.
    All of a sudden the icon no longer appears automatically in the system tray and so I have to manually connect the mouse each time
    It is still listed in the startup menu on the desktop and it is still checked in startup in the msconfig.
    How do I fix this?
    Thanks in advance

    I have just gotten off the phone with a microsoft tech who actually seems to have fixed this somewhat
    He went to start/run to get to services.msc.
    He chose "SSDP Discovery Services" which "enables discovery of
    UPnP devices on your home network" and DISABLED it.
    Go figure
    The BT icon now appears in my system tray and starts up automatically when the computer starts.
    I say somewhat because It still disconnects if left idle for a long period, which it did not do previously, but at least it is there when I log on.
    I want to mention that I have a Dell, not a Toshiba (did not realize this forum was for Toshiba laptops rather than Toshiba software) but perhaps
    you will find this information useful.
    Also, at http://technet.microsoft.com/en-us/sysinternals/bb963902.aspx you will find an autorun tool that lets you fix what is or is not
    in the startup menus. It seems to work better than using msconfig which on my laptop was not making a difference as to what started up and what did not.
    It is meant for IT professionals so I would not mess with it too much. However if you just check or uncheck in the startups for the BT manager you will
    not do any damage.

  • I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.Not working in USA timezone.

    I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works fine in our side (Timezone,kolkata ,india even for Timezone,slvaniya,USA) but our USA client is telling that on changing the date it not starts from start-up sequence.Can anyone plz suggest the reason for it.

    This is the code which we have used.
    //////////Return if it is first time for the day or not//////////////
    + (BOOL)isFirstTimeToday {
    BOOL result = YES;
    NSDate *now = [[NSDate alloc] init];     /// represents the current time
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: now];
    NSDate *today = [gregorian dateFromComponents:components];
    [now release];
    [gregorian release];
    NSDate *savedDate = [[NSUserDefaults standardUserDefaults] objectForKey:LAST_TIME_VISITED];
    if (savedDate) {
    if ([today earlierDate:savedDate] == today) {
    result = NO;
    return result;
    ////////Stores the date/////////////
    + (void)userDidVisitReenforceScreenToday {
    [[NSUserDefaults standardUserDefaults] setObject:[NSDate todayAtMidnight] forKey:LAST_TIME_VISITED];
    ////////////What [NSDate todayAtMidnight] stores/////////////////////
    + (NSDate *)daysFromNowAtMidnight:(NSInteger)nOfDays {
    NSDate *date = [NSDate dateWithTimeIntervalSinceNow: (86400*nOfDays)];
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: date];
    NSDate *dateAtMidnight = [gregorian dateFromComponents:components];
    [gregorian release];
    NSLog(@"dateAtMidnight : %@",dateAtMidnight);
    return dateAtMidnight;
    + (NSDate *)todayAtMidnight {
    return [self daysFromNowAtMidnight:0];
    Please Suggest..

  • I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works with iPod not with iPhone

    I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works with iPod not with iPhone

    Try posting in the developer forums to see if you can get some assistance,you'll have to be a registered developer for access though.
    developer.apple.com

  • Can a subVI tell when the application it is part of has been stopped and restarted?

    Can a subVI tell when the application it is part of has been stopped and restarted?
    It is easy enough for a subVI to tell when it has been run for the first time after having been loaded into memory. But is there a way for a subVI to tell when the application it is part of has been stopped and restarted? Is there some property or application-invocation-specific refnum that when queried multiple times during the same run of the application would return the same value yet when queried during different runs of the application would return different values?
    I don�t want to depend on anything that happens when a run is exited.
    I don�t want to require code to be included in the main V
    I to accomplish the solution.
    (Otherwise I could, in the main VI create an un-named semaphore tied to a global; the subVI could then check the global to see if the value changed, which it would between runs of the application.)
    Any ideas?

    Have you tried the First Call? function? It's on the Advanced>Synchronization palette.

  • I have been dealing with crashing and freezing issues on my iMac for 6 months.  A supervisor has been assisting me but the issue is not getting fixed.  The computer was under when the issues started.  He wants to get us a new computer but is not allowed.

    Our iMac was under warranty when it began freezing and or crashing.  I have spent several hours on the phone with a supervisor and had the machine in 2x.  We have also had a repair done in our home.  The problems persist.  We feel apple owes us a new computer.   Help!!!

    Do you have a written record of your attempts to get it repaired?  When you took the machine "in" for repairs, did you take it to an Apple Store or to an Apple Authorized Reseller or Repair Facility, and do you have copies of invoices or statements showing what repairs were made?  If the answers are yes, you need to be persistent in attempting to get a new computer.  Ask to talk to the supervisor's supervisor to "escalate" the complaint to a higher level.  Get copies of all your repair information and send a letter to the Apple Customer Service people in California and ask them for help.
    If your iMac was under warranty when the problems started and the problems have not been resolved, your position should be that the problems should still be fixed or the computer replaced even though the warranty may have expired in the interim.  Do you live in the US?  If yes, your home state has a Consumer Protection agency.  File a complaint with them and ask for their assistance in mediating and/or resolving the matter.

Maybe you are looking for

  • Print dialog opens automatically

    Using Acrobat Pro 9.5.2 I have a two-page form. I only desire to print page two of the form upon a mouse up button event. I thought I had used this before: this.print({bUI: true, nStart: 1, nEnd: 1}); But this causes the print dialog to open when the

  • Print issue with eprint and iPad mini

    Eprint has stopped working on my iPad mini. It used to work fine. It says, "Photosmart C6200 series doesn't support this file type". Yet, I can print the same file from my iphone 5 s with no problem. I tried deleting and reinstalling. It didn't help.

  • Output from v$version

    Hello, on one of our databases i get the following when doing select * from v$version: BANNER Oracle9i Release 9.2.0.5.0 - Production PL/SQL Release 9.2.0.5.0 - Production CORE 9.2.0.6.0 Production TNS for 32-bit Windows: Version 9.2.0.5.0 - Producti

  • Any good books on Object Oriented Programming?

    I switched to ABAP Objects about a year ago and I must say after reading more about the concept I started to like it as it gives me more tools that procedural programming couldn´t easily accomplish. I'm planning on getting a book in order to incrase

  • Sorted list view slow.. OS9 is better..

    its when making a folder view option as a list view then sort it by date or size, the window refresh slow or it doesnt refresh at all, u still the same view even if theres more files came, or bigger file saved into that folder, like the finder forget