Skip to content

Commit

Permalink
Merge pull request #8 from cliedeman/feature/change-classloader
Browse files Browse the repository at this point in the history
Changed AnnotationUtils work with executable spring boot jars
  • Loading branch information
bpatters authored Jan 9, 2017
2 parents f8cc563 + 6738747 commit 138f5c2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.Map;

/**
* Common Annotaiton related utility methods.
* Common Annotation related utility methods.
*/
public class AnnotationUtils {

Expand All @@ -27,10 +27,11 @@ public class AnnotationUtils {
private static ClassPath classPath;

public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}

static {
try {
classLoader = AnnotationUtils.class.getClassLoader();
// Change classloader to work with spring boot executable jars
// http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
classLoader = Thread.currentThread().getContextClassLoader();
classPath = ClassPath.from(classLoader);
} catch (IOException ex) {
Throwables.propagate(ex);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.bretpatterson.schemagen.graphql.utils;

import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import org.junit.Test;

import java.util.Map;

import static org.junit.Assert.*;

public class AnnotationUtilsTest {

@Test
public void getClassesWithAnnotation() throws Exception {
Map<Class<?>, GraphQLTypeMapper> classes = AnnotationUtils.getClassesWithAnnotation(
GraphQLTypeMapper.class, "com.bretpatterson.schemagen");

assertFalse(classes.isEmpty());
}

}

0 comments on commit 138f5c2

Please sign in to comment.