Best place to put startup code in EJB deployment?

Hi,
I'm working on an application which involves timer services and JMX, and I'd like to ask for your opinion on how to deal with startup of those services in an EJB deployment. If you dealt with those issues before, I'd appreciate it if you could share your experiences/best practices on the subject.
Timer services need to be started, and MBeans need to be registered with the MBeanServer, so I'd like to see how can this be done upon application deployment.
I'm using Sun Server as an EJB server.
Thanks,
Mark

Since the ejb spec doesn't define an application initialization event, the only portable way of doing this that I've heard of is to use the ServletContextListener.contextInitialized() event to send a message to an MDB within the same application. Since EJB Timers are persistent and their identity is tied to a particular application component, the MDB's onMessage method can use getTimers() to see whether the timer already exists. If not, it's the first time the application has been deployed.
I agree the auto-creation of timers upon deployment would be a good addition to the spec :-)
--ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Best place to put validation code?

    Hey,
    When using jsp and html forms for passing information from the
    client to the server, where should i put the validation code? Is
    it better to put the code in the bjc4 classes or to make some
    FormHandler.jsp which checks wheter correct values/types typed
    in the form by the user?
    If i put the code in the bc4j classes, how can i then interact
    with user, when he makes an error?
    thx

    The question is the classic stand off between resuablity and
    modularity and user interface.
    If you put the validation code in the client (jsp) then the user
    sees the error quickly and it is relatively painless. However,
    if the rules change, you must change ALL of the clients that
    enforce that rule.
    If you put it in the middle-tier then there is the delay in the
    user feedback. The middle-tier will only validate the code on
    some sort of post. However, your validation code will be in only
    one place and therefore easy to maintain over time.
    So what's the solution. I suggest for JSPs a combination. If the
    rule is a real business rule then it needs to be validated in
    the middle-tier. If it is something that is prone to user typing
    error and is simple enough to be enforced within html, then it
    should go there also. You must remember that those client based
    rules can spread and your maintenance effort will go up.
    Gary
    JDev Team

  • Where is the best place to put custom functions?

    Hi,
    I have a composition which has a number of symbols. I have to call some custom methods externally and was wondering where is the best place to put the custom methods?
    I have seen posts that I should put the code in the CompositionReady event of the stage but I would like to put it a bit closer to the symbol.
    Is this the best place?
    Sham.

    Here is a case:
    It's a good idea if you well understand global and local variables.
    About complete event, you are right.

  • Where is the best place to put cfqueries?

    Where is the best place to put cfqueries, in the <head> </head> or before the html tag? Thanks

    So before the doctype tag? Thanks
    I just doesn't really matter.  the doctype, head, body, etc only matter to the browser; the CF tags only matter to CF.  The browser doesn't see the CFML, and CF doesn't care about the mark-up one bit: it just ignores it.
    The best place - as I said - is not in the same file at all.  But if you insist on slapping your business logic in with your display logic, then the only consideration is that you need to set your variables before you use them.  Other than that: it simply doesn't matter.
    One consideration you might make is - even if it's all thrown into the same one file - at least separate the file itself into sections: have all your CFML code that gets your data at the top, and try to limit the CFML you have mixed in with the mark-up, eg: limit it to stuff like loops and conditionals.
    But, seriously, separate your concerns.  Dan's pretty much just wrong when he said it's over-engineering. It's just sloppy to not to write tidy, well-maintained, well-organised code.
    Adam

  • Best place to put cffunctions?

    Hi All,
    I've created a cffunction which I need to access more or less from every page. Where is the best place to put it?
    Can I put it in the Application.cfc? If yes how, and how can I call it from a page?
    Thanks!

    ianskinner wrote:
    Just realize if you are putting the function into the session scope, each and every user is getting an entire copy of the function in the server's memory.
    Depending on the purpose of the function and how you are using it, this may or may not be a lot of memory used up unnecessarily.
    If the function is something that each user does not need their very own copy then it might make more sense to put it into the application scope.  Then there would be one copy of the function that all users utilize.  You could, of course, do that in the OnApplicaitonStart() function of the Application.cfc.
    I agree with Ian that Dan's advice in this case is suboptimal.
    The only things that should go in the session scope are things that specifically related to the session.  Which is not the case here.
    Adam

  • The best place to put the global parameter

    hello:
    i am now studying the petstore1.3,and find that the global parameters are kept in the servlet context,i wonder if it is a good solution.in my project,i seldom use the servlet context,session context etc,i feel more like to put the global parameter in a singleton that is loaded when the app is started. i don't know where is the best place to put the global parameter,servlet context or singleton?

    thanks for your answer.
    1 do your mean that the singleton can be shared among the different "war"
    packages if both of them are within the same jvm?if yes,must they be in the
    same "ear" package?
    2 if my app is deployed in the weblogic cluster environment,which one can be
    shared? singleton or servlet context?

  • Where is the best place to put programs to start on X/Openbox startup?

    Hi,
    There are several places to put programs to startup when you start X or a WM.  I'm using Openbox and presently have placed these into my .xinitrc file, but I'm not sure this really the best place.  Openbox has a autostart file, which sorta looks like a better bet.
    Any suggestions would be great.
    Thanks,
    Jon

    Hadn't heard of consolekit; it's not clear to me from looking at their website what it's supposed to be offering? Maybe after it matures more, the documentation will improve, and all will become clear.
    When I used Openbox, I just launched everything such as conky from the Openbox autostart file. I guess if you had a weird set up such as some of your Openbox configs sitting on unmounted partitions, their mount commands would go in .xinitrc, otherwise autostart.sh seems better.
    Just IMO of course, do what you want on your own machine :-)
    Last edited by /dev/zero (2011-10-27 21:04:37)

  • Best place in VOimpl java code to call a stored proc to populate results

    Hello all,
    Using JDev 11g, ADF BC and Trinidad.
    I am building an application that is primarily used for searching large amounts of data. We already have stored procedures on the database that perform the searches and dump the results into a holding table (together with a "search id"). I have easilly built a prototype of this application: my view object is simply "select a, b, c from results where search_id = :bv" - I have a service method in the AM that runs the stored procedure, obtains the search ID, binds it to the :bv in the VO and executes the VO's query - it's all working really nicely. Range paging is effective, the VO itself performs well, and I am able to control how long the stored proc runs via setting a timeout value.
    Now, I'd like to generalize this. My thinking is this:
    1). I'll add a custom property to my VO that is the SQL statement needed to call the stored procedure.
    2). I'll add some bind variables to the VO to represent all the query parameters that can be passed to the stored proc. I'll also use custom properties to indicate these are "fake" bvs, and not in the SQL query itself.
    3). The VO's SQL will remain simply "select a, b, c from results where search_id = :bv"
    4). I will (have already tested) override bindParametersForCollection so that the "fake" bind variables aren't bound into the SQL.
    Now, the question: I want to override some method in the VO's java code to call the stored procedure. The stored proc needs to be called before the actual query for the VO is run, and also before the method getQueryHitCount is called (so that the count is correct). What is the method that would be the "best" place to do this? My current thinking is that I would put the call in an over-ridden executeQueryForCollection call. As far as my analysis has gone, it seems to be always called before getQueryHitCount, but I have no way of knowing if this is completely safe.
    Any thoughts from the BC experts out there?
    Best regards,
    John

    John,
    from your description I understand that you essentially program the VO yourself. So I suggest that you read chapter 35.9 of the 'Fusion Developer’s Guide for Oracle Application Development Framework' (I guess you know where to find it). Since you still call the actual SQL not all of the chapter apply, but you get the idea how it works.
    And yes you analyzed the behavior correct. executeQueryForCollection() is allways called bevore getQueryHitCount().
    Timo

  • Right place to put external datafiles accessed from deployed code

    Hi
    Our application needs to access data files (text files of thousands of records).
    Which is the best place to keep them on the WLS.
    I have tried the following
    1. Placed them in APP-INF/lib directory.
    The files are accessed in code by following code::
    URL url = Thread.currentThread().getContextClassLoader().getResource("MYFILENAME.DAT");
    BufferedReader brw = new BufferedReader(new InputStreamReader(url.openStream()));
    But i always get brw as null
    Also tried using the method getResourceAsStream("MYFILENAME.DAT"). But got the
    same error
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    InputStream is = cl.getResourceAsStream("BANKFILE_20030607.DAT");
    BufferedReader brw = new BufferedReader(new InputStreamReader(is));
    here also a NullPointerexception is thrown while creating a BufferedReader
    What is the best strategy to keep such files in a WLS environment.
    We could not pack them as part of ear as these data files would be very large
    running into MBs
    OR is it common to have such packaging in EARs ...
    We also want to avoid accesseing them from an absolute path reference. The best
    bet being the classpath
    thanks
    jaz

    Only .jar files in APP-INF/lib are part of the classpath.
    If you put them in APP-INF/classes, that should work.
    -- Rob
    jasmeet wrote:
    Hi
    Our application needs to access data files (text files of thousands of records).
    Which is the best place to keep them on the WLS.
    I have tried the following
    1. Placed them in APP-INF/lib directory.
    The files are accessed in code by following code::
    URL url = Thread.currentThread().getContextClassLoader().getResource("MYFILENAME.DAT");
    BufferedReader brw = new BufferedReader(new InputStreamReader(url.openStream()));
    But i always get brw as null
    Also tried using the method getResourceAsStream("MYFILENAME.DAT"). But got the
    same error
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    InputStream is = cl.getResourceAsStream("BANKFILE_20030607.DAT");
    BufferedReader brw = new BufferedReader(new InputStreamReader(is));
    here also a NullPointerexception is thrown while creating a BufferedReader
    What is the best strategy to keep such files in a WLS environment.
    We could not pack them as part of ear as these data files would be very large
    running into MBs
    OR is it common to have such packaging in EARs ...
    We also want to avoid accesseing them from an absolute path reference. The best
    bet being the classpath
    thanks
    jaz

  • Place to put a code for dunning level change in F150

    Hi,
    I have a requirement to block the credit management of a customer ( KNKK-CRBLB) when dunning level of a customer reaches 3 (KNB5-MAHNS or MHND-MAHNS).
    I put my code in FM 'CHANGE_DUNNING_DATA'. But this  FM is executed only for the few cases. Reasons are unknown to me. It may be because this FM is called in another FM 'PRINT_DUNNING_NOTICE'.
    I believe that dunning is completed when the dunning notice is successfully mailed, faxed or printed. Then only the customer master is updated.
    The program for F150 is SAPF150V. But neither KNB5 or MHND is updated in this program.
    I tried BTE's also. But none of the BTE's is called when a dunning notice is printed.
    I am not able find the place where i can put my code.
    Kindly help..!!!!

    Hi
    With the field that I told you in OVA8 you can achieve to lock some SO or delivery because the customer has some level in dunning (it's updated from F150 but you can change it in customer master). To know BTE's in dunning see SAP Note 156985 - Reference Note: BTE for dunning, but I have doubts that it will help you
    Regards
    Eduardo

  • 2 HD laptop setup - Best place to put Catalog, Cache, and Images??

    If I have two 500GB 7200rpm hard drives in my MBP, what is the best place for LR3, the catalog/previews, ACRcache, and the image files themselves?
    SATA3 connection for both HDs
    Should the boot drive hold the app and cache, while the second drive hold the files and catalog?
    Should the catalog and cache always stay on the same drive?
    Does it matter at all where the image (raw) files sit?
    Thanks!!

    I'd just keep the images on a different drive with a 2 internal drive setup.

  • Where is the best place to put music for itunes

    I have just downloaded Itunes
    I have a lot of music I want to add to the Itunes Program
    Where do I store the music I have in the Windows 7 there is a folder called music
    do I place all the folders into this (Music Folder)
    and then have Itunes find the music folder and add them into the program
    Is the best way to do it.
    Over time I will add more songs do I just keep placing them into the music folder and have Itunes fiund the new songs and add?
    I need your assistance
    THanks
    Mike

    iTunes will not find files, you need to add them to your library.
    launch iTunes, go preferences > advanced and verify the copy files ... when adding and keep ... organized options are checkmarked.
    next, look inside the iTunes folder for a subfolder called automatically add to iTunes. drop your music files in there. when iTunes has finished adding the files to your library, you may delete the original files.

  • Best place to put shared folders

    Switching from pc to mac. In windows you have a "shared folders" folder for all accounts and under each account a public shared folder. Where would I put the "shared folders" folder? at the HD root?

    I usually recommend the bootdrive -> Users ->Shared folder.

  • Best place to put the event listener?

    Hey there!
    I am loading several images using a loop. My question is, would it be better to put the "contentLoaderInfo.addEventListener(Event.COMPLETE..." in the loop so it loads the compelte handler each time it goes through the loop, or is it fine to put it outside of the loop at the end?
    Also, could you explain the reason for your answer?
    Thanks!

    alright. here is what I have:
              public function placePictures():void {
                   private var imageURLs:Array = ["images/1.jpg","images/2.jpg","images/3.jpg","images/4.jpg",
                                         "images/5.jpg", "images/6.jpg","images/7.jpg", "images/8.jpg",
                                         "images/9.jpg"];               
                   var ba:Array = new Array();
                   ba.push(b1,b2,b3,b4,b5,b6,b7,b8,b9);
                   for(var i:uint=0;i<ba.length;i++) {
                        trace(name + ba[i]);
                        ba[i].name = i;
                        imageLoader = new Loader();
                        imageLoader.load(new URLRequest(imageURLs.shift()));
                        //HERE...///////////////////////////////////////////////////////
                        //imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
                        imageHolder = new Sprite();
                        imageHolder.graphics.lineStyle(5, 0x000000, 100, false, LineScaleMode.NORMAL, CapsStyle.NONE, JointStyle.MITER);
                        imageHolder.graphics.drawRect(0, 0, 180, 100);
                        imageHolder.addChild(imageLoader);
                        if (i<=2){
                             imageHolder.x = 250 + i * 300;
                             imageHolder.y = 0;
                        } else if (i<6) {
                             imageHolder.x = 250 - 900 + i * 300;
                             imageHolder.y = 200;
                        } else {
                             imageHolder.x = 250 - 1800 + i * 300;
                             imageHolder.y = 400;
                        ba[i].y = 230;
                        ba[i].x = 0;
                        ba[i].buttonMode=true;
                        ba[i].addChild(imageHolder);
                        peHolder.addChild(ba[i]);
                        ba[i].addEventListener(MouseEvent.CLICK, onButtonClick);
                   //OR HERE...//////////////////////////////////////////////////////////////
                   imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
              public function loadCompleteHandler(e:Event) {
                   trace ("load complete handler loaded");
                   imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadCompleteHandler);

  • Sequence of startup classes and EJB deployment

    The default sequence when WLS is starting is deploying EJB first and then startUpClasses. Could someone tell me if it's possible to change the sequence.
    Thanks a lot in advance.

    Sure have your startup class do its work and then hot-deploy the EJB.
    -- Rob
    Jack wrote:
    >
    The default sequence when WLS is starting is deploying EJB first and then startUpClasses. Could someone tell me if it's possible to change the sequence.
    Thanks a lot in advance.

Maybe you are looking for

  • Another Printing Question

    I have a customer that using Loftware for label printing.  The software uses and RFC listener to receive print requests initiated by SAP.  The documentation states "Similar to receiving IDocs, the [RFC] Listener will register with SAP.  This will tak

  • I ve deauthorized all my computer how do I add one

    Can anyone help ?

  • Method 'WriteRecord' of business component 'Contact'

    Hi All, I'm trying to upload data into CRMOD for contact object, I'm an Administrator , I'm using Stubs to create my SOAP XML. Below is the response i received. Can anyone help me on this. Its urgent. ERROR 1: <siebelf:errormsg_>Method 'WriteRecord'

  • New Command Doubt

    Hi, I have a doubt concerning new commands. When we add a command to the command list after duplicating a command group , where do we actually code for that command to work. Please forgive me if this doubt is a silly one. Also when we are doing in th

  • SQL SERVER 2014 DISASTER RECOVERY

    Hi All, Please let me know on below topic. SQL SERVER 2014 DISASTER RECOVERY