Guice

In Shiro Guice, how can I change authc to a different subclass?

南笙酒味 提交于 2019-12-25 04:59:15
问题 Example: In shiro.ini I have: # Change from FormAuthenticationFilter to VerboseFormAuthenticationFilter authc=webapp.filters.VerboseFormAuthenticationFilter authc.loginUrl=/login authc.successUrl=/oncall How can I perform the above using Shiro Guice? I'm interested in the following line: authc=webapp.filters.VerboseFormAuthenticationFilter 回答1: public class YourShiroSecurityModule extends ShiroWebModule { private static final Key<VerboseFormAuthenticationFilter> VERBOSE_AUTH = Key.get

Install custom Jersey ViewProcessor from Guice ServletModule

倖福魔咒の 提交于 2019-12-25 03:05:27
问题 I am using jersey-guice to set up all my Jersey 1 resources using a bunch of Guice (Servlet)Modules. I have written a custom ViewProcessor ( CustomViewProcessor ) that relies on a configuration object, that I want to be injected into it using Guice. This CustomViewProcessor should be picked up and used by Jersey every time it needs one. How do I tell Jersey to fetch a Guice-created CustomViewProcessor instance whenever it needs a ViewProcessor ? I want to set all this up within my Guice

Field level injection with Gin

扶醉桌前 提交于 2019-12-25 02:34:08
问题 I'm trying to do field-level injection so I don't have to pass "models" when my controllers are instantiated, like, UserController controller = new UserController(/*No need to pass models here*/); However my application throws NullPointerException, here my code: UserController.java public class UserController implements Controller { @Inject private UserModel model; public UserController() { model.doSomething(); // NullPointerException } } ClientGinModule.java public class ClientGinModule

spring integration with drools

五迷三道 提交于 2019-12-24 23:34:29
问题 I want to integrate the drools in Spring.My spring config is: <kie:import releaseId-ref="ksession-rules2" enableScanner="true" scannerInterval="20000"/> <kie:releaseId id="ksession-rules2" groupId="com.test" artifactId="epay-risk2" version="1.0.3"/> <bean id="kiePostProcessor" class="org.kie.spring.annotations.KModuleAnnotationPostProcessor"/> I don't know why the following exception is thrown: java.lang.NoSuchMethodError: com.google.inject.Binder.bindListener(Lcom/google/inject/matcher

Binding the same interface twice (Guice)

我与影子孤独终老i 提交于 2019-12-24 20:34:22
问题 My classes (let call them X and Y ) both implementing Parser interface do (relatively) CPU intensive operations to build parsers for certain syntaxes (different syntaxes for X and Y ). Now I want to inject (with Guice) dependencies of both X and Y into constructor of an (upper level) parser P . Both arguments of P should be of the type Parser : class P implements Parser { @Inject public P(Parser x, Parser y) { // ... } } How can I make Guice to differentiate which of the two arguments of P

Running inside Guice injector, @Injects not respected on `new`-ed class

我怕爱的太早我们不能终老 提交于 2019-12-24 11:02:20
问题 We have a Swing-application we would like to add a slight touch of dependency injection to using Guice-3.0. Our reason is to migrate our old Factories into something more flexible. I have ensured that the application runs inside an injector, and we now want to have a class way down have some fields @Inject'ed, and it appears to my untrained eye that the @Inject annotations on this class is ignored when the "new" is running. Question now is if I have understood correctly that classes being new

Properties framework in java apps

隐身守侯 提交于 2019-12-24 10:48:37
问题 I have been using spring for a while as my IOC. It has also a very nice way of injecting properties in your beans. Now I am participating in a new project where the IOC is Guice. I dont understand fully the concept how should I inject properties in to my beans using Guice. The question : Is it actually possible to inject raw properties ( strings , ints ) into my guice beans. If the answer is no , than maybe you know some nice Properties Framework for java. Because right now I wanted to use

How can I a get singleton from Guice that's configured with runtime parameters?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 06:49:43
问题 My overall goal is to load properties from a properties file and then inject those properties into my objects. I would also like to use those properties to instantiate certain singleton classes using Guice. My singleton class looks like this: public class MainStore(){ private String hostname; @Inject public void setHostname(@Named("hostname") String hostname){ this.hostname = hostname; } public MainStore(){ System.out.println(hostname); } } I'm trying to instantiate a singleton using this

How to get String from config.yml file in Dropwizard resource?

旧城冷巷雨未停 提交于 2019-12-24 04:55:24
问题 I want to geta String in my Dropwizard config.yml and access it from a resource class. I have added the class to the configuration public class DropwizardBackendConfiguration extends Configuration { @NotEmpty private String uploadFileLocation; @JsonProperty public String getUploadFileLocation() { return uploadFileLocation; } @JsonProperty public void setUploadFileLocation(String uploadFileLocation) { this.uploadFileLocation = uploadFileLocation; } } I am able to get the content in the run

Can Guice be configured to hide the class path in stack traces?

佐手、 提交于 2019-12-24 03:18:12
问题 Guice's stack traces can get so verbose that they are very painful to read. Here's an example: 1) No implementation for java.util.Set<com.mydomain.myapp.android.activities.catbrowser.generalizedbrowser.listview.helpers.databaseitem.itemmanipulators.ItemManipulator<com.mydomain.myapp.flash.Cat>> annotated with @com.google.inject.assistedinject.Assisted(value=) was bound. while locating java.util.Set<com.mydomain.myapp.android.activities.catbrowser.generalizedbrowser.listview.helpers