|
| 1 | +/* |
| 2 | + * Copyright 2021 the original author or authors. |
| 3 | + * |
| 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 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 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.springframework.data.repository.config; |
| 17 | + |
| 18 | +import org.springframework.beans.factory.FactoryBean; |
| 19 | +import org.springframework.data.mapping.context.MappingContext; |
| 20 | +import org.springframework.data.mapping.context.PersistentEntities; |
| 21 | + |
| 22 | +/** |
| 23 | + * Factory been to create {@link PersistentEntities} from a {@link MappingContext}. |
| 24 | + * |
| 25 | + * @author Jens Schauder |
| 26 | + * @since 3.0 |
| 27 | + */ |
| 28 | +public class PersistentEntitiesFactoryBean implements FactoryBean<PersistentEntities> { |
| 29 | + |
| 30 | + private final MappingContext context; |
| 31 | + |
| 32 | + /** |
| 33 | + * Creates a new {@link PersistentEntitiesFactoryBean} for the given {@link MappingContext}. |
| 34 | + * |
| 35 | + * @param context must not be {@literal null}. |
| 36 | + */ |
| 37 | + public PersistentEntitiesFactoryBean(MappingContext context) { |
| 38 | + this.context = context; |
| 39 | + } |
| 40 | + |
| 41 | + /* |
| 42 | + * (non-Javadoc) |
| 43 | + * @see org.springframework.beans.factory.FactoryBean#getObject() |
| 44 | + */ |
| 45 | + @Override |
| 46 | + public PersistentEntities getObject() { |
| 47 | + return PersistentEntities.of(context); |
| 48 | + } |
| 49 | + |
| 50 | + /* |
| 51 | + * (non-Javadoc) |
| 52 | + * @see org.springframework.beans.factory.FactoryBean#getObjectType() |
| 53 | + */ |
| 54 | + @Override |
| 55 | + public Class<?> getObjectType() { |
| 56 | + return PersistentEntities.class; |
| 57 | + } |
| 58 | +} |
0 commit comments