commit
44b7f29ee3
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.data.neo4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.neo4j.ogm.session.Neo4jSession;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScanPackages;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.data.neo4j.config.Neo4jConfiguration;
|
||||
import org.springframework.data.neo4j.template.Neo4jOperations;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data Neo4j.
|
||||
*
|
||||
* @author Michael Hunger
|
||||
* @author Josh Long
|
||||
* @author Vince Bickers
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Neo4jSession.class, Neo4jOperations.class })
|
||||
@ConditionalOnMissingBean(Neo4jOperations.class)
|
||||
@EnableConfigurationProperties(Neo4jProperties.class)
|
||||
public class Neo4jDataAutoConfiguration {
|
||||
|
||||
private final Neo4jProperties properties;
|
||||
|
||||
public Neo4jDataAutoConfiguration(Neo4jProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public org.neo4j.ogm.config.Configuration configuration() {
|
||||
return this.properties.createConfiguration();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class SpringBootNeo4jConfiguration extends Neo4jConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final org.neo4j.ogm.config.Configuration configuration;
|
||||
|
||||
SpringBootNeo4jConfiguration(ApplicationContext applicationContext,
|
||||
org.neo4j.ogm.config.Configuration configuration) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactory getSessionFactory() {
|
||||
return new SessionFactory(this.configuration, getPackagesToScan());
|
||||
}
|
||||
|
||||
private String[] getPackagesToScan() {
|
||||
List<String> packages = EntityScanPackages.get(this.applicationContext)
|
||||
.getPackageNames();
|
||||
if (packages.isEmpty()
|
||||
&& AutoConfigurationPackages.has(this.applicationContext)) {
|
||||
packages = AutoConfigurationPackages.get(this.applicationContext);
|
||||
}
|
||||
return packages.toArray(new String[packages.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
@Scope(scopeName = "${spring.data.neo4j.session.scope:singleton}", proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public Session getSession() throws Exception {
|
||||
return super.getSession();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Class for storing {@link EntityScan @EntityScan} specified packages for reference later
|
||||
* (e.g. by JPA auto-configuration).
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.4.0
|
||||
* @see EntityScan
|
||||
* @see EntityScanner
|
||||
*/
|
||||
public class EntityScanPackages {
|
||||
|
||||
private static final String BEAN = EntityScanPackages.class.getName();
|
||||
|
||||
private static final EntityScanPackages NONE = new EntityScanPackages();
|
||||
|
||||
private final List<String> packageNames;
|
||||
|
||||
EntityScanPackages(String... packageNames) {
|
||||
List<String> packages = new ArrayList<String>();
|
||||
for (String name : packageNames) {
|
||||
if (StringUtils.hasText(name)) {
|
||||
packages.add(name);
|
||||
}
|
||||
}
|
||||
this.packageNames = Collections.unmodifiableList(packages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the package names specified from all {@link EntityScan @EntityScan}
|
||||
* annotations.
|
||||
* @return the entity scan package names
|
||||
*/
|
||||
public List<String> getPackageNames() {
|
||||
return this.packageNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link EntityScanPackages} for the given bean factory.
|
||||
* @param beanFactory the source bean factory
|
||||
* @return the {@link EntityScanPackages} for the bean factory (never {@code null})
|
||||
*/
|
||||
public static EntityScanPackages get(BeanFactory beanFactory) {
|
||||
// Currently we only store a single base package, but we return a list to
|
||||
// allow this to change in the future if needed
|
||||
try {
|
||||
return beanFactory.getBean(BEAN, EntityScanPackages.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the specified entity scan packages with the system.
|
||||
* @param registry the source registry
|
||||
* @param packageNames the package names to register
|
||||
*/
|
||||
public static void register(BeanDefinitionRegistry registry, String... packageNames) {
|
||||
Assert.notNull(registry, "Registry must not be null");
|
||||
Assert.notNull(packageNames, "PackageNames must not be null");
|
||||
register(registry, Arrays.asList(packageNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the specified entity scan packages with the system.
|
||||
* @param registry the source registry
|
||||
* @param packageNames the package names to register
|
||||
*/
|
||||
public static void register(BeanDefinitionRegistry registry,
|
||||
Collection<String> packageNames) {
|
||||
Assert.notNull(registry, "Registry must not be null");
|
||||
Assert.notNull(packageNames, "PackageNames must not be null");
|
||||
if (registry.containsBeanDefinition(BEAN)) {
|
||||
BeanDefinition beanDefinition = registry.getBeanDefinition(BEAN);
|
||||
ConstructorArgumentValues constructorArguments = beanDefinition
|
||||
.getConstructorArgumentValues();
|
||||
constructorArguments.addIndexedArgumentValue(0,
|
||||
addPackageNames(constructorArguments, packageNames));
|
||||
}
|
||||
else {
|
||||
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
|
||||
beanDefinition.setBeanClass(EntityScanPackages.class);
|
||||
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0,
|
||||
packageNames.toArray(new String[packageNames.size()]));
|
||||
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
registry.registerBeanDefinition(BEAN, beanDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] addPackageNames(
|
||||
ConstructorArgumentValues constructorArguments,
|
||||
Collection<String> packageNames) {
|
||||
String[] existing = (String[]) constructorArguments
|
||||
.getIndexedArgumentValue(0, String[].class).getValue();
|
||||
Set<String> merged = new LinkedHashSet<String>();
|
||||
merged.addAll(Arrays.asList(existing));
|
||||
merged.addAll(packageNames);
|
||||
return merged.toArray(new String[merged.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ImportBeanDefinitionRegistrar} to store the base package from the importing
|
||||
* configuration.
|
||||
*/
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
static class Registrar implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata metadata,
|
||||
BeanDefinitionRegistry registry) {
|
||||
register(registry, getPackagesToScan(metadata));
|
||||
}
|
||||
|
||||
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
|
||||
AnnotationAttributes attributes = AnnotationAttributes.fromMap(
|
||||
metadata.getAnnotationAttributes(EntityScan.class.getName()));
|
||||
String[] basePackages = attributes.getStringArray("basePackages");
|
||||
Class<?>[] basePackageClasses = attributes
|
||||
.getClassArray("basePackageClasses");
|
||||
Set<String> packagesToScan = new LinkedHashSet<String>();
|
||||
packagesToScan.addAll(Arrays.asList(basePackages));
|
||||
for (Class<?> basePackageClass : basePackageClasses) {
|
||||
packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
|
||||
}
|
||||
if (packagesToScan.isEmpty()) {
|
||||
String packageName = ClassUtils.getPackageName(metadata.getClassName());
|
||||
Assert.state(!StringUtils.isEmpty(packageName),
|
||||
"@EntityScan cannot be used with the default package");
|
||||
return Collections.singleton(packageName);
|
||||
}
|
||||
return packagesToScan;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* An entity scanner that searches the classpath from a {@link EntityScan @EntityScan}
|
||||
* specified packages.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class EntityScanner {
|
||||
|
||||
private final ApplicationContext context;
|
||||
|
||||
/**
|
||||
* Create a new {@link EntityScanner} instance.
|
||||
* @param context the source application context
|
||||
*/
|
||||
public EntityScanner(ApplicationContext context) {
|
||||
Assert.notNull(context, "Context must not be null");
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan for entities with the specified annotations.
|
||||
* @param annotationTypes the annotation types used on the entities
|
||||
* @return a set of entity classes
|
||||
* @throws ClassNotFoundException if an entity class cannot be loaded
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final Set<Class<?>> scan(Class<? extends Annotation>... annotationTypes)
|
||||
throws ClassNotFoundException {
|
||||
List<String> packages = getPackages();
|
||||
if (packages.isEmpty()) {
|
||||
return Collections.<Class<?>>emptySet();
|
||||
}
|
||||
Set<Class<?>> entitySet = new HashSet<Class<?>>();
|
||||
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
|
||||
false);
|
||||
scanner.setEnvironment(this.context.getEnvironment());
|
||||
scanner.setResourceLoader(this.context);
|
||||
for (Class<? extends Annotation> annotationType : annotationTypes) {
|
||||
scanner.addIncludeFilter(new AnnotationTypeFilter(annotationType));
|
||||
}
|
||||
for (String basePackage : packages) {
|
||||
if (StringUtils.hasText(basePackage)) {
|
||||
for (BeanDefinition candidate : scanner
|
||||
.findCandidateComponents(basePackage)) {
|
||||
entitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
|
||||
this.context.getClassLoader()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
private List<String> getPackages() {
|
||||
List<String> packages = EntityScanPackages.get(this.context).getPackageNames();
|
||||
if (packages.isEmpty() && AutoConfigurationPackages.has(this.context)) {
|
||||
packages = AutoConfigurationPackages.get(this.context);
|
||||
}
|
||||
return packages;
|
||||
}
|
||||
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.neo4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.neo4j.ogm.session.Neo4jSession;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.neo4j.SessionFactoryProvider;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.data.neo4j.config.Neo4jConfiguration;
|
||||
import org.springframework.data.neo4j.template.Neo4jOperations;
|
||||
import org.springframework.data.neo4j.template.Neo4jTemplate;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Neo4j support.
|
||||
* <p>
|
||||
* Registers a {@link Neo4jTemplate} bean if no other bean of the same type is configured.
|
||||
*
|
||||
* @author Michael Hunger
|
||||
* @author Josh Long
|
||||
* @author Vince Bickers
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Neo4jSession.class, Neo4jOperations.class })
|
||||
@ConditionalOnMissingBean(Neo4jOperations.class)
|
||||
@EnableConfigurationProperties(Neo4jProperties.class)
|
||||
public class Neo4jAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@Import(SessionFactoryProviderConfiguration.class)
|
||||
public static class SpringBootNeo4jConfiguration extends Neo4jConfiguration {
|
||||
|
||||
private final ObjectProvider<SessionFactoryProvider> sessionFactoryProvider;
|
||||
|
||||
public SpringBootNeo4jConfiguration(
|
||||
ObjectProvider<SessionFactoryProvider> sessionFactoryProvider) {
|
||||
this.sessionFactoryProvider = sessionFactoryProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactory getSessionFactory() {
|
||||
return this.sessionFactoryProvider.getObject().getSessionFactory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(scopeName = "${spring.data.neo4j.session.scope:singleton}", proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
@Override
|
||||
public Session getSession() throws Exception {
|
||||
return getSessionFactory().openSession();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import(Neo4jConfigurationConfiguration.class)
|
||||
static class SessionFactoryProviderConfiguration implements BeanFactoryAware {
|
||||
|
||||
private final org.neo4j.ogm.config.Configuration configuration;
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
SessionFactoryProviderConfiguration(
|
||||
org.neo4j.ogm.config.Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SessionFactoryProvider sessionFactoryProvider() {
|
||||
SessionFactoryProvider provider = new SessionFactoryProvider();
|
||||
provider.setConfiguration(this.configuration);
|
||||
provider.setPackagesToScan(getPackagesToScan());
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
protected String[] getPackagesToScan() {
|
||||
if (AutoConfigurationPackages.has(this.beanFactory)) {
|
||||
List<String> basePackages = AutoConfigurationPackages
|
||||
.get(this.beanFactory);
|
||||
return basePackages.toArray(new String[basePackages.size()]);
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class Neo4jConfigurationConfiguration {
|
||||
|
||||
private final Neo4jProperties properties;
|
||||
|
||||
Neo4jConfigurationConfiguration(Neo4jProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public org.neo4j.ogm.config.Configuration configuration() {
|
||||
return this.properties.createConfiguration();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotationConfigurationException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link EntityScanPackages}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class EntityScanPackagesTests {
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@After
|
||||
public void cleanup() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWhenNoneRegisteredShouldReturnNone() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.refresh();
|
||||
EntityScanPackages packages = EntityScanPackages.get(this.context);
|
||||
assertThat(packages).isNotNull();
|
||||
assertThat(packages.getPackageNames()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getShouldReturnRegisterPackages() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EntityScanPackages.register(this.context, "a", "b");
|
||||
EntityScanPackages.register(this.context, "b", "c");
|
||||
this.context.refresh();
|
||||
EntityScanPackages packages = EntityScanPackages.get(this.context);
|
||||
assertThat(packages.getPackageNames()).containsExactly("a", "b", "c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerFromArrayWhenRegistryIsNullShouldThrowException()
|
||||
throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Registry must not be null");
|
||||
EntityScanPackages.register(null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerFromArrayWhenPackageNamesIsNullShouldThrowException()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("PackageNames must not be null");
|
||||
EntityScanPackages.register(this.context, (String[]) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerFromCollectionWhenRegistryIsNullShouldThrowException()
|
||||
throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Registry must not be null");
|
||||
EntityScanPackages.register(null, Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerFromCollectionWhenPackageNamesIsNullShouldThrowException()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("PackageNames must not be null");
|
||||
EntityScanPackages.register(this.context, (Collection<String>) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityScanAnnotationWhenHasValueAttributeShouldSetupPackages()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
EntityScanValueConfig.class);
|
||||
EntityScanPackages packages = EntityScanPackages.get(this.context);
|
||||
assertThat(packages.getPackageNames()).containsExactly("a");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityScanAnnotationWhenHasBasePackagesAttributeShouldSetupPackages()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
EntityScanBasePackagesConfig.class);
|
||||
EntityScanPackages packages = EntityScanPackages.get(this.context);
|
||||
assertThat(packages.getPackageNames()).containsExactly("b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityScanAnnotationWhenHasValueAndBasePackagesAttributeShouldThrow()
|
||||
throws Exception {
|
||||
this.thrown.expect(AnnotationConfigurationException.class);
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
EntityScanValueAndBasePackagesConfig.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityScanAnnotationWhenHasBasePackageClassesAttributeShouldSetupPackages()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
EntityScanBasePackageClassesConfig.class);
|
||||
EntityScanPackages packages = EntityScanPackages.get(this.context);
|
||||
assertThat(packages.getPackageNames())
|
||||
.containsExactly(getClass().getPackage().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityScanAnnotationWhenNoAttributesShouldSetupPackages()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
EntityScanNoAttributesConfig.class);
|
||||
EntityScanPackages packages = EntityScanPackages.get(this.context);
|
||||
assertThat(packages.getPackageNames())
|
||||
.containsExactly(getClass().getPackage().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityScanAnnotationWhenLoadingFromMultipleConfigsShouldCombinePackages()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(EntityScanValueConfig.class,
|
||||
EntityScanBasePackagesConfig.class);
|
||||
EntityScanPackages packages = EntityScanPackages.get(this.context);
|
||||
assertThat(packages.getPackageNames()).containsExactly("a", "b");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan("a")
|
||||
static class EntityScanValueConfig {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan(basePackages = "b")
|
||||
static class EntityScanBasePackagesConfig {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan(value = "a", basePackages = "b")
|
||||
static class EntityScanValueAndBasePackagesConfig {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan(basePackageClasses = EntityScanPackagesTests.class)
|
||||
static class EntityScanBasePackageClassesConfig {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan
|
||||
static class EntityScanNoAttributesConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.boot.autoconfigure.domain.scan.a.EmbeddableA;
|
||||
import org.springframework.boot.autoconfigure.domain.scan.a.EntityA;
|
||||
import org.springframework.boot.autoconfigure.domain.scan.b.EmbeddableB;
|
||||
import org.springframework.boot.autoconfigure.domain.scan.b.EntityB;
|
||||
import org.springframework.boot.autoconfigure.domain.scan.c.EmbeddableC;
|
||||
import org.springframework.boot.autoconfigure.domain.scan.c.EntityC;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link EntityScanner}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class EntityScannerTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void createWhenContextIsNullShouldThrowException() throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Context must not be null");
|
||||
new EntityScanner(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scanShouldScanFromSinglePackage() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
ScanConfig.class);
|
||||
EntityScanner scanner = new EntityScanner(context);
|
||||
Set<Class<?>> scanned = scanner.scan(Entity.class);
|
||||
assertThat(scanned).containsOnly(EntityA.class, EntityB.class, EntityC.class);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scanShouldScanFromMultiplePackages() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
ScanAConfig.class, ScanBConfig.class);
|
||||
EntityScanner scanner = new EntityScanner(context);
|
||||
Set<Class<?>> scanned = scanner.scan(Entity.class);
|
||||
assertThat(scanned).containsOnly(EntityA.class, EntityB.class);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scanShouldFilterOnAnnotation() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
ScanConfig.class);
|
||||
EntityScanner scanner = new EntityScanner(context);
|
||||
assertThat(scanner.scan(Entity.class)).containsOnly(EntityA.class, EntityB.class,
|
||||
EntityC.class);
|
||||
assertThat(scanner.scan(Embeddable.class)).containsOnly(EmbeddableA.class,
|
||||
EmbeddableB.class, EmbeddableC.class);
|
||||
assertThat(scanner.scan(Entity.class, Embeddable.class)).containsOnly(
|
||||
EntityA.class, EntityB.class, EntityC.class, EmbeddableA.class,
|
||||
EmbeddableB.class, EmbeddableC.class);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan("org.springframework.boot.autoconfigure.domain.scan")
|
||||
static class ScanConfig {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan(basePackageClasses = EntityA.class)
|
||||
static class ScanAConfig {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EntityScan(basePackageClasses = EntityB.class)
|
||||
static class ScanBConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain.scan.a;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class EmbeddableA {
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain.scan.b;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class EmbeddableB {
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain.scan.b;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class EntityB {
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain.scan.c;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class EmbeddableC {
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.domain.scan.c;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class EntityC {
|
||||
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.autoconfigure.neo4j;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.neo4j.ogm.drivers.http.driver.HttpDriver;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.neo4j.template.Neo4jOperations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link Neo4jAutoConfiguration}. Tests can't use the embedded driver as we use
|
||||
* lucene 4 and Neo4j still requires 3.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Michael Hunger
|
||||
* @author Vince Bickers
|
||||
*/
|
||||
public class Neo4jAutoConfigurationTests {
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultConfiguration() {
|
||||
load(null, "spring.data.neo4j.uri=http://localhost:8989");
|
||||
assertThat(this.context.getBeansOfType(Neo4jOperations.class)).hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(org.neo4j.ogm.config.Configuration.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(SessionFactory.class)).hasSize(1);
|
||||
assertThat(this.context.getBeanDefinition("scopedTarget.getSession").getScope())
|
||||
.isEqualTo("singleton");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customScope() {
|
||||
load(null, "spring.data.neo4j.uri=http://localhost:8989",
|
||||
"spring.data.neo4j.session.scope=prototype");
|
||||
assertThat(this.context.getBeanDefinition("scopedTarget.getSession").getScope())
|
||||
.isEqualTo("prototype");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customNeo4jOperations() {
|
||||
load(CustomNeo4jOperations.class);
|
||||
assertThat(this.context.getBean(Neo4jOperations.class))
|
||||
.isSameAs(this.context.getBean("myNeo4jOperations"));
|
||||
assertThat(this.context.getBeansOfType(org.neo4j.ogm.config.Configuration.class))
|
||||
.hasSize(0);
|
||||
assertThat(this.context.getBeansOfType(SessionFactory.class)).hasSize(0);
|
||||
assertThat(this.context.getBeansOfType(Session.class)).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customConfiguration() {
|
||||
load(CustomConfiguration.class);
|
||||
assertThat(this.context.getBean(org.neo4j.ogm.config.Configuration.class))
|
||||
.isSameAs(this.context.getBean("myConfiguration"));
|
||||
assertThat(this.context.getBeansOfType(Neo4jOperations.class)).hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(org.neo4j.ogm.config.Configuration.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(SessionFactory.class)).hasSize(1);
|
||||
}
|
||||
|
||||
public void load(Class<?> config, String... environment) {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
||||
if (config != null) {
|
||||
ctx.register(config);
|
||||
}
|
||||
ctx.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
Neo4jAutoConfiguration.class);
|
||||
ctx.refresh();
|
||||
this.context = ctx;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomNeo4jOperations {
|
||||
|
||||
@Bean
|
||||
public Neo4jOperations myNeo4jOperations() {
|
||||
return mock(Neo4jOperations.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomConfiguration {
|
||||
|
||||
@Bean
|
||||
public org.neo4j.ogm.config.Configuration myConfiguration() {
|
||||
org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration();
|
||||
configuration.driverConfiguration()
|
||||
.setDriverClassName(HttpDriver.class.getName());
|
||||
return configuration;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.context.scan;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
/**
|
||||
* A base {@link BeanPostProcessor} implementation that holds the packages to use for a
|
||||
* given component. An implementation must implement
|
||||
* {@link #postProcessBeforeInitialization(Object, String)} and update the component
|
||||
* responsible to manage the packages to scan.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Oliver Gierke
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public abstract class AbstractEntityScanBeanPostProcessor
|
||||
implements BeanPostProcessor, Ordered {
|
||||
|
||||
private final String[] packagesToScan;
|
||||
|
||||
protected AbstractEntityScanBeanPostProcessor(String[] packagesToScan) {
|
||||
this.packagesToScan = packagesToScan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the packages to use.
|
||||
* @return the packages to use.
|
||||
*/
|
||||
protected String[] getPackagesToScan() {
|
||||
return this.packagesToScan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.neo4j;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.context.scan.AbstractEntityScanBeanPostProcessor;
|
||||
import org.springframework.boot.context.scan.AbstractEntityScanRegistrar;
|
||||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link ImportBeanDefinitionRegistrar} used by {@link NodeEntityScan}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class NodeEntityScanRegistrar extends AbstractEntityScanRegistrar {
|
||||
|
||||
NodeEntityScanRegistrar() {
|
||||
super(NodeEntityScan.class, "nodeEntityScanBeanPostProcessor",
|
||||
NodeEntityScanBeanPostProcessor.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link BeanPostProcessor} to set
|
||||
* {@link SessionFactoryProvider#setPackagesToScan(String...)} based on an
|
||||
* {@link NodeEntityScan} annotation.
|
||||
*/
|
||||
static class NodeEntityScanBeanPostProcessor extends
|
||||
AbstractEntityScanBeanPostProcessor implements SmartInitializingSingleton {
|
||||
|
||||
private boolean processed;
|
||||
|
||||
NodeEntityScanBeanPostProcessor(String[] packagesToScan) {
|
||||
super(packagesToScan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
if (bean instanceof SessionFactoryProvider) {
|
||||
SessionFactoryProvider provider = (SessionFactoryProvider) bean;
|
||||
provider.setPackagesToScan(getPackagesToScan());
|
||||
this.processed = true;
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
Assert.state(this.processed,
|
||||
"Unable to configure "
|
||||
+ "SessionFactoryFactoryBean from @NodeEntityScan, "
|
||||
+ "ensure an appropriate bean is registered.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.neo4j;
|
||||
|
||||
import org.neo4j.ogm.config.Configuration;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
/**
|
||||
* Provide a Neo4j {@link SessionFactory} instance based on a configurable
|
||||
* {@link Configuration} and custom packages to scan.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
* @see NodeEntityScan
|
||||
*/
|
||||
public class SessionFactoryProvider {
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
private String[] packagesToScan;
|
||||
|
||||
/**
|
||||
* Set the configuration to use.
|
||||
* @param configuration the configuration
|
||||
*/
|
||||
public void setConfiguration(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the packages to scan.
|
||||
* @param packagesToScan the packages to scan
|
||||
*/
|
||||
public void setPackagesToScan(String... packagesToScan) {
|
||||
this.packagesToScan = packagesToScan;
|
||||
}
|
||||
|
||||
public SessionFactory getSessionFactory() {
|
||||
return new SessionFactory(this.configuration, this.packagesToScan);
|
||||
}
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.orm.jpa;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.context.scan.AbstractEntityScanBeanPostProcessor;
|
||||
import org.springframework.boot.context.scan.AbstractEntityScanRegistrar;
|
||||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link ImportBeanDefinitionRegistrar} used by {@link EntityScan}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class JpaEntityScanRegistrar extends AbstractEntityScanRegistrar {
|
||||
|
||||
JpaEntityScanRegistrar() {
|
||||
super(EntityScan.class, "entityScanBeanPostProcessor",
|
||||
JpaEntityScanBeanPostProcessor.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link BeanPostProcessor} to set
|
||||
* {@link LocalContainerEntityManagerFactoryBean#setPackagesToScan(String...)} based
|
||||
* on an {@link EntityScan} annotation.
|
||||
*/
|
||||
static class JpaEntityScanBeanPostProcessor extends
|
||||
AbstractEntityScanBeanPostProcessor implements SmartInitializingSingleton {
|
||||
|
||||
private boolean processed;
|
||||
|
||||
JpaEntityScanBeanPostProcessor(String[] packagesToScan) {
|
||||
super(packagesToScan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
if (bean instanceof LocalContainerEntityManagerFactoryBean) {
|
||||
LocalContainerEntityManagerFactoryBean factoryBean = (LocalContainerEntityManagerFactoryBean) bean;
|
||||
factoryBean.setPackagesToScan(getPackagesToScan());
|
||||
this.processed = true;
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
Assert.state(this.processed,
|
||||
"Unable to configure "
|
||||
+ "LocalContainerEntityManagerFactoryBean from @EntityScan, "
|
||||
+ "ensure an appropriate bean is registered.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.context.scan;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* EntityScan test annotation.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Import(TestEntityScanRegistrar.class)
|
||||
public @interface TestEntityScan {
|
||||
|
||||
@AliasFor("basePackages")
|
||||
String[] value() default {};
|
||||
|
||||
@AliasFor("value")
|
||||
String[] basePackages() default {};
|
||||
|
||||
Class<?>[] basePackageClasses() default {};
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.context.scan;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
/**
|
||||
* Test implementation of {@link AbstractEntityScanRegistrar}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class TestEntityScanRegistrar extends AbstractEntityScanRegistrar {
|
||||
|
||||
static final String BEAN_NAME = "testEntityScanBeanPostProcessor";
|
||||
|
||||
TestEntityScanRegistrar() {
|
||||
super(TestEntityScan.class, BEAN_NAME, TestEntityScanBeanPostProcessor.class);
|
||||
}
|
||||
|
||||
static class TestFactoryBean {
|
||||
private String[] packagesToScan;
|
||||
|
||||
public void setPackagesToScan(String... packagesToScan) {
|
||||
this.packagesToScan = packagesToScan;
|
||||
}
|
||||
|
||||
public String[] getPackagesToScan() {
|
||||
return this.packagesToScan;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class TestEntityScanBeanPostProcessor
|
||||
extends AbstractEntityScanBeanPostProcessor {
|
||||
|
||||
TestEntityScanBeanPostProcessor(String[] packagesToScan) {
|
||||
super(packagesToScan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
if (bean instanceof TestFactoryBean) {
|
||||
TestFactoryBean factoryBean = (TestFactoryBean) bean;
|
||||
factoryBean.setPackagesToScan(getPackagesToScan());
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.context.scan;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.boot.context.scan.TestEntityScanRegistrar.TestFactoryBean;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotationConfigurationException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
/**
|
||||
* Tests for {@link TestEntityScan}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class TestEntityScanTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@After
|
||||
public void closeContext() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValue() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(ValueConfig.class);
|
||||
assertSetPackagesToScan("com.mycorp.entity");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basePackages() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(BasePackagesConfig.class);
|
||||
assertSetPackagesToScan("com.mycorp.entity2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basePackageClasses() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
BasePackageClassesConfig.class);
|
||||
assertSetPackagesToScan(getClass().getPackage().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromConfigurationClass() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(FromConfigConfig.class);
|
||||
assertSetPackagesToScan(getClass().getPackage().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueAndBasePackagesThrows() throws Exception {
|
||||
this.thrown.expect(AnnotationConfigurationException.class);
|
||||
this.thrown.expectMessage(allOf(containsString("'value'"),
|
||||
containsString("'basePackages'"), containsString("com.mycorp.entity"),
|
||||
containsString("com.mycorp")));
|
||||
this.context = new AnnotationConfigApplicationContext(ValueAndBasePackages.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueAndBasePackageClassesMerges() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
ValueAndBasePackageClasses.class);
|
||||
assertSetPackagesToScan("com.mycorp.entity", getClass().getPackage().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basePackageAndBasePackageClassesMerges() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
BasePackagesAndBasePackageClasses.class);
|
||||
assertSetPackagesToScan("com.mycorp.entity2", getClass().getPackage().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void considersMultipleAnnotations() {
|
||||
this.context = new AnnotationConfigApplicationContext(MultiScanFirst.class,
|
||||
MultiScanSecond.class);
|
||||
assertSetPackagesToScan("foo", "bar");
|
||||
}
|
||||
|
||||
private void assertSetPackagesToScan(String... expected) {
|
||||
String[] actual = this.context.getBean(TestFactoryBean.class).getPackagesToScan();
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class BaseConfig {
|
||||
|
||||
@Bean
|
||||
public TestFactoryBean testFactoryBean() {
|
||||
return new TestFactoryBean();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan("com.mycorp.entity")
|
||||
static class ValueConfig extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan(basePackages = "com.mycorp.entity2")
|
||||
static class BasePackagesConfig extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan(basePackageClasses = TestEntityScanTests.class)
|
||||
static class BasePackageClassesConfig extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan
|
||||
static class FromConfigConfig extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan(value = "com.mycorp.entity", basePackages = "com.mycorp")
|
||||
static class ValueAndBasePackages extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan(value = "com.mycorp.entity", basePackageClasses = TestEntityScanTests.class)
|
||||
static class ValueAndBasePackageClasses extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan(basePackages = "com.mycorp.entity2", basePackageClasses = TestEntityScanTests.class)
|
||||
static class BasePackagesAndBasePackageClasses extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan(basePackages = "foo")
|
||||
static class MultiScanFirst extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
@TestEntityScan(basePackages = "bar")
|
||||
static class MultiScanSecond extends BaseConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.springframework.boot.neo4j;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link NodeEntityScan}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class NodeEntityScanTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@After
|
||||
public void closeContext() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleValue() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext(ValueConfig.class);
|
||||
assertSetPackagesToScan("com.mycorp.entity");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void needsSessionFactoryFactory() throws Exception {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("Unable to configure "
|
||||
+ "SessionFactoryFactoryBean from @NodeEntityScan, "
|
||||
+ "ensure an appropriate bean is registered.");
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
MissingSessionFactory.class);
|
||||
}
|
||||
|
||||
private void assertSetPackagesToScan(String... expected) {
|
||||
String[] actual = this.context.getBean(TestSessionFactoryProvider.class)
|
||||
.getPackagesToScan();
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class BaseConfig {
|
||||
|
||||
@Bean
|
||||
public SessionFactoryProvider sessionFactoryFactoryBean() {
|
||||
return new TestSessionFactoryProvider();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NodeEntityScan("com.mycorp.entity")
|
||||
static class ValueConfig extends BaseConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@NodeEntityScan("com.mycorp.entity")
|
||||
static class MissingSessionFactory {
|
||||
}
|
||||
|
||||
private static class TestSessionFactoryProvider extends SessionFactoryProvider {
|
||||
|
||||
private String[] packagesToScan;
|
||||
|
||||
@Override
|
||||
public void setPackagesToScan(String... packagesToScan) {
|
||||
this.packagesToScan = packagesToScan;
|
||||
}
|
||||
|
||||
public String[] getPackagesToScan() {
|
||||
return this.packagesToScan;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue