Monday, August 17, 2009

Pattern: InvocationContext Propagation

Another good name for this pattern might be ThreadLocal Encapsulation.

This pattern is a real ThreadLocal killer as it is a way to track state over several calls without widespread ThreadLocal usage.

Internally in OpenEJB we have managed to boil all our ThreadLocal usage down to this sort of "one to rule them all" approach. When attempting to describe it to a user I started using the javax.interceptor.InvocationContext as an example. The result was an ejb3 design pattern that is too cool not to share.

Add the following Interceptor as a global interceptor at the beginning of the interceptor stack.
The Interceptor uses a private ThreadLocal to propagate invocation state by linking the InvocationContext objects together. The result is that you can do an infinite amount of state tracking as well as write some pretty impressive diagnostic tools.

Anyone downstream of this interceptor can make a call like this to get access the an infinite amout of state up the stack. You can move specific state forward for quick access. You can also look infinitely back the invocation chain for state set in a previous InvocationContext. Or perhaps more elegantly as a recursive method. A JavaDoc'ed and ASL licensed version here: http://gist.github.com/168153

29 comments:

.:raPHa:. said...

Hi David, I am implementing an auditor for EJBs methods and need a solution like this to record the call stack between methods in enterprise application.
This mechanism is safe for concurrent calls?

Danish Ahmed said...

Thanks for sharing this article, now you can also check your Admit card & Recuritment 2017 by following below given links...

police si admit card 2017

gpsc medical officer admit card 2017

tamilnadu teacher recuritment 2017

bihar police constable recuritment 2017

gujarat high court recruitment 2017

Habib Malik said...

Karnataka TET Notification 2017-18
Jharkhand TET Notification 2017-18
HTET Notification 2017-18
HP TET Notification 2017-18

adidas nmd said...

nhl jerseys
cheap ray bans
oakley sunglasses wholesale
ralph lauren polo
fitflops sale clearance
nike blazer pas cher
christian louboutin shoes
cheap ray ban sunglasses
oakley sunglasses
nike outlet

Habib Malik said...

Feliz año nuevo 2018 Imágenes

Habib Malik said...

Odisha CHSE Date Sheet 2018
LNMU Date Sheet 2018
Kota University Date Sheet 2018
Allahabad University Date Sheet 2018
RMLAU Time Table 2018
MAHA Board HSC Date Sheet 2018
MAHA Board SSC Date Sheet 2018
Odisha Board HSC Date Sheet 2018

Habib Malik said...

Haryana TET Admit Card 2017
REET Admit Card 2018
Bank of Baroda Specialist Officer Admit Card 2018
JEE Main Admit Card 2018

Unknown said...

airtel ussd code list
idea ussd code list
bsnl ussd code list
aircel ussd code list
vodafone ussd code list
jio ussd code list
telenor ussd code list
docomo ussd code list
airtel phone no check

Unknown said...

techmaniya
tutorialshubspot
ussd codes
bestpromarket
photographer in gurgaon
genxguys
graphics card under 100 dollar

Habib Malik said...

महात्मा गांधी राष्ट्रीय ग्रामीण रोजगार गारंटी अधिनियम (मनरेगा / MNREGA)

SWAMI AYYAPPA said...

are raspberries bad for dogs
can i give my dog raspberries
know more
can dogs eat red raspberries
click here

Pooja Sharma said...

Aadhaar Card Download By Name And Date Of Birth
Download Aadhar Card By Name
Aadhar Card Change Address Online
Download Aadhar Card by Enrollment Number
Aadhar Card Photo Change
Aadhar Card Enrollment Status
lost Aadhar Card Number
Aadhar Card Verification Online
Aadhar Card Enrollment Form
Aadhar Card Name Change Online

Freedom Apk said...


home button not working
Click here
iphone 6 home button
iphone 6 home button not working
iphone home button not working

Uttam Simepuruskar said...

thank you for it. keep up the good work.
best of crick

Unknown said...

Mobile USSD Codes
Idea Easy Share
Idea Loan Number
Idea Internet Setting
Idea DND Service
Idea Unlimited Calling Plan

Freedom Apk said...

Best Facebook tips

bike rent in dehradun said...

bike rental in dehradun
www.technicalbud.com
yubikey 4
Defence Jobs in India

Admin said...

pmsby

Admin said...

nice articlelink aadhar to pan

remuk said...

now present in your city cara menggugurkan kandungan

Sharon Wood said...

Lifelock Phone Number
Brother Printers Support
HP Printer Support Number
Canon Printer Help Number

khalifa said...

@Admin
Very good article. I like it keep posting this kind of post.
This article is very hepful people are also chec kExtraclass.com
ncert solution class 10 maths
ncert solution class 10 science
ncert solution class 10 english
ncert solution class 10 hindi
Happy Learning!!!

Darren Demers said...

This pattern is a real ThreadLocal killer as it is a way to track state over several calls without widespread ThreadLocal usage. scarf suppliers , ladies wraps and shawls , wholesale shawl suppliers , velvet shawl , new york wholesale , elegant shawl , kashmiri shawls wholesalers , red shawl

Sophie Grace said...

This is my first visit to this website, you have posted valuable content which i like reading.I expect more similar articles from you in future . Go with our site webstagram to download free anything you like on iinstagram.

Anaminka said...




Our client can choose any of them as per their convenient. We are also open to send our angels any other place of your choice.Female Escorts in Mahipalpur are waiting eagerly to meet you. You need to decide whether you want to meet them at home or at any hotel. If you are facing any challenges in arranging any place, let me inform you that we have tie-ups with 3 start hotels as well as 5 start hotels. Check our other services...
Russian Call Girls in Mahipalpur
Russian Escorts in Mahipalpur
Escorts in Aerocity
Escorts Service in Aerocity
Female Escorts in Aerocity
Escorts in Aerocity



Darren Demers said...

The Interceptor uses a private ThreadLocal to propagate invocation state by linking the InvocationContext objects together. The result is that you can do an infinite amount of state tracking as well as write some pretty impressive diagnostic tools. double bed bedsheet cotton , pretty bed sheets , best quality bed sheets online , bridal satin sheets , sateen duvet cover set , baby razai set , 3 cushion sofa covers , crushed velvet bedding

nituroy.com said...

I really appreciate the way you write...Please check my work as well
Jaipur Call Girl
Jaipur Call Girl
Jaipur Call Girl
Delhi Call Girl
Guwahati Call Girl
Guwahati Call Girl
Guwahati Call Girl
Guwahati Call Girl
Aerocity Call Girl
Lucknow Call Girl

postsblog said...

It may take some time for new users to remember your SIM card number. If you have forgotten your Airtel number or do not know your Airtel number, you should get one. These are different ways to check airtel number

Arnold DK said...

Thanks for sharing this article. keep it up work done job. Thanks for sharing this information with all of us. whatsapp mod