Best way to have only one  instance of an object in web application.

Hello,
I defined a class that provides services to my web application: subscribes user, check if user already subscrubed etc. The objects don't need to save any session information. So it is like a Stateless Session Bean (from what I've read about Session beans).
The webapp is small and I don't want to use EJBs.
What would be the best way to have one instance of the above class in my webapp ?
Would making the class static be a good method ? Using a factory ?
Is there a way to put in web.xml something that asks the container to instantiate an object that is not a servlet and place it in Application scope, so that I cann retrieve it whenever required in my app ?
Other suggestions ?
Thank you,
Vlad.

Hi
The best way to have only one instance is use the singleton pattern. The idea is : the class has a private
contructor, a public static method that returns an instance of this object and a static member that is false if not any instance and true if there si an instance.
To obtain one instance you can do some like
MyObject ob=MyObject.getIntance();
this method inspect the static member and returns null if true. If false set to true and return the object
via the private constructor.
You can lear more at book of Gramma .... (gang of four)
Hope this helps

Similar Messages

  • Best way to push change data from sql server to windows/web application

    i apologized that i do not know should i ask this question in this forum or not.
    i have win apps which will load all data initially from db and display through grid but from the next time when any data will change in db or any data will be inserted newly in db then only change or newly inserted data need to be pushed from db side to
    my win apps. now only sql dependency class is coming to my mind but there is a problem regarding sql dependency class that it notify client but do not say which data is updated or inserted.
    so i am looking for best guidance and easy way to achieve my task. what will be the best way to push data from sql server to win or web client.
    there is two issue
    1) how to determine data change or data insert. i guess that can be handle by trigger
    2) next tough part is how very easily push those data from sql server end to win apps end.
    so looking for expert guide. thanks

    Hello,
    Yes, you can create DML trigger on INSERT and UPDATE to get the changed data into a temp table. And then query the temp table from application.
    If you are use SQL Server 2008 or later version, you can also try to use
    Change data capture, which
    can track insert, update, and delete activity that is applied to a SQL Server table and store the changed values on the Change Table.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Had problem with DSL, now have only one tab with favicon matching that tab.

    After a storm I had a problem with my U-Verse DSL. I lost access and got a message that it may be due to a problem with the filters on my phones, fax or satellite box. I disconnected all the items that had filters. I was then able to click on a link that AT&T had sent on the message and I got a response, I previously could not get a response because I had no connection. I got pack to the pages on all my tabs by hitting the back arrow on each one. I now have only one tab with favicon matching this WEB site for that tab, the rest all have the AT&T globe. I tried refresh and also opening a new tab and then going to one of the sites.
    This problem is on a different PC that the one I am on now. It has version 21, and is Window 7 Home Premium. I have pasted the trouble shooting info from that PC.

    Hello,
    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    Did this fix your problems? Please report back to us!
    Thank you.

  • Hi...I have 4 folders in my MobileMe Gallery.....but only one is shown in Aperture under WEB. Anybody who can help? best, Per

    Hi...I have 4 folders in my MobileMe Gallery.....but only one is shown in Aperture under WEB. Anybody who can help? best, Per

    Hello Per,
    did you create the other Mobile Me galleries in iPhoto? If I remember correctly. you can manage each web album only in one application, either Aperture or iPhoto. I cannot test it any longer, since I upgraded to iCloud, but it used to be possible to assign the application (iPhoto or Aperture) for each album when you log into Mobile Me and select the album.
    Regards
    Léonie

  • Getting Error :- Only one instance of COBRAS Export can be running at a time

    Hi All,
    I was checking the Briefcase Mode help file and it mentions for Unity Conection
    that COBRAS will run multiple instances of itself – if you schedule multiple backups to fire up at the same time they will all run at the same time.
    However if I schedule multiple backups to fire at the same time then I get the error :- "Only one instance of COBRAS Export can be running at a time".
    This also happens if the COBRAS windows is left open and the scheduled backup starts in the background.
    http://www.ciscounitytools.com/Applications/General/COBRAS/Help/COBRAS_Briefcase/COBRAS_Briefcase.htm#_Toc276653845
    I am not sure if I am making a mistake in understanding the statement :- "COBRAS will run multiple instances of itself – if you schedule multiple backups to fire up at the same time" or do we need to add any switch like lot of other application need like /m etc in the field of the scheduled backups as I see as /silent switch for process to run in background automatically but none for multiple instances.
    I am attaching the screen shots of the errors I got when
    A.) I scheduled 2 backups to run at the same time and the COBRAS application window was open "COBRASExportCUC7.exe" was running  and no backup took place and got errors for both the scheduled backups.
    And
    B.) I scheduled 2 backups to run at the same time and the COBRAS application window was closed off and "COBRASExportCUC7.exe" was not running and one of the scheduled backups started to work and the other one gave error and didn't work
    Unity Connection in use :- Version 8.0.3.20000-18
    Cobras Export :- Version 1.0 Build 76
    Please Suggest.
    Regards,
    Prad
    (E-Mail :- [email protected])

    Yeah, I’m of two minds on that – on the one hand it’s bad style to have a scheduled application popping dialog boxes (especially if you’re running as an account you don’t log in as regularly) – one the other hand I did have some sites go a while not noticing backups were failing (due to a UNC not flying any longer after a server reconfig) – folks can be bad about checking log files or the event log for issues.  A pop up would pretty much guarantee they’d notice on next login at any rate.
    I think I may stitch in email notifications in COBRAS Export in the same way they’re in the User Data Dump so failures of scheduled backups would be noticed right away (big, bright email in your box saying “failed!” would do it). 
    Either way, I’ll update the help and make sure it fails quietly for now when I update some other items on the site middle of next week.
    Thanks for the report.

  • PAR iView: Only one instance need to be opened by a user in a portal sessio

    Hi All,
      Please  let us know how to enforce only one instance of PAR iView is opened at a given time for a user.
    Regards,
    Gangadharayya.
    For Eg: let us say We have created PAR iview <b>A</b>. Once user <b>U</b> logs in to portal and opens A by clcking on iView link(Let us say that it opens in New Window).
            If U clicks once again on A iView link now , it is opening in one more new window.
           How to stop this scenario i.e. when user tries to open A once again, it should clsoe previous window or SOMETHING LIKE THAT

    Hi,
    How do you link to IView ? If you link with html like
    <a href="http://www.sap.com" target="_blank">SAP</a>
    try to use a target parameter
    <a href="http://www.sap.com" target="sap">SAP</a>
    If you link in this way,
    First time user clicks link,
    It opens new window
    If user clicks the link second time it just refreshes previous opened window.
    Regards
    Abdul.

  • Consumer Group/Resource Plan to use only one instance of a RAC

    What would be the way to create a Consumer Group/Resource Plan to use only one instance of a RAC? I have 10.1.0.5 database
    running on 10.1.0.5 RAC.
    Thanks,

    You should use "services" to limit workload to just one specific node of RAC:
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10739/create.htm#sthref400

  • Why we have only one log writer in oracle

    Why we have only one log writer in oracle while we have more than one DB writer and archiver in oracle.

    skvaish1 wrote:
    Was this a interview question? Looks like to me..
    High DML allows multiple log writer processes as well by spawning multiple log writer processes.
    No - there is only one log writer process per instance.
    Don't confuse the function of I/O slaves with the function of the log writer.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Display only one instance if value is repeating

    hii everyone,
    i have a requirement i want to show following data
    no name
    1 a
    1 b
    1 c
    2 d
    2 e
    3 f
    3 g
    3 h
    in this form
    1 a
    b
    c
    2 d
    e
    3 f
    g
    h
    i.e if elements are reeating then show their only one instance
    i am using oracle 11g is there any way to write this on sqlplus??
    thanks

    Hi,
    810345 wrote:
    i am using oracle 11g is there any way to write this on sqlplus??The SQL*Plus command is
    BREAK   ON  noAfter you give this command, if the first column in the output is called no, then SQL*Plus will not show it if it is the same as the value on the line right above it.
    You may have noticed that this site noramlly compresses whitespace.
    Whenever you post formatted text (such as query output) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to restrict only one instance of web service running at a time

    Hi All,
    Have a requirement to ensure that only one instance of java web service is active at any point of time.
    Using Application Server 10.1.3.4. Not the soa suite.
    Thanks
    Saikrishna

    Thanks for the reply..
    I have a java web service that pulls up some files produced periodically from remote machine and uploads them to some doc mgmt system and then update the database that what files are uplaoded successfully so that during next run it will ignore those files.
    so, if my web service executes second time before completion of first run. It would pick files that were already processed by first run since the first run might have not updated the databse yet.
    Thanks
    Saikrishna

  • Way to rollback only one row of a view object

    Is there a way to "rollback" only one row of a view object? That is, two or more rows have been modified but we wish to only restore one of the rows to the original (database) values.
    Is there a way to retain all of the current rows in all of the view objects for an application module after issuing a jbo:Rollback?
    Thanks

    Is there a way to "rollback" only one row of a view object? That is, two or more rows have been modified but we wish to only restore one of the rows to the original (database) values.In jdev903, a new method is being added to Row interface to reset the row state to the transaction-original state i.e., rollback the row to it's original values.
    Is there a way to retain all of the current rows in all of the view objects for an application module after issuing a jbo:Rollback?No. You may however override before/afterRollback methods on the ViewObjectImpl subclasses to cache the current row key in beforeRollback and restore currency on the default iterator to that rowkey in afterRollback
    Thanks

  • Instead of creating multiple Instances I want to create only one Instance.

    Hi Everyone
    Good morning, How are you.
    I have a requirement to transfer files from one location to another location, I am able to do this successfully using FTP Adapters.
    I have some Issues please help any one.
    1) When I deployed my process it is creating one instance for one file transfer, Suppose If I have 50 files in my Get
    directory, After deploy the process 50 instances are creating and 50 Email generating saying files are not tranfered successfully.
    Instead of creating 50 Instances I want to create only one Instance.
    2) When files are not transferd it will fire error mail saying that not success (I want to display all file names(not tranfered files) in my mail , i.e whatever files are not tranfered, need to diplay in mail).
    3) And I am not able to transfer 0 size files, But in BPEL Console Instance is creating for 0 size file also and I am getting Email for success... and In put directory 0 size file is not showing. (Instance is creating and Success Email coming but file is not exists in Put directory)
    Please help me.
    Regards
    Venkat
    Edited by: user10263255 on Oct 1, 2008 8:10 AM
    Edited by: user10263255 on Oct 1, 2008 9:15 AM

    Hi Dharmendra,
    Thanks for your reply.
    I am not able to see any thing about singleton process in mentioned URL.
    Can you please provide me the another URL or please paste here about singleton process .
    Thanks in Advance.
    Regards
    Venkat

  • What is the best way to have access to OSX and OS9 from the same machine?

    What is the best way to have access to OSX and OS9 from the same machine?
    Do I need to partition the hard drive? Installed both Tiger and OS 9 on the G5 and it is having problems starting up properly.
    G5   Mac OS X (10.4)  

    And here is the prove for Edwin's message: Macintosh: Some Computers Only Start Up in Mac OS X

  • Allowing only ONE instance of a PDF to be open

    I'm trying to work out a new system for proofreading and commenting in our business using the Comment and Markup tools in Acrobat 8 Professional. I'd like to allow multiple users on a network to interact and markup a PDF easily. I'd like to make it so that one of two things can happen:
    a) Only one instance of a PDF can be opened at once on the same network. That is to say, if a user on one computer opens a PDF, another user on the network on a different computer cannot open that same PDF at all, until the first user has closed it. Also, I'm not sure if the functionality for this would be implemented in Acrobat or the operating system (Mac OS X 10.6, to be precise).
    b) Multiple users can open a PDF simultaneously, and markups and comments from all users are somehow saved.
    I'm sure it's more of a possibility for a) to happen, but perhaps I'm wrong. Anyway, I hope there is a solution out there! Thanks for all your help!

    George,
    Thank you for your helpful reply. It does appear that Shared Reviews is capable of providing our business exactly what we need in this regard. I have found that Acrobat 8 does support Shared Reviews, but it only does so with Network Folder locations and WebDAV folders as locations for comment servers. I know how to get to the process to set up Shared Reviews, but not how to designate or set up a folder as a comment server using Network Folders or WebDAV. Unless you just so happen to know about that process as well, I will post a new thread, since the problem of finding a solution has been solved, but the new problem of implementing it has risen.
    Although using Acrobat X Pro to share PDFs and collaborate automatically using Acrobat.com sounds mighty tempting...

  • Only one instance in a RAC will start at a time

    All:
    I have a 4 node Oracle RAC running on RHEL AS 4 64 bit. 10.2.0.1 64 Bit
    This DB was running just fine last week.
    Now all of a sudden only one instance will start.
    In the alert log I get an ORA-1102
    crsctl shows everything good
    srvctl show all node apps running
    srvctl shows all ASM instances running
    When the second instance starts the alert log shows the reconfiguration taking place.
    Then the second instance will die after getting an ORA-1102.
    I have tried deleting and re-adding all the instances with DBCA.
    ocrcheck comes back fine on all nodes.
    I have another RAC on the same set of HP Blades that is still hunky dorey so I don't know what is going on.
    Please help.

    Hi,
    check the value of cluster_database parameter
    it should be TRUE on all instances, also post ur alert log and trace file.
    Thanks
    Kuljeet

Maybe you are looking for

  • Upgrade from Server 10.4.3 - 10.4.4 hosed login

    I just upgraded a server from 10.4.3 to 10.4.4 (and then 10.4.5). After the upgrade, I can't get to the login panel. Besides not being to login at the server it seems to be running normally (web server, mail server, etc. functioning). I can login rem

  • Service entry sheet quantities and UOM not flowing into accounting document

    Hi All, I have a problem at the moment where the quantities and unit of measure entered in a service entry sheet, are being changed to '1 ACT' for all line items in the accounting document. We would like the real quant /UOM to be transferred here. We

  • How to build projects of ADF application

    I need to use ANT to deploy EAR file to weblogic 10.3.5. I download source code from SVN. Then, in the Jdev 11.1.1.4, I create build.xml and build.properties for Model and ViewController using Jdev . Then, I delete all this application and re downloa

  • Passing int[] parameter to PL/SQL stored proc via SQLJ

    This should be easy. I want to pass an array of Java integers i.e. int[] as an IN parameter to a PL/SQL stored procedure that expects a TABLE OF INTEGER. But SQLJ keeps giving me an error when I try to call the procedure, saying that int[] is an unsu

  • WRT54G Ver 6 Constant Need To Reset!

    I purchased a WRT54G Ver 6.0 Router in April to bring to Iraq with me.  I have it connected to my iDirect 3000 Satellite Modem, with the static IP config input into the WRT54G. I have two computers on my desk, my personnal XPS 1710 with Vista and my