Search in sources :

Example 41 with Advised

use of org.springframework.aop.framework.Advised in project spring-framework by spring-projects.

the class CountingAspectJAdvice method testIsProxy.

@Test
public void testIsProxy() throws Exception {
    ITestBean bean = getTestBean();
    assertThat(AopUtils.isAopProxy(bean)).as("Bean is not a proxy").isTrue();
    // check the advice details
    Advised advised = (Advised) bean;
    Advisor[] advisors = advised.getAdvisors();
    assertThat(advisors.length > 0).as("Advisors should not be empty").isTrue();
}
Also used : ITestBean(org.springframework.beans.testfixture.beans.ITestBean) Advised(org.springframework.aop.framework.Advised) Advisor(org.springframework.aop.Advisor) Test(org.junit.jupiter.api.Test)

Example 42 with Advised

use of org.springframework.aop.framework.Advised in project cxf by apache.

the class SpringClassUnwrapper method getRealObject.

@Override
public Object getRealObject(Object o) {
    if (o instanceof Advised) {
        try {
            Advised advised = (Advised) o;
            Object target = advised.getTargetSource().getTarget();
            // could be a proxy of a proxy.....
            return getRealObject(target);
        } catch (Exception ex) {
        // ignore
        }
    }
    return o;
}
Also used : Advised(org.springframework.aop.framework.Advised) BeanCreationException(org.springframework.beans.factory.BeanCreationException)

Example 43 with Advised

use of org.springframework.aop.framework.Advised in project spring-security-oauth by spring-projects.

the class AbstractIntegrationTests method clear.

private void clear(TokenStore tokenStore) throws Exception {
    if (tokenStore instanceof Advised) {
        Advised advised = (Advised) tokenStore;
        TokenStore target = (TokenStore) advised.getTargetSource().getTarget();
        clear(target);
        return;
    }
    if (tokenStore instanceof InMemoryTokenStore) {
        ((InMemoryTokenStore) tokenStore).clear();
    }
    if (tokenStore instanceof JdbcTokenStore) {
        JdbcTemplate template = new JdbcTemplate(dataSource);
        template.execute("delete from oauth_access_token");
        template.execute("delete from oauth_refresh_token");
        template.execute("delete from oauth_client_token");
        template.execute("delete from oauth_code");
    }
}
Also used : InMemoryTokenStore(org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore) JdbcTokenStore(org.springframework.security.oauth2.provider.token.store.JdbcTokenStore) Advised(org.springframework.aop.framework.Advised) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) TokenStore(org.springframework.security.oauth2.provider.token.TokenStore) InMemoryTokenStore(org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore) JdbcTokenStore(org.springframework.security.oauth2.provider.token.store.JdbcTokenStore)

Example 44 with Advised

use of org.springframework.aop.framework.Advised in project spring-security-oauth by spring-projects.

the class AbstractIntegrationTests method clear.

private void clear(ApprovalStore approvalStore) throws Exception {
    if (approvalStore instanceof Advised) {
        Advised advised = (Advised) tokenStore;
        ApprovalStore target = (ApprovalStore) advised.getTargetSource().getTarget();
        clear(target);
        return;
    }
    if (approvalStore instanceof InMemoryApprovalStore) {
        ((InMemoryApprovalStore) approvalStore).clear();
    }
    if (approvalStore instanceof JdbcApprovalStore) {
        JdbcTemplate template = new JdbcTemplate(dataSource);
        template.execute("delete from oauth_approvals");
    }
}
Also used : InMemoryApprovalStore(org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore) Advised(org.springframework.aop.framework.Advised) InMemoryApprovalStore(org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore) ApprovalStore(org.springframework.security.oauth2.provider.approval.ApprovalStore) JdbcApprovalStore(org.springframework.security.oauth2.provider.approval.JdbcApprovalStore) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) JdbcApprovalStore(org.springframework.security.oauth2.provider.approval.JdbcApprovalStore)

Example 45 with Advised

use of org.springframework.aop.framework.Advised in project spring-framework by spring-projects.

the class EnableCachingIntegrationTests method assertCacheProxying.

private void assertCacheProxying(AnnotationConfigApplicationContext ctx) {
    FooRepository repo = ctx.getBean(FooRepository.class);
    boolean isCacheProxy = false;
    if (AopUtils.isAopProxy(repo)) {
        for (Advisor advisor : ((Advised) repo).getAdvisors()) {
            if (advisor instanceof BeanFactoryCacheOperationSourceAdvisor) {
                isCacheProxy = true;
                break;
            }
        }
    }
    assertTrue("FooRepository is not a cache proxy", isCacheProxy);
}
Also used : Advised(org.springframework.aop.framework.Advised) BeanFactoryCacheOperationSourceAdvisor(org.springframework.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor) Advisor(org.springframework.aop.Advisor) BeanFactoryCacheOperationSourceAdvisor(org.springframework.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor)

Aggregations

Advised (org.springframework.aop.framework.Advised)78 Advisor (org.springframework.aop.Advisor)21 Test (org.junit.jupiter.api.Test)20 Test (org.junit.Test)18 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)16 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)13 ProxyFactory (org.springframework.aop.framework.ProxyFactory)10 Advice (org.aopalliance.aop.Advice)8 JoinPoint (org.aspectj.lang.JoinPoint)6 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)6 TargetSource (org.springframework.aop.TargetSource)6 BeanCreationException (org.springframework.beans.factory.BeanCreationException)6 MessageChannel (org.springframework.messaging.MessageChannel)6 TestBean (org.springframework.beans.testfixture.beans.TestBean)4 ChannelAccessPolicy (org.springframework.integration.security.channel.ChannelAccessPolicy)4 ChannelSecurityInterceptor (org.springframework.integration.security.channel.ChannelSecurityInterceptor)4 ConfigAttribute (org.springframework.security.access.ConfigAttribute)4 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 List (java.util.List)3