Results 1 to 3 of 3

Thread: Preventing access to beans from a contect

  1. #1
    Join Date
    Aug 2004
    Posts
    107

    Default Preventing access to beans from a contect

    Hi all,

    I have a bean named UserFacade. The application context defines the UserFacade and injects the UserBusinessLayer into the UserFacade which in turn injects UserDAO into the UserBusinessLayer.

    The initial lookup is done via the application context user the getBean method (getBean("userFacade"). How do I allow the web layer to retrieve the UserFacade only and not the other beans. In other works, the web layer should not be allowed to call getBean in order to retrieve the UserBusinessLayer and UserDAO bean objects.

    dino

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    dino,
    I do not know of a way to prevent a client code, that has a reference to a Spring context, to access this context non abstract beans.
    If you are using Spring MVC for your Web Layer, your can Inverse the Control and inject your facade bean into your controller.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Do you mean "web layer" as in JSPs or the like, or web controllers? JSPs and other views should only access model objects exposed by the web tier, and should never have access to a Spring context. Web controllers should normally receive context objects using DI, and try to avoid lookups.

    If you are using Spring MVC for your Web Layer, your can Inverse the Control and inject your facade bean into your controller
    Yes, you want to avoid using getBean() at all if possible, and prefer a DI approach, which doesn't tie you to the Spring API.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. Replies: 0
    Last Post: Aug 25th, 2005, 05:11 AM
  3. Replies: 1
    Last Post: Aug 24th, 2005, 02:40 PM
  4. Replies: 4
    Last Post: Aug 17th, 2005, 04:42 AM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM

Posting Permissions

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