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 7077163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:23:19+00:00 2026-05-28T06:23:19+00:00

In My app I am using a User bean that is Autowired to my

  • 0

In My app I am using a User bean that is Autowired to my service MyService and its used as the principle logged in user’s info (So the user is not coming as a static bean from an xml but dynamically generated from a logged in user) If there are ten users logged in I will have ten candidates for the @AutoWired User field. (right?) and I can get any one of them cos AutoWired looks in the Spring container and not session.

tell me if I am wrong on this. and how to actually solve it if possible. But what if my AutoWired field is annotated with @Scope ("Session")

Like this :

@Component("user")
@Scope("session")
public class User 
{
String userid;
String name;
//getter setters etc
}

@Component
public class MyService
{
    @Autowired
    private User user;

}

Is it possible to get some other user’s User bean when I call my MyService Component. Cos MyService is only @Component even though the User is @Scope(session).

Basically, (If I am wrong in my assumption) I think that when you @Autowire a field, its looks into the container as whole and the container is not divided into subcontainers per session.

  • 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-05-28T06:23:19+00:00Added an answer on May 28, 2026 at 6:23 am

    When you annotate User with @Scope("session") and then @Autowire that into another non-scoped component, Spring will generate a proxy which sits between MyService and User. This proxy will locate the User from the current session, and will delegate any calls from MyService to the proxy to the session-scoped User.

    So it’s perfectly safe, the MyService component will only have access to the User from the current session.

    If the proxying didn’t happen, then the container would fail to start, since you can’t directly inject a session-scoped bean into singleton-scoped bean.

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

Sidebar

Related Questions

I have a Spring MVC app where I am using a singleton bean that
I'm developing an app using Silverlight control for Bing Maps . User can search
In C# I can get the current user of a web app using the
So I am using Devise for user authentication in my rails app. I have
I'm using Google App Engine python. I want to know what browser the user
I want to develop an app for WP7 using C# where a user taps
I am trying to know if a user is guest using Yii::app()->user->isGuest but I
I created a Facebook canvas app. I tried using the app as a user.
I am using Flexigrid in my web App.When user add or delete a record,the
My app changes statuses in iChat according to the user's hot keys, using AppleScript.

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.