/** * Adds an alias to an existing well-known name or registers a new instance of a {@link PathMatcher} * under that well-known name, unless already registered. * @return a RuntimeBeanReference to this {@link PathMatcher} instance */ public static RuntimeBeanReference registerPathMatcher(@Nullable RuntimeBeanReference pathMatcherRef, ParserContext parserContext, @Nullable Object source) { if (pathMatcherRef != null) { if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME); } parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME); } else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME) && !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) { RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class); pathMatcherDef.setSource(source); pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(PATH_MATCHER_BEAN_NAME, pathMatcherDef); parserContext.registerComponent(new BeanComponentDefinition(pathMatcherDef, PATH_MATCHER_BEAN_NAME)); } return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME); }
/** * Adds an alias to an existing well-known name or registers a new instance of a {@link UrlPathHelper} * under that well-known name, unless already registered. * @return a RuntimeBeanReference to this {@link UrlPathHelper} instance */ public static RuntimeBeanReference registerUrlPathHelper( @Nullable RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, @Nullable Object source) { if (urlPathHelperRef != null) { if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME); } parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME); } else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME) && !parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) { RootBeanDefinition urlPathHelperDef = new RootBeanDefinition(UrlPathHelper.class); urlPathHelperDef.setSource(source); urlPathHelperDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(URL_PATH_HELPER_BEAN_NAME, urlPathHelperDef); parserContext.registerComponent(new BeanComponentDefinition(urlPathHelperDef, URL_PATH_HELPER_BEAN_NAME)); } return new RuntimeBeanReference(URL_PATH_HELPER_BEAN_NAME); }
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { logger.warn("\n\n" + "********************************************************************\n" + "********** Security debugging is enabled. *************\n" + "********** This may include sensitive information. *************\n" + "********** Do not use in a production system! *************\n" + "********************************************************************\n\n"); // SPRING_SECURITY_FILTER_CHAIN does not exist yet since it is an alias that has // not been processed, so use FILTER_CHAIN_PROXY if (registry.containsBeanDefinition(BeanIds.FILTER_CHAIN_PROXY)) { BeanDefinition fcpBeanDef = registry .getBeanDefinition(BeanIds.FILTER_CHAIN_PROXY); BeanDefinitionBuilder debugFilterBldr = BeanDefinitionBuilder .genericBeanDefinition(DebugFilter.class); debugFilterBldr.addConstructorArgValue(fcpBeanDef); // Remove the alias to SPRING_SECURITY_FILTER_CHAIN, so that it does not // override the new // SPRING_SECURITY_FILTER_CHAIN definition registry.removeAlias(BeanIds.SPRING_SECURITY_FILTER_CHAIN); registry.registerBeanDefinition(BeanIds.SPRING_SECURITY_FILTER_CHAIN, debugFilterBldr.getBeanDefinition()); } }
/** * Adds an alias to an existing well-known name or registers a new instance of a {@link UrlPathHelper} * under that well-known name, unless already registered. * @return a RuntimeBeanReference to this {@link UrlPathHelper} instance */ public static RuntimeBeanReference registerUrlPathHelper( @Nullable RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, @Nullable Object source) { if (urlPathHelperRef != null) { if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME); } parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME); } else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME) && !parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) { RootBeanDefinition urlPathHelperDef = new RootBeanDefinition(UrlPathHelper.class); urlPathHelperDef.setSource(source); urlPathHelperDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(URL_PATH_HELPER_BEAN_NAME, urlPathHelperDef); parserContext.registerComponent(new BeanComponentDefinition(urlPathHelperDef, URL_PATH_HELPER_BEAN_NAME)); } return new RuntimeBeanReference(URL_PATH_HELPER_BEAN_NAME); }
/** * Adds an alias to an existing well-known name or registers a new instance of a {@link PathMatcher} * under that well-known name, unless already registered. * @return a RuntimeBeanReference to this {@link PathMatcher} instance */ public static RuntimeBeanReference registerPathMatcher(@Nullable RuntimeBeanReference pathMatcherRef, ParserContext parserContext, @Nullable Object source) { if (pathMatcherRef != null) { if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME); } parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME); } else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME) && !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) { RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class); pathMatcherDef.setSource(source); pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(PATH_MATCHER_BEAN_NAME, pathMatcherDef); parserContext.registerComponent(new BeanComponentDefinition(pathMatcherDef, PATH_MATCHER_BEAN_NAME)); } return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME); }
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { logger.warn("\n\n" + "********************************************************************\n" + "********** Security debugging is enabled. *************\n" + "********** This may include sensitive information. *************\n" + "********** Do not use in a production system! *************\n" + "********************************************************************\n\n"); // SPRING_SECURITY_FILTER_CHAIN does not exist yet since it is an alias that has // not been processed, so use FILTER_CHAIN_PROXY if (registry.containsBeanDefinition(BeanIds.FILTER_CHAIN_PROXY)) { BeanDefinition fcpBeanDef = registry .getBeanDefinition(BeanIds.FILTER_CHAIN_PROXY); BeanDefinitionBuilder debugFilterBldr = BeanDefinitionBuilder .genericBeanDefinition(DebugFilter.class); debugFilterBldr.addConstructorArgValue(fcpBeanDef); // Remove the alias to SPRING_SECURITY_FILTER_CHAIN, so that it does not // override the new // SPRING_SECURITY_FILTER_CHAIN definition registry.removeAlias(BeanIds.SPRING_SECURITY_FILTER_CHAIN); registry.registerBeanDefinition(BeanIds.SPRING_SECURITY_FILTER_CHAIN, debugFilterBldr.getBeanDefinition()); } }
private void removeDependantBeans(String parentName) { String[] dependentBeans = this.beanFactory.getDependentBeans(parentName); for (String beanName : dependentBeans) { removeDependantBeans(beanName); this.beanDefinitionRegistry.removeBeanDefinition(beanName); // TODO until https://jira.spring.io/browse/SPR-16837 String[] aliases = this.beanDefinitionRegistry.getAliases(beanName); for (String alias : aliases) { this.beanDefinitionRegistry.removeAlias(alias); } } }
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { Logger.logger.warn("\n\n" + "********************************************************************\n" + "********** Security debugging is enabled. *************\n" + "********** This may include sensitive information. *************\n" + "********** Do not use in a production system! *************\n" + "********************************************************************\n\n"); // SPRING_SECURITY_FILTER_CHAIN does not exist yet since it is an alias that has not been processed, so use FILTER_CHAIN_PROXY if (registry.containsBeanDefinition(BeanIds.FILTER_CHAIN_PROXY)) { BeanDefinition fcpBeanDef = registry.getBeanDefinition(BeanIds.FILTER_CHAIN_PROXY); BeanDefinitionBuilder debugFilterBldr = BeanDefinitionBuilder.genericBeanDefinition(DebugFilter.class); debugFilterBldr.addConstructorArgValue(fcpBeanDef); // Remove the alias to SPRING_SECURITY_FILTER_CHAIN, so that it does not override the new // SPRING_SECURITY_FILTER_CHAIN definition registry.removeAlias(BeanIds.SPRING_SECURITY_FILTER_CHAIN); registry.registerBeanDefinition(BeanIds.SPRING_SECURITY_FILTER_CHAIN, debugFilterBldr.getBeanDefinition()); } }
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { logger.warn("\n\n" + "********************************************************************\n" + "********** Security debugging is enabled. *************\n" + "********** This may include sensitive information. *************\n" + "********** Do not use in a production system! *************\n" + "********************************************************************\n\n"); // SPRING_SECURITY_FILTER_CHAIN does not exist yet since it is an alias that has // not been processed, so use FILTER_CHAIN_PROXY if (registry.containsBeanDefinition(BeanIds.FILTER_CHAIN_PROXY)) { BeanDefinition fcpBeanDef = registry .getBeanDefinition(BeanIds.FILTER_CHAIN_PROXY); BeanDefinitionBuilder debugFilterBldr = BeanDefinitionBuilder .genericBeanDefinition(DebugFilter.class); debugFilterBldr.addConstructorArgValue(fcpBeanDef); // Remove the alias to SPRING_SECURITY_FILTER_CHAIN, so that it does not // override the new // SPRING_SECURITY_FILTER_CHAIN definition registry.removeAlias(BeanIds.SPRING_SECURITY_FILTER_CHAIN); registry.registerBeanDefinition(BeanIds.SPRING_SECURITY_FILTER_CHAIN, debugFilterBldr.getBeanDefinition()); } }
/** * Adds an alias to an existing well-known name or registers a new instance of a {@link PathMatcher} * under that well-known name, unless already registered. * @return a RuntimeBeanReference to this {@link PathMatcher} instance */ public static RuntimeBeanReference registerPathMatcher( RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) { if (pathMatcherRef != null) { if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME); } parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME); } else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME) && !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) { RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class); pathMatcherDef.setSource(source); pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(PATH_MATCHER_BEAN_NAME, pathMatcherDef); parserContext.registerComponent(new BeanComponentDefinition(pathMatcherDef, PATH_MATCHER_BEAN_NAME)); } return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME); }
/** * Adds an alias to an existing well-known name or registers a new instance of a {@link UrlPathHelper} * under that well-known name, unless already registered. * @return a RuntimeBeanReference to this {@link UrlPathHelper} instance */ public static RuntimeBeanReference registerUrlPathHelper( RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, Object source) { if (urlPathHelperRef != null) { if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME); } parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME); } else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME) && !parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) { RootBeanDefinition urlPathHelperDef = new RootBeanDefinition(UrlPathHelper.class); urlPathHelperDef.setSource(source); urlPathHelperDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(URL_PATH_HELPER_BEAN_NAME, urlPathHelperDef); parserContext.registerComponent(new BeanComponentDefinition(urlPathHelperDef, URL_PATH_HELPER_BEAN_NAME)); } return new RuntimeBeanReference(URL_PATH_HELPER_BEAN_NAME); }
private void removeDependantBeans(String parentName) { String[] dependentBeans = this.beanFactory.getDependentBeans(parentName); for (String beanName : dependentBeans) { removeDependantBeans(beanName); this.beanDefinitionRegistry.removeBeanDefinition(beanName); // TODO until https://jira.spring.io/browse/SPR-16837 String[] aliases = this.beanDefinitionRegistry.getAliases(beanName); for (String alias : aliases) { this.beanDefinitionRegistry.removeAlias(alias); } } }