From 86ac482a5485f9eb7ede03a88e5daf1df531be67 Mon Sep 17 00:00:00 2001 From: Alfredo Gutierrez Date: Mon, 26 Aug 2024 14:49:25 -0600 Subject: [PATCH] Settling for Factory instead of Builder when passing the configuration Signed-off-by: Alfredo Gutierrez --- .../BlockNodeAppInjectionComponent.java | 29 ++++++------------- .../java/com/hedera/block/server/Server.java | 4 +-- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionComponent.java b/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionComponent.java index 05ed8be9..114bedc0 100644 --- a/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionComponent.java +++ b/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionComponent.java @@ -45,29 +45,18 @@ public interface BlockNodeAppInjectionComponent { */ BlockNodeApp getBlockNodeApp(); - // @Component.Factory - // interface Factory { - // BlockNodeAppInjectionComponent create(@BindsInstance Configuration configuration); - // } - - /** Builder for the BlockNodeAppInjectionComponent. */ - @Component.Builder - interface Builder { - + /** + * Factory for the block node app injection component, needs a configuration to create the + * component and the block node app with all the wired dependencies. + */ + @Component.Factory + interface Factory { /** - * Bind the configuration to the BlockNodeAppInjectionComponent. + * Create the block node app injection component. * * @param configuration the configuration - * @return the BlockNodeAppInjectionComponentBuilder - */ - @BindsInstance - Builder configuration(Configuration configuration); - - /** - * Build the BlockNodeAppInjectionComponent. - * - * @return the BlockNodeAppInjectionComponent + * @return the block node app injection component */ - BlockNodeAppInjectionComponent build(); + BlockNodeAppInjectionComponent create(@BindsInstance Configuration configuration); } } diff --git a/server/src/main/java/com/hedera/block/server/Server.java b/server/src/main/java/com/hedera/block/server/Server.java index 4c8b0413..51c8df1e 100644 --- a/server/src/main/java/com/hedera/block/server/Server.java +++ b/server/src/main/java/com/hedera/block/server/Server.java @@ -55,10 +55,8 @@ public static void main(final String[] args) throws IOException { // Init Dagger DI Component, passing in the configuration. // this is where all the dependencies are wired up (magic happens) - // final BlockNodeAppInjectionComponent daggerComponent = - // DaggerBlockNodeAppInjectionComponent.factory().create(configuration); final BlockNodeAppInjectionComponent daggerComponent = - DaggerBlockNodeAppInjectionComponent.builder().configuration(configuration).build(); + DaggerBlockNodeAppInjectionComponent.factory().create(configuration); // Use Dagger DI Component to start the BlockNodeApp with all wired dependencies final BlockNodeApp blockNodeApp = daggerComponent.getBlockNodeApp();