Skip to content

Commit

Permalink
#1023 Deprecate separate context injector in favor of default injecto…
Browse files Browse the repository at this point in the history
…r, add populator tests
  • Loading branch information
GuusLieben committed Dec 20, 2023
1 parent 5bd0ac9 commit c071a45
Show file tree
Hide file tree
Showing 28 changed files with 271 additions and 592 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.dockbox.hartshorn.component.processing.ComponentPreProcessor;
import org.dockbox.hartshorn.component.processing.ComponentProcessor;
import org.dockbox.hartshorn.component.processing.ServiceActivator;
import org.dockbox.hartshorn.inject.processing.UseContextInjection;
import org.dockbox.hartshorn.util.ContextualInitializer;
import org.dockbox.hartshorn.util.Customizer;
import org.dockbox.hartshorn.util.LazyStreamableConfigurer;
Expand Down Expand Up @@ -252,13 +251,13 @@ public static class Configurer {

private final LazyStreamableConfigurer<ApplicationBootstrapContext, Annotation> activators = LazyStreamableConfigurer.of(
TypeUtils.annotation(UseBootstrap.class),
TypeUtils.annotation(UseProxying.class),
TypeUtils.annotation(UseContextInjection.class)
TypeUtils.annotation(UseProxying.class)
);

private final LazyStreamableConfigurer<ApplicationContext, ComponentPreProcessor> componentPreProcessors = LazyStreamableConfigurer.empty();
private final LazyStreamableConfigurer<ApplicationContext, ComponentPostProcessor> componentPostProcessors = LazyStreamableConfigurer.<ApplicationContext, ComponentPostProcessor>empty()
.customizer(collection -> collection.add(ComponentFinalizingPostProcessor.create(Customizer.useDefaults())));
private final LazyStreamableConfigurer<ApplicationContext, ComponentPostProcessor> componentPostProcessors = LazyStreamableConfigurer.of(collection -> {
collection.add(ComponentFinalizingPostProcessor.create(Customizer.useDefaults()));
});

private final LazyStreamableConfigurer<ApplicationBootstrapContext, Class<?>> standaloneComponents = LazyStreamableConfigurer.empty();
private final LazyStreamableConfigurer<ApplicationBootstrapContext, String> scanPackages = LazyStreamableConfigurer.empty();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

package org.dockbox.hartshorn.component.factory;

import org.dockbox.hartshorn.component.processing.ServiceActivator;
import org.dockbox.hartshorn.inject.processing.UseContextInjection;
import org.dockbox.hartshorn.component.UseProxying;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.dockbox.hartshorn.component.UseProxying;
import org.dockbox.hartshorn.component.processing.ServiceActivator;

/**
* @deprecated See {@link Factory}.
*/
Expand All @@ -35,7 +34,6 @@
FactoryServicePostProcessor.class,
FactoryServicePreProcessor.class,
})
@UseContextInjection
@UseProxying
public @interface UseFactoryServices {
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ElementAnnotationsIntrospector annotations() {

@Override
public SequencedCollection<InjectionPoint> injectionPoints() {
return List.of(new InjectionPoint(this.field.genericType(), this.field));
return List.of(new InjectionPoint(this.field));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ElementAnnotationsIntrospector annotations() {
@Override
public SequencedCollection<InjectionPoint> injectionPoints() {
return this.method.parameters().all().stream()
.map(parameter -> new InjectionPoint(parameter.genericType(), parameter))
.map(InjectionPoint::new)
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

package org.dockbox.hartshorn.component.populate;

import java.util.List;
import java.util.Set;

import org.dockbox.hartshorn.application.context.ApplicationContext;
import org.dockbox.hartshorn.component.ComponentPopulateException;
import org.dockbox.hartshorn.component.ComponentPopulator;
import org.dockbox.hartshorn.component.populate.context.ContextPopulationStrategy;
import org.dockbox.hartshorn.component.populate.inject.InjectPopulationStrategy;
import org.dockbox.hartshorn.context.ContextCarrier;
import org.dockbox.hartshorn.proxy.ProxyManager;
Expand All @@ -31,9 +33,6 @@
import org.dockbox.hartshorn.util.StreamableConfigurer;
import org.dockbox.hartshorn.util.introspect.view.TypeView;

import java.util.List;
import java.util.Set;

/**
* A {@link ComponentPopulator} that populates components using a set of {@link ComponentPopulationStrategy}s. The
* strategies are executed in the order they are provided to the constructor. If a strategy is applicable to a given
Expand Down Expand Up @@ -124,9 +123,8 @@ public static ContextualInitializer<ApplicationContext, ComponentPopulator> crea

public static class Configurer {

private final LazyStreamableConfigurer<ApplicationContext, ComponentPopulationStrategy> strategies = LazyStreamableConfigurer.<ApplicationContext, ComponentPopulationStrategy>empty().customizer(collection -> {
private final LazyStreamableConfigurer<ApplicationContext, ComponentPopulationStrategy> strategies = LazyStreamableConfigurer.of(collection -> {
collection.add(InjectPopulationStrategy.create(Customizer.useDefaults()));
collection.add(ContextPopulationStrategy.create(Customizer.useDefaults()));
});
private ContextualInitializer<ApplicationContext, ComponentInjectionPointsResolver> injectionPointsResolver = ContextualInitializer.of(MethodsAndFieldsInjectionPointResolver::new);

Expand Down
Loading

0 comments on commit c071a45

Please sign in to comment.