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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:02:49+00:00 2026-05-30T13:02:49+00:00

I wonder what scopes folowing two bindings have: bind(PermissionManager.class).in(Singleton.class); and bind(PermissionManager.class); I have read

  • 0

I wonder what scopes folowing two bindings have:

bind(PermissionManager.class).in(Singleton.class);

and

bind(PermissionManager.class);

I have read the JavaDocs, they are as following. For Singleton:

/**
* Apply this to implementation classes when you want only one instance
* (per {@link Injector}) to be reused for all injections for that binding.
*
* @author crazybob@google.com (Bob Lee)
*/

For no scope:

/**
* No scope; the same as not applying any scope at all.  Each time the
* Injector obtains an instance of an object with "no scope", it injects this
* instance then immediately forgets it.  When the next request for the same
* binding arrives it will need to obtain the instance over again.
*
* <p>This exists only in case a class has been annotated with a scope
* annotation such as {@link Singleton @Singleton}, and you need to override
* this to "no scope" in your binding.
*
* @since 2.0
*/

What does this mean in practical terms? Are singletons per client or per JVM? For no scope, is every instance different?

  • 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-30T13:02:51+00:00Added an answer on May 30, 2026 at 1:02 pm

    In practical terms for Gin, the Singleton scope makes the most sense when considered per client instance, or even more accurately, per Ginjector instance. If you make the mistake of making two Ginjectors by GWT.createing an instance twice, you likely will have one ‘singleton’ per instance, since each Ginjector can only keep track of the instances it manages.

    So each time your application loads, it will have its own singleton. If the user opens the same application twice in two different tabs, each will have its own singleton. You could consider each tab to be its own JVM, as it will have its own copy of all of the classes, and won’t be able communicate, or call methods* on the other window.

    For no scope, yes, by default each instance is different. When a type is @Injected, it will be a new instance there, but if you @Inject a Provider for a field, every time you call get() you can get a fresh instance. This can be helpful to get several newly injected instances easily.

    Singletons make sense to use in two main cases

    • When the instance holds shared state that needs to be common across many injections – the most common case.
    • When the instance is expensive to create – on the server this is often done as a pool, so no more than X objects are created, but the expensive objects on the client tend to be views, with lots of widgets, and generally more than one is not required.

    * It is possible to call methods on another window, but you need to use the browser’s capabilities for this, by posting a message, not by just passing an object back and forth.

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

Sidebar

Related Questions

wonder whether someone can help me with the following one... I have a struct
Wonder how I could do the following wit jquery - I have a url
wonder what's wrong <table id=tblDomainVersion> <tr> <td>Version</td> <td>No of sites</td> </tr> <tr> <td class=clsversion>1.25</td>
I just read a few threads on the discussion of singleton design in javascript.
We have a lot of open discussions with potential clients, and they ask frequently
we have a SVN-repo with a bunch of projects [they are related to each
Wonder if anyone can clear up the following for me. What happens if I
Wonder if anyone can help me. I have a setup whereby a main menu
Wonder what the difference between: static PROCESSWALK pProcess32First=(PROCESSWALK)GetProcAddress(hKernel,Process32First); ... pProcess32First(...); what is hKernel? Look
Wonder if anyone can help me understand how to sum up the column of

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.