Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:03:59+00:00 2026-06-08T10:03:59+00:00

I use JSF, Hibernate and CDI with Weld. My application is divided in: View

  • 0

I use JSF, Hibernate and CDI with Weld. My application is divided in: View (xhtml), Control (Request/Session/View scoped Beans), Model (Entities) and Business (BO’s marked as Application scoped beans).

I try to keep Model and Business layers decoupled from View and Control as much as possible, meaning that if want to change all of the xhtmls + control beans, it’s possible without affecting Business Layer and Entities.

My problem is: There are a lot of methods in the Business Layer that need to know who is the logged user (or at least his Profile), because that will affect the results that are going to be returned back to the control layer.

E.g.: When requesting a list of Users to edit, an Administrator would receive a list with all registered users, and a Manager would receive a list with only the users that are “below” his profile.

I don’t want to inject my Session Bean (containing the logged user) into my Business Layer, because that would cause coupling (meaning that I wouldn’t be able to just change my Control/View layer at any time).

Nowadays I do this by passing the logged user as a parameter of my BO’s methods, but to me that “feels” wrong. I keep thinking that the Control layer can just pass whoever it wants as the logged user, and my Business layer would never know about it.

My final questions are:

  1. Is there anything wrong with the way I’m doing it? Or am I over thinking too much?
  2. Is there a better way to do it?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:04:00+00:00Added an answer on June 8, 2026 at 10:04 am

    I think it’s fine to put the user identity in the session scope, from where it can be picked up by beans in the domain layer. If your domain layer needs to know about user identity, then it’s a domain concept, and it’s okay for there to be an object for it there.

    However, you are right be concerned about leaking abstractions from the presentation layer. I would suggest that you define an interface for the user identity in the domain layer, with code in the domain layer being written in terms of that interface, and then inject an implementation of it from the presentation layer. Because the interface is defined in the domain layer, it can be written in terms of domain concepts, preventing leakage of presentation concepts into it.

    If you wanted to change your presentation layer, you would need to write a new implementation of the interface, but that shouldn’t be a problem.

    There is another approach you could take, which would be to use the Java Authentication and Authorization Service to bind the user identity to the thread of execution as it passes into the domain layer. Objects in that layer can then use standard JAAS constructs to access it. If your container supports JACC, then it might already be making user identities available through JAAS; i’m not really sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a JSF web application. I use Beans as Spring Beans (not JSF
Here is a code I use : request.jsf <h:form> <!-- form inputs ... -->
what is best way to use logger in JSF application
I'm running a JSF 2.0 application on Tomcat 7. I want to use javascript
I have a Java-JSF Web Application on GlassFish, in which I want to use
I am developing a web application based on JSF technology. I use Eclipse as
I am programming a Web-Application with Java EE, JSF and Hibernate. I do not
I'm trying to use hibernate to fill my jsf selectonemenu in ApplicationBean (in Liferay).
Here is my scenario: I have my-jsf-app.war (JSF 1.2 application) and daos-and-entities.har (Hibernate 3.3.1)
I am developing a Java web application using Hibernate and JSF/primefaces. am sometimes getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.