Skip to content

Commit 065300e

Browse files
authored
Merge pull request #28095 from njr-11/27748-EntityDefining
EntityDefining from Jakarta Data
2 parents 742ca76 + 6836639 commit 065300e

File tree

7 files changed

+45
-10
lines changed

7 files changed

+45
-10
lines changed

dev/com.ibm.websphere.appserver.features/visibility/public/data-1.0/io.openliberty.data-1.0.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ IBM-API-Package: \
1414
jakarta.data.metamodel.impl; type="spec",\
1515
jakarta.data.page; type="spec",\
1616
jakarta.data.page.impl; type="spec",\
17-
jakarta.data.repository; type="spec"
17+
jakarta.data.repository; type="spec",\
18+
jakarta.data.spi; type="spec"
1819
Subsystem-Name: Jakarta Data 1.0
1920
#TODO io.openliberty.jakartaeePlatform-11.0
2021
-features=\

dev/io.openliberty.data.internal.persistence/src/io/openliberty/data/internal/persistence/cdi/DataExtension.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import jakarta.data.repository.Repository;
6969
import jakarta.data.repository.Save;
7070
import jakarta.data.repository.Update;
71+
import jakarta.data.spi.EntityDefining;
7172
import jakarta.enterprise.event.Observes;
7273
import jakarta.enterprise.inject.Instance;
7374
import jakarta.enterprise.inject.spi.AfterBeanDiscovery;
@@ -595,7 +596,8 @@ private boolean supportsEntity(Class<?> entityClass, AnnotatedType<?> repository
595596
Class<? extends Annotation> annoClass = anno.annotationType();
596597
if (annoClass.equals(Entity.class))
597598
return true;
598-
else if (annoClass.getSimpleName().endsWith("Entity"))
599+
else if (annoClass.getSimpleName().endsWith("Entity") // also covers Jakarta NoSQL entity
600+
|| annoClass.isAnnotationPresent(EntityDefining.class))
599601
hasEntityAnnos = true;
600602
}
601603

dev/io.openliberty.data.internal_fat/test-applications/ProviderTestApp/src/test/jakarta/data/inmemory/provider/PalindromeExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ public void afterTypeDiscovery(@Observes AfterTypeDiscovery event, BeanManager b
7979
if (entityClass == null)
8080
throw new MappingException("Did not find the entity class for " + repositoryInterface);
8181

82-
PalindromicEntity entityAnno = entityClass.getAnnotation(PalindromicEntity.class);
82+
Palindromic entityAnno = entityClass.getAnnotation(Palindromic.class);
8383

8484
if (entityAnno == null) {
8585
Repository repository = repositoryType.getAnnotation(Repository.class);
8686
if (!Repository.ANY_PROVIDER.equals(repository.provider()))
8787
throw new MappingException("The Palindrome mock Jakarta Data provider cannot provide the " +
8888
repositoryType.getJavaClass().getName() + " repository because the repository's " +
89-
entityClass.getName() + " entity class is not annotated with " + PalindromicEntity.class.getName());
89+
entityClass.getName() + " entity class is not annotated with " + Palindromic.class.getName());
9090
} else {
9191
BeanAttributes<?> attrs = beanMgr.createBeanAttributes(repositoryType);
9292
Bean<?> bean = beanMgr.createBean(attrs, repositoryInterface, new PalindromeRepositoryProducer.Factory<>());

dev/io.openliberty.data.internal_fat/test-applications/ProviderTestApp/src/test/jakarta/data/inmemory/provider/PalindromicEntity.java renamed to dev/io.openliberty.data.internal_fat/test-applications/ProviderTestApp/src/test/jakarta/data/inmemory/provider/Palindromic.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023 IBM Corporation and others.
2+
* Copyright (c) 2023,2024 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -17,10 +17,13 @@
1717
import java.lang.annotation.RetentionPolicy;
1818
import java.lang.annotation.Target;
1919

20+
import jakarta.data.spi.EntityDefining;
21+
2022
/**
2123
* Fake entity annotation.
2224
*/
25+
@EntityDefining
2326
@Retention(RetentionPolicy.RUNTIME)
2427
@Target(ElementType.TYPE)
25-
public @interface PalindromicEntity {
28+
public @interface Palindromic {
2629
}

dev/io.openliberty.data.internal_fat/test-applications/ProviderTestApp/src/test/jakarta/data/inmemory/web/Palindrome.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2022,2023 IBM Corporation and others.
2+
* Copyright (c) 2022,2024 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -13,12 +13,12 @@
1313

1414
package test.jakarta.data.inmemory.web;
1515

16-
import test.jakarta.data.inmemory.provider.PalindromicEntity;
16+
import test.jakarta.data.inmemory.provider.Palindromic;
1717

1818
/**
1919
* Entity class for tests
2020
*/
21-
@PalindromicEntity
21+
@Palindromic
2222
public class Palindrome {
2323
public long id;
2424
public String letters;

dev/io.openliberty.jakarta.data.1.0/bnd.bnd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Export-Package: \
2929
jakarta.data.metamodel.impl;version="1.0.0",\
3030
jakarta.data.page;version="1.0.0",\
3131
jakarta.data.page.impl;version="1.0.0",\
32-
jakarta.data.repository;version="1.0.0"
32+
jakarta.data.repository;version="1.0.0",\
33+
jakarta.data.spi;version="1.0.0"
3334

3435
instrument.classesExcludes: jakarta/data/*.class
3536

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* IBM Corporation - initial API and implementation
12+
*******************************************************************************/
13+
package jakarta.data.spi;
14+
15+
import java.lang.annotation.Documented;
16+
import java.lang.annotation.ElementType;
17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.RetentionPolicy;
19+
import java.lang.annotation.Target;
20+
21+
/**
22+
* Method signatures are copied from Jakarta Data.
23+
*/
24+
@Documented
25+
@Retention(RetentionPolicy.RUNTIME)
26+
@Target(ElementType.ANNOTATION_TYPE)
27+
public @interface EntityDefining {
28+
}

0 commit comments

Comments
 (0)