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
1
vote
1 answer

DryIoc open generic interception with castle core

I want to register open generic interception, so I modified explample from https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/Interception.md [TestFixture] public class UnitTest3 { public interface IFoo { void Greet(); …
1
vote
2 answers

Mixing in side-table data with NHibernate interceptors and DynamicProxy

I'm working on a problem in which I have a number of entities, each of which has a corresponding one-to-many translations table, which specify the localized versions of entity's fields. (all of this is legacy schema I'm adding a map on top of). For…
user24359
1
vote
1 answer

Endless loop and StackOverflow with a proxy

I'm trying to make the tricky thing. I have method ObjectFactory.getObject() which returns an Object that needs to implement Serializable. I'm trying to make a proxy of an already existing instance of ObjectFactory, intercept its method getObject()…
Woods
  • 119
  • 1
  • 12
1
vote
1 answer

Which feature of kotlin can be used as a replacedment of method interception via java proxies

In java if I want to intercept the method calls on a class I can use Proxy.newProxyInstance() and provide an InvocationHandler implementing invoke(). I've seen that in kotlin you can use delegated properties to kind of intercept property access. …
Marinos An
  • 9,481
  • 6
  • 63
  • 96
1
vote
2 answers

Apply Dynamic Proxy to all the classes in an application

I want to apply the Dynamic Proxy I created to all the classes that are part of my application. But, I also want to be able to use dependency injection (Spring) instead of writing something like MyDynamicProxy.newInstance(new Account()); Where…
1
vote
2 answers

cost of .net dynamic proxies

What is the cost of using dynamic proxies? I do not want to clutter my project with Interface Implementations, so I am considering using Dynamic proxies created by some 3rd party library like LinFu , Castle, Unity etc. Do they generate one instance…
hazimdikenli
  • 5,709
  • 8
  • 37
  • 67
1
vote
2 answers

Why method invoke return null for method put from proxied Map

There is a problem when method invoke is called for the method- 'V put(K key, V val)' from proxied Map it returns null. But for the method - V get(K key) it is all right. See code example package com.dynamic.proxy; import…
user11517667
1
vote
0 answers

StructureMap interceptor and DynamicProxy

I am trying to upgrade StructureMap from 2.6 to 4.7. I had an interceptor which creates and return proxy. public object Process(object target, IContext context) { Type targetType = target.GetType(); var instanceRef =…
user2412672
  • 1,459
  • 3
  • 20
  • 36
1
vote
1 answer

Resolve EF dynamic proxy in Autofac

I'm using Entity Framework and have registered some types for use in a factory class. Registration is performed using Keyed like this: builder.RegisterType().Keyed(typeof(TypeA)); Here TypeA is an…
Vincent
  • 1,119
  • 11
  • 25
1
vote
2 answers

Detailed ServiceDescription / Proxy from WSDL

I am using the classes ServiceDescription / ServiceDescriptionImporter to dynamically call web services. I'd like to dig a bit deeper into the WSDL description and get 1) Parameter info for each of the web methods 2) The actual types / composition…
Sean Thoman
  • 7,429
  • 6
  • 56
  • 103
1
vote
0 answers

How would you expose type of implementing (not invocation handler!) class from proxy?

How would you expose type of implementing class of an object regardless of whether it's real object or proxy ? Here is example of the problem https://github.com/AsyncHttpClient/async-http-client/issues/1523 I thought I could intercept getClass call…
expert
  • 29,290
  • 30
  • 110
  • 214
1
vote
2 answers

CastleDynamic only get the virtual values

While I'm testing the Castle DynamicProxy I found an weird behavior I didn't found good documentation, so the closer information I found was theses 2 ask Castle Dynamic Proxy not intercepting method calls when invoked from within the class and Why…
Nicollas Braga
  • 802
  • 7
  • 27
1
vote
2 answers

TypeScript API in .NET Core version

Does the ABP template for .NET Core have the features listed in Javascript-API? More importantly, can the .NET Core version generate the dynamic proxy (services.ts) corresponding to my server-side entities?
pinale
  • 2,060
  • 6
  • 38
  • 72
1
vote
1 answer

Why jdk dynamic proxy invoke InvocationHandler.invoke "toString" method when debug every step over mode

When I use jdk dynamic proxy ,seems Object proxy = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { xx }, handler); When I debug the program ,step over one by one, handler variant will…
Jim Green
  • 1,088
  • 3
  • 15
  • 40
1
vote
0 answers

AutoMapper not calling AfterMap when mapping a dynamic proxy

Let's say I've designed a class A and also I've designed a DTO class called Dto. If A is a dynamic proxy generated with Castle DynamicProxy, AutoMapper won't fire AfterMap: mappingConfig.CreateMap() .AfterMap ( (dto, a,…
Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206