Example usage for org.springframework.aop.framework ProxyFactory setOpaque

List of usage examples for org.springframework.aop.framework ProxyFactory setOpaque

Introduction

In this page you can find the example usage for org.springframework.aop.framework ProxyFactory setOpaque.

Prototype

public void setOpaque(boolean opaque) 

Source Link

Document

Set whether proxies created by this configuration should be prevented from being cast to Advised to query proxy status.

Usage

From source file:org.springframework.data.rest.core.projection.ProxyProjectionFactory.java

@Override
@SuppressWarnings("unchecked")
public <T> T createProjection(Object source, Class<T> projectionType) {

    Assert.isTrue(projectionType.isInterface(), "Projection type must be an interface!");

    if (source == null) {
        return null;
    }/*from   w  w  w  .  j  av a2  s  .  c  o m*/

    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(source);
    factory.setOpaque(true);
    factory.setInterfaces(projectionType, TargetClassAware.class);

    factory.addAdvice(new TargetClassAwareMethodInterceptor(source.getClass()));
    factory.addAdvice(getMethodInterceptor(source, projectionType));

    return (T) factory.getProxy();
}