-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move restx.config from core to factory
- ConfigLoader is no more annotated with @component, a FactoryMachine have been implemented to provides ConfigLoader components: ConfigLoaderFactoryMachine - new FactoryMachine in restx-factory have been declared in META-INF/services/restx.factory.FactoryMachine (ConsolidatedConfigFactoryMachine, ElementsFromConfigFactoryMachine and ConfigLoaderFactoryMachine) - In FactoryTest ElementsFromConfig component is deactivated, it can not be build because of "missing.dependency" injected in "mandatory.dep.result1" component (from TestMandatoryDependency module). This commit don't change the fact that restx-core-annotation-processor and restx-core should be used as dependencies in order to use @Settings, @SettingsKey and ConfigSupplier. Next thing to do is to move SettingsAnnotationProcessor in restx-factory.
- Loading branch information
Showing
9 changed files
with
96 additions
and
19 deletions.
There are no files selected for viewing
19 changes: 16 additions & 3 deletions
19
restx-factory-testing/src/test/java/restx/factory/FactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
restx-factory/src/main/java/restx/config/ConfigLoaderFactoryMachine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package restx.config; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
|
||
import restx.factory.BillOfMaterials; | ||
import restx.factory.BoundlessComponentBox; | ||
import restx.factory.Factory; | ||
import restx.factory.Machine; | ||
import restx.factory.Name; | ||
import restx.factory.SatisfiedBOM; | ||
import restx.factory.SingleNameFactoryMachine; | ||
import restx.factory.StdMachineEngine; | ||
|
||
/** | ||
* Machine for {@link ConfigLoader}. | ||
*/ | ||
@Machine | ||
public class ConfigLoaderFactoryMachine extends SingleNameFactoryMachine<ConfigLoader> { | ||
public static final Name<ConfigLoader> NAME = Name.of(ConfigLoader.class, "ConfigLoader"); | ||
|
||
public ConfigLoaderFactoryMachine() { | ||
super(0, new StdMachineEngine<ConfigLoader>(NAME, 0, BoundlessComponentBox.FACTORY) { | ||
private final Factory.Query<String> env = Factory.Query.byName(Name.of(String.class, "env")).optional(); | ||
|
||
@Override | ||
public BillOfMaterials getBillOfMaterial() { | ||
return new BillOfMaterials(ImmutableSet.<Factory.Query<?>>of( | ||
env | ||
)); | ||
} | ||
|
||
@Override | ||
protected ConfigLoader doNewComponent(SatisfiedBOM satisfiedBOM) { | ||
return new ConfigLoader( | ||
satisfiedBOM.getOneAsComponent(env) | ||
); | ||
} | ||
}); | ||
} | ||
} |
File renamed without changes.
24 changes: 19 additions & 5 deletions
24
...fig/ConsolidatedConfigFactoryMachine.java → ...fig/ConsolidatedConfigFactoryMachine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion
5
restx-factory/src/main/resources/META-INF/services/restx.factory.FactoryMachine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
restx.factory.SystemPropertyFactoryMachine | ||
restx.factory.SystemPropertyFactoryMachine | ||
restx.config.ConfigLoaderFactoryMachine | ||
restx.config.ConsolidatedConfigFactoryMachine | ||
restx.config.ElementsFromConfigFactoryMachine |