Skip to content

Commit

Permalink
Fix configuration not supplying for Beans
Browse files Browse the repository at this point in the history
  • Loading branch information
CitralFlo committed Jan 23, 2025
1 parent 65ca9cd commit 1442f68
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.eternalcode.core;

import com.eternalcode.core.compatibility.CompatibilityService;
import com.eternalcode.core.configuration.ReloadableConfig;
import com.eternalcode.core.configuration.compatibility.ConfigurationCompatibilityV21_2;
import com.eternalcode.core.injector.DependencyInjector;
import com.eternalcode.core.injector.annotations.component.Component;
import com.eternalcode.core.injector.annotations.component.ConfigurationFile;
Expand Down Expand Up @@ -78,6 +80,8 @@ public EternalCore(Plugin plugin) {
beanFactory.addCandidate(beanCandidate);
}

beanFactory.initializeCandidates(ConfigurationCompatibilityV21_2.class); // TODO: Remove this when the cdn will be fixed
beanFactory.initializeCandidates(ReloadableConfig.class); // TODO: Remove this when the cdn will be fixed
beanFactory.initializeCandidates();

this.publisher = beanFactory.getDependency(Publisher.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import com.eternalcode.core.injector.annotations.component.Controller;
import com.eternalcode.core.publish.Subscribe;

// TODO: Make this package private
@Controller
@Compatibility(from = @Version(minor = 21, patch = 2))
class ConfigurationCompatibilityV21_2 {
public class ConfigurationCompatibilityV21_2 {

@Subscribe
void onConfigSettingsSetup(ConfigurationSettingsSetupEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public LazyBeanCandidate(String name, Supplier<Object> instanceSupplier) {

@Override
public boolean isCandidate(Class<?> clazz) {
Class<?> type = this.getInstance().getClass();

return clazz.isAssignableFrom(type);
return clazz.isAssignableFrom(getType());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public LazyFieldBeanCandidate(Supplier<Object> instance, Field field, Bean bean)
}

public LazyFieldBeanCandidate(DependencyInjector dependencyInjector, Class<?> componentClass, Field field, Bean bean) {
this(() -> dependencyInjector.newInstance(componentClass), field, bean);
this(() -> dependencyInjector.getDependencyProvider().getDependency(componentClass), field, bean);
}

@Override
Expand Down

0 comments on commit 1442f68

Please sign in to comment.