Example usage for org.springframework.aop.target SingletonTargetSource getTarget

List of usage examples for org.springframework.aop.target SingletonTargetSource getTarget

Introduction

In this page you can find the example usage for org.springframework.aop.target SingletonTargetSource getTarget.

Prototype

@Override
    public Object getTarget() 

Source Link

Usage

From source file:annis.test.TestHelper.java

public static Object proxyTarget(Object proxy) {
    if (!(proxy instanceof Proxy))
        fail("Not a proxy: " + proxy);

    SingletonTargetSource targetSource = null;
    try {//from   w w  w  .j ava 2s.  c  o  m
        targetSource = (SingletonTargetSource) proxy.getClass().getMethod("getTargetSource").invoke(proxy);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    if (targetSource == null)
        fail("Couldn't get target of annisDao proxy");

    return targetSource.getTarget();
}

From source file:org.springframework.aop.target.CommonsPoolTargetSourceTests.java

@Test
public void testTargetSourceSerializableWithoutConfigMixin() throws Exception {
    CommonsPoolTargetSource cpts = (CommonsPoolTargetSource) beanFactory.getBean("personPoolTargetSource");

    SingletonTargetSource serialized = (SingletonTargetSource) SerializationTestUtils
            .serializeAndDeserialize(cpts);
    assertTrue(serialized.getTarget() instanceof Person);
}