Skip to content

Commit

Permalink
make one scan
Browse files Browse the repository at this point in the history
wcekan committed Mar 12, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent de539e3 commit d56ad8b
Showing 2 changed files with 12 additions and 15 deletions.
12 changes: 11 additions & 1 deletion elide-core/src/main/java/com/yahoo/elide/core/EntityBinding.java
Original file line number Diff line number Diff line change
@@ -240,6 +240,16 @@ public List<AccessibleObject> getAllFields() {
*/
private void bindEntityFields(Class<?> cls, String type, Collection<AccessibleObject> fieldOrMethodList) {
for (AccessibleObject fieldOrMethod : fieldOrMethodList) {
// Special handling for Eclipse. Load missing annotations
if (fieldOrMethod.getAnnotations().length == 0 && fieldOrMethod instanceof Method) {
Method m = (Method) fieldOrMethod;
try {
fieldOrMethod = m.getDeclaringClass().getMethod(m.getName(), m.getParameterTypes());
} catch (NoSuchMethodException | SecurityException e) {
// Not expected, leave alone
}
}

bindTriggerIfPresent(OnCreatePreSecurity.class, fieldOrMethod);
bindTriggerIfPresent(OnDeletePreSecurity.class, fieldOrMethod);
bindTriggerIfPresent(OnUpdatePreSecurity.class, fieldOrMethod);
@@ -390,7 +400,7 @@ private void bindRelation(AccessibleObject fieldOrMethod, String fieldName, Clas

relationshipsDeque.push(fieldName);
fieldsToValues.put(fieldName, fieldOrMethod);
fieldsToTypes.put(fieldName, fieldType);
fieldsToTypes.put(fieldName, fieldType == null ? Void.class : fieldType);
}

private void bindAttr(AccessibleObject fieldOrMethod, String fieldName, Class<?> fieldType) {
Original file line number Diff line number Diff line change
@@ -25,8 +25,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import javax.persistence.Entity;

/**
* Simple in-memory only database.
*/
@@ -44,18 +42,7 @@ public HashMapDataStore(Set<Package> beanPackages) {
this.beanPackages = beanPackages;

for (Package beanPackage : beanPackages) {
ClassScanner.getAnnotatedClasses(beanPackage, Include.class).stream()
.filter(modelClass -> modelClass.getName().startsWith(beanPackage.getName()))
.filter(modelClass -> dictionary.getFirstAnnotation(modelClass,
Arrays.asList(Include.class, Exclude.class)) instanceof Include)
.forEach(modelClass -> dataStore.put(modelClass,
Collections.synchronizedMap(new LinkedHashMap<>())));
}

for (Package beanPackage : beanPackages) {
ClassScanner.getAnnotatedClasses(beanPackage, Entity.class).stream()
.filter(modelClass -> modelClass.getName().startsWith(beanPackage.getName()))
.filter(modelClass -> !dataStore.containsKey(modelClass))
ClassScanner.getAllClasses(beanPackage.getName()).stream()
.filter(modelClass -> dictionary.getFirstAnnotation(modelClass,
Arrays.asList(Include.class, Exclude.class)) instanceof Include)
.forEach(modelClass -> dataStore.put(modelClass,

0 comments on commit d56ad8b

Please sign in to comment.