@Override @Nullable public Object getSource() { return this.pointcutDefinition.getSource(); }
/** * Expose the bean definition's source object. * @see BeanDefinition#getSource() */ @Override @Nullable public Object getSource() { return this.beanDefinition.getSource(); }
@Override @Nullable public Object getSource() { return this.advisorDefinition.getSource(); }
/** * Determine whether the given new bean definition is compatible with * the given existing bean definition. * <p>The default implementation considers them as compatible when the existing * bean definition comes from the same source or from a non-scanning source. * @param newDefinition the new bean definition, originated from scanning * @param existingDefinition the existing bean definition, potentially an * explicitly defined one or a previously generated one from scanning * @return whether the definitions are considered as compatible, with the * new definition to be skipped in favor of the existing definition */ protected boolean isCompatible(BeanDefinition newDefinition, BeanDefinition existingDefinition) { return (!(existingDefinition instanceof ScannedGenericBeanDefinition) || // explicitly registered overriding bean (newDefinition.getSource() != null && newDefinition.getSource().equals(existingDefinition.getSource())) || // scanned same file twice newDefinition.equals(existingDefinition)); // scanned equivalent class twice }
/** * Determine whether the given new bean definition is compatible with * the given existing bean definition. * <p>The default implementation considers them as compatible when the existing * bean definition comes from the same source or from a non-scanning source. * @param newDefinition the new bean definition, originated from scanning * @param existingDefinition the existing bean definition, potentially an * explicitly defined one or a previously generated one from scanning * @return whether the definitions are considered as compatible, with the * new definition to be skipped in favor of the existing definition */ protected boolean isCompatible(BeanDefinition newDefinition, BeanDefinition existingDefinition) { return (!(existingDefinition instanceof ScannedGenericBeanDefinition) || // explicitly registered overriding bean (newDefinition.getSource() != null && newDefinition.getSource().equals(existingDefinition.getSource())) || // scanned same file twice newDefinition.equals(existingDefinition)); // scanned equivalent class twice }
/** * Expose the bean definition's source object. * @see BeanDefinition#getSource() */ @Override @Nullable public Object getSource() { return this.beanDefinition.getSource(); }
private <T> Stream<String> getBeanNamesByTypeWithAnnotation(Class<? extends Annotation> annotationType, Class<T> beanType) throws Exception { return Stream.of(applicationContext.getBeanNamesForType(beanType)) .filter(name -> { final BeanDefinition beanDefinition = applicationContext.getBeanFactory().getBeanDefinition(name); final Map<String, Object> beansWithAnnotation = applicationContext.getBeansWithAnnotation(annotationType); if (beansWithAnnotation.containsKey(name)) { return true; } else if (beanDefinition.getSource() instanceof AnnotatedTypeMetadata) { return AnnotatedTypeMetadata.class.cast(beanDefinition.getSource()).isAnnotated(annotationType.getName()); } return false; }); }
private void validateComponentDefinition(ComponentDefinition compDef) { BeanDefinition[] beanDefs = compDef.getBeanDefinitions(); for (BeanDefinition beanDef : beanDefs) { assertNotNull("BeanDefinition has no source attachment", beanDef.getSource()); } }
private void createRememberMeProvider(String key) { RootBeanDefinition provider = new RootBeanDefinition( RememberMeAuthenticationProvider.class); provider.setSource(rememberMeFilter.getSource()); provider.getConstructorArgumentValues().addGenericArgumentValue(key); String id = pc.getReaderContext().generateBeanName(provider); pc.registerBeanComponent(new BeanComponentDefinition(provider, id)); rememberMeProviderRef = new RuntimeBeanReference(id); }
/** * Given a Factory Name return the generic type parameters of the factory (The actual repository class, and its properties class)o */ public static Type[] getEnvironmentRepositoryFactoryTypeParams(ConfigurableListableBeanFactory beanFactory, String factoryName) { MethodMetadata methodMetadata = (MethodMetadata) beanFactory.getBeanDefinition(factoryName).getSource(); Class<?> factoryClass = null; try { factoryClass = Class.forName(methodMetadata.getReturnTypeName()); } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } Optional<AnnotatedType> annotatedFactoryType = Arrays.stream(factoryClass.getAnnotatedInterfaces()) .filter(i -> { ParameterizedType parameterizedType = (ParameterizedType) i.getType(); return parameterizedType.getRawType().equals(EnvironmentRepositoryFactory.class); }).findFirst(); ParameterizedType factoryParameterizedType = (ParameterizedType) annotatedFactoryType .orElse(factoryClass.getAnnotatedSuperclass()).getType(); return factoryParameterizedType.getActualTypeArguments(); }
emBeanDefinition.setSource(definition.getBeanDefinition().getSource()); emBeanDefinition.setLazyInit(true);
/** * Expose the bean definition's source object. * @see BeanDefinition#getSource() */ public Object getSource() { return this.beanDefinition.getSource(); }
setSource(other.getSource()); copyAttributesFrom(other);
setSource(other.getSource()); copyAttributesFrom(other);
setFactoryMethodName(original.getFactoryMethodName()); setRole(original.getRole()); setSource(original.getSource()); copyAttributesFrom(original);
@Override public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (beanDefinition instanceof AnnotatedBeanDefinition) { AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata(); Map<String, Object> annotationAttributes = metadata .getAnnotationAttributes(GlobalChannelInterceptor.class.getName()); if (CollectionUtils.isEmpty(annotationAttributes) && beanDefinition.getSource() instanceof MethodMetadata) { MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource(); annotationAttributes = beanMethod.getAnnotationAttributes(GlobalChannelInterceptor.class.getName()); // NOSONAR not null } if (!CollectionUtils.isEmpty(annotationAttributes)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .genericBeanDefinition(GlobalChannelInterceptorWrapper.class) .addConstructorArgReference(beanName) .addPropertyValue("patterns", annotationAttributes.get("patterns")) .addPropertyValue("order", annotationAttributes.get("order")); BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), registry); } } } }
@Override public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (beanDefinition instanceof AnnotatedBeanDefinition) { AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata(); boolean hasIntegrationConverter = metadata.hasAnnotation(IntegrationConverter.class.getName()); if (!hasIntegrationConverter && beanDefinition.getSource() instanceof MethodMetadata) { MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource(); hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName()); // NOSONAR never null } if (hasIntegrationConverter) { this.registerConverter(registry, new RuntimeBeanReference(beanName)); } } } }
@Override public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; Map<String, Set<String>> securityInterceptors = new ManagedMap<>(); Map<String, Map<Pattern, ChannelAccessPolicy>> policies = new HashMap<>(); for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (ChannelSecurityInterceptor.class.getName().equals(beanDefinition.getBeanClassName())) { collectPatternsFromInterceptor(securityInterceptors, beanName, beanDefinition); } else if (beanDefinition instanceof AnnotatedBeanDefinition) { Object beanSource = beanDefinition.getSource(); if (beanSource instanceof MethodMetadata) { collectInterceptorsAndPoliciesBySecuredChannel(securityInterceptors, policies, beanName, (MethodMetadata) beanSource); } } } if (!securityInterceptors.isEmpty()) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ChannelSecurityInterceptorBeanPostProcessor.class) .addConstructorArgValue(securityInterceptors); if (!policies.isEmpty()) { builder.addConstructorArgValue(policies); } registry.registerBeanDefinition(CHANNEL_SECURITY_INTERCEPTOR_BPP_BEAN_NAME, builder.getBeanDefinition()); } }
setFactoryMethodName(original.getFactoryMethodName()); setRole(original.getRole()); setSource(original.getSource()); copyAttributesFrom(original);
private void createRememberMeProvider(String key) { RootBeanDefinition provider = new RootBeanDefinition( RememberMeAuthenticationProvider.class); provider.setSource(rememberMeFilter.getSource()); provider.getConstructorArgumentValues().addGenericArgumentValue(key); String id = pc.getReaderContext().generateBeanName(provider); pc.registerBeanComponent(new BeanComponentDefinition(provider, id)); rememberMeProviderRef = new RuntimeBeanReference(id); }