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

Find out if an object is already a ByteBuddy proxy

I'm implementing the DDD repository pattern (using an object database, but that is not important for the question) and in the repository there is a method like this: Entity save(Entity entity); Where Entity is an interface. In the implementation, I…
diegomtassis
  • 3,557
  • 2
  • 19
  • 29
2
votes
2 answers

AOP for C# dotnet core 2.0, access method parameter values before method body runs

This is my method, I am trying to validate componentToSave (or access method parameter values) and throw an exception before method body even runs. public Component SaveComponent(Component componentToSave) { ... } I tried using PostSharp but…
Node.JS
  • 1,042
  • 6
  • 44
  • 114
2
votes
3 answers

Using always encrypted on a entity framework [code first] database

I have an MVC application that uses entity framework / code first. I'm trying to set up always encrypted in order to encrypt a column (social security number / SSN). I'm running everything in Azure, including using Azure vault to store keys. I have…
2
votes
1 answer

Cannot get method annotation from JDK dynamic proxy

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this In my client, I could get the annotation on my method using my Real Object, but not Proxy Object. I used to think it was because of the lack…
mik2sa
  • 21
  • 1
  • 2
2
votes
1 answer

IntelliJ IDEA debug enter method multiple times

When debugging the following code: public class MyProxy { public static void main(String[] args){ Consumer f = (Consumer) Proxy.newProxyInstance( Consumer.class.getClassLoader(), new Class[] {…
matrix
  • 349
  • 3
  • 12
2
votes
3 answers

How to have a Spring dynamic proxy with 2 interfaces?

I have an object that is injected into my class by Spring (JdbcCursorItemReader if you care). It implements 5 interfaces, two of which I care about (ItemReader, ItemStream). If I code my class to one or the other, the spring dynamic proxy gets…
bwawok
  • 14,898
  • 7
  • 32
  • 43
2
votes
0 answers

Automapper EF6 Dynamic Proxy

We are developing an EF6 web project Code first. After reviewing a lot of different approaches for our project we have decided to divide our solution into these projects: "Model" project, contain the EF DataContext and all the Entities "Service"…
2
votes
2 answers

Java dynamically invoke method which is dynamically attached (by dynamic proxy) on an object

I have a method which has arguments an object instance and a string which represents the name of a method, with the following signature: Object executeDynamicMethod(Object instance, String methodName); I can easily execute the method by name by…
2
votes
2 answers

How to "really" down-cast a DynamicProxy back to its original type (to send over WCF)

OK, the situation is we have a class, PatientDto, and a DynamicProxy generated by Castle, PatientDtoProxy. We're using this proxy in the Silverlight client, then want to send it back to the server via a WCF service call. The WCF service Contract…
Bobby
  • 1,666
  • 3
  • 16
  • 27
2
votes
2 answers

How to call generic function in dynamic proxy by C#

The java version: I have the generic function as follows: public JsonEnvelop readResponse(Class t, Class k) And one class that implements InvocationHandler, in the invoke function, it will call the generic function just as…
Tommy Tan
  • 95
  • 1
  • 12
2
votes
1 answer

Dynamic Proxy vs Scripting in java

In case of customize object behavior at runtime, Java seems to provide two solutions, Java Scripting and Dynamic Proxy. suppose I have a configuration file and an interface I in Java, I can either create and load class implementing I according to…
Korben
  • 734
  • 1
  • 7
  • 26
2
votes
1 answer

Is the instance of Method class in java is global unique

In the whole jvm run life, is the Method class instance always unique? for example, I have a class which implements InvocationHandler. In method invoke, which has a Method parameter. I know all methods that i can handle, and I want to use different…
CodeBoy
  • 591
  • 6
  • 12
2
votes
2 answers

Castle dynamic proxy object to original object convertion

ProxyGenerator generator = new ProxyGenerator(); var interceptor = new StandardInterceptor(); MyInterfaceImpl test = (MyInterfaceImpl)generator.CreateClassProxy(typeof(MyInterfaceImpl), interceptor); In above example, test object is proxy…
amar kumar
  • 31
  • 2
2
votes
1 answer

Castle Dynamic Proxy in Windsor Container

I've got a bit of a problem. I'm working in the Castle Windsor IOC Container. Now what i wanted to do is just mess about with some AOP principles and what i specifically want to do is based on a method name perform some logging. I have been looking…
Iffy
  • 219
  • 3
  • 15
2
votes
0 answers

Castle.DynamicProxy.IInterceptor and Parallel transactions

I'm Building a class to intercept transactions DAO methods consultations, but I have a problem. If I run the application, the page called many methods at the same time and I get this error message: SqlConnection does not support parallel…