I faced with common issue: I want be able to check if sender is a authorized user and to know who she/he is. I Decided to provide some heads to every single call by Injecting authorization token. For this purpose i made a ProtocolWrapper that do stuff like the following:
Then It's needed to process request , take out this authorization token, change it on user information and provide access to it inside methods of a heandler.
Taking out authorization token from data stream is pretty easy to do. For instance TMultiplexProcessor does the same stuff. Or there is even a better way - providing a ProcessorEventHandler which operates callContext which can do this work.
But the accessing taken data inside methods of a handler appeared a very difficult thing because callContext CAN NOT really influence on a method call or method arguments!
So, the idea is to generate a handler interface which can take callContext of Processor for it's direct access.
For example from this thrift service definition
would generate the following code:
This requires small change in a SomeServiceProcessor. It should call method with context.
But this change wont break an existing code because of forwarding calls to non-context methods by default.
Does it make any sense or there is a better way to do what I want?
you can look at prototype of this change in my fork