restx.CoreModuleFactoryMachine Maven / Gradle / Ivy
package restx;
import com.google.common.collect.ImmutableSet;
import restx.factory.*;
import restx.CoreModule;
@Machine
public class CoreModuleFactoryMachine extends DefaultFactoryMachine {
private static final CoreModule module = new CoreModule();
public CoreModuleFactoryMachine() {
super(10000, new MachineEngine[] {
new StdMachineEngine(Name.of(restx.config.ConfigSupplier.class, "coreAppConfigSupplier"), 10000, BoundlessComponentBox.FACTORY) {
private final Factory.Query configLoader = Factory.Query.byClass(restx.config.ConfigLoader.class).mandatory();
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
configLoader
));
}
@Override
public restx.config.ConfigSupplier doNewComponent(SatisfiedBOM satisfiedBOM) {
return module.coreAppConfigSupplier(
satisfiedBOM.getOne(configLoader).get().getComponent()
);
}
},
new StdMachineEngine(Name.of(restx.config.ConfigSupplier.class, "httpConfigSupplier"), 10000, BoundlessComponentBox.FACTORY) {
private final Factory.Query configLoader = Factory.Query.byClass(restx.config.ConfigLoader.class).mandatory();
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
configLoader
));
}
@Override
public restx.config.ConfigSupplier doNewComponent(SatisfiedBOM satisfiedBOM) {
return module.httpConfigSupplier(
satisfiedBOM.getOne(configLoader).get().getComponent()
);
}
},
new StdMachineEngine(Name.of(com.google.common.eventbus.EventBus.class, "eventBus"), 10000, BoundlessComponentBox.FACTORY) {
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
));
}
@Override
public com.google.common.eventbus.EventBus doNewComponent(SatisfiedBOM satisfiedBOM) {
return module.eventBus(
);
}
},
new StdMachineEngine(Name.of(restx.factory.AutoStartable.class, "loadEventBusOnStartUp"), 10000, BoundlessComponentBox.FACTORY) {
private final Factory.Query eventBus = Factory.Query.byClass(com.google.common.eventbus.EventBus.class).mandatory();
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
eventBus
));
}
@Override
public restx.factory.AutoStartable doNewComponent(SatisfiedBOM satisfiedBOM) {
return module.loadEventBusOnStartUp(
satisfiedBOM.getOne(eventBus).get().getComponent()
);
}
},
new StdMachineEngine(Name.of(restx.common.metrics.api.health.HealthCheckRegistry.class, "HealthChekcRegistry"), 10000, BoundlessComponentBox.FACTORY) {
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
));
}
@Override
public restx.common.metrics.api.health.HealthCheckRegistry doNewComponent(SatisfiedBOM satisfiedBOM) {
return module.healthCheckRegistry(
);
}
},
new StdMachineEngine(Name.of(restx.common.UUIDGenerator.class, "UUIDGenerator"), 10000, BoundlessComponentBox.FACTORY) {
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
));
}
@Override
public restx.common.UUIDGenerator doNewComponent(SatisfiedBOM satisfiedBOM) {
return module.uuidGenerator(
);
}
},
});
}
}