Layering struts application

Discussion in 'Java' started by Grzegorz Stasica, Feb 19, 2004.

  1. Hi',

    Let's make 3 layer: presentation,business object and DAO. Having in mind
    principle no layer should know how the other works I've question
    regarding DAO layer. Let's assume I've a CustomerDAO object which
    resposibility is limited to talking with underlying DB. My question or
    I'd say ignorance is how to get a connection in DB layer since all
    information about parameters are stored in application context
    (struts-config.xml). Surely I can get DataSource object from JNDI but
    whouldn't it be breaking a base principle(the above solution I've seen
    on apache.org web site).

    I've somebody will explain it to me :)
    Please don't slam me to much :)
     
    Grzegorz Stasica, Feb 19, 2004
    #1
    1. Advertising

  2. Grzegorz Stasica

    SPG Guest

    Hi,

    It would be the responsibility of the business layer to obtain the
    'application' DataSource.
    The data layer would simply accept a DataSource in its constructor.

    This way you would not be breaking any layer separation rules. The business
    layer knows it has to call the data layer some how. It also now knows it is
    responsible for obtaining the DataSource and sending it to the Data Access
    Layer.

    The Data Access Layer will not care what type of DataSource it gets, as
    DataSource is an interface (or abstract class, cannot remember right now),
    but knows how to act upon the DataSource.

    I hope this helps you in the right direction..

    Steve

    "Grzegorz Stasica" <> wrote in message
    news:c125c7$boh$...
    > Hi',
    >
    > Let's make 3 layer: presentation,business object and DAO. Having in mind
    > principle no layer should know how the other works I've question
    > regarding DAO layer. Let's assume I've a CustomerDAO object which
    > resposibility is limited to talking with underlying DB. My question or
    > I'd say ignorance is how to get a connection in DB layer since all
    > information about parameters are stored in application context
    > (struts-config.xml). Surely I can get DataSource object from JNDI but
    > whouldn't it be breaking a base principle(the above solution I've seen
    > on apache.org web site).
    >
    > I've somebody will explain it to me :)
    > Please don't slam me to much :)
     
    SPG, Feb 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF1bCBLZWVnc3RyYQ==?=

    Layering Images in ASP.Net 1.1

    =?Utf-8?B?UGF1bCBLZWVnc3RyYQ==?=, Mar 28, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    665
    darrel
    Mar 28, 2005
  2. Katie Wright
    Replies:
    8
    Views:
    4,335
    Andrea Desole
    Jan 7, 2005
  3. Replies:
    7
    Views:
    576
    dorayme
    Jun 16, 2009
  4. Mr. Magic

    Layering pictures.

    Mr. Magic, Jan 4, 2010, in forum: ASP .Net
    Replies:
    3
    Views:
    2,228
    Alexey Smirnov
    Jan 5, 2010
  5. news.verizon.net

    javascript layering? Maybe wrong question..

    news.verizon.net, Jul 9, 2003, in forum: Javascript
    Replies:
    1
    Views:
    98
    Chris Leonard
    Jul 9, 2003
Loading...

Share This Page