Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Not exposing DAO's to web layer?

  1. #1
    Join Date
    Oct 2008
    Location
    SoCal.
    Posts
    23

    Default Not exposing DAO's to web layer?

    I've got a bunch of services and dao's in one project jar, and it contains an applicationContext that is mixed with the war project. I guess this means that the beans in the webapp (or their programmers) could just ignore the service beans and start futzing with the dao's directly.

    How do I stop this? How do I expose the service beans to the webapp, but not the DAOs. Note: some daos are known by multiple services , so I can't just make them anonymous in the service definition.

    Is there a way to enforce that a bean in that xml file is *only* used in that xml file?

    Jamie
    Last edited by jbriant; Feb 26th, 2009 at 01:49 PM. Reason: haha

  2. #2
    Join Date
    Oct 2008
    Posts
    136

    Default

    Is the 'webapp' a separate application from the app running the DAOs?

    I am asking because it occurred to me that maybe Spring Security could help you control what (usually who) invokes the methods on the DAOs.

    Of course, if someone has physical access, not to mention access to the code, there is usually a way around such protections.

    Alternatively, you can slap the programmers about the head and shoulders with a two by four.

  3. #3
    Join Date
    Oct 2008
    Location
    SoCal.
    Posts
    23

    Default

    No. Its a different JAR, but ends up in the same war. I'm thinking this dm-server might be the answer. But that's only because I don't know of a better way, and it seems like using a sledge-hammer.

  4. #4
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    123

    Default

    I remember seeing a presentation by Alef Arendsen where he was using some Aspects to be able to do exactly what you're describing. It would give programmers compile-time errors, so that's pretty cool/

    I don't remember exactly how he achieved it but I suppose this could send you in a possible direction...
    Hans Westerbeek
    Software Engineer

  5. #5
    Join Date
    Oct 2008
    Location
    SoCal.
    Posts
    23

    Default

    Thanks! Googling Alef Arendsen turned up tons of things I didn't know I didn't know. :-) Didn't find exactly what you describe, but this sounds similar and very interesting:

    http://blog.arendsen.net/index.php/2...de-and-design/

  6. #6
    Join Date
    Feb 2009
    Posts
    7

    Default

    Maybe what I propose is a naive way, but I would declare the dao layer and service layer in the same package and declare the dao to have package level access. The web layer code would be in a different package. This would make sure you can't even declare a dao in your web layer. The service layer is public, so it can be declared in the web layer.

    I think there was a presentation by Eberhard Wolff at SpringOne in Antwerp last year where the access restriction was also discussed. I don't recall all the details, but since the conference was all about S2AP (DM server), I can imagine it was in that context as well.

    Edit: the presentation I referred to can be found at Parleys.com:http://www.parleys.com/display/PARLE...rchitec tures
    Last edited by petervds; Mar 2nd, 2009 at 07:01 AM.

  7. #7
    Join Date
    Oct 2008
    Location
    SoCal.
    Posts
    23

    Default

    Thanks. The more I read the more I think the modularisation of the DM server is what I need. Package level security doesn't help when someone else can just create the same package in their jar (unless I'm missing something). Forcing everything through proxied interfaces seems the way to go, and DM just makes that guaranteed.

  8. #8
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    123

    Default

    Quote Originally Posted by petervds View Post
    I think there was a presentation by Eberhard Wolff at SpringOne in Antwerp last year where the access restriction was also discussed. I don't recall all the details, but since the conference was all about S2AP (DM server), I can imagine it was in that context as well.

    Edit: the presentation I referred to can be found at Parleys.com:http://www.parleys.com/display/PARLE...rchitec tures
    I was at that presentation It wasn't so much focused on s2ap but more on the theoretics of what constitutes a module. Visibility of of the module was one of the key aspects. And it seems indeed that class visibillity control is what Jamie is looking for.

    Obviousyly, s2ap/osgi is a great option but it may still be a bit overkill if all you want to achieve is making sure that other programmers don't do stupid stuff Maybe code-reviews are a better option...
    Hans Westerbeek
    Software Engineer

  9. #9
    Join Date
    Oct 2008
    Posts
    107

    Default

    Can't you just lock the jar file and declare a public interface and implement it to provide access to your service as a jar? The other alternative seems to me to be one of two options: distribute the jar (modules) and just give a verbal "use the interface only" or create an actual web service... (overkill)

    Keith

  10. #10
    Join Date
    Oct 2008
    Location
    SoCal.
    Posts
    23

    Default

    Ok, how do I lock a jar file?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •