getOwnedDocuments();
+
+ @Mapping("partnerDocument.age")
+ Long getAge();
+
+ @Mapping("SIZE(ownedDocuments)")
+ Long getNumPartners();
+
+ DocumentViewInterface getPartnerDocument();
+
+}
diff --git a/integration/entity-view-spring/pom.xml b/integration/entity-view-spring/pom.xml
new file mode 100644
index 0000000000..0031fe138e
--- /dev/null
+++ b/integration/entity-view-spring/pom.xml
@@ -0,0 +1,64 @@
+
+
+
+ blaze-persistence-integration
+ com.blazebit
+ 1.2.0-SNAPSHOT
+
+ 4.0.0
+
+ blaze-persistence-integration-entity-view-spring
+ jar
+
+
+ 4.3.3.RELEASE
+
+
+
+
+ com.blazebit
+ blaze-persistence-entity-view-api
+
+
+ javax.enterprise
+ cdi-api
+ 1.2
+ provided
+
+
+ org.springframework
+ spring-context
+ ${version.spring}
+ provided
+
+
+
+
+
+ com.blazebit
+ blaze-persistence-entity-view-impl
+ test
+
+
+ javax
+ javaee-api
+ 7.0
+ test
+
+
+ org.springframework
+ spring-test
+ ${version.spring}
+ test
+
+
+ junit
+ junit
+ test
+
+
+
+
+
\ No newline at end of file
diff --git a/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EnableEntityViews.java b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EnableEntityViews.java
new file mode 100644
index 0000000000..ee0223df79
--- /dev/null
+++ b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EnableEntityViews.java
@@ -0,0 +1,46 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import org.springframework.context.annotation.Import;
+import org.springframework.core.annotation.AliasFor;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME)
+@Target(value={java.lang.annotation.ElementType.TYPE})
+@Documented
+@Import({EntityViewRegistrar.class})
+public @interface EnableEntityViews {
+ /**
+ * Alias for {@link #basePackages}.
+ * Allows for more concise annotation declarations if no other attributes
+ * are needed — for example, {@code @ComponentScan("org.my.pkg")}
+ * instead of {@code @ComponentScan(basePackages = "org.my.pkg")}.
+ */
+ @AliasFor("basePackages")
+ String[] value() default {};
+
+ /**
+ * Base packages to scan for annotated components.
+ *
{@link #value} is an alias for (and mutually exclusive with) this
+ * attribute.
+ *
Use {@link #basePackageClasses} for a type-safe alternative to
+ * String-based package names.
+ */
+ @AliasFor("value")
+ String[] basePackages() default {};
+
+ /**
+ * Type-safe alternative to {@link #basePackages} for specifying the packages
+ * to scan for annotated components. The package of each class specified will be scanned.
+ *
Consider creating a special no-op marker class or interface in each package
+ * that serves no purpose other than being referenced by this attribute.
+ */
+ Class>[] basePackageClasses() default {};
+}
diff --git a/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewClassesHolder.java b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewClassesHolder.java
new file mode 100644
index 0000000000..55e5503f9b
--- /dev/null
+++ b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewClassesHolder.java
@@ -0,0 +1,21 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import java.util.Set;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+public class EntityViewClassesHolder {
+
+ private final Set> entityViewClasses;
+
+ public EntityViewClassesHolder(Set> entityViewClasses) {
+ this.entityViewClasses = entityViewClasses;
+ }
+
+ public Set> getEntityViewClasses() {
+ return entityViewClasses;
+ }
+}
diff --git a/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewConfigurationProducer.java b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewConfigurationProducer.java
new file mode 100644
index 0000000000..c63997014c
--- /dev/null
+++ b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewConfigurationProducer.java
@@ -0,0 +1,37 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.EntityViews;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@Configuration
+public class EntityViewConfigurationProducer {
+
+ private final EntityViewConfiguration configuration = EntityViews.createDefaultConfiguration();
+
+ @Inject
+ private EntityViewClassesHolder entityViewClassesHolder;
+
+ @PostConstruct
+ public void initEntityViewConfiguration() throws ClassNotFoundException {
+ for (Class> entityViewClass : entityViewClassesHolder.getEntityViewClasses()) {
+ configuration.addEntityView(entityViewClass);
+ }
+ }
+
+ @Bean
+ public EntityViewConfiguration getEntityViewConfiguration() {
+ return configuration;
+ }
+
+
+}
diff --git a/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewNamespaceHandler.java b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewNamespaceHandler.java
new file mode 100644
index 0000000000..7bf9c25d68
--- /dev/null
+++ b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewNamespaceHandler.java
@@ -0,0 +1,16 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import org.springframework.beans.factory.xml.NamespaceHandler;
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 13.10.2016.
+ */
+public class EntityViewNamespaceHandler extends NamespaceHandlerSupport {
+ @Override
+ public void init() {
+ registerBeanDefinitionParser("entity-views", new EntityViewRegistrar());
+ }
+}
diff --git a/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewRegistrar.java b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewRegistrar.java
new file mode 100644
index 0000000000..57d46072ad
--- /dev/null
+++ b/integration/entity-view-spring/src/main/java/com/blazebit/persistence/view/impl/spring/EntityViewRegistrar.java
@@ -0,0 +1,122 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.EntityView;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.parsing.ReaderContext;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
+import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
+import org.springframework.core.type.AnnotationMetadata;
+import org.springframework.core.type.filter.AnnotationTypeFilter;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
+
+import java.util.*;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+public class EntityViewRegistrar implements ImportBeanDefinitionRegistrar, BeanDefinitionParser {
+
+ private static final String BASE_PACKAGE = "base-package";
+
+ @Override
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ try {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+
+ List basePackages = getBasePackages(element);
+ if (basePackages.isEmpty()) {
+ parserContext.getReaderContext().error("You have to specify at least one base package for entity views!", element);
+ }
+
+ scanAndRegisterEntityViews(basePackages, registry);
+ } catch (RuntimeException e) {
+ handleError(e, element, parserContext.getReaderContext());
+ }
+
+ return null;
+ }
+
+ public List getBasePackages(Element element) {
+ String attribute = element.getAttribute(BASE_PACKAGE);
+ return Arrays.asList(StringUtils.delimitedListToStringArray(attribute, ",", " "));
+ }
+
+ private void handleError(Exception e, Element source, ReaderContext reader) {
+ reader.error(e.getMessage(), reader.extractSource(source), e);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
+ MultiValueMap annotationAttributes = importingClassMetadata.getAllAnnotationAttributes(EnableEntityViews.class.getName());
+
+ List basePackages = new ArrayList();
+ Collections.addAll(basePackages, (String[]) annotationAttributes.getFirst("value"));
+ Class>[] basePackageClasses = (Class>[]) annotationAttributes.getFirst("basePackageClasses");
+ for (Class> basePackageClass : basePackageClasses) {
+ basePackages.add(basePackageClass.getPackage().getName());
+ }
+ if (basePackages.isEmpty()) {
+ try {
+ basePackages.add(Class.forName(importingClassMetadata.getClassName()).getPackage().getName());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ scanAndRegisterEntityViews(basePackages, registry);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void scanAndRegisterEntityViews(List basePackages, BeanDefinitionRegistry registry) {
+ Set> entityViewClasses = new HashSet>();
+ ClassPathScanningCandidateComponentProvider provider = createComponentScanner();
+ for (String basePackage : basePackages) {
+ for (BeanDefinition beanDef : provider.findCandidateComponents(basePackage)) {
+ try {
+ entityViewClasses.add(Class.forName(beanDef.getBeanClassName()));
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ final String entityViewClassHolderBeanName = "entityViewClassesHolder";
+ if (registry.containsBeanDefinition(entityViewClassHolderBeanName)) {
+ BeanDefinition existingClassHolder = registry.getBeanDefinition(entityViewClassHolderBeanName);
+ Set> existingEntityViewClasses = (Set>) ((GenericBeanDefinition) existingClassHolder).getConstructorArgumentValues().getGenericArgumentValue(Set.class).getValue();
+ existingEntityViewClasses.addAll(entityViewClasses);
+ } else {
+ GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
+ beanDefinition.setBeanClass(EntityViewClassesHolder.class);
+ beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(entityViewClasses);
+ registry.registerBeanDefinition(entityViewClassHolderBeanName, beanDefinition);
+
+ // register configuration class
+ beanDefinition = new GenericBeanDefinition();
+ beanDefinition.setBeanClass(EntityViewConfigurationProducer.class);
+ registry.registerBeanDefinition("entityViewConfigurationProducer", beanDefinition);
+ }
+ }
+
+ private ClassPathScanningCandidateComponentProvider createComponentScanner() {
+ ClassPathScanningCandidateComponentProvider provider
+ = new ClassPathScanningCandidateComponentProvider(false) {
+ protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
+ return beanDefinition.getMetadata().isIndependent();
+ }
+ };
+ provider.addIncludeFilter(new AnnotationTypeFilter(EntityView.class, false, true));
+ return provider;
+ }
+}
diff --git a/integration/entity-view-spring/src/main/resources/META-INF/spring.handlers b/integration/entity-view-spring/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..67a5dbc961
--- /dev/null
+++ b/integration/entity-view-spring/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.blazebit.com/persistence/view/spring=com.blazebit.persistence.view.impl.spring.EntityViewNamespaceHandler
\ No newline at end of file
diff --git a/integration/entity-view-spring/src/main/resources/META-INF/spring.schemas b/integration/entity-view-spring/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..ece33c20a4
--- /dev/null
+++ b/integration/entity-view-spring/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.blazebit.com/persistence/view/spring/spring-entity-views-1.2.xsd=/com/blazebit/persistence/view/spring/spring-entity-views-1.2.xsd
\ No newline at end of file
diff --git a/integration/entity-view-spring/src/main/resources/com/blazebit/persistence/view/spring/spring-entity-views-1.2.xsd b/integration/entity-view-spring/src/main/resources/com/blazebit/persistence/view/spring/spring-entity-views-1.2.xsd
new file mode 100644
index 0000000000..ddbad9d30d
--- /dev/null
+++ b/integration/entity-view-spring/src/main/resources/com/blazebit/persistence/view/spring/spring-entity-views-1.2.xsd
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationBasePackageClassesTest.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationBasePackageClassesTest.java
new file mode 100644
index 0000000000..5ae3ef7213
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationBasePackageClassesTest.java
@@ -0,0 +1,38 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.impl.spring.views.sub1.TestView1;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.Set;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = AnnotationBasePackageClassesTest.TestConfig.class)
+public class AnnotationBasePackageClassesTest {
+
+ @Inject
+ private EntityViewConfiguration entityViewConfiguration;
+
+ @Test
+ public void testInjection() {
+ Set> entityViews = entityViewConfiguration.getEntityViews();
+ Assert.assertEquals(1, entityViews.size());
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView1.class));
+ }
+
+ @Configuration
+ @EnableEntityViews(basePackageClasses = TestView1.class)
+ static class TestConfig {
+ }
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationBasePackagesTest.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationBasePackagesTest.java
new file mode 100644
index 0000000000..7012397f0e
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationBasePackagesTest.java
@@ -0,0 +1,38 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.impl.spring.views.sub1.TestView1;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.Set;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = AnnotationBasePackagesTest.TestConfig.class)
+public class AnnotationBasePackagesTest {
+
+ @Inject
+ private EntityViewConfiguration entityViewConfiguration;
+
+ @Test
+ public void testInjection() {
+ Set> entityViews = entityViewConfiguration.getEntityViews();
+ Assert.assertEquals(1, entityViews.size());
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView1.class));
+ }
+
+ @Configuration
+ @EnableEntityViews(basePackages = "com.blazebit.persistence.view.impl.spring.views.sub1")
+ static class TestConfig {
+ }
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationPlainTest.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationPlainTest.java
new file mode 100644
index 0000000000..8958404ec6
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationPlainTest.java
@@ -0,0 +1,40 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.impl.spring.views.sub1.TestView1;
+import com.blazebit.persistence.view.impl.spring.views.sub2.TestView2;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.Set;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = AnnotationPlainTest.TestConfig.class)
+public class AnnotationPlainTest {
+
+ @Inject
+ private EntityViewConfiguration entityViewConfiguration;
+
+ @Test
+ public void testInjection() {
+ Set> entityViews = entityViewConfiguration.getEntityViews();
+ Assert.assertEquals(2, entityViews.size());
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView1.class));
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView2.class));
+ }
+
+ @Configuration
+ @EnableEntityViews
+ static class TestConfig {
+ }
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationValueTest.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationValueTest.java
new file mode 100644
index 0000000000..06e4ce4c4d
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/AnnotationValueTest.java
@@ -0,0 +1,38 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.impl.spring.views.sub1.TestView1;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.Set;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = AnnotationValueTest.TestConfig.class)
+public class AnnotationValueTest {
+
+ @Inject
+ private EntityViewConfiguration entityViewConfiguration;
+
+ @Test
+ public void testInjection() {
+ Set> entityViews = entityViewConfiguration.getEntityViews();
+ Assert.assertEquals(1, entityViews.size());
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView1.class));
+ }
+
+ @Configuration
+ @EnableEntityViews("com.blazebit.persistence.view.impl.spring.views.sub1")
+ static class TestConfig {
+ }
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/CombinedConfigTest.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/CombinedConfigTest.java
new file mode 100644
index 0000000000..c284689e60
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/CombinedConfigTest.java
@@ -0,0 +1,49 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.impl.spring.views.sub1.TestView1;
+import com.blazebit.persistence.view.impl.spring.views.sub2.TestView2;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.ImportResource;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.Set;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = CombinedConfigTest.TestConfig.class)
+public class CombinedConfigTest {
+
+ @Inject
+ private EntityViewConfiguration entityViewConfiguration;
+
+ @BeforeClass
+ public static void test() {
+ CombinedConfigTest.class.getClassLoader().getResource("entity-views-config.xml");
+ }
+
+ @Test
+ public void testInjection() {
+ Set> entityViews = entityViewConfiguration.getEntityViews();
+ Assert.assertEquals(2, entityViews.size());
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView1.class));
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView2.class));
+ }
+
+ @Configuration
+ @EnableEntityViews("com.blazebit.persistence.view.impl.spring.views.sub2")
+ @ImportResource("/com/blazebit/persistence/view/impl/spring/entity-views-config.xml")
+ static class TestConfig {
+ }
+
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/TestEntity.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/TestEntity.java
new file mode 100644
index 0000000000..bdd9380b6b
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/TestEntity.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 Blazebit.
+ *
+ * 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 com.blazebit.persistence.view.impl.spring;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+/**
+ *
+ * @author Christian Beikov
+ * @since 1.0
+ */
+@Entity
+public class TestEntity implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Long id;
+
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/XmlConfigTest.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/XmlConfigTest.java
new file mode 100644
index 0000000000..502bcf750c
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/XmlConfigTest.java
@@ -0,0 +1,33 @@
+package com.blazebit.persistence.view.impl.spring;
+
+import com.blazebit.persistence.view.impl.spring.views.sub1.TestView1;
+import com.blazebit.persistence.view.spi.EntityViewConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.Set;
+
+/**
+ * Created
+ * by Moritz Becker (moritz.becker@gmx.at)
+ * on 12.10.2016.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("entity-views-config.xml")
+public class XmlConfigTest {
+
+ @Inject
+ private EntityViewConfiguration entityViewConfiguration;
+
+ @Test
+ public void testInjection() {
+ Set> entityViews = entityViewConfiguration.getEntityViews();
+ Assert.assertEquals(1, entityViews.size());
+ Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView1.class));
+ }
+
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/views/sub1/TestView1.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/views/sub1/TestView1.java
new file mode 100644
index 0000000000..08ac580e63
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/views/sub1/TestView1.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2014 Blazebit.
+ *
+ * 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 com.blazebit.persistence.view.impl.spring.views.sub1;
+
+import com.blazebit.persistence.view.EntityView;
+import com.blazebit.persistence.view.IdMapping;
+import com.blazebit.persistence.view.impl.spring.TestEntity;
+
+/**
+ *
+ * @author Christian Beikov
+ * @since 1.0
+ */
+@EntityView(TestEntity.class)
+public interface TestView1 {
+
+ @IdMapping("id")
+ public String getId();
+
+}
diff --git a/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/views/sub2/TestView2.java b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/views/sub2/TestView2.java
new file mode 100644
index 0000000000..219559d287
--- /dev/null
+++ b/integration/entity-view-spring/src/test/java/com/blazebit/persistence/view/impl/spring/views/sub2/TestView2.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 Blazebit.
+ *
+ * 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 com.blazebit.persistence.view.impl.spring.views.sub2;
+
+import com.blazebit.persistence.view.EntityView;
+import com.blazebit.persistence.view.IdMapping;
+import com.blazebit.persistence.view.Mapping;
+import com.blazebit.persistence.view.impl.spring.TestEntity;
+
+/**
+ *
+ * @author Christian Beikov
+ * @since 1.0
+ */
+@EntityView(TestEntity.class)
+public interface TestView2 {
+
+ @IdMapping("id")
+ public String getId();
+
+ @Mapping("id + 2")
+ public String getIdPlusTwo();
+
+}
diff --git a/integration/entity-view-spring/src/test/resources/com/blazebit/persistence/view/impl/spring/entity-views-config.xml b/integration/entity-view-spring/src/test/resources/com/blazebit/persistence/view/impl/spring/entity-views-config.xml
new file mode 100644
index 0000000000..484cf548ba
--- /dev/null
+++ b/integration/entity-view-spring/src/test/resources/com/blazebit/persistence/view/impl/spring/entity-views-config.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/integration/pom.xml b/integration/pom.xml
index df79628b91..1ae21b45ee 100644
--- a/integration/pom.xml
+++ b/integration/pom.xml
@@ -27,5 +27,6 @@
openjpa
base-cdi
entity-view-cdi
+ entity-view-spring