Example usage for org.springframework.cglib.proxy Enhancer registerStaticCallbacks

List of usage examples for org.springframework.cglib.proxy Enhancer registerStaticCallbacks

Introduction

In this page you can find the example usage for org.springframework.cglib.proxy Enhancer registerStaticCallbacks.

Prototype

public static void registerStaticCallbacks(Class generatedClass, Callback[] callbacks) 

Source Link

Document

Similar to #registerCallbacks , but suitable for use when multiple threads will be creating instances of the generated class.

Usage

From source file:com.example.post.MyConfigurationClassEnhancer.java

/**
 * Uses enhancer to generate a subclass of superclass,
 * ensuring that callbacks are registered for the new subclass.
 *//*from   ww  w .  j  a va 2  s.c  o  m*/
private Class<?> createClass(Enhancer enhancer) {
    Class<?> subclass = enhancer.createClass();
    // Registering callbacks statically (as opposed to thread-local)
    // is critical for usage in an OSGi environment (SPR-5932)...
    Enhancer.registerStaticCallbacks(subclass, CALLBACKS);
    return subclass;
}