Questions tagged [dynamic-proxy]

A Dynamic Proxy is a class that implements a list of interfaces specified at runtime such that a method invocation through one of the interfaces on an instance of the class will be encoded and dispatched to another object through a uniform interface.

A Dynamic Proxy is a class that implements a list of interfaces specified at runtime such that a method invocation through one of the interfaces on an instance of the class will be encoded and dispatched to another object through a uniform interface. Thus, a dynamic proxy class can be used to create a type-safe proxy object for a list of interfaces without requiring pre-generation of the proxy class, such as with compile-time tools. Method invocations on an instance of a dynamic proxy class are dispatched to a single method in the instance's invocation handler, and they are encoded with a java.lang.reflect.Method object identifying the method that was invoked and an array of type Object containing the arguments.

Dynamic proxy classes are useful to an application or library that needs to provide type-safe reflective dispatch of invocations on objects that present interface APIs. For example, an application can use a dynamic proxy class to create an object that implements multiple arbitrary event listener interfaces (interfaces that extend java.util.EventListener) to process a variety of events of different types in a uniform fashion, such as by logging all such events to a file.

226 questions
2
votes
1 answer

How can I create a dynamic proxy out of a List

I'm using Castle Dynamic Proxy CreateClassProxyWithTarget using an already existing list. Basically, I'd like to to intercept the calls being made to the list indexer. I've tried a bunch of combination to achieve this goal but each time the created…
Literal
  • 757
  • 6
  • 16
2
votes
1 answer

How to get the type of an EF dynamic proxy class without a class instance

Dynamic proxies have names like ClassName_00394CF1F92740F13E3EDBE858B6D599DFAF87AA5A089245977F61A32C75AA22 where the POCO class was simply called Classname. I know to can get the POCO type of an EF dynamic proxy instance with…
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
2
votes
1 answer

Is it possible create a single dynamic proxy that can add functionality to any concrete class?

I'll give a brief overview of my goals below just in case there are any better, alternative ways of accomplishing what I want. This question is very similar to what I need, but not quite exactly what I need. My question... I have an…
Ryan J
  • 2,502
  • 5
  • 31
  • 41
2
votes
1 answer

Creating a dynamic proxy in Java steals focus on OS X

Creating a dynamic proxy (java.lang.reflect.Proxy) causes OS X (at least 10.7 and 10.8) to give focus to the Java application that created the proxy. The proxy I create wraps an object that starts an external process. This external process expects…
Jonatan
  • 297
  • 1
  • 6
2
votes
1 answer

Allowing a Dynamic Proxy to cast to any compatible interface. Regardless

I made a Dynamic Proxy to be the middle man when handling specific methods in a class. I'm doing this to avoid having to override every single method in each of the interfaces that I need to take control of. Waffley bit that nobody will understand…
Chris Watts
  • 6,197
  • 7
  • 49
  • 98
1
vote
2 answers

Java Intercepting the calls to an Interface Method

I need to intercept the calls to all the method calls to an Interface. I've gone through the Java Dynamic Proxies however that will not help me. I'm not even sure whether this can be achieved, but thought of confirming. So basically lets say i have…
user320550
  • 1,093
  • 6
  • 20
  • 37
1
vote
2 answers

Is it possible to create dynamic proxy for enum in Java?

Am I right that's it impossible to use dynamic proxy with java enums? Thanks in advance.
dhblah
  • 9,751
  • 12
  • 56
  • 92
1
vote
1 answer

EF4.1, POCOS, Dynamic Proxies and collections

Is there any particular reason why adding an item to an EF4.1 collection, saving it to the database and then selecting that collection out again would produce weird results? When I do the initial load, all the items in the collection are of a type…
user32826
1
vote
1 answer

Looking for an one file AOP proxy generator

I'm working on an automatic pageable collection for WPF. I'm using internally the excellent library LinFu.DynamicProxy. I would like to minimize the dependencies, and I did not find any "one file" solution implementyng a DynamicProxy generator, so I…
Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
1
vote
0 answers

com.chaquo.python.PyException: NotImplementedError: com.chaquo.python.PyProxy._chaquopyGetDict is abstract and cannot be called

I'm using 'class R(dynamic_proxy(Runnable)):' to modify textview component of my app UI def pBar(count_value, total, prefix, activity, textView_debug): bar_length = 10 filled_up_Length = int(round(bar_length*count_value/(total))) …
Bot Bahlul
  • 11
  • 1
  • 2
1
vote
2 answers

Unable to cast Playlist to FolderPlaylist using obstmusic Java applescript wrapper for MacOS Music app

Trying to use https://github.com/japlscript/obstmusic to talk to Apple Music app on macOS with Java, I used to write native AppleScript and then java applescript library but that was removed from Java. In this method it looks for a existing folder…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
1
vote
0 answers

Java Reflection. Unable to create java.reflect.Proxy because of 'Methods with same signature'

I am trying to make a Proxy class that implements a class called Player. public Player asPlayer() { return (Player) Proxy.newProxyInstance(Player.class.getClassLoader(), new Class[]{Player.class}, new…
J.Doe
  • 11
  • 1
1
vote
2 answers

RMI's dynamic proxy stub implementation

I want to understand how the dynamic proxy stub implementation is actually done behind the scene. According to what I read, by the time a remote object is exported if no pre-generated stub class is found, the RMI runtime would generate a dynamic…
Buu
  • 49,745
  • 5
  • 67
  • 85
1
vote
1 answer

How to make the JVM proxy the only one interface method?

public interface Action { void doSomething(); void dontProxy(); } For example with this interface, I just want the JVM to proxy the doSomething method. class DynamicProxy implements InvocationHandler{ private Action work; public…
1
vote
1 answer

Proxy object invoke throws argument type mismatch

I use a Proxy call another Proxy failed. Always throws argument type mismatch exception. Is there anyone who can help? Here is the code. // 1, use mybatis sqlSessionFactory create a Proxy object for MapperProxy. @Suppress("UNCHECKED_CAST") private…
w-0821
  • 31
  • 4