Use of synchronisation with the SUN DAO Pattern

With reference to the design pattern Core J2EE Patterns Data Access Object: http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
I am writing a DAO package to handle access to multiple datasources at a record level (e.g. user records may be located at datasource A, but customer records at datasource B). The role of the package is to provide DAO objects to clients (e.g. business objects in an application package to come later). Nothing too unusual. I have digested the SUN design pattern for DAO.
As I understand it, it can be summarised as: client code calls on an abstract DAOFactory to provide the appropriate concrete DAOFactory . The concrete factory can then supply the correct DAO object. The concrete DAOFactory is also responsible for providing the connection services (such as pooling). So far so good. I have pasted the concrete DAOFactory code form the design pattern page:
// Cloudscape concrete DAO Factory implementation
import java.sql.*;
public class CloudscapeDAOFactory extends DAOFactory {
public static final String DRIVER=
"COM.cloudscape.core.RmiJdbcDriver";
public static final String DBURL=
"jdbc:cloudscape:rmi://localhost:1099/CoreJ2EEDB";
// method to create Cloudscape connections
public static Connection createConnection() {
// Use DRIVER and DBURL to create a connection
// Recommend connection pool implementation/usage
*** can a connection pool be implemented in a static method? ***
public CustomerDAO getCustomerDAO() {
// CloudscapeCustomerDAO implements CustomerDAO
return new CloudscapeCustomerDAO();
public AccountDAO getAccountDAO() {
// CloudscapeAccountDAO implements AccountDAO
return new CloudscapeAccountDAO();
public OrderDAO getOrderDAO() {
// CloudscapeOrderDAO implements OrderDAO
return new CloudscapeOrderDAO();
I have some questions on this overall design.
1)     The design for the factories as given looks inelegant and requires upgrading each time a new DAO is added ? much better surely to dynamically generate the DAOs using reflection. If I implement a mapping of data type to data source using a properties file (typical entry, Key = Role, Value = Oracle), the use of abstract and concrete factories can be reduced to a single factory. The single factory reads in the mapping on initialisation and provides a method getDAO to client code. The method takes the data type, looks up the data source and returns the correct DAO class using reflection (e.g. the client passes ?Role? to getDAO and the factory returns Oracle + DAO + Role = OracleDAORole.class). This also has the advantage that the client code does not need to specify the data source to use. I have read some forums and note that performance is an issue with reflection; however I have not seen any significant difference in performance between using reflection to generate a class name and using a factory pattern (e.g. testing just the code paths, for 10 million operations, both reflection and factory took 2.5 seconds each). Does anyone have any opinions on the pros and cons of this approach?
2)     If we go with the original DAO design (ignoring 1 above) I have marked the part of the concrete factory code that I have a problem with: using a connection pool in the concrete factory. As the factory?s createConnection method is static, you cannot use NotifyAll or Wait methods here, and therefore you cannot synchronise access to the pool (correct?). I have therefore created a separate connection pool class (which uses the singleton pattern and uses synchronised methods to manage the pool). Is this a sensible way to approach this or is there a clever way to synchronise access to static methods?
Thanks in advance - Alan

These resources may be helpful:
http://daoexamples.sourceforge.net/related.html
http://daoexamples.sourceforge.net/index.html

Similar Messages

  • How to use glob search with the wildcard in command find?

    How to use glob search with the wildcard in command find?
    I want to find any file its names begin with "readme" string using command find. Why the following command cannot work?
    $find /usr/share/doc -name readme*
    However, the following commands can work?
    $find /usr/share/doc -name readme\* or
    $find /usr/share/doc -name readme'*'
    I want to know: After using the “\” or ' ', why the wildcard do not become a character "*"?(still a metacharacter).
    Another question:
    I want to find any file its names begin with "readme*" string using the command find.What command should I use?

    I want to know: After using the “\” or ' ', why the
    wildcard do not become a character "*"?(still a
    metacharacter). The backslash is known as an escape character. It means 'use the character value of the next character, not the special meaning' It is used in a lot of places such as command line, global regular expression patterns, and editors such as vi.
    In a typical shell, the splat (*) expands to all file names before passing the file names to the current command. So a \* sequence tells the shell to pass a *, not a list of file names, to the command.
    Demo - OpenSuSE Linux 10.3
    - I have a bunch of files. Let's list those that end in grid. Create one called *grid, and list again
    pops@fuzzyVM:~/pops> ls 
    a  b  c  startgrid  stopgrid
    pops@fuzzyVM:~> ls *grid
    startgrid  stopgrid
    pops@fuzzyVM:~> ls \*grid
    ls: cannot access *grid: No such file or directory
    pops@fuzzyVM:~> touch '*grid'
    pops@fuzzyVM:~/pops> ls
    a  b  c  *grid  startgrid  stopgrid
    pops@fuzzyVM:~/pops> ls *grid
    *grid  startgrid  stopgrid
    pops@fuzzyVM:~/pops> ls \*grid
    *grid
    pops@fuzzyVM:~/pops>In the above, how would I remove the file *grid, and only that file?
    Another question:
    I want to find any file its names begin with
    "readme*" string using the command find.What command
    should I use?What were the results of the two versions you tried? And why?

  • TS1702 Renewed my subscription with the Sun app, was charged £0.69 but app won't load seem that I am not the only one having issue with this app. How can I claim my money back?

    Renewed my subscription with the Sun app, was charged £0.69 but app won't load seem that I am not the only one having issue with this app. How can I claim my money back?

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • Will weblogic 4.5 work with the Sun Java Servlet Development Kit Version 2.1?

              Will weblogic 4.5 work with the Sun Java Servlet Development Kit Version 2.1
              (JSDK 2.1). The reason I want this is we want our application servlets to
              use the new 2.1 redirection mechanism to redirect to JSP files.
              

    WL 4.5 supports JSP 1.0 (and, therefore Servlet 2.1).
              What I want to know is when will it support JSP 1.1 (and, therefore Servlet
              2.2)!
              Regards,
              Murali Krishna Devarakonda
              Cox News <[email protected]> wrote in message
              news:7rk40p$s00$[email protected]..
              >
              > Will weblogic 4.5 work with the Sun Java Servlet Development Kit Version
              2.1
              > (JSDK 2.1). The reason I want this is we want our application servlets to
              > use the new 2.1 redirection mechanism to redirect to JSP files.
              >
              >
              >
              >
              

  • When I try to sign in to iTunes, it tells me that my Apple ID has not yet been used with the iTunes Store. How do I use my account with the iTunes Store?

    When I try to sign in to iTunes, it tells me that my Apple ID has not yet been used with the iTunes Store. How do I use my account with the iTunes Store?

    Hello Daijalove97,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    Using an existing Apple ID with the iTunes Store and Mac App Store
    http://support.apple.com/kb/HT2589
    To use your Apple ID at the iTunes Store
    Open the latest version of iTunes.
    Choose Store > Sign In from the Store menu.
    Enter your Apple ID and password, then click Sign In.
    Click Review when asked to review your information.
    Enter your billing information, a credit card will be required.
    Click Continue when you're done entering your credit card and billing information.
    Best of luck,
    Mario

  • I have 2 computers (1 Pc and 1 MAC) and 1 Iphone.The I phone is synchronised with the PC. I want to synchronised it also with my MAC, without erasing all my music and files. Someone can help me to find the answer ?

    I have 2 computers (1 Pc and 1 MAC) and 1 Iphone.The I phone is synchronised with the PC. I want to synchronised it also with my MAC, without erasing all my music and files. Someone can help me to find the answer ?
    i have already try the copy/paste thing with the ID of the file "iTunes Music Library.xml" it didn't change a thing. each time I relaunched Itunes, the ID is the first I have in the MAC.
    I have more than 5 000 files of music. I don't want to recreate one by one all my playlits.
    Many thnaks for your answers.
    Constance

    You can sync iphone with one and only one computer at a time.  If you sync to another, it will erase the current content and replace with content form the new computer.  There is no way around this.
    Put everything on one computer and sync from there.
    BTW, you posted in the Home Share forum.  Your question seems to have nothing to do with home share.

  • How can i use text expander with the new Mavericks,

    how can i use text expander with the new Mavericks,

    I regret upgrading to mavericks for the same reason
    ftamez wrote:
    how can i use text expander with the new Mavericks,
    Now I have been searching - and you have to buy an app and it will cost you $34.99 (what a rip off)

  • Can't I use my Scanner with the Elements 10 editor without the organizer??

    I have been using Photoshop Elements for a looong time to help me create the product images I need for my online business. It's been a love-love relationship... until I took advantage of a special offer and bought Elements 10. Now it seems the only way I can scan images is thru the Organizer.... and the organizer is something I don't need.
    Is there a way to scan my images thru the Editor only... and completely bypass the organizer (as I'm able to do with my older version of Elements)? Like a twain plugin I can install or something?
    I may scan 10 images and decide to use only 3 of them... and those are the only ones I save.
    With the way PSE10 is set up using the Organizer to scan, it's saving all 10 of them. Not to mention the extra steps of scanning thru the Organizer... (which means that pop-up window for my scanner every time), back over to the editor to pull the images in for editing, back to my files to delete the ones the organizer saved that I don't want... etc etc etc.
    It's like 5-6 extra steps altogether and a huge time-sink for me (you know the old saying... time is money).
    If there's no way to bypass the Organizer for scanning.... can I get a refund on my purchase? My older version of Elements works beautifully for me...  I was just hoping for  more sophisticated image editing capabilities.
    VERY frustrated right now.

    Thank you very much for your explanation which I fully understand.  Since a "fix", as you say, is not a solution might it not be a good idea to alert purchasers of the latest editions of Elements that they have an option to try this alteration to the installation in order to be able to import images from a scanner?  (My own experience with versions prior to 9 always worked perfectly!)  I do not know but does Photoshop CS5 allow the user to import images from a scanner or does the user have to use a similar solution to what applies to Photoshop Elements?  I find Elements to be a very good app and am sure it is a good selling product for Adobe for amateur/semi-pro users that the alternative that I suggest may be a useful tool for existing or new users who want or need the capability to import from a scanner rather than having to go through other more difficulty and time consuming ways of doing the same task.  Kindest regards and with my best intentions.
    Fergus Cooper
    Date: Tue, 20 Dec 2011 12:50:51 -0700
    From: [email protected]
    To: [email protected]
    Subject: Can't I use my Scanner with the Elements 10 editor without the organizer??
        Re: Can't I use my Scanner with the Elements 10 editor without the organizer??
        created by Barbara B. in Photoshop Elements - View the full discussion
    It's not a "fix", exactly. The TWAIN plug-in causes a lot of crashing in PSE so in the past couple of versions adobe makes you install it if you want it.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4096095#4096095
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4096095#4096095. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Photoshop Elements by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • I've deleted Adobe Reader 11 and rebooted and reinstalled Adobe Reader 11 and I still get the error message that 'Adobe Reader is blocked because it is out of date'. Using Windows XP with the latest updates (SP3).

    I've deleted Adobe Reader 11 and rebooted and reinstalled Adobe Reader 11 and I still get the error message that 'Adobe Reader is blocked because it is out of date'. Using Windows XP with the latest updates (SP3).

    Screenshots attached to email replies will not make it back to the forum; you need to login to the forum and post it in your topic using the camera icon in the editor.
    Google Chrome is a problem:
    if you use Chrome's own PDF viewer, the results are unpredictable.
    if you use the Adobe Reader plugin with Chrome, it may reject (block) it if it is not the latest version.  Reader 11.0.08 is the latest version for Windows XP, but Chrome may insist on the current version 11.0.10.
    My suggestion; use a different browser!

  • I'm using Adobe Acrobat with the hope of editing a url on the graphic...a simple 3-letter change, save, close and send for printing..how do I get in edit mode to delete 3 letters and insert 3 new letters?

    ?I'm using Adobe Acrobat with the hope of editing a url on the graphic...a simple 3-letter change, save, close and send for printing..how do I get in edit mode to delete 3 letters and insert 3 new letters?

    pkg4ibm wrote:
    editing a url on the graphic...
    Not sure what you mean by that: is that URL in an image, or is it actual text?
    If it is in an image, then you need to extract the image, edit it with something like Photoshop, then add it back to the PDF.
    If the URL is actual text, I suggest that you remove the entire URL, then add the corrected link.

  • HT4437 I have successffully used my iPad with the Apple TV with no problem but just recently, the Airplay icon doesn't come up on the iPad anymore when I'm trying to connect.   What can I do to fix this?

    I have successffully used my iPad with the Apple TV with no problem but just recently, the Airplay icon doesn't come up on the iPad anymore when I'm trying to connect.   What can I do to fix this? 

    Try restarting your router as a first thing, this sometimes works for me.

  • When I print a 4x6 color picture using an iMac with the latest operating system using a Canon MX892 printer, faint black lines appear every 3/16 of an inch. When I print the same picture using iPhoto there is no problem.

    When I print a 4x6 color picture using an iMac with the latest operating system using a Canon MX892 printer, faint black lines appear every 3/16 of an inch. When I print the same picture using iPhoto there is no problem. Any suggestions?

    What is the resolution of the picture that you are trying to print?
    Go to Image>resize>image size, read the resolution in px/in, then report back, please.
    Also, are you in a position to try printing with another printer in an attempt to narrow this down?

  • I am looking to buy a Mac mini, but I already have a monitor with a dvi plug in. Will I be able to use this monitor with the Mac mini??

    I am looking to buy a Mac mini, but I already have a monitor with a dvi plug in. Will I be able to use this monitor with the Mac mini??

    Here are the Mini's specs:

  • How to use TYPE addition with the OPEN DATASET ?

    Hi,
    How to use TYPE addition with the OPEN DATASET and what is the use ?
    For Example:
    OPEN DATASET 'test.dat'
      TYPE 'lrecl=80, blksize=8000, recfm=FB'
      FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    Also, if I wish to do the same for a .CSV file how can we do it.
    Thanks,
    -Sid

    Hi,
    OPEN DATASET 'test.dat'
      TYPE 'lrecl=80, blksize=8000, recfm=FB'
      FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
    For more information press F1 on OPEN DATASET.
    Thanks

  • Does anyone have SSL working with the Sun Java System App Server PE?

    We have been having problems (to say the least) getting SSL to work with the Sun Java Application Server 8.1 Platform Edition.
    We have a signed certificate from VeriSign and have it imported correctly, but when you test it by going to https://localhost:8182/ (note that 8182 is the port set up for SSL) you get a warning mesage saying that the certificate cannot be verified. When you view the certificate you see that it is the one that got automatically generated for you by the app server and not the one we purchased from VeriSign.
    So, I was just wondering if anyone out there has gotten this to work and if so, what document did you follow to tell yoiu how it was done!
    THANK YOU!

    once apon a time i had a real problem with the same issue.. best of luck.. i forget now how to fix.. sorry.

Maybe you are looking for

  • Order Type wise GL Account While doing Good Issue.

    Dear All, Good Day, We have Different types of Plant Maintenance Order , now when we do Goods Issue against the order we need specific GL Account based on Order type. Example: Preventive Order should need XXXX GL Account                Corrective Ord

  • Lost Connection To Airport Extreme HD after Upgrading to Lio

    Since installing Lion, I cannot access a specific HD connected to my Airport Extreme. It locks up the computer with a permanent spinning beach ball.  All of the others on the network - not running Lion - connect to that drive as usual without difficu

  • Won't automatically connect to Airport network after 10.4.8 update

    After updating my Mac Mini CoreDuo from 10.4.7 to 10.4.8, it will no longer automatically connect to our Airport Express based Wi-Fi network. Even though the Network settings in System Preferences have not changed, and they do list it as the preferre

  • Oracle 11GR2 + RMAN

    Hi all, I have a RAC database 11GR2 with 2 nodes. I backup database via RMAN and catalog. My catalog is stored in this database. Could you explain me how to create a second RMAN catalog on another database (on another host) ? Thanks !

  • Cant grab bezier handles in effect controls

    Am I gaoin mad? I want to control the ease out of a simple pan accross a frame.  I set the keyframe > temporal (and spatial) to beziere. Handle appears. Cant do anything with it. Just tried this on another clip (a nested sequence) and it worked fine.