-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added Google Guice ActionHooks support (#113)
Refs: #106
- Loading branch information
Showing
7 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
...ain/java/ch/sbb/polarion/extension/interceptor_manager/guice/GuiceActionHooksFactory.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,33 @@ | ||
package ch.sbb.polarion.extension.interceptor_manager.guice; | ||
|
||
import ch.sbb.polarion.extension.interceptor_manager.model.IActionHook; | ||
import com.google.inject.Inject; | ||
import com.polarion.core.util.logging.Logger; | ||
import com.polarion.platform.guice.internal.GuicePlatform; | ||
import lombok.Getter; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@Getter | ||
public class GuiceActionHooksFactory { | ||
private static final Logger logger = Logger.getLogger(GuiceActionHooksFactory.class); | ||
private final Set<IActionHook> actionHooks = new HashSet<>(); | ||
|
||
private GuiceActionHooksFactory() {} | ||
|
||
public static GuiceActionHooksFactory build() { | ||
GuiceActionHooksFactory actionHooksFactory = new GuiceActionHooksFactory(); | ||
GuicePlatform.tryInjectMembers(actionHooksFactory); | ||
return actionHooksFactory; | ||
} | ||
|
||
@Inject | ||
@SuppressWarnings("unused") | ||
public void setActionHooks(Set<IActionHook> actionHooks) { | ||
if (actionHooks != null) { | ||
this.actionHooks.addAll(actionHooks); | ||
logger.info("Added guice action hooks: " + actionHooks.size()); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/ch/sbb/polarion/extension/interceptor_manager/guice/GuiceModule.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,13 @@ | ||
package ch.sbb.polarion.extension.interceptor_manager.guice; | ||
|
||
import ch.sbb.polarion.extension.interceptor_manager.model.IActionHook; | ||
import com.google.inject.AbstractModule; | ||
import com.google.inject.multibindings.Multibinder; | ||
|
||
public class GuiceModule extends AbstractModule { | ||
|
||
@Override | ||
protected void configure() { | ||
Multibinder.newSetBinder(binder(), IActionHook.class); | ||
} | ||
} |
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
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