f4e78dce4956c76a42f4f2ba56fc1bd7862b6a4f
[externalapi/nbi.git] / src / main / java / org / onap / nbi / configuration / MongoConfig.java
1 /**
2  * Copyright (c) 2018 Orange
3  * <p>
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * <p>
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * <p>
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.nbi.configuration;
17
18 import org.springframework.beans.BeansException;
19 import org.springframework.beans.factory.config.BeanPostProcessor;
20 import org.springframework.context.annotation.Configuration;
21 import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
22
23 @Configuration
24 public class MongoConfig implements BeanPostProcessor {
25
26     @Override
27     public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
28         if (bean instanceof MappingMongoConverter) {
29             MappingMongoConverter converter = (MappingMongoConverter) bean;
30             converter.setMapKeyDotReplacement("__");
31         }
32         return bean;
33     }
34
35     @Override
36     public Object postProcessBeforeInitialization(Object o, String s) throws BeansException {
37         return o;
38     }
39 }