Re: How do I create two EntityManager binding, one without any annotation and one with annotation?

2016-06-13 Thread Stephan Classen
This is not possible. You need to define an notation for both entitymanagers. Also have a look at onami-persist for enhanced multi pu support Am 13. Juni 2016 12:11:42 MESZ, schrieb Kohei Nozaki : >Hello, > >I want to create two EntityManager binding with guice-persist

Re: Changing the injection key for a binding

2016-03-30 Thread Stephan Classen
I only allow usage of the EDSL within the abstract method PersistenceModule.configurePersistence(). All EDSL methods have a check as the very first statement to ensure that they are called from within the configurePersistence(). The configurePersistence() itself is a callback which will be

Re: Multiple modules, conflicting on @Provides

2016-03-22 Thread Stephan Classen
Private modules is the way to go. A binding in a private module can see all other bindings in the same private module and all bindings of all non private modules. On 22.03.2016 21:58, Chris Kessel wrote: I'm adding two Guice modules, but they both have an @Provides for the same item.

Re: inject object into module

2016-03-27 Thread Stephan Classen
There are several points to mention. But don't worry we will get you where you want to be. 1. Guice modules do not get injected. Modules define what is binded in the injector. This means the modules are used to construct the injector. So they exist before the injector does. This makes it

Re: Changing the injection key for a binding

2016-03-29 Thread Stephan Classen
OK, I read you post several times still I am not 100% sure if I understood your problem entirely. Maybe some more code or concrete examples would be helpful... From what I think you are trying to achieve I have done something similar myself once before. Have a look at the following classes: -

Re: TypeListener does not detect Map instance

2016-04-23 Thread Stephan Classen
You canot intercept methods on instances created by a provider. What guice does is to create a subclass of the thing you want to to intercept. But when you use a provider to create this object you are calling new yourself which makes it impossible for guice to sneak in the subclass. Therefore

Re: When to close an injected Closeable resource?

2016-05-02 Thread Stephan Classen
If this is about testing: My recomendation is to use constructor injection. And then in the unit test I simply call the constructor. This way I have full controll over what is passed to the subject under test. As a consequence of this. I do not make use of dependency injection during unit

Re: When to close an injected Closeable resource?

2016-05-01 Thread Stephan Classen
Look at guice-persist or onami-persist. They deal wir DB connections which also need to be closed after it has been used. To do so they both use the concept of UnitOfWork. The application is then responsible for spanning the UnitOfWork around the code which needs the resource. Am 30. April

Re: Object is injected only once, but it's constructor is called twice :(

2016-08-10 Thread Stephan Classen
I had such a behavior once. In the end I had one point in the code where I injected the interface and another where I injected the concrete instance. Guice created a just in time binding for the concrete inatance. This was the reason the constructor was called twice. Am 10. August 2016

Re: PrivateModule

2016-07-19 Thread Stephan Classen
While reading the code example I assumed you would get an exception because you bind IResourceSetProvider twice. Anyways the thing you are looking for is Modules.override()

Re: JPA entity with custom annotations

2016-08-15 Thread Stephan Classen
Yes the entityManager is created by guice. But the entities that you retrieve from the DB are not created by guice and therefore the interceptor does not work. On 14.08.2016 16:51, Travis Collins wrote: I'm running a small test that uses a Guice managed JPA context. It's working very well.

Re: Module overrides don't work with MapBinder

2017-01-16 Thread Stephan Classen
If you only want to add server to the MapBinder then there is no need to overwrite modules. From the JavaDoc [1]: Contributing mapbindings from different modules is supported. For example, it is okay to have both |CandyModule| and |ChipsModule| both create their own |MapBinder

Re: Problem binding Base abstract class

2017-02-26 Thread Stephan Classen
So far this code looks correct. Can you also provide some of the test methods. Maybe something is hiding there. Am 27. Februar 2017 03:45:39 MEZ schrieb Nandish MC : > > >I have multiple hierarchical class like below > >public abstract class Page extends SelPage >{

Re: Problem binding Base abstract class

2017-02-27 Thread Stephan Classen
I see in you code how you construct the injector. But I never see you making use of it. I am not familiar with the Selenium library. Does it make use of the injector in the SeleniumTest.getCurrentPage() method? I rather doubt that Selenium will use you injector. So where do you use the

Re: Guice Persist support for Neo4j

2016-09-16 Thread Stephan Classen
I was using guice-persist in an environment with multiple databases and ran into some limitations (see the guice bug tracker). Since there was not much effort from the official developers I decided to write my own persist extension. I supports out of the box: - All features of guice-persist

Re: Injecting an EntityManager specifying the persistence unit with @javax.inject.Qualifier

2016-09-28 Thread Stephan Classen
Where do you bind the EntityManager? Is it bound just in time? At runtime do you have a container or similar which provides the EntityManager? Am 28. September 2016 17:20:16 MESZ, schrieb "Robério Cardoso Fernandes" : >Hi folks, >I'm doing the unit tests in my project, and

Re: Injecting an EntityManager specifying the persistence unit with @javax.inject.Qualifier

2016-09-29 Thread Stephan Classen
The binding bind(EntityManager.class).annotatedWith(ConnectionDatabase.class).to(EntityManager.class); tells guice to use the default binding of defined for EntityManager. So there must be somewhere a binding or a provider method which defines how to get an implementation of the EntityManager

Re: Injecting an EntityManager specifying the persistence unit with @javax.inject.Qualifier

2016-09-28 Thread Stephan Classen
I am not 100% sure but I think guice does not support the @Produces annotation. So far I only used @Provides Also if you are using tomEE you already have a CDI container. What is your reason to use guice in such an environment. Don't missunderstand me. I prefer guice over CDI but why chose

Re: Inject a sequence of components that implement the same interface and have dependencies themselves

2016-11-08 Thread Stephan Classen
Have a look at https://github.com/google/guice/wiki/Multibindings this does not solve the problem of how to configure them. But it allows you to inject a set/map of things. On 11/07/2016 11:42 PM, Dominik wrote: I want to inject a sequence

Re: Is guice-persist alive?

2017-04-04 Thread Stephan Classen
Hard to say I'm not working for Google but last time I asked this question it remained unanswered. Last real development I see in 2011. After this only whitespace refactorings. The Issues in the issue tracker are also open since a very long time. Because of this I wrote my own persistence

Re: Inject into a being injected class

2017-04-18 Thread Stephan Classen
You would need to bind the dependencies of your fancy email service. If those are configuration values like "url", "port" or similiar I recommend looking ate some of the 3rd party extensions which allow you to easily bind values from a properties file to a @Named singleton. Maybe you find

Re: Guice module integration issue with REST

2017-04-24 Thread Stephan Classen
Set a breakpoint or add a log statement at the end of the WorkerBean.findAll() to see what this method returns and if it is differen from what you see returned by the methodInvocation.proceed call Am 24. April 2017 17:56:21 MESZ schrieb pradrone dev : >Thanks it does work

Re: Is guice-persist alive?

2017-07-25 Thread Stephan Classen
o maintain it so thanks for releasing it. This is another matter, but lack of extensions make us think about leaving Guice and start with Spring, as most projects are using it because of its rich ecosystem. Regards El miércoles, 5 de abril de 2017 0:52:48 (CEST) Stephan Classen escribió: Hard t

Re: Profiling Modules

2017-07-01 Thread Stephan Classen
While Guice AOP is a nice and cool feature and I love to use it for certain use cases I also found that it becomes a performance issue if used to heavely. Because of this and the limitations you mention in your question I recommend using a classic profiler to investigate performance issues. For

Re: Guice module integration issue with REST

2017-04-24 Thread Stephan Classen
I think you problem is that you are mixing spring an guice (in an inappropriate way). I reproduced your above example (by the way, can you tell me from which library you use Worker and WorkerRepository?). The code is missing the binding for the worker. I added it. Next problem is the

Re: Guice module integration issue with REST

2017-04-25 Thread Stephan Classen
Sorry I have no Spring experience what so ever. So I guess I will not be of any help here. Hopefully someone else can jump in. On 25.04.2017 09:49, pradrone dev wrote: Can you please guide me steps how to Integrate Guice with Spring ? Tried few more stuff but it is unclear ? For your

Re: MethodInterceptor for class extending ebean Model not working

2017-05-15 Thread Stephan Classen
Be aware that AOP adds overhead onto these operations. I had to revert usage of AOP in a project once where we some of the methods were called very frequent. In most cases it is no problem but if you application will make heavy use of these getters and setters it could become noticeable. To

Re: RequestScoped and background threads

2017-06-13 Thread Stephan Classen
The request scope uses internally a thread local. So when you run stuff in a background thread you are not in a request as guice sees it. You need to call the same method as the mentioned filter does inorder to begin and end a request. Am 13. Juni 2017 20:21:00 MESZ schrieb Arun Thirupathi

Re: Is guice-persist alive?

2017-09-12 Thread Stephan Classen
jects are using it because of its rich > ecosystem. > > Regards > > El miércoles, 5 de abril de 2017 0:52:48 (CEST) Stephan Classen escribió: >> Hard to say >> >> I'm not working for Goog

Re: Is guice-persist alive?

2017-09-12 Thread Stephan Classen
- I was thinking more that those who have developed libraries based on guice-persist who may be wondering about being dependent on it, and possibly also willing to collaborate On 12 September 2017 at 09:43, Stephan Classen <st.clas...@gmx.ch <mailto:st.clas...@gmx.ch>> wrote:

Re: Is guice-persist alive?

2017-09-12 Thread Stephan Classen
thinking of projects like this one <https://github.com/xvik/guice-persist-orient> On 12 September 2017 at 09:01, Stephan Classen <st.clas...@gmx.ch <mailto:st.clas...@gmx.ch>> wrote: So a quick search on github finds 3 forks of onami-persist. https://github.com/toc

Re: Guice#bindMembers() and listeners initialized by the class itself cause NPEs

2017-11-28 Thread Stephan Classen
First of all I would not inject a model. Model classes are not meant to be handled with DI. Second you can use assisted injection to use constructor injection if you have both parameters and dependencies in a constructor. Non of the above helps clarify you question. But maybe it helps you

Re: current status of Guice

2017-11-22 Thread Stephan Classen
Guice never had a lot of activity in the open source area. There was once a Apache project (Onami) which became abandoned a few years ago. I feel Google is not very interested in a vivid community around Guice. Maybe they have enough internal factors driving Guice and do not want too many

Re: When is the google guice injector garbage collected?

2017-11-17 Thread Stephan Classen
They will also get garbage collected unless they have been injected somewhere. Then they only get garbage collected once the objects holding these references are also garbage collectable. In short. Guice does not change any behavior of the GC. The injector and all created instances (singleton

Re: NullPointerException in JpaPersistService

2017-12-04 Thread Stephan Classen
This is what I mentioned before. You cannot use any of the JPA stuff until PersistService.start() has been called. This will be called by the PersistFilter.init(). So you have to wait with the appLifeCycle.init() until after the init() method of PersistFilter On 04.12.2017 16:58, Diogo

Re: NullPointerException in JpaPersistService

2017-12-04 Thread Stephan Classen
Is this an open source project? If sou you could point me to the repo and I can have a look. On 04.12.2017 16:22, Diogo Luzzardi de Carvalho wrote: Hi, I tried both of your solutions, and the nullpointer keeps happen. Also I debug the application and I installed the JpaPersistModule before

Re: NullPointerException in JpaPersistService

2017-12-11 Thread Stephan Classen
Did you make any progress on this issue? On 04.12.2017 17:43, Diogo Luzzardi de Carvalho wrote: humm, at moment I call the appLifeCycle.init() the PersistFilter is already configured in the application because it is configured at the MainModule class configure method. There is any other way

Re: NullPointerException in JpaPersistService

2017-12-01 Thread Stephan Classen
Can you please give more of the stack trace (all of it). Because the cause of this NPE is different depending on where the call comes from. On 01.12.2017 20:27, Diogo Luzzardi de Carvalho wrote: The following exception is ocorring for me: | java.lang.NullPointerException at

Re: NullPointerException in JpaPersistService

2017-12-01 Thread Stephan Classen
A second cause could be that the PersistenceService has not been started yet. The persistence service is started by the PersistFiler.init() method. Unfortunately there is no way of checking if the PersistanceService is already started. And trying to start it twice will cause an exception the

Re: NullPointerException in JpaPersistService

2017-12-01 Thread Stephan Classen
OK, this is easy to fix. Guice JPA needs a running UnitOfWork in order to function. The UnitOfWork is a thread local context and therefore needs to be started and stopped for every thread which wants to make use of JPA. Be advised that you must end the UnitOfWork because starting it a second

Re: Help with @Inject, for some reason it doesn't work.

2018-05-24 Thread Stephan Classen
The question is: How are you creating the instance of Blob? Most likely the instance of Blob was not created by guice. This happens when you call "new". In order to have guice create the instance you must do either one of the following: - ask the injector for an instance --

Re: Guice injection not working in web application

2018-06-18 Thread Stephan Classen
Unless you tell guice that a dependency is optional it will never inject null. It would fail with an exception if it could not fullfil a dependency. So for me the most likely cause of you seeing null is that the instance you are inspecting is created by calling new, using reflection or by

Re: Guice pattern for long lived dynamic 1:1 relationships?

2018-06-14 Thread Stephan Classen
Scopes are surely a way to handle this situation. But Scopes are also hard to get right and they introduce a little "magic" because you need to know that a dependency is scoped. Because if you cache the instance you get from guice in a field it may not be the one you expect at a later state...

Re: Hierarchical lookup

2018-06-05 Thread Stephan Classen
Multibindings are the way Guice is implementing plug-in mechanism. The best I can think of is having a single SetBinder and add all pluggable classes there. Then implement your own methods which iterate over all binded classes and filter for the criteria you need. class Fruity { @Inject Set

Re: Dynamic binding inference

2018-06-19 Thread Stephan Classen
You could have a look at multi binders. https://github.com/google/guice/wiki/Multibindings Then bind all possible implementations of an interface and use the value from the properties to select the one out of the set. On 19.06.2018 16:33, 'Mariano Gonzalez' via google-guice wrote: Hello,

Re: Dynamic binding inference

2018-06-19 Thread Stephan Classen
I don't think this would be a good approach. And I am not even sure if guice would allow it. I would rather propose that every plugin comes with a Module which is then passed to the injector creation method. This way every plugin can bind whatever it needs. If multiple plugins try to bind the

Re: Dynamic binding inference

2018-06-20 Thread Stephan Classen
with a module is not an option in this case, which is why I'm looking for a way to leverage guice goodies while while keeping spring's behavior. Thanks On Tue, Jun 19, 2018, 12:09 PM Stephan Classen <mailto:st.clas...@gmx.ch>> wrote: I don't think this would be a good approach. And I am

Re: Providers - generation ?

2018-02-12 Thread Stephan Classen
There are many different implementations depending on the scope and the binding. An incomplete list is: - InjectorImpl.getProviderOrThrow() - Scopes.SINGLETON - ProviderLookup.getProvider() - Providers.of() - Providers.gucify() In the end it doesn't matter which implementation is actually

Re: JpaPersistModule, Hibernate and URL Variables

2018-02-14 Thread Stephan Classen
When are you passing this string? Is it part of you Giuce Module?? Could you read the environment variable before creating the string and than manually create the URL string? On 14.02.2018 11:38, Evan Ruff wrote: Hey guys, I've got what I think is a pretty straightforward task but I'm

Re: JpaPersistModule, Hibernate and URL Variables

2018-02-14 Thread Stephan Classen
Maybe you can make your path relative to the user directory as described here: http://www.h2database.com/html/faq.html#database_files Am 14. Februar 2018 21:06:34 MEZ schrieb Evan Ruff : >Hey guys, > >So I'm actually just letting Guice Persist pull it straight out of

Re: JpaPersistModule, Hibernate and URL Variables

2018-02-15 Thread Stephan Classen
Only way you can try to achieve this is the methode: JpaPersistModule.setProperties() The properties passed in will be used to create the entity manager factory (see JpaPersistService.start()) Maybe you can overwrite the URL in the properties you pass. On 15.02.2018 12:05, Evan Ruff wrote:

Re: JpaPersistModule, Hibernate and URL Variables

2018-02-15 Thread Stephan Classen
Can't you simply do the following?? public class MyModule extends ServletModule {   protected void configureServlets() {     install(new JpaPersistModule("myJpaUnit").setProperties(myProperties));   } } On 15.02.2018 14:46, Evan Ruff wrote: scl, Thanks for the tip, this works as expected.

Re: How do I retrieve an object injected through Guice

2018-08-29 Thread Stephan Classen
Checkout the tutorial in the guice github wiki: https://github.com/google/guice/wiki/GettingStarted Am 29. August 2018 18:56:14 MESZ schrieb Arul Prakasam Narasimhan : >Under my Module Class, I inject objects > > @Override >protected void configure() { >

[no subject]

2018-07-12 Thread Stephan Classen
http://espace-bien-naitre.fr/knmdhgt.php?ckukz -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscr...@googlegroups.com. To post to this group,

Re: Can I Inject x Class?

2018-06-21 Thread Stephan Classen
Jukito takes another approach. They use an ElementVisitor to collect all bindings and then decide if the required binding is in the module(s). Have a look at the BindingsCollector.java class https://github.com/ArcBees/Jukito/blob/master/jukito/src/main/java/org/jukito/BindingsCollector.java

Re: dynamically reload the property bindings using guice .

2018-12-10 Thread Stephan Classen
Not when you are using Names.bindProperties. What you could do is bind custom provider methods for the different config parameters. This provider methods are then under your control and you can cache/reload the value as you like. On 10.12.18 18:34, Bharath Vishnu Neelakantan wrote: I load

Re: Two instances of the same class, different properties, is it possible?

2019-02-18 Thread Stephan Classen
Could you give some more details. Best would be some code example Am 18. Februar 2019 22:16:20 MEZ schrieb jhertz : >I have two instances of the same class. I want to inject them with two >different set of properties in the form of a Map. The >instances are read dynamically from and XML file so

Re: Delay initialization support

2019-03-07 Thread Stephan Classen
You cannot change the configuration of an injector after it has been created. What you can do is create a child injector which inherits all bindings from its parent and can add extra bindings. But I think the problem should be tackled by your bean container. Which one are you using. Can you

Re: How to override module

2019-01-29 Thread Stephan Classen
Look at the class Modules. There is a method "override" Usage: Modules.override(new WriterModule()).with(new AbcWriterModule()) On 29.01.19 12:21, Sammy wrote: Hi, I got below final module public final class WriterModuleextends AbstractModule { with below provides

<    1   2