P
P
pqgg7nwkd42016-11-09 18:03:10
Java
pqgg7nwkd4, 2016-11-09 18:03:10

How to create a proxy for a class in Java?

Good afternoon.
There are many places on the Internet where you can find instructions for creating a Proxy wrapper for a set of interfaces. This is done with java.lang.reflect.Proxy.newProxyInstance(). But this method cannot create a proxy wrapper for a non-interface class.
Nevertheless, while studying Java EE, namely CDI, namely interceptors, I found that the container creates a proxy for the class, and not for the interface. For my MyTest class, he created a wrapper org.jboss.weld.proxies.MyTest$Proxy$_$$_WeldSubclass.
The question is, should I do it myself?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evhen, 2016-11-09
@EugeneP2

cglib
It is used by sprig to create proxies for classes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question