Commit ffb14454 authored by Dmitriy Novikov's avatar Dmitriy Novikov
Browse files

Added RemoveBeanBeanDefinitionBeanFactoryPostProcessor

parent df39b292
/*
* Copyright 2022 Google LLC
* Copyright 2022 EPAM Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opengroup.osdu.indexer.di;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.stereotype.Component;
/**
* BeanFactoryPostProcessor removes undesirable beans from bean definition registry.
*/
@Component
public class RemoveBeanBeanDefinitionBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
@Override
public void postProcessBeanFactory(@NotNull ConfigurableListableBeanFactory beanFactory)
throws BeansException {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
removeBeanDefinition(registry, "scopedTarget.tenantInfoFactory");
removeBeanDefinition(registry, "tenantInfoFactory");
}
private void removeBeanDefinition(BeanDefinitionRegistry registry, String beanDefinitionName) {
if (registry.containsBeanDefinition(beanDefinitionName)) {
registry.removeBeanDefinition(beanDefinitionName);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment