• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DAO help please

 
Greenhorn
Posts: 27
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys

Here's my problem, used a factory pattern for DAO access in my web app, allowing MySQL, SQL Server, and XML versions for Data Access. I must put together method calls via java reflection during runtime, i will not know until runtime what method i might be calling, the browser will tell me what method to run and an xml file will tell me what DAO that method is in. How should i go about this properly. I was think java reflection will solve my problems, but are there any other opinions...

Greg B
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A better less complicated way without using reflection would be to create an interface and let each DAO implement the interface.

Then have the logic to decide which methods to call....
 
Greg Belyea
Greenhorn
Posts: 27
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ummmm, I stated that i had used the J2EE Factory Pattern which means that i am using interface implementation. I must not have expllained well enough what i am doing... It is not an option for me to just let the logic decide which method to call, users who are building screens will be telling me by way of a string which method they want to call, all methods return them a map which the screen is smart enough to display as a table.

R there any GURU's out there who have a suggestion for the best way to handle this? I have an XML file with the details about whatever method string they send me, it says which DAOFactory to instantiate, and which DAO Interface the method belongs to, as well as info about the parameters to expect. The users are not java developers, they cannot just call the method, they are designing an HTML screen, of which they may want certain data from the database, to get this data they drop a jsp tag of sorts on the html page they are designing. I disect the tag to figure out what it is they want.

My biggest issue lays in figuring out how to go about instantiating the DAO, i am thinking i somehow need a MainDAO object that can be an instantiation of any of the other DAO objects. I have never designed DAO before though and have myself in a bit of confusion.....
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg,


I have an XML file with the details about whatever method string they send me, it says which DAOFactory to instantiate, and which DAO Interface the method belongs to, as well as info about the parameters to expect.


Quite an unusual problem you have to solve there. I�m not sure why you end up so "badly" but it looks to me that your main problem is to find an acceptable solution in order to implement a proprietary protocol for translating your client�s streams of data to object method calls. This is no easy task and there is no magical solution for this problem. However I�d like to bring to the table one more idea: first divide your problem in two: the data access logic and the communication protocol. You might use whatever design you like for your data access layer; using DAO is a good start. As for the communication protocol you might take the advantage of the fact that your users� requests are in XML format. Then why not to use SOAP for solving this problem? Only think about: you�d implement an "umbrella" class that forwards all client's requests to your data access layer and returns the result (in whatever format you whish) back to the clients again. Finally just make this class SOAP service and now your problem gets much simplified: you have to transform your clien�s XML request to a SOAP message, which is another XML. Ideally applying an XSL stylesheet might get you there (or even better you'll educate your users to use SOAP messages directly).
Regards.
 
reply
    Bookmark Topic Watch Topic
  • New Topic