Guice

JPA 2 + EclipseLink : Caching Issue

拜拜、爱过 提交于 2020-01-15 10:57:05
问题 I have a strange behavior with caching and JPA Entities (EclipseLink 2.4.1 ) + GUICE PERSIST I will not use caching, nevertheless I get randomly an old instance that has already changed in MySQL database. I have tried the following: Add @ Cacheable (false) to the JPA Entity. Disable Cache properties in the persistence.xml file : <class>MyEntity</class> <shared-cache-mode>NONE</shared-cache-mode> <properties> <property name="eclipselink.cache.shared.default" value="false"/> <property name=

Guice : Inject an ArrayList of Strings

江枫思渺然 提交于 2020-01-13 17:54:37
问题 I'm trying to inject an ArrayList of String s with the help of Guice. I want to show a panel with many RadioButtons (for example) where an user can select some services to activate. Once selected, I would like to get all the names of the selected services and add them into a list, and inject this list to the manager responsible to create the services. Here is an example: public class UIProviderModule extends ProviderServiceModule { private ArrayList<String> requestedServices; public

Scala Dependency injection with generic class

拈花ヽ惹草 提交于 2020-01-11 13:21:50
问题 Using Guice in Scala, I'm trying to reproduce the following Java code. Foo interface and class declaration: public interface Foo[T] {} public class FooImpl[T] implements Foo[T] {} Guice binding code: bind(Foo.class).to(FooImpl.class); And one use example would be; @Inject public class Bar(Foo<String> foo) {} In scala, my first bet was: bind(classOf[Foo]).to(classOf[FooImpl]) But it's complaining about 'Type Foo takes type parameter' How do I achieve this in scala? Thank you 回答1: Your question

Guice: is it possible to inject modules?

▼魔方 西西 提交于 2020-01-09 12:52:13
问题 I have a Module that requires some Depedency . Is there a way Modules themselves can be injected? I realize this is a bit of a chicken and egg situation... Example: public class MyModule implements Module { private final Dependency d_; @Inject public MyModule(Dependency d) { d_ = d; } public void configure(Binder b) { } @Provides Something provideSomething() { // this requires d_ } } I suppose in this case the solution would be to turn the @Provides method into a full-fledged Provider

Jersey, Guice using non-root request paths

流过昼夜 提交于 2020-01-06 14:19:13
问题 I'm using Jersey 1.11 over Guice 3.0 on Tomcat 6.0.32 in a standard configuration: configureServlets() { filter("/ws/*").through(GuiceContainer.class); } And a simple resource class: @Path("/resource") public class Resource { ... } Given that, I would suppose that accessing "/ws/resource" would work; but actually no resources are found. The problem seems to lie in the request path not being computed correctly. As a workaround I have set the parameter PROPERTY_FILTER_CONTEXT_PATH to /ws ,

trying to access spring bean from guice module

╄→гoц情女王★ 提交于 2020-01-06 05:35:05
问题 I am using guice 4.2.2 in my Java application and need to utilize Spring beans (as part of a library I need to incorporate into my application). I have tried using SpringIntegration within guice and I am able to print the names of the beans loaded. However, when I try to access an object using injector.getInstance, the object I get is null. Any thoughts on how I can go about troubleshooting this further? I can use Spring-projects's spring-guice integration if needed. guice module public class

Using Mockito & Guice to test interfaces with generics in Scala

我是研究僧i 提交于 2020-01-05 05:57:16
问题 I am new to Scala, and I'm running into this problem when I'm trying to unit test some of my interfaces. I have an InputService trait with method def poll(parameters: HashMap[String, String]): Option[T] where T is generic, so InputService has a type parameter [T]. In my module, I have val inputService: InputService[String] = mock(classOf[InputService[String]]) bind[InputService[String]].toInstance(inputService) and in my InputServiceTest, I have var inputService: InputService[String] = _

When is Assisted-inject useful?

自古美人都是妖i 提交于 2020-01-05 05:18:15
问题 I'm currently using Guice in my App. However i find myself mostly using assisted inject because there is a chain of injected objects that all depend on what was the input of the program. Hence almost everything is assisted inject. For instance A need B who need c who need Z which needs input from the command line. In the end i feel like everything will be assisted injected. So given that i'm stuck with it i want to be sure that i m using it right. I personally feel like writing my own

When is Assisted-inject useful?

流过昼夜 提交于 2020-01-05 05:18:14
问题 I'm currently using Guice in my App. However i find myself mostly using assisted inject because there is a chain of injected objects that all depend on what was the input of the program. Hence almost everything is assisted inject. For instance A need B who need c who need Z which needs input from the command line. In the end i feel like everything will be assisted injected. So given that i'm stuck with it i want to be sure that i m using it right. I personally feel like writing my own

Create an Instance of class which does DI via Playframework Guice Independently in Scala

假装没事ソ 提交于 2020-01-05 04:23:21
问题 I'm working on Playframework2.5 with play-slick and programs related to it such as batch. current project structure is like /rootPlayProject /app /controllers /filters /services ... Modules /core (sub-project - DAOs,services are placed here) /batch (sub-project depends on core) I'm using Guice DI almost everywhere include Database Access Object(DAO). And interfaces in core are bound in Module placed in core which end up getting inherited by Module in root project. Core Module(/rootPlayProject