Skip to content

Instantly share code, notes, and snippets.

Last active December 10, 2015 20:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AdamBien/806784f71a9e0a2d0dcb to your computer and use it in GitHub Desktop.
Copy link

Hi Adam,

I am maintaining a multi-tenant enterprise application in which special metadata on requests (headers, params) identify specific tenants. Each tenant has custom configurations in the system that override some defaults. The configurations come from a cache-augmented database fronted by an EJB. To successfully look up one such custom configuration, a key and a tenant identifier is needed. If the tenant identifier is not present, the key alone is used to retrieve the default for the key's entry.

From the remote interfaces that receive these requests (servlets, web services, etc) I want to retrieve such identifiers and setup contexts (e.g put properties in EJBContext) with them such that producer methods can leverage to setup appropriate beans to service each tenant's clients. I would also ideally want to favor CDI over EJBs for this case as much as reasonable.

I was thinking along the lines of the following strategy but I got stuck.

  1. Create a @Config qualifier so that the CDI container resolves to the configuration producer.
  2. Create a @Key(String) configuration annotation through which the lookup key of the desired configuration entry can be obtained.
  3. Create a Producer method which takes an InjectionPoint as a parameter. The InjectionPoint allows to obtain the @Key annotation, the declared type of the field being targeted and the class in which this injected field is declared (enclosing class). A sweet scenario would be if InjectionPoint allows me to obtain an instance of the the enclosing class. But thinking of it, this doesn't make sense as the instance wouldn't be ready yet until all it's dependencies have been created/located and injected.

Is this a case CDI is not meant for? How could this best be implemented?

Copy link

Hello Adam, thanks for your videos!!

My question is how to create a Single Sign On for all of my web systems in java ee?
Are you in favor on create a new one from scratch or to reuse something that it is already built in java?

Thank you very much !!!!

Copy link

I already take the java ee 7 essentials vimeo course, thanks for these course, was great for me, because I am learning java ee!! (I already know jsf).
Do you plan to create a javascript + java course? I need to connect a java ee rest service using react.js or angular.js.
What do think about that? what are the best practices to follow to connect bouth of them?
Can you point me into an example?

Thank you very much!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment