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

40 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...

docomo balance check codes
telenor balance check codes
airtel phone no check

vodafone balance check code
airtel balance check code

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

Unknown said...

Vodafone Balance Transfer
Vodafone Unlimited Calling Plan
Vodafone SMS Pack
Voafone Caller Tune
Vodafone Internet settings
Vodafone DND Services
Vodafone Loan Number
Vodafone Customer Care Numbers
Port Vodafone Number

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

Unknown said...

just information we only provide information for those who need it cara menggugurkan hamil
A. cara agar cepat hamil setelah selesai haid
B. cara agar cepat hamil
C. cara alami untuk segera mendapat kehamilan
D. makanan dan minuman agar cepat hamil
E. masa subur biar cepat hamil
F. panduan agar cepat hamil

Bigg Boss said...

Bigg Boss 12 Winner
http://biggboss11winner.com
Bigg Boss 12 Winner
http://biggboss11winner.com/bigg-boss-12-winner/

bike rent in dehradun said...

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

Unknown said...

Helplinehub bankhelp axis bank account balance check allahbad bank account balance check andhra bank account blance check airtel payment bank balance check

Sahib Khan said...


bestlaptops12
bestphones90
bestmobiles44
bestlaptop22
bestlaptopsunder40000
bestphonesunder15000
bestlaptopsunder25000
bestlaptopsunder20000
bestphonesunder5000
bestphonesunder10000

Sahib Khan said...


Sandeep Maheshwari
Sandeep Maheshwari Quotes

Renu said...

JioFi Local Html

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



Sahib Khan said...

home depot black friday sales
bose black friday headphone deals
built in bbq black friday sale
black friday xbox
automotive parts ordered on black friday vs cyber monda

home depot black friday sales
bose black friday headphone deals
built in bbq black friday sale
black friday xbox
automotive parts ordered on black friday vs cyber monda

Ms Nikita Agarwal said...

Thanks for sharing the article...You write very well...If you need backlinks please reach me on genuinehotelescorts@gmail.com
Call girls in jaipur
Call girls in Jaipur
Call girls in Jaipur
Call girls in Delhi
Call girls in Guwahati
Call girls in Guwahati
Call girls in Guwahati
Call girls in Guwahati
Call girls in Aerocity
Call girls in Lucknow

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

Chicks in Dubai said...

Independent Escorts in Dubai is the right decision. the top Dubai Escorts at your one Click. Log on to us for entertainment.

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