Skip to content

Commit

Permalink
Settling for Factory instead of Builder when passing the configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Aug 26, 2024
1 parent 56af241 commit 86ac482
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 1 addition & 3 deletions server/src/main/java/com/hedera/block/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 86ac482

Please sign in to comment.