[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 900
  • Last Modified:

How to set a global variable at EAR level from MDB?

My application server is weblogic 10.
An EAR file has an EJB (MDB) and WAR.
Can the MDB set a variable in global context, which the WAR or any other EAR component can access?

There is the database option and the file option.
But I am looking at an in memory option, like an application context variable at EAR level. Any pointers?
0
p_ashwinram
Asked:
p_ashwinram
1 Solution
 
Jim CakalicSenior Developer/ArchitectCommented:
One thought would be to simply use System properties. The information that I've read on Weblogic is that it has a fairly standard ClassLoader hierarchy as shown in this figure: http://gemsres.com/photos/story/res/42876/fig1.jpg. The System class is loaded by the bootstrap ClassLoader and so the same Class instance (along with the static data it manages) is visible to all child ClassLoaders.

If Weblogic happens to prohibit the use of System.setProperty then you could implement a similar solution using your own class akin to System in a jar that is loaded by the system ClassLoader. The same Class instance (and the data it manages) would be visible to all WARs and EJBs.

If you only have one EAR (or only want the value to be shared amongst the WARs and EJBs in one EAR) then I think you could use a Stateless Session Bean that shares data amongst all of its instances. It might be possible to do the same using JNDI. Both these options seem somewhat heavyweight to me.

The simplest solution, if allowed by Weblogic, is to use System.

Regards,
Jim
0
 
p_ashwinramAuthor Commented:
Thank you very much for covering my blindspot. Appreciate your time and effort to answer this question.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now