pass task context when dealing with Java Dynamic Proxy
See original GitHub issueHi , create a new Task inside Dynamic Proxy invoke method could get around the non-weaved problem , but if i put the execution logic inside the Task Body, then i will lost the previous Task’s context . `@override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final Method mtd = method;
final Object[] ags = args;
if (!sppCmdMap.containsKey(method.getName())) {
return null;
}
final RpcContext rpcContext = RpcContext.getContext(KilimTask.getCurrentTask().id);
Task t = new Task() {
public void execute() throws Exception, Pausable {
if (!sppCmdMap.containsKey(mtd.getName())) {
return;
}
RpcCmdInfo cmd = sppCmdMap.get(mtd.getName());
if (ags[0] instanceof List) {
List<Message> reqs = (List<Message>) ags[0];
exit(rpcInvokeBatch(reqs, cmd, rpcContext));
} else {
Message req = (Message) ags[0];
exit(rpcInvoke(req, cmd, rpcContext));
}
}
};
t.start();
ExitMsg m = t.joinb();
return m.result;
} `
here if i want get the previous Task’s Context , i have to use KilimTask.getCurrentTask().id but this is a Pausable method … is there any good idea to solve this ? Tks advance ! : ) BTW , Kilim is really awesome ! our team is really enjoy with it .
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (2 by maintainers)
Top Results From Across the Web
Java Dynamic Proxy - How reference concrete class
The way to intercept methods using dynamic proxies are by: public class FooHandler implements InvocationHandler { private Object realObject; ...
Read more >Dynamic Proxies in Java - Baeldung
Simply put, proxies are fronts or wrappers that pass function invocation through their own facilities (usually onto real methods) – potentially ...
Read more >Dynamic Proxy Classes
A dynamic proxy class is a class that implements a list of interfaces specified at runtime such that a method invocation through one...
Read more >Dynamic Proxies | Java Type Information and Reflection
A dynamic proxy can intercept a method call, examine or modify the parameters, pass the call to some other object, examine or modify...
Read more >A Guide To Java Dynamic Proxies And It In Coding. - Xperti
Java dynamic proxies is a design pattern used to extend the pre-made methods without making any changes in them.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JasonHuangHuster i just saw your DynamicWeaverExampleKilim.txt file - i’ll take a look and see if that helps me understand this problem
the invoke demo is working with java 7, 8, 9, 10 and 11 - closing this issue, feel free to reopen or create a new issue if this doesn’t solve your issue (no additional comments since january)