org.springframework.nativex.type.Type

Here are the examples of the java api org.springframework.nativex.type.Type taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

62 Examples 7

19 View Source File : WebComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Override
public boolean handle(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    Type resolvedComponentType = imageContext.getTypeSystem().resolveDotted(componentType, true);
    return resolvedComponentType != null && resolvedComponentType.isAtController();
}

19 View Source File : WebComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private void replacedyze(NativeContext imageContext, Type type, Set<String> added) {
    List<Field> fields = type.getFields();
    for (Field field : fields) {
        Set<String> fieldTypenames = field.getTypesInSignature();
        for (String fieldTypename : fieldTypenames) {
            if (fieldTypename == null) {
                continue;
            }
            String dottedFieldTypename = fieldTypename.replace("/", ".");
            if (!ignore(dottedFieldTypename) && added.add(dottedFieldTypename)) {
                added.addAll(imageContext.addReflectiveAccessHierarchy(dottedFieldTypename, AccessBits.CLreplaced | AccessBits.DECLARED_METHODS | AccessBits.DECLARED_CONSTRUCTORS));
                // Recursive replacedysis - helps with something like a Vets type that includes a List<Vet>. Vet gets
                // recognized too.
                replacedyze(imageContext, imageContext.getTypeSystem().resolveDotted(dottedFieldTypename, true), added);
            }
        }
    }
}

@Override
public boolean handle(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    // Need to do deeper digging here so let's look at everything that can be resolved
    Type type = imageContext.getTypeSystem().resolveName(componentType);
    return type != null;
}

19 View Source File : PropertiesAccessChecker.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Override
public boolean check(TypeSystem typeSystem, String typename) {
    boolean isOK = true;
    if (typename.endsWith("Properties") || typename.contains("Properties$")) {
        String[] dependants = requiredTypes.get(typename);
        if (dependants != null) {
            for (String dependant : dependants) {
                Type resolvedDependant = typeSystem.resolveDotted(dependant, true);
                if (resolvedDependant == null) {
                    // System.out.println("Check on " + typename + " failed due to missing " + dependant);
                    isOK = false;
                    break;
                }
            }
        }
    }
    return isOK;
}

19 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private boolean isProjectionInterface(Type repositoryDomainType, Type signatureType) {
    return signatureType.isInterface() && !signatureType.isPartOfDomain("java.") && !isPartOfSpringData(signatureType) && !signatureType.isreplacedignableFrom(repositoryDomainType);
}

@Override
public boolean handle(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    Type type = imageContext.getTypeSystem().resolveName(componentType);
    boolean hasTxMethods = type != null && type.hasTransactionalMethods();
    boolean isInteresting = (type != null && (type.isTransactional() || hasTxMethods));
    // if (isInteresting && !type.isInterface() && (!type.isTransactional() && hasTxMethods)) {
    // throw new IllegalStateException("Unable to process @Transactional on methods of a clreplaced (found on methods in: "+
    // componentType+"), only proxies for @Transactional annotated interface methods are currently supported");
    // }
    return isInteresting;
}

private boolean inSimilarPackage(Type type, Type repositoryInterface) {
    String repoPackage = repositoryInterface.getPackageName();
    String typePackage = type.getPackageName();
    if (repoPackage.startsWith(typePackage) || typePackage.startsWith(repoPackage)) {
        return true;
    }
    return false;
}

@Override
public boolean handle(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    Type type = imageContext.getTypeSystem().resolveName(componentType);
    return (type != null && (type.isAtPrePostSecured()));
}

18 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private boolean isPartOfSpringData(Type type) {
    return type.isPartOfDomain(SPRING_DATA_NAMESPACE);
}

18 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private void registerSpringDataAnnotations(Method method, NativeContext context) {
    for (Type annotation : method.getAnnotationTypes()) {
        registerSpringDataAnnotation(annotation, context);
    }
}

18 View Source File : TypeSystemTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void test() throws Exception {
    Type t = typeSystem.resolveName("java.lang.String");
    replacedertNotNull(t);
}

18 View Source File : TypeSystemTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void testArray() throws Exception {
    Type s = typeSystem.resolveName("java.lang.String");
    replacedertEquals("Ljava/lang/String;", s.getDescriptor());
    Type t = typeSystem.resolveName("java.lang.String[]");
    replacedertNotNull(t);
    replacedertEquals(1, t.getDimensions());
    replacedertTrue(t.isArray());
    replacedertEquals("[Ljava/lang/String;", t.getDescriptor());
    replacedertEquals("java/lang/String[]", t.getName());
    replacedertEquals("java.lang.String[]", t.getDottedName());
}

18 View Source File : ConfigurationCollector.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

public void initializeAtRunTime(Type type) {
    initializeAtRunTime(type.getDottedName());
}

18 View Source File : ConfigurationCollector.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private boolean checkTypes(List<String> types, Predicate<Type> test) {
    for (int i = 0; i < types.size(); i++) {
        String clreplacedName = types.get(i);
        Type clazz = ts.resolveDotted(clreplacedName, true);
        if (!test.test(clazz)) {
            return false;
        }
    }
    return true;
}

18 View Source File : ConfigurationCollector.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

public void initializeAtBuildTime(List<Type> types) {
    for (Type type : types) {
        initializationDescriptor.addBuildtimeClreplaced(type.getDottedName());
    }
    for (Type type : types) {
        initializeAtBuildTime(type.getDottedName());
    }
}

18 View Source File : ConfigurationCollector.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

public void initializeAtBuildTime(Type type) {
    initializeAtBuildTime(type.getDottedName());
}

@Override
public void process(NativeContext context, String candidateClreplacedName, List<String> clreplacedifiers) {
    Type type = context.getTypeSystem().resolveDotted(candidateClreplacedName, true);
    if (ifIsRSocketClientInterface(context, candidateClreplacedName, clreplacedifiers)) {
        registerInvariants(context, candidateClreplacedName);
        log.info("process(context, " + candidateClreplacedName + ", " + String.join(",", clreplacedifiers) + "): " + type.getDottedName() + ".");
        log.info("registering proxy and reflection for " + candidateClreplacedName + '.');
        context.addProxy(candidateClreplacedName, org.springframework.aop.SpringProxy.clreplaced.getName(), org.springframework.aop.framework.Advised.clreplaced.getName(), org.springframework.core.DecoratingProxy.clreplaced.getName());
        context.addReflectiveAccessHierarchy(type, AccessBits.ALL);
    }
}

@Override
public void process(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    Type type = imageContext.getTypeSystem().resolveName(componentType);
    List<String> transactionalInterfaces = new ArrayList<>();
    for (Type intface : type.getInterfaces()) {
        transactionalInterfaces.add(intface.getDottedName());
    }
    if (transactionalInterfaces.size() == 0) {
        imageContext.log("TransactionalComponentProcessor: unable to find interfaces to proxy on " + componentType);
        return;
    }
    transactionalInterfaces.add("org.springframework.aop.SpringProxy");
    transactionalInterfaces.add("org.springframework.aop.framework.Advised");
    transactionalInterfaces.add("org.springframework.core.DecoratingProxy");
    imageContext.addProxy(transactionalInterfaces);
    imageContext.log("TransactionalComponentProcessor: creating proxy for these interfaces: " + transactionalInterfaces);
}

@Override
public void process(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    Type type = imageContext.getTypeSystem().resolveName(componentType);
    Predicate<Type> isSpringAnnotation = anno -> anno.getDottedName().startsWith("org.springframework");
    Set<Type> collector = new HashSet<>();
    for (Type annotationType : type.getAnnotations()) {
        annotationType.collectAnnotations(collector, isSpringAnnotation);
    }
    List<Method> methods = type.getMethods();
    // Example with annotations on the method and against parameters:
    // @GetMapping("/greeting")
    // public String greeting( @RequestParam(name = "name", required = false, defaultValue = "World") String name, Model model) {
    for (Method method : methods) {
        for (Type methodAnnotationType : method.getAnnotationTypes()) {
            methodAnnotationType.collectAnnotations(collector, isSpringAnnotation);
        }
        for (int pi = 0; pi < method.getParameterCount(); pi++) {
            List<Type> parameterAnnotationTypes = method.getParameterAnnotationTypes(pi);
            for (Type parameterAnnotationType : parameterAnnotationTypes) {
                parameterAnnotationType.collectAnnotations(collector, isSpringAnnotation);
            }
        }
    }
    List<Field> fields = type.getFields();
    for (Field field : fields) {
        for (Type fieldAnnotationType : field.getAnnotationTypes()) {
            fieldAnnotationType.collectAnnotations(collector, isSpringAnnotation);
        }
    }
    // From the candidate annotations, determine those that are truly the target
    // of aliases (either because @AliasFor'd from another annotation or using
    // internal @AliasFor references amongst its own attributes)
    Set<String> aliasForTargets = new HashSet<>();
    for (Type annotationType : collector) {
        annotationType.collectAliasReferencedMetas(aliasForTargets);
    }
    List<String> proxied = new ArrayList<>();
    for (String aliasForTarget : aliasForTargets) {
        if (!ignore(aliasForTarget)) {
            List<String> interfaces = new ArrayList<>();
            interfaces.add(aliasForTarget);
            interfaces.add("org.springframework.core.annotation.SynthesizedAnnotation");
            imageContext.addProxy(interfaces);
            proxied.add(aliasForTarget);
        }
    }
    imageContext.log("SynthesizerComputerComponentProcessor: From examining " + type.getDottedName() + " determined " + proxied.size() + " types as synthesized proxies: " + proxied);
}

@Override
public void process(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    Type type = imageContext.getTypeSystem().resolveName(componentType);
    List<String> prePostSecuredInterfaces = new ArrayList<>();
    for (Type intface : type.getInterfaces()) {
        prePostSecuredInterfaces.add(intface.getDottedName());
    }
    if (prePostSecuredInterfaces.size() == 0) {
        imageContext.log("PrePostSecuredComponentProcessor: unable to find interfaces to proxy on " + componentType);
        return;
    }
    prePostSecuredInterfaces.add("org.springframework.aop.SpringProxy");
    prePostSecuredInterfaces.add("org.springframework.aop.framework.Advised");
    prePostSecuredInterfaces.add("org.springframework.core.DecoratingProxy");
    imageContext.addProxy(prePostSecuredInterfaces);
    imageContext.log("PrePostSecuredComponentProcessor: creating proxy for these interfaces: " + prePostSecuredInterfaces);
}

17 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private void registerSpringDataAnnotation(Type annotation, NativeContext context) {
    if (!context.hasReflectionConfigFor(annotation) && isPartOfSpringData(annotation)) {
        context.addReflectiveAccess(annotation.getDottedName(), Flag.allPublicMethods);
        context.addProxy(annotation.getDottedName(), "org.springframework.core.annotation.SynthesizedAnnotation");
        log.annotationFound(annotation);
    }
}

17 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void typeParameters() {
    Type extenderClreplaced = typeSystem.resolveName(Extender.clreplaced.getName());
    Set<String> typesInSignature = extenderClreplaced.getTypesInSignature();
    replacedertEquals(3, typesInSignature.size());
    Iterator<String> iterator = typesInSignature.iterator();
    replacedertEquals("java/lang/Object", iterator.next());
    replacedertEquals("org/springframework/nativex/TypeTests$Finder", iterator.next());
    replacedertEquals("org/springframework/nativex/TypeTests$TXClreplaced4", iterator.next());
    Type extender2 = typeSystem.resolveName(Extender2.clreplaced.getName());
    typesInSignature = extender2.getTypesInSignature();
    iterator = typesInSignature.iterator();
    replacedertEquals(2, typesInSignature.size());
    replacedertEquals("java/io/Serializable", iterator.next());
    replacedertEquals("org/springframework/nativex/TypeTests$TXClreplaced4", iterator.next());
}

17 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void findReactiveCrudTypeParameter() {
    Type t = typeSystem.resolveName(Foo.clreplaced.getName());
    String s = t.findTypeParameterInSupertype(FooI.clreplaced.getName(), 0);
    replacedertEquals(TestController1.clreplaced.getName(), s);
}

17 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

// @Test
// public void isTransactional() {
// // TODO verify how to deal with a type extending a type that has transactional methods - are instances
// // of the subtype considered transactional?
// Type txClreplaced1 = typeSystem.resolveName(TXClreplaced1.clreplaced.getName());
// replacedertTrue(txClreplaced1.isTransactional());
// Type txClreplaced2 = typeSystem.resolveName(TXClreplaced2.clreplaced.getName());
// replacedertFalse(txClreplaced2.isTransactional());
// replacedertTrue(txClreplaced2.hasTransactionalMethods());
// Type tClreplaced1 = typeSystem.resolveName(TestClreplaced1.clreplaced.getName());
// replacedertFalse(tClreplaced1.isTransactional());
// Type txClreplaced3 = typeSystem.resolveName(TXClreplaced3.clreplaced.getName());
// replacedertFalse(txClreplaced3.isTransactional());
// Type txClreplaced4 = typeSystem.resolveName(TXClreplaced4.clreplaced.getName());
// replacedertFalse(txClreplaced4.isTransactional());
// }
@Test
public void responseBody() {
    Type testController = typeSystem.resolveName(TestController1.clreplaced.getName());
    replacedertTrue(testController.hasAnnotation("L" + ResponseBody.clreplaced.getName().replace(".", "/") + ";", true));
    Type testController2 = typeSystem.resolveName(TestController2.clreplaced.getName());
    replacedertTrue(testController2.hasAnnotation("L" + ResponseBody.clreplaced.getName().replace(".", "/") + ";", true));
}

17 View Source File : ConfigurationCollector.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

public void initializeAtRunTime(List<Type> types) {
    for (Type type : types) {
        initializationDescriptor.addRuntimeClreplaced(type.getDottedName());
    }
}

16 View Source File : WebComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Override
public void process(NativeContext imageContext, String componentType, List<String> clreplacedifiers) {
    Type controllerType = imageContext.getTypeSystem().resolveDotted(componentType, true);
    List<Method> mappings = controllerType.getMethods(m -> m.isAtMapping());
    imageContext.log("WebComponentProcessor: in controller " + componentType + " processing mappings " + mappings);
    for (Method mapping : mappings) {
        List<Type> toProcess = new ArrayList<>();
        toProcess.addAll(mapping.getParameterTypes());
        toProcess.add(mapping.getReturnType());
        for (Type type : toProcess) {
            if (type == null) {
                continue;
            }
            String typename = type.getDottedName();
            if (typename.startsWith("java.") || typename.startsWith("org.springframework.ui.") || typename.startsWith("org.springframework.validation.")) {
                continue;
            }
            if (added.add(typename)) {
                Set<String> added = imageContext.addReflectiveAccessHierarchy(typename, AccessBits.CLreplaced | AccessBits.DECLARED_METHODS | AccessBits.DECLARED_CONSTRUCTORS);
                replacedyze(imageContext, type, added);
                imageContext.log("WebComponentProcessor: adding reflective access to " + added + " (whilst introspecting controller " + componentType + ")");
            }
        }
    }
}

@Override
public boolean handle(NativeContext imageContext, String key, List<String> values) {
    Type resolvedKey = imageContext.getTypeSystem().resolveDotted(key);
    if (resolvedKey.hasAnnotationInHierarchy("Lorg/springframework/stereotype/Repository;")) {
        imageContext.log(LOG_PREFIX + "handling @Repository " + key);
        return true;
    }
    return false;
}

@Override
public void process(NativeContext imageContext, String key, List<String> values) {
    try {
        Type repositoryType = imageContext.getTypeSystem().resolveDotted(key);
        Set<String> processed = new HashSet<>();
        processRepositoryType(repositoryType, imageContext, processed);
        registerRepositoryProxy(imageContext, repositoryType, processed);
    } catch (Throwable t) {
        imageContext.log(LOG_PREFIX + "WARNING: Problem with SpringAtRepositoryComponentProcessor: " + t.getMessage());
        t.printStackTrace();
    }
}

public void registerRepositoryProxy(NativeContext imageContext, Type repositoryType, Set<String> processed) {
    List<String> repositoryInterfacesStrings = repositoryType.getInterfacesStrings();
    if (repositoryInterfacesStrings.size() != 0) {
        List<String> repositoryInterfaces = new ArrayList<>();
        imageContext.log(LOG_PREFIX + repositoryType.getDottedName() + " is getting a proxy created");
        for (String s : repositoryInterfacesStrings) {
            repositoryInterfaces.add(s.replace("/", "."));
        }
        repositoryInterfaces.add("org.springframework.aop.SpringProxy");
        repositoryInterfaces.add("org.springframework.aop.framework.Advised");
        repositoryInterfaces.add("org.springframework.core.DecoratingProxy");
        imageContext.addProxy(repositoryInterfaces);
    } else {
        imageContext.log(LOG_PREFIX + "WARNING: unable to create proxy for repository " + repositoryType.getDottedName() + " because it has no interfaces");
    }
}

public void processRepositoryType(Type repositoryType, NativeContext imageContext, Set<String> processed) {
    // For example: JdbcOwnerRepositoryImpl implements OwnerRepository
    Type[] repositoryInterfaces = repositoryType.getInterfaces();
    for (Type repositoryInterface : repositoryInterfaces) {
        addAllTypesFromSignaturesInRepositoryInterface(repositoryInterface, imageContext, processed);
    }
    imageContext.log(String.format(LOG_PREFIX + "%s reflective access added - adding this repository type and its hierarchy", repositoryType.getDottedName()));
    imageContext.addReflectiveAccessHierarchy(repositoryType, AccessBits.LOAD_AND_CONSTRUCT_AND_PUBLIC_METHODS | AccessBits.DECLARED_FIELDS);
}

16 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Override
public void process(NativeContext imageContext, String key, List<String> values) {
    keysSeen.add(key);
    try {
        Type repositoryType = imageContext.getTypeSystem().resolveName(key);
        Type repositoryDomainType = resolveRepositoryDomainType(repositoryType, imageContext.getTypeSystem());
        if (repositoryDomainType == null) {
            // give up!
            logger.debug(LOG_PREFIX + "Unable to work out repository contents for repository " + key);
            return;
        }
        log.repositoryFoundForType(repositoryType, repositoryDomainType);
        registerRepositoryInterface(repositoryType, imageContext);
        registerDomainType(repositoryDomainType, imageContext);
        registerQueryMethodResultTypes(repositoryType, repositoryDomainType, imageContext);
        detectCustomRepositoryImplementations(repositoryType, imageContext);
    } catch (Throwable t) {
        logger.debug("WARNING: Problem with SpringDataComponentProcessor: " + t.getMessage());
    }
}

16 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private Type resolveRepositoryDomainType(Type repositoryType, TypeSystem typeSystem) {
    for (String repositoryDeclarationName : repositoryDeclarationNames()) {
        String domainTypeName = repositoryType.findTypeParameterInSupertype(repositoryDeclarationName, 0);
        if (StringUtils.hasText(domainTypeName)) {
            log.message(String.format("Found %s for domain type %s.", repositoryDeclarationName, domainTypeName));
            return typeSystem.resolveName(domainTypeName);
        }
    }
    return null;
}

16 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private void registerRepositoryInterface(Type repositoryType, NativeContext imageContext) {
    imageContext.addReflectiveAccess(repositoryType, Flag.allPublicMethods, Flag.allDeclaredConstructors);
    {
        // proxy configuration
        // as is
        imageContext.addProxy(repositoryType.getDottedName(), "org.springframework.aop.SpringProxy", "org.springframework.aop.framework.Advised", "org.springframework.core.DecoratingProxy");
        // transactional
        imageContext.addProxy(repositoryType.getDottedName(), repositoryName, "org.springframework.transaction.interceptor.TransactionalProxy", "org.springframework.aop.framework.Advised", "org.springframework.core.DecoratingProxy");
        /*
			 * Generated proxies extend Proxy and Proxy implements Serializable. So the call:
			 * 	    protected void evaluateProxyInterfaces(Clreplaced<?> beanClreplaced, ProxyFactory proxyFactory) {
			 * 		    Clreplaced<?>[] targetInterfaces = ClreplacedUtils.getAllInterfacesForClreplaced(beanClreplaced, getProxyClreplacedLoader());
			 * is going to find targetInterfaces contains Serializable when called on the beanClreplaced.
			 */
        if (repositoryType.isAtComponent()) {
            imageContext.addProxy(repositoryType.getDottedName(), repositoryName, "org.springframework.transaction.interceptor.TransactionalProxy", "org.springframework.aop.framework.Advised", "org.springframework.core.DecoratingProxy", "java.io.Serializable");
        }
    }
    // reactive repo
    if (repositoryType.implementsInterface("org/springframework/data/repository/reactive/ReactiveCrudRepository")) {
        // TODO: check if we really need this!
        imageContext.initializeAtBuildTime(repositoryType);
    }
}

16 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void defaultValue() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced1a.clreplaced.getName());
    List<HintDeclaration> compilationHints = testClreplaced.getCompilationHints();
    replacedertEquals(1, compilationHints.size());
    HintDeclaration ch = compilationHints.get(0);
    replacedertEquals(Object.clreplaced.getName(), ch.getTriggerTypename());
}

16 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void configurationHintConversion() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced1.clreplaced.getName());
    List<HintDeclaration> compilationHints = testClreplaced.getCompilationHints();
    replacedertEquals(1, compilationHints.size());
    HintDeclaration ch = compilationHints.get(0);
    replacedertEquals(Integer.clreplaced.getName(), ch.getTriggerTypename());
}

16 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void testFields() {
    Type t = typeSystem.resolveName(TestFields.clreplaced.getName());
    Field one = t.getField("one");
    Set<String> tis = one.getTypesInSignature();
    Iterator<String> iterator = tis.iterator();
    replacedertEquals(1, tis.size());
    replacedertEquals("java/lang/String", iterator.next());
    Field two = t.getField("two");
    tis = two.getTypesInSignature();
    iterator = tis.iterator();
    replacedertEquals(2, tis.size());
    replacedertEquals("java/lang/Integer", iterator.next());
    replacedertEquals("java/util/List", iterator.next());
    Field three = t.getField("three");
    tis = three.getTypesInSignature();
    iterator = tis.iterator();
    replacedertEquals(0, tis.size());
    Field four = t.getField("four");
    tis = four.getTypesInSignature();
    iterator = tis.iterator();
    replacedertEquals(1, tis.size());
    replacedertEquals("java/lang/String", iterator.next());
}

16 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void flags() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced4.clreplaced.getName());
    List<HintDeclaration> compilationHints = testClreplaced.getCompilationHints();
    replacedertEquals(1, compilationHints.size());
    HintDeclaration ch = compilationHints.get(0);
    replacedertTrue(ch.isAbortIfTypesMissing());
}

16 View Source File : HintTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void resources() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced3.clreplaced.getName());
    List<HintApplication> hints = testClreplaced.getApplicableHints();
    replacedertEquals(1, hints.size());
    HintApplication hint = hints.get(0);
    List<ResourcesDescriptor> resourcesDescriptors = hint.getResourceDescriptors();
    replacedertEquals(2, resourcesDescriptors.size());
    String[] patterns = resourcesDescriptors.get(0).getPatterns();
    replacedertEquals("aaa", patterns[0]);
    replacedertEquals("bbb", patterns[1]);
    replacedertFalse(resourcesDescriptors.get(0).isBundle());
    patterns = resourcesDescriptors.get(1).getPatterns();
    replacedertEquals("ccc", patterns[0]);
    replacedertTrue(resourcesDescriptors.get(1).isBundle());
}

16 View Source File : ConfigurationCollector.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private boolean verifyMembers(ClreplacedDescriptor clreplacedDescriptor) {
    Type t = ts.resolveDotted(clreplacedDescriptor.getName(), true);
    if (t == null) {
        logger.warn("Failed verification check: this type was requested to be added to configuration but is not resolvable " + clreplacedDescriptor.getName() + " it will be skipped");
        return false;
    } else {
        return t.verifyMembers(aotOptions.isDebugVerify());
    }
}

16 View Source File : ConfigurationCollector.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private boolean verifyType(ClreplacedDescriptor clreplacedDescriptor) {
    Type t = ts.resolveDotted(clreplacedDescriptor.getName(), true);
    if (t == null) {
        logger.warn("Failed verification check: this type was requested to be added to configuration but is not resolvable: " + clreplacedDescriptor.getName() + " it will be skipped");
        return false;
    } else {
        return t.verifyType(aotOptions.isDebugVerify());
    }
}

15 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void arrayValue() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced1b.clreplaced.getName());
    List<HintDeclaration> compilationHints = testClreplaced.getCompilationHints();
    replacedertEquals(1, compilationHints.size());
    HintDeclaration ch = compilationHints.get(0);
    replacedertEquals(Object.clreplaced.getName(), ch.getTriggerTypename());
    replacedertEquals("java.lang.String[]", ch.getDependantTypes().keySet().iterator().next().toString());
}

15 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void parameterCount() {
    Type t = typeSystem.resolveName(TestMethods.clreplaced.getName());
    // public void one(String a) {}
    Method one = t.getMethod("one").get(0);
    replacedertEquals(1, one.getParameterCount());
    replacedertEquals("java.lang.String", one.getParameterTypes().get(0).getDottedName());
    // public void two(java.io.Serializable a,String b) {}
    Method two = t.getMethod("two").get(0);
    replacedertEquals(2, two.getParameterCount());
    replacedertEquals("java.io.Serializable", two.getParameterTypes().get(0).getDottedName());
    replacedertEquals("java.lang.String", two.getParameterTypes().get(1).getDottedName());
}

15 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void testTypesInSignatureForMethods() {
    Type t = typeSystem.resolveName(TestMethods.clreplaced.getName());
    Method foo = t.getMethod("foo").get(0);
    Set<String> tis = foo.getTypesInSignature();
    Iterator<String> iterator = tis.iterator();
    replacedertEquals("java/lang/String", iterator.next());
    replacedertEquals("java/util/List", iterator.next());
    replacedertFalse(iterator.hasNext());
    Method bar = t.getMethod("bar").get(0);
    tis = bar.getTypesInSignature();
    iterator = tis.iterator();
    replacedertEquals("java/lang/String", iterator.next());
    replacedertEquals("java/util/List", iterator.next());
    replacedertFalse(iterator.hasNext());
    Method boo = t.getMethod("boo").get(0);
    tis = boo.getTypesInSignature();
    iterator = tis.iterator();
    replacedertEquals("java/lang/String", iterator.next());
    replacedertFalse(iterator.hasNext());
}

15 View Source File : HintTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void directHints() {
    Type t = typeSystem.resolveName(TH1.clreplaced.getName());
    List<HintDeclaration> hints = t.getCompilationHints();
    replacedertEquals(1, hints.size());
    HintDeclaration hd = hints.get(0);
    replacedertEquals(TH1.clreplaced.getName(), hd.getTriggerTypename());
    replacedertTrue(hd.getDependantTypes().containsKey("java.lang.String"));
    t = typeSystem.resolveName(TH2.clreplaced.getName());
    hd = t.getCompilationHints().get(0);
    replacedertEquals(TH2.clreplaced.getName(), hd.getTriggerTypename());
    replacedertTrue(hd.getDependantTypes().containsKey("java.lang.String"));
    replacedertTrue(hd.getDependantTypes().containsKey("java.lang.Integer"));
}

15 View Source File : HintTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void proxies() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced2.clreplaced.getName());
    List<HintApplication> hints = testClreplaced.getApplicableHints();
    replacedertEquals(1, hints.size());
    HintApplication hint = hints.get(0);
    List<ProxyDescriptor> proxies = hint.getProxyDescriptors();
    replacedertEquals(1, proxies.size());
    String[] types = proxies.get(0).getTypes();
    replacedertEquals("java.lang.String", types[0]);
    replacedertEquals("java.lang.Integer", types[1]);
}

15 View Source File : HintTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void initializations() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced5.clreplaced.getName());
    List<HintApplication> hints = testClreplaced.getApplicableHints();
    replacedertEquals(1, hints.size());
    HintApplication hint = hints.get(0);
    List<InitializationDescriptor> initializationDescriptors = hint.getInitializationDescriptors();
    replacedertEquals(2, initializationDescriptors.size());
    Set<String> btc = initializationDescriptors.get(0).getBuildtimeClreplacedes();
    Set<String> btp = initializationDescriptors.get(0).getBuildtimePackages();
    Set<String> rtc = initializationDescriptors.get(0).getRuntimeClreplacedes();
    Set<String> rtp = initializationDescriptors.get(0).getRuntimePackages();
    replacedertEquals(0, btc.size());
    replacedertEquals(3, rtc.size());
    replacedertContains("aaa", rtc);
    replacedertContains("bbb", rtc);
    replacedertContains("java.lang.String", rtc);
    replacedertEquals(0, btp.size());
    replacedertEquals(0, rtp.size());
    btc = initializationDescriptors.get(1).getBuildtimeClreplacedes();
    btp = initializationDescriptors.get(1).getBuildtimePackages();
    rtc = initializationDescriptors.get(1).getRuntimeClreplacedes();
    rtp = initializationDescriptors.get(1).getRuntimePackages();
    replacedertEquals(0, btc.size());
    replacedertEquals(0, rtc.size());
    replacedertEquals(1, btp.size());
    replacedertContains("ccc", btp);
    replacedertEquals(0, rtp.size());
}

14 View Source File : SpringDataComponentProcessor.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private void detectCustomRepositoryImplementations(Type repositoryType, NativeContext imageContext) {
    List<Type> customImplementations = new ArrayList<>();
    {
        log.message("Looking for custom repository implementations of " + repositoryType.getDottedName());
        Type customImplementation = imageContext.getTypeSystem().resolveName(repositoryType.getName() + customRepositoryImplementationPostfix(), true);
        if (customImplementation != null) {
            log.customImplementationFound(repositoryType, customImplementation);
            customImplementations.add(customImplementation);
        }
    }
    log.message("Inspecting repository interfaces for potential extensions.");
    for (Type repoInterface : repositoryType.getInterfaces()) {
        if (isPartOfSpringData(repoInterface)) {
            log.message("Skipping spring data interface " + repoInterface.getDottedName());
            continue;
        }
        log.message("Detected non spring data interface " + repoInterface.getDottedName());
        String customImplementationName = repoInterface.getName() + customRepositoryImplementationPostfix();
        Type customImplementation = imageContext.getTypeSystem().resolveName(customImplementationName, true);
        if (customImplementation != null) {
            log.customImplementationFound(repoInterface, customImplementation);
            customImplementations.add(customImplementation);
        }
    }
    for (Type customImpl : customImplementations) {
        imageContext.addReflectiveAccessHierarchy(customImpl, AccessBits.DECLARED_CONSTRUCTORS | AccessBits.DECLARED_METHODS);
        for (Method method : customImpl.getMethods()) {
            for (Type signatureType : method.getSignatureTypes(true)) {
                registerDomainType(signatureType, imageContext);
            }
        }
    }
}

14 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void testMethodsToDescriptors() {
    Type t = typeSystem.resolveName(TestMethodsDescriptors.clreplaced.getName());
    MethodDescriptor descriptor = t.getMethod("aaa").get(0).getMethodDescriptor();
    replacedertEquals("aaa", descriptor.getName());
    List<String> parameterTypes = descriptor.getParameterTypes();
    replacedertEquals(0, parameterTypes.size());
    descriptor = t.getMethod("bbb").get(0).getMethodDescriptor();
    replacedertEquals("bbb", descriptor.getName());
    parameterTypes = descriptor.getParameterTypes();
    replacedertEquals(4, parameterTypes.size());
    replacedertEquals("java.lang.String", parameterTypes.get(0));
    replacedertEquals("int", parameterTypes.get(1));
    replacedertEquals("long[]", parameterTypes.get(2));
    replacedertEquals("java.lang.String[]", parameterTypes.get(3));
}

14 View Source File : TypeTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void testMethodsToArray() {
    Type t = typeSystem.resolveName(TestMethods.clreplaced.getName());
    Method one = t.getMethod("one").get(0);
    String[] array = one.asConfigurationArray();
    replacedertEquals(2, array.length);
    replacedertEquals("one", array[0]);
    replacedertEquals("java.lang.String", array[1]);
    Method two = t.getMethod("two").get(0);
    array = two.asConfigurationArray();
    replacedertEquals(3, array.length);
    replacedertEquals("two", array[0]);
    replacedertEquals("java.io.Serializable", array[1]);
    replacedertEquals("java.lang.String", array[2]);
}

14 View Source File : HintTests.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

@Test
public void hints() {
    Type testClreplaced = typeSystem.resolveName(TestClreplaced1.clreplaced.getName());
    List<HintApplication> hints = testClreplaced.getApplicableHints();
    replacedertEquals(1, hints.size());
    Map<String, AccessDescriptor> specificTypes = hints.get(0).getSpecificTypes();
    AccessDescriptor accessDescriptor = specificTypes.get("java.lang.String[]");
    replacedertThat(accessDescriptor).isNotNull();
    replacedertThat(accessDescriptor.getAccessBits()).isEqualTo(AccessBits.CLreplaced);
}

See More Examples