Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe you're mixing up two ways of proxy creation: CGLib and runtime proxy. First one creates proxy while your class is being loaded and the second one as it name says does it in a runtime. They are the same in a way that both of they are creating transparent proxy around your object, but there are some significant differences between them. For example, CGlib requires a class to be non-final and have default constructor. Or let's consider following example. Let's say you have a service <code>MyService</code>:</p> <pre><code>public class MyService { @Transactional public void proxifiedMethod(){ // some logic here } public void pureMethod(){ // some logic here... proxifiedMethod(); // ...and here } } </code></pre> <p>Let's say you need <code>proxifiedMethod</code> to run inside a transaction and you give a hint to a framework you use with <code>@Transactional</code> annotation. If the framework (let's say Spring) is confiured to use runtime proxies, a transaction for the <code>proxifiedMethod</code> which is invoked from <code>pureMethod</code> won't be created, in case of CGLib it will.</p> <p>Answering your questions:</p> <ol> <li><p>Original class is a class around instance of which the proxy object is created.</p></li> <li><p>Runtime proxies you're referring to are widely used in Java enterprise world when it comes to such <a href="http://en.wikipedia.org/wiki/Cross-cutting_concern" rel="nofollow">cross-cutting concerns</a> as transactions or security. Usually you don't want to mess your code with manual transaction management, it's something that's done by a framework like Spring or even an application container like JBoss. So you add some meta information like <code>@Transactional</code> annotation, and framework creates a proxy around your annotated service to handle logic of transaction management there. </p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload