Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 2b20e1b
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Wed Feb 8 18:45:55 2023 -0500

    order constants

commit 80dcb5c
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Wed Feb 8 18:35:12 2023 -0500

    Update pom.xml

commit a4e0de9
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Wed Feb 8 17:47:57 2023 -0500

    use avaje prism (it works, but is not deployed)

commit e051806
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 19:04:25 2023 -0500

    Update module-info.java

commit df99f4b
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 19:04:09 2023 -0500

    Update module-info.java

commit ce72b23
Merge: ad3f269 df12d0c
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 18:57:45 2023 -0500

    Merge branch 'prism' of https://github.com/SentryMan/avaje-inject into prism

commit ad3f269
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 18:57:29 2023 -0500

    static inject

commit df12d0c
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 18:48:12 2023 -0500

    static requires

commit d09c0e2
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 18:14:25 2023 -0500

    don't need prism module

commit b23e7f0
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 18:04:34 2023 -0500

    Update ExternalProvider.java

commit 84da34b
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 17:57:38 2023 -0500

    fix module

commit 2e9008e
Merge: 6e65622 91c5da2
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 17:55:29 2023 -0500

    Merge branch 'prism2' into prism

commit 91c5da2
Merge: 2ee8553 2b0f8d4
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 17:55:04 2023 -0500

    Merge pull request #3 from agentgt/prism

    Switch to generating module-info for prisms

commit 6e65622
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 17:47:15 2023 -0500

    rc5

commit 2b0f8d4
Author: Adam Gent <adam.gent@snaphop.com>
Date:   Tue Feb 7 17:30:33 2023 -0500

    Switch to generating module-info for prisms

commit ca6c9e5
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 17:01:32 2023 -0500

    minor stuff

commit 6f896d7
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 16:52:31 2023 -0500

    fix test

commit 5f8b4bf
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 16:45:17 2023 -0500

    compiles

commit e7577ca
Merge: b932fd8 2ee8553
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 15:42:27 2023 -0500

    Merge remote-tracking branch 'origin/prism2' into prism

commit 2ee8553
Merge: 8258618 a121495
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 15:34:49 2023 -0500

    Merge pull request #2 from agentgt/prism

    Merge prism changes

commit b932fd8
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 15:01:46 2023 -0500

    Update pom.xml

commit 585e707
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 15:01:29 2023 -0500

    Update pom.xml

commit f876306
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 14:49:31 2023 -0500

    external

commit a121495
Author: Adam Gent <adam.gent@snaphop.com>
Date:   Tue Feb 7 14:53:57 2023 -0500

    Move prisms to new module

commit 13c8300
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Tue Feb 7 13:21:45 2023 -0500

    working

commit 65c022e
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Mon Feb 6 21:48:57 2023 -0500

    Update pom.xml

commit 264d51d
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Mon Feb 6 21:47:12 2023 -0500

    sorta work

commit 8258618
Merge: 244360d 12eba7f
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Mon Feb 6 09:56:59 2023 -0500

    Merge remote-tracking branch 'upstream/master'

commit 244360d
Author: Josiah Noel <32279667+SentryMan@users.noreply.github.com>
Date:   Thu Feb 2 18:17:12 2023 -0500

    Update pom.xml
  • Loading branch information
rbygrave committed Feb 9, 2023
1 parent 12eba7f commit 064d8be
Show file tree
Hide file tree
Showing 28 changed files with 297 additions and 304 deletions.
2 changes: 1 addition & 1 deletion blackbox-aspect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>avaje-inject-parent</artifactId>
<groupId>io.avaje</groupId>
<version>8.12-RC4</version>
<version>8.12-RC5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion blackbox-other/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>avaje-inject-parent</artifactId>
<groupId>io.avaje</groupId>
<version>8.12-RC4</version>
<version>8.12-RC5</version>
</parent>

<artifactId>blackbox-other</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion blackbox-test-inject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>avaje-inject-parent</artifactId>
<groupId>io.avaje</groupId>
<version>8.12-RC4</version>
<version>8.12-RC5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
30 changes: 22 additions & 8 deletions inject-generator/pom.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject-parent</artifactId>
<version>8.12-RC4</version>
<version>8.12-RC5</version>
</parent>

<artifactId>avaje-inject-generator</artifactId>
<name>avaje inject generator</name>
<description>annotation processor generating di as source code</description>

<dependencies>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject</artifactId>
<version>8.12-RC4</version>
<version>${project.version}</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms</artifactId>
<version>1.0</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
Expand All @@ -40,8 +51,13 @@
<configuration>
<source>11</source>
<target>11</target>
<!-- Turn off annotation processing for building -->
<compilerArgument>-proc:none</compilerArgument>
<annotationProcessorPaths>
<path>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms</artifactId>
<version>1.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>

Expand All @@ -54,8 +70,6 @@
</argLine>
</configuration>
</plugin>

</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.avaje.inject.generator;

import io.avaje.inject.InjectModule;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


final class AllScopes {

Expand Down Expand Up @@ -59,7 +59,7 @@ void readModules(List<String> customScopeModules) {
for (String customScopeModule : customScopeModules) {
final TypeElement module = context.element(customScopeModule);
if (module != null) {
final InjectModule injectModule = module.getAnnotation(InjectModule.class);
InjectModulePrism injectModule = InjectModulePrism.getInstanceOn(module);
if (injectModule != null) {
final String customScopeType = injectModule.customScopeType();
final TypeElement scopeType = context.element(customScopeType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.avaje.inject.generator;

import io.avaje.inject.aop.Aspect;

import javax.lang.model.element.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -27,7 +27,7 @@ List<AspectPair> read() {
List<AspectPair> aspects = new ArrayList<>();
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
Element anElement = annotationMirror.getAnnotationType().asElement();
Aspect aspect = anElement.getAnnotation(Aspect.class);
AspectPrism aspect = AspectPrism.getInstanceOn(anElement);
if (aspect != null) {
Meta meta = readTarget(anElement);
if (meta != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.avaje.inject.generator;

import io.avaje.inject.Primary;
import io.avaje.inject.Prototype;
import io.avaje.inject.Secondary;
import io.avaje.inject.spi.Proxy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.util.*;


final class BeanReader {

Expand Down Expand Up @@ -40,10 +41,10 @@ final class BeanReader {
this.beanType = beanType;
this.type = beanType.getQualifiedName().toString();
this.shortName = shortName(beanType);
this.prototype = (beanType.getAnnotation(Prototype.class) != null);
this.primary = (beanType.getAnnotation(Primary.class) != null);
this.secondary = !primary && (beanType.getAnnotation(Secondary.class) != null);
this.proxy = (beanType.getAnnotation(Proxy.class) != null);
this.prototype = (PrototypePrism.getInstanceOn(beanType) != null);
this.primary = (PrimaryPrism.getInstanceOn(beanType) != null);
this.secondary = !primary && (SecondaryPrism.getInstanceOn(beanType) != null);
this.proxy = (ProxyPrism.getInstanceOn(beanType) != null);
this.typeReader = new TypeReader(GenericType.parse(type), beanType, context, importTypes, factory);
typeReader.process();
this.requestParams = new BeanRequestParams(type);
Expand Down Expand Up @@ -319,7 +320,7 @@ boolean isRequestScopedController() {
}

String suffix() {
return isRequestScopedController() ? Constants.FACTORY : Constants.DI;
return isRequestScopedController() ? Constants.DOLLAR_FACTORY : Constants.DI;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ final class Constants {

static final int ORDERING_DEFAULT = 1000;

static final String FACTORY = "$Factory";
static final String DOLLAR_FACTORY = "$Factory";
static final String DI = "$DI";
static final String IO_CLOSEABLE = "java.io.Closeable";
static final String AUTO_CLOSEABLE = "java.lang.AutoCloseable";
static final String OPTIONAL = "java.util.Optional";
static final String KOTLIN_METADATA = "kotlin.Metadata";
static final String TYPE = "java.lang.reflect.Type";

static final String PROVIDER = "jakarta.inject.Provider";
static final String SINGLETON = "jakarta.inject.Singleton";
static final String INJECT = "jakarta.inject.Inject";
static final String SCOPE = "jakarta.inject.Scope";
static final String QUALIFIER = "jakarta.inject.Qualifier";
static final String NAMED = "jakarta.inject.Named";

static final String PATH = "io.avaje.http.api.Path";
static final String CONTROLLER = "io.avaje.http.api.Controller";
Expand All @@ -30,10 +32,16 @@ final class Constants {
static final String BEANSCOPE = "io.avaje.inject.BeanScope";
static final String INJECTMODULE = "io.avaje.inject.InjectModule";
static final String TESTSCOPE = "io.avaje.inject.test.TestScope";
static final String PRIMARY = "io.avaje.inject.Primary";
static final String SECONDARY = "io.avaje.inject.Secondary";
static final String PROTOTYPE = "io.avaje.inject.Prototype";
static final String COMPONENT = "io.avaje.inject.Component";
static final String FACTORY = "io.avaje.inject.Factory";
static final String BEAN = "io.avaje.inject.Bean";

static final String REFLECT_METHOD = "java.lang.reflect.Method";
static final String ASPECT = "io.avaje.inject.aop.Aspect";
static final String ASPECT_PROVIDER ="io.avaje.inject.aop.AspectProvider";
static final String ASPECT_PROVIDER = "io.avaje.inject.aop.AspectProvider";
static final String INVOCATION = "io.avaje.inject.aop.Invocation";
static final String INVOCATION_EXCEPTION = "io.avaje.inject.aop.InvocationException";
static final String METHOD_INTERCEPTOR = "io.avaje.inject.aop.MethodInterceptor";
Expand All @@ -46,5 +54,4 @@ final class Constants {
static final String DEPENDENCYMETA = "io.avaje.inject.spi.DependencyMeta";
static final String MODULE = "io.avaje.inject.spi.Module";
static final String GENERICTYPE = "io.avaje.inject.spi.GenericType";

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package io.avaje.inject.generator;

import io.avaje.inject.spi.Module;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;

import java.util.*;
import io.avaje.inject.spi.Module;
import io.avaje.inject.spi.Plugin;

/**
* The types provided by other modules in the classpath at compile time.
Expand All @@ -11,13 +15,29 @@
*/
final class ExternalProvider {

private final Set<String> providedTypes = new HashSet<>();
private static final boolean injectAvailable = moduleCP();

private ExternalProvider() {}

private static boolean moduleCP() {
try {
Class.forName(Constants.MODULE);
return true;
} catch (final ClassNotFoundException e) {

return false;
}
}

public static void registerModuleProvidedTypes(Set<String> providedTypes) {

if (!injectAvailable) return;

Iterator<Module> iterator =
ServiceLoader.load(Module.class, ExternalProvider.class.getClassLoader()).iterator();

void init(Set<String> moduleFileProvided) {
providedTypes.addAll(moduleFileProvided);
ServiceLoader<Module> load = ServiceLoader.load(Module.class, ExternalProvider.class.getClassLoader());
Iterator<Module> iterator = load.iterator();
while (iterator.hasNext()) {

try {
Module module = iterator.next();
for (final Class<?> provide : module.provides()) {
Expand All @@ -36,10 +56,19 @@ void init(Set<String> moduleFileProvided) {
}

/**
* Return true if this type is provided by another module in the classpath. We will add it to
* autoRequires().
* Register types provided by the plugin so no compiler error when we have a dependency on these
* types and the only thing providing them is the plugin.
*
* @param defaultScope
*/
boolean provides(String type) {
return providedTypes.contains(type);
public static void registerPluginProvidedTypes(ScopeInfo defaultScope) {

if (!injectAvailable) return;

for (final Plugin plugin : ServiceLoader.load(Plugin.class, Processor.class.getClassLoader())) {
for (final Class<?> provide : plugin.provides()) {
defaultScope.pluginProvided(provide.getCanonicalName());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package io.avaje.inject.generator;

import java.util.Stack;
import java.util.ArrayDeque;
import java.util.Deque;

final class GenericTypeParser {

private final String raw;
private StringBuilder buf = new StringBuilder();
private final Stack<GenericType> stack = new Stack<>();
private final Deque<GenericType> stack = new ArrayDeque<>();

GenericTypeParser(String raw) {
this.raw = raw;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.avaje.inject.generator;

import io.avaje.inject.spi.DependencyMeta;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;


/**
* Holds the data as per <code>@DependencyMeta</code>
Expand Down Expand Up @@ -41,14 +39,14 @@ final class MetaData {
private boolean usesExternalDependency;
private String externalDependency;

MetaData(DependencyMeta meta) {
MetaData(DependencyMetaPrism meta) {
this.type = meta.type();
this.name = trimName(meta.name());
this.shortType = Util.shortName(type);
this.method = meta.method();
this.providesAspect = meta.providesAspect();
this.provides = asList(meta.provides());
this.dependsOn = Stream.of(meta.dependsOn()).map(Dependency::new).collect(Collectors.toList());
this.provides = meta.provides();
this.dependsOn = meta.dependsOn().stream().map(Dependency::new).collect(Collectors.toList());
this.autoProvides = meta.autoProvides();
}

Expand Down Expand Up @@ -113,13 +111,6 @@ void setWired() {
this.wired = true;
}

private List<String> asList(String[] content) {
if (content == null || content.length == 0) {
return new ArrayList<>();
}
return Arrays.asList(content);
}

void update(BeanReader beanReader) {
this.provides = beanReader.provides();
this.dependsOn = beanReader.dependsOn();
Expand Down

0 comments on commit 064d8be

Please sign in to comment.