Best way to implement application level persistant objects?

I'm designing a J2EE application and want to create some objects that represent lookup tables in the database. I would like these to be static objects that get created either at application startup or the first time they are called and remain in application scope globally for all users/sessions. These are objects that contain lists used for drop-downs/listboxes. I don't necessarilly want to take up unecessary memory
and take a performance hit for each session by creating them new for each session. The question is what is the recommended design for this scenario? Should these be implemented as static Stateless Session beans with an application scope? Are there any examples on the best way to do this in J2EE?
Thanks.

You can simply (and properly) implement the Singleton pattern. Then multiple threads can all query the cached reference table values in the Singleton. Now, I know, that Singletons and J2EE are supposedly no-no's, but sometimes the easiest and simplest solution really is the best one. Perform the database query at startup in a static initializer. Then ensure that you do not have mutator methods (e.g., removeXXX(), setXXX(), addXXX(), etc.) Only provide accessor/getter methods. If you want to be able to refresh the cache without restarting the server, you will have to think about race conditions. But if you are implementing a vanilla cache, I would go with a Singleton.
- Saish
"My karma ran over your dogma." - Anon

Similar Messages

  • What is the best way to implement a cluster-wide object ID generator?

    What is the best way to implement a cluster-wide object ID generator?

    What is the best way to implement a cluster-wide
    object ID generator?Always use 3 because it is prime.
    Alternatively more information about the system and the needs of the system might prompt alternative ideas some of which are likely to be better than others for your particular implementation and system constraints.

  • Implement Transactions best way, in my application

    Hi all,
    I 'm currently developing an application, 3 - tire one, where its business services are exposed as web services, and those web services directly invokes DAO operations for data base operations.
    I have a question, what is the best way to implement transsactions in my application.
    Do i need to implement transactions in both Service layer as well as DAO layer ? if not is it enough to implemnt in only one layer?
    What are the disadvantages im facing if i implement TX in both layers?
    What are the techniques i have to follow, i mean, are there specific techniques to implement service level transactions compared to DAO transactions?
    can i use spring frameowrk? with AOP support?
    I'm really confused abt the way i should handle transactions, so ur reply will be a huge help for me... thanks in advance
    Thanks a lot
    saj
    PS : if this is not the correct forum to post this questions, could you please let me know the forum i should post this instead
    Edited by: sajhak on Jan 2, 2010 1:39 AM

    First step, what makes you think you need transactions at all. What business rule drives it?

  • Best way to implement a standard layout across application

    What is the best way to implement a standard layout across the application?  For example, I am converting an HTML/ColdFusion site to Flex and I need to keep the look of the existing site in the new Flex app.  I need a standard layout on every screen in the new app with a standard header, footer and left nav bar.  Do I need to add that code to every screen in the app or can I just create on layout file and call that into every screen?  Thanks!

    There a few that will help you, look for Form and validator.
    Sincerely,
    Michael
    El 16/05/2009, a las 14:01, lee704 <[email protected]> escribió:
    >
    Thanks.  Are there sample data entry apps in the Tour de Flex samples?
    >

  • Best way to implement a simple read of multiple stings from a db

    Hello guys,
    I am trying to read a collection of countries (Strings) into a collection inside a Movie object. The countries reside in a separate DB table with a FK referencing the Movie.
    My questions:
    1) What is the best way to implement this? Do I need a seperate entity 'country' ? Is there a general way to read many strings into a collection?
    2) the countries list does not have to be updated, only read. How do I make sure it is not persistent?
    I have noticed that in my JPA implementation (in netbeans) I do not have something like CollectionOfElements (that is present in hybernate).
    Thank you,
    Marek

    >
    My questions:
    1) What is the best way to implement this? Do I need a seperate entity 'country' ? Is there a general way to read many strings into a collection?
    Probably yes, you need to have one entity for country.for getting the right answer, Post it here - Enterprise Technologies - Java EE SDK (http://forums.sun.com/forum.jspa?forumID=136)

  • Best way to implement m to n relation?

    Could you please give me some advice on the best way to implement m-n relations in apex?
    Example: I want to store server and database info. A server can have multiple database of course. But in case of a RAC database, the database can be running on multiple servers. So I have tables:
    create table SERVERS (id number primary key, name varchar2(30));
    create table DATABASES(id number primary key, name varchar2(30))
    and an m-to-n table
    create table SERV_DB(serv_id number references SERVERS(id), db_id number references DATABASES(id), instance_name varchar2(30))
    So the table SERV_DB can tell me e.g. that database PROD is running on server 'prdsrv1' with instance PROD1 and on server 'prdsrv2' with instance name PROD2
    How would you design an apex page to maintain this information (adding relations, updating instance names, etc)? I have a solution using checkboxes and 2 for-loops over htmldb_application.g_f40 (to process checkboxes) and g_f41 (to process text fields with instance names) and some delete statements but the logic behind it looks too complex for me. I am convinced that this can be done more simpler. Seems like a common problem to me, so I wonder if there is no out-of-the-box solution in apex for this?
    Could you please show me or create a small demo application with the solution that looks most elegant to you?
    Thanks,
    Geert

    Thanks for your reply. You modified the question slightly, but conceptually it is still the same. What you call the instances table corresponds with my serv_db table. I understand the solution you propose using the tabular report. If I see it correctly, you would have an insert button above the tabular report for each new relation (instance - server) you would want to add. This is ok for the case i used (databases, servers, instances) because there are relatively few relations. However I would not like this solution for other cases. E.g.:
    case: you have a list of persons and a list of tasks. You want to assign tasks to persons in a way that each person has multiple tasks to do and each task can be assigned to multiple persons.
    Suppose you add a new person, and you want to assign 15 tasks to him. The solution above (with the tabular report) would be quite some work because you would have to click 15 times on the insert button and on each click select a task from the select list. In this case it would be more appropriate to, after selecting the new person, see a list of all tasks (e.g. 30 tasks) with a checkbox in front, so you can mark 15 out of the 30 checkboxes and press submit. It gets more complex when you want to assign also an attribute to the relation, i.e. showing the list with all tasks, a checkbox in front and a select list next to each task where you can choose from e.g. "priority high" or "priority low" to indicate that this task is high or low priority for that person. Is there an easy way to implement that?

  • Displaying Multiple Values on GUI components - best way to implement

    Hi,
    my program needs to implement a basic function that most commercial programs use very widely: If the program requires that a GUI component (say a JTextField) needs to display multiple values it either goes <blank> or say something more meaningfull like "multiple values". What is the best way of implementing it?
    In particular:
    My data is a class called "Student" that among other things has a field for the student name, like: protected String name; and the usual accessor methods (getName, setName) for it.
    Assuming that the above data (i.e. Student objects) is stored in a ListModel and the user can select multiple "Students", if a JTextField is required to display the user selection (blank for multiple selections, or the student "name" for a single selection), what is the best (OO) way of implementing it? Is there any design pattern (best practice) for this basic piece of functionality? A crude way is to have the JTextField check and compare all the time the user selections one by one, but I'm sure there must be a more OO/better approach.
    Any ideas much appreciated.
    Kyri.

    Ok, I will focus on building a solution on 12c.
    right now I have used a USER_DATASTORE with a procedure to glue all the field together in one document.
    This works fine for the search.
    I have created a dummy table on which the index is created and also has an extra field which contains the key related to all the tables.
    So, I have the following tables:
    dummy_search
    contracts
    contract_ref
    person_data
    nac_data
    and some other tables...
    the current design is:
    the index is on dummy_search.
    When we update contracts table a trigger will update dummy_search.
    same configuration for the other tables.
    Now we see locking issues when having a lot of updates on these tables as the same time.
    What is you advice for this situation?
    Thanks,
    Edward

  • Best way to implement a shared Blocking Queue?

    What's the best way to implement a shared Blocking Queue that multiple JVMs can enqueue objects in and multiple JVM's can dequeue from simultaneously?
    Also, I see references on the web to com.tangosol.coherence.component.util.queue.ConcurrentQueue but I don't see it in the current API docs...
    Thanks

    Hi snidely_whiplash,
    snidely_whiplash wrote:
    What's the best way to implement a shared Blocking Queue that multiple JVMs can enqueue objects in and multiple JVM's can dequeue from simultaneously?
    Also, I see references on the web to com.tangosol.coherence.component.util.queue.ConcurrentQueue but I don't see it in the current API docs...
    ThanksThat class is an internal class, AFAIK.
    As for implementing a queue, you might want to look at Ashish Srivastava's ezMQ component for some ideas:
    http://ezsaid.blogspot.com/2009/01/implementing-jms-queue-on-top-of-oracle.html
    Best regards,
    Robert

  • Best way to implement app wide process

    I am working on an application that has a list of art work in an sql report.. I want to be able to add each piece to a collection of items (which is stored in a table), so I added another column to the sql report to store the id of the art work. I am just wondering what is the best way to implement the process to insert the item to the collection of items. Since I want to do this from multiple pages - link from art work sql report; link from the edit page for a particular art work; and on the artists page where there is also an sql report, I thought it may be best to have an application process, to save duplicating the process on multiple pages.. however I don't think there's a way to pass the id of the item to the application process? as I was thinking best to have the application process conditional based on request, and then have the link as a doSubmit().
    So is it best just to have the link redirect to the same page, passing the id of the item, and then having a process that runs before header that inserts the item, then assigning the item to NULL?
    Thanks in advance,
    Trent

    Daniel:
    Thanks for the info. I have found that the IFRAME works nicely for some applications,
    however, some applications I want to re-write the front end to look better in
    the portal rather than screen scrape.
    Thanks for the help
    Ryan
    "Daniel Selman" <[email protected]> wrote:
    Ryan,
    Check out the thread (a few days old) titled "Different ways of creating
    portlets".
    Sincerely,
    Daniel Selman
    "Ryan Richards" <[email protected]> wrote in message
    news:3d2eda12$[email protected]..
    I have a few existing applications that I need to port over to portletsin
    Weblogic
    Portal 4.0. One application is a servlet based web application witha few
    html front-end
    screens. I am trying to determine how to do this in the best way. Ihave
    noticed
    that portlets behave differently inside the portal than do stand-aloneweb
    apps.
    Any help would be appreciated.
    The other web application is the Microsoft Outlook Web Access. (Thisone
    is going
    to be difficult because it is actually an ASP app. I dont know if thisis
    possible
    without building some proxy code between bea and iis.)
    Thanks
    Ryan

  • Best way to transfer application from Test Environment to Dev. Environment

    Hi All,
    We are try to create an application on Hosted Environment similar to www.apex.oracle.com.
    We got two work space
    1. app_production
    2. app_test
    My application will have 200+ tables and many other supporting object.
    My question is in hosted environment what is the best way to copy application from test to production environment (P.S In hosted environment I can uses SQL Developer / TOAD or any other tool .. its similar to www.apex.oracle.com)
    With my present workaround I have to use
    Go to Utilites -> Generate DLL
    and then export this and application..
    The main problem is 200+ table and associated structures .. its very difficult to keep track ...
    Can anyone suggest me any good way for HOSTED ENVIRONMENT

    Hi,
    Just an idea:
    1 - Do a DDL export of the source env
    2 - Do a DDL export of the target env
    3 - Use some tool to compare those files and highlight the differences. There are even some tools that are smart enough to generate SQL statements to apply the differences in the target env.
    I hope this helps.
    Luis

  • Best way to implement a docking container

    Hi everyone,
    I need to create a docking container that behaves the same way the draggable panel system works in Flex Builder (Eclipse):
    - Dock other containers to the edges
    - Automatically layout other containers when the dragged container is docked into/out of an edge
    Is there a custom control that would enable me to do this? If not, what's the best approach to create one?
    Thanks,
    Amir

    Hi snidely_whiplash,
    snidely_whiplash wrote:
    What's the best way to implement a shared Blocking Queue that multiple JVMs can enqueue objects in and multiple JVM's can dequeue from simultaneously?
    Also, I see references on the web to com.tangosol.coherence.component.util.queue.ConcurrentQueue but I don't see it in the current API docs...
    ThanksThat class is an internal class, AFAIK.
    As for implementing a queue, you might want to look at Ashish Srivastava's ezMQ component for some ideas:
    http://ezsaid.blogspot.com/2009/01/implementing-jms-queue-on-top-of-oracle.html
    Best regards,
    Robert

  • Best way to implement request-response and still reliability

              HI,
              what is the best way to implement a request -response paradigm and still have
              the reliability that message will be 100% processed and give response...do i need
              to create the permanant queues with storage..
              anybody gives suggestions..
              Akhil
              

    Hi Akhil,
              Temporary destinations can only store non-persistent messages
              as per JMS spec - so they are not useful for reliable for holding
              responses that must survive longer than the life of the
              interested client. For persistence, you will need to use configured
              queues or durable subscriptions. For detailed
              discussion of request/response, I suggest reading the "WebLogic JMS
              Performance Guide" white-paper on dev2dev.bea.com. If you
              have many clients, or expect large message back-logs,
              there can be a performance impact when using selectors...
              FYI: There is a new pub/sub subscriber index enhancement
              that is available in 8.1 and
              in the latest service-packs for 6.1, 7.0.
              "Indexing Topic Subscriber Message Selectors To Optimize Performance"
              http://edocs.bea.com/wls/docs81/jms/implement.html#1294809
              This may be useful.
              Tom, BEA
              Akhil Nagpal wrote:
              > HI,
              > what is the best way to implement a request -response paradigm and still have
              > the reliability that message will be 100% processed and give response...do i need
              > to create the permanant queues with storage..
              >
              > anybody gives suggestions..
              > Akhil
              

  • Best way to implement auto increment in JPA.

    What is the best way to implement auto increment in JPA so that it will support all databases such as MySQL, MSSQL Server, Oracle etc. ? Or is there any way to set auto increment strategy in common place such as persistence.xml? Please help...

    All JPA strategies require something (like a table or sequence object) be in the database, with table sequencing being the most portable, though EclipseLink does allow custom sequence stratgies where you could use something else, such as the UUID. Sequencing is described here described here http://wiki.eclipse.org/EclipseLink/Examples/JPA/PrimaryKey with a custom UUID example shown here http://wiki.eclipse.org/EclipseLink/Examples/JPA/CustomSequencing .

  • Best way to implement Aperture on a shared Mac

    I'm looking for some suggestions on the best way to implement Aperture on my work computer.  It's a 15" MacBook Pro Retina.  Since I don't own the laptop, can I just run Aperture from an external drive in case I have to give the computer up on short notice?  I have a 1 TB Lacie drive (USB 3.0) that currently holds a copy of all of my images.  I don't currently have Aperture, so this would be a completely new install.
    I know I can keep the images on the external drive as Referenced files, but what about the Library?  Can (or should) it be stored on the external drive?  If not, would a backup copy on the external drive (perhaps using Vault) be sufficient for portability?  For example, if I have to give the laptop back could I simply hook the Lacie up to a new MacBook, install Aperture, restore the latest Vault backup and be up and running?
    Any thoughts (pro & con) would be appreciated.

    If you use a fast drive with a relatively fast port (Thunderbolt, USB 3) you can keep your Aperture library on the external volume. But I would keep the Aperture application on the internal drive. If you buy Aperture from the AppStore, your licence would entitle you to install Aperture on any Mac you own or control - for private purposes. So while you have the work computer and control it, you can use Aperture there - for private purposes. Simply delete the app when you return it and unplug your external drive.
    For example, if I have to give the laptop back could I simply hook the Lacie up to a new MacBook, install Aperture, restore the latest Vault backup and be up and running?
    That would work.
    Make sure, your Lacie drive is formatted MacOS X Extended (Journaled), and set the "Ignore Ownership on this volume" flag. I assume, you are using different account names on the two macs.
    You should be able to download Aperture again to your new MacBook, if you use the same AppleID.

  • Best way to call methods on similar objects without an interface

    Hi,
    I have two objects that i need to iterate, they both have the same method i need to call during iteration, but those two objects are from different libraries and i cannot change them to add them as implement interface...
       for (Iterator it = documents.iterator(); it.hasNext();) {
               Document1 document = (Document1) it.next();
               document.getName();
    But I can also get a documents's collection where the object is Document2 and not Document1 that also has getName(), what's the best way to implement this? I mean i know i can just add if conditions to say if (instanceof) do this or that.. but I don't think this is good as everytime there's a new type of doc i'd have to add one more...
    Any suggestions?
    Thanks,

    I have two objects that i need to iterate, they both have the same method i need to call during iteration, but those two objects are from different libraries and i cannot change them to add them as implement interface...
    You already know what you need to do. You just don't want to do it.
    You can't treat two (or more) instances the same if they aren't the same. Here are three methods:
    1. Add code (like you propose) to determine which type you have
    2. Create your own classes that extend those classes and have your own class implement your own interface that has the 'getName' method. When you create instances of your own class the constructor can have code that determines which type you have and then use the appropriate 'getName' method. Your app code would use your own classes instead of the ones from the libraries
    3. Use reflection to call the 'getName' method.

Maybe you are looking for

  • Change start date of an object..

    hello guru's, i was wondering if the start date for objects like org unit or possition or job can be changed or we can only delimit or delete it...and if the start date can be changed then how can we do it...

  • How to set code page to Windows-1252

    Hello, I would like to set a specific page to Windows-1252 while others are Apex standard Please help Thank you.

  • KDE 3.4.2 requires GCC 4?

    I just updated to KDE 3.4.2 in Testing, and even though I could log in fine, when trying to launch Konqueror I get  "/usr/lib/libstdc++.so.6: version `CXXABI_1.3.1' not found (required by /opt/kde/lib/libkhtml.so.4)". I searched a bit, and for me it

  • Tried so many solutions to error #34506, HELP!

    I am a 29 year old woman who has just walked 2,650 miles on the Pacific Crest Trail from Mexico to Canada. I don't give up on anything easliy. I get home and have a brand new computer waiting for me, an Ibook G4, download my photos and begin making m

  • It is too slow to load an image on JPanel

    i overwrite the JPanel's method paintComponent(Graphics g) to load a gif image(1024*786) from local harddisk,but it will cost at least 5 secs to display the image.is there any other way to do this ? my code: import javax.swing.*; import java.awt.*; p