geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markku Saarela <>
Subject Re: How to determine in which container code is running?
Date Mon, 31 Dec 2012 16:18:43 GMT
My use case is to implement Martin Fowler's Domain Model enterprise 
design pattern with Unit Of Work and  Data Mapper.

This UOW does not work with ThreadLocal in every app server due to 
thread pooling.

So only solution to use different UOW storing mechanism in different layers;
session persistence in web container and pass UOW instance to the EJB 
container and store it to TransactionSynchronizationRegistry. Of course 
standalone Java client could use TrhreadLocal implementation.

In UOW static methods to manipulate current UOW instance (getCurrent(), 
newCurrent() etc,) must some how decide which implementation to use.


On 12/31/2012 06:06 PM, David Jencks wrote:
> On Dec 31, 2012, at 7:57 AM, Markku Saarela wrote:
>> Hi,
>> Has Java EE spec any API to determine is code running in EJB or WEB container?
> no.
>> Or is there any better way than examine stacktrace?
> I'm imagining that you have some library or perhaps CDI code that is called from both
a servlet and an ejb?  Why do you care?  Just to figure out why something is working the way
it is, or do you need to take different action depending on what calls this code?  You could
pass appropriate context information to the code in question from the caller.
> david jencks
>> Rgds,
>> Markku

View raw message