Advisor[] advisors = getAdvisors(); List<Advisor> freshAdvisors = new ArrayList<>(advisors.length); for (Advisor advisor : advisors) {
assertEquals("Have one advisors", 1, config.getAdvisors().length); assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(config.getObjectType())); assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(factory.getType("test1"))); assertEquals("Have correct advisor count", 2, config.getAdvisors().length);
/** * Checks that globals get invoked, * and that they can add aspect interfaces unavailable * to other beans. These interfaces don't need * to be included in proxiedInterface []. */ @Test public void testGlobalsCanAddAspectInterfaces() { AddedGlobalInterface agi = (AddedGlobalInterface) factory.getBean("autoInvoker"); assertTrue(agi.globalsAdded() == -1); ProxyFactoryBean pfb = (ProxyFactoryBean) factory.getBean("&validGlobals"); // Trigger lazy initialization. pfb.getObject(); // 2 globals + 2 explicit assertEquals("Have 2 globals and 2 explicit advisors", 3, pfb.getAdvisors().length); ApplicationListener<?> l = (ApplicationListener<?>) factory.getBean("validGlobals"); agi = (AddedGlobalInterface) l; assertTrue(agi.globalsAdded() == -1); try { agi = (AddedGlobalInterface) factory.getBean("test1"); fail("Aspect interface should't be implemeneted without globals"); } catch (ClassCastException ex) { } }
ti.setTime(time); int oldCount = config.getAdvisors().length; config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class)); assertTrue(config.getAdvisors().length == oldCount + 1); assertTrue(config.getAdvisors().length == oldCount); assertTrue(config.getAdvisors().length == oldCount);
/** * Return an independent advisor chain. * We need to do this every time a new prototype instance is returned, * to return distinct instances of prototype Advisors and Advices. */ private List freshAdvisorChain() { Advisor[] advisors = getAdvisors(); List freshAdvisors = new ArrayList(advisors.length); for (int i = 0; i < advisors.length; i++) { if (advisors[i] instanceof PrototypePlaceholderAdvisor) { PrototypePlaceholderAdvisor pa = (PrototypePlaceholderAdvisor) advisors[i]; if (logger.isDebugEnabled()) { logger.debug("Refreshing bean named '" + pa.getBeanName() + "'"); } // Replace the placeholder with a fresh protoype instance resulting // from a getBean() lookup Object bean = this.beanFactory.getBean(pa.getBeanName()); Advisor refreshedAdvisor = namedBeanToAdvisor(bean); freshAdvisors.add(refreshedAdvisor); } else { // Add the shared instance. freshAdvisors.add(advisors[i]); } } return freshAdvisors; }
Advisor[] advisors = getAdvisors(); List<Advisor> freshAdvisors = new ArrayList<>(advisors.length); for (Advisor advisor : advisors) {
Advisor[] advisors = getAdvisors(); List<Advisor> freshAdvisors = new ArrayList<Advisor>(advisors.length); for (Advisor advisor : advisors) {