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 infl

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: 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 @ProvidesIntoOptional(Type.

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 the

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() { >bind(AuthorizationService.class

[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-20 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 On

Re: Dynamic binding inference

2018-06-20 Thread Stephan Classen
having each plugin ship 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

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 sa

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, I

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 anothe

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: 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 -- injector.getInstan

Re: rollback transactions on success in test cases

2018-05-13 Thread Stephan Classen
Guice persist by itself does not support this feature There are a few approaches you could take 1. Jukito Jukito is a JUnit4 test runner. It adds guice support to JUnit. Thous it allows to inject Objects into methods (this includes @After method). You could take advantage of this and have your

Re: strange performance behaviour

2018-03-28 Thread Stephan Classen
Best guess is that the modules you pass to the injector depend on some external state and runtime for createInjector is different because of this Am 28. März 2018 12:06:33 MESZ schrieb g.prand...@fdlservizi.com: >Thanks for suggestion >Taking the createinjector out of that method (using a singlet

Re: How do I get injected reference from Guice created instance?

2018-02-16 Thread Stephan Classen
Two approaches I know of: Use constructor injection. This means make all your dependencies final and have them passed to the constructor which is annotated with @Inject. The constructor can be package visible only. It does not need to be public. In your test you don't need to use DI any more, si

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. Jpa

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: I

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 >META-INF/persistence.xml fi

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 havi

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 inject

Re: Providers - generation ?

2018-02-12 Thread Stephan Classen
Yes, Providers are generated on the fly by guice. https://github.com/google/guice/wiki/InjectingProviders On 12.02.2018 13:19, competitiveprogramming.pie...@gmail.com wrote: Hi all, I apologise if my question sounds silly or badly grounded. I am working on a project which makes intense use

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 to

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 Luz

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 I

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 b

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 t

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 com.google.inj

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 thin

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 com

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 or

Re: AOP to slf4j logger.info

2017-10-18 Thread Stephan Classen
If the @Logger causes Guice to inject an instance of a logger class which was not created by you (i.e. bindInstance) then it should work. Given the class injected is not final. Am 19. Oktober 2017 03:56:35 MESZ schrieb Yan Jiang : >Thanks, Luke. > >I get it now. > >I still get one shot, SLF4j.lo

Re: Is guice-persist alive?

2017-09-12 Thread Stephan Classen
brary - 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 <mailto:st.clas...@gmx.ch>> wrote: Maybe in a s

Re: Is guice-persist alive?

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

Re: Is guice-persist alive?

2017-09-12 Thread Stephan Classen
ng, 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 to say >> >> I'm

Re: Clarification regarding getting a singleton instance in GUICE

2017-08-16 Thread Stephan Classen
I don't understand what you are trying to achieve. Guice is all about injecting so you cannot have guice without an injector. If you try to have Guice inject an instance depending on the current classloader you could try to write a scope which ensures one instance per classloader. Am 16. Aug

Re: Clarification regarding getting a singleton instance in GUICE

2017-08-16 Thread Stephan Classen
I don't understand what you are trying to achieve. Guice is all about injecting so you cannot have guice without an injector. If you try to have Guice inject an instance depending on the current classloader you could try to write a scope which ensures one instance per classloader. Am 16. Aug

Re: Is guice-persist alive?

2017-07-25 Thread Stephan Classen
nowledge to 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

Re: Inject but pass an existing reference?

2017-07-14 Thread Stephan Classen
I don't think guice can do this. Maybe there is a hook you could use to take controle while the injection happens. Does someone else know more? What you could do as an alternative is to use assisted injection and then manually pass this as an assisted parameter. The advantages over calling a se

Re: Mixing injected with passed parameters

2017-07-03 Thread Stephan Classen
look at: https://github.com/google/guice/wiki/AssistedInject On 03.07.2017 15:59, Javier G. Visiedo wrote: Hi, I wonder if it is possible to mixed injected parameters with user passed parameters. Let me try to illustrate with an example in scala. Imagine a class using a remote service. Let

Re: Profiling Modules

2017-06-30 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 a

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 : >I

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 yo

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 refer

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 but now methodInvocatio

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 @Autowi

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 somet

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 ex

Re: Problem binding Base abstract class

2017-02-27 Thread Stephan Classen
Guice. On Feb 27, 2017, at 5:17 PM, Stephan Classen <mailto:st.clas...@gmx.ch>> wrote: 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.getCurrentPa

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 injector?

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 >{ >public method 1{} >public meth

Re: How to create/bind singleton object of 3rd party class which has 2 argument constructor. I need to pass 2 singleton object in the constructor

2017-01-21 Thread Stephan Classen
Or simply: bind(GetTemplate.class).toInstance(new GetTemplate(...)); Am 21. Januar 2017 20:47:45 MEZ schrieb "Olivier Grégoire" : >I think this would have better been asked on Stack Overflow, but still >here's an answer: > > >public class MyModule extends AbstractModule { > @Override protected v

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|, and to each co

Re: Non-thread-based request scoping

2016-12-20 Thread Stephan Classen
This does not solve the problem. The custom scope example uses a ThreadLocal, Object>> to store the scoped values. I am currently also looking for a "RequestScope" in an environment where a request may be handled by more than one thread. On 20.12.2016 08:57, Paweł Cesar Sanjuan Szklarz wrote:

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 o

Re: Listening for object instantiation so I can call start() on services.

2016-10-22 Thread Stephan Classen
Are your services singletons? Because if they are not this is not possible because you do not have all instances at application startup. If yes the BindingListener is sufficient. Because if you have the class you can always get the singleton instance from the injector using the get() method of

Re: Making scope depending on lifetime of another object

2016-10-21 Thread Stephan Classen
Just I little question out of curiosity: Do multiple As exist at the same time or is the lifetime of an A strictly separated (time wise) from the other As. If multiple As exist at the same time. How do you decide to which A a B belongs while it is requesting injection of C... On 21.10.2016

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 tomEE

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 I'm trying to use the

Re: Guice Persist support for Neo4j

2016-09-15 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: 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: 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 16:43:32

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() https://google.github.io/guice/api-docs/latest/javadoc/com/google/inject/util/Modules.html#override-com.google.inject.Modul

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 as >follows: > >1. Without

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 testin

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 2016

Re: TypeListener does not detect Map instance

2016-04-23 Thread Stephan Classen
Yes. Guice can only provide the filter if guice created the instance. It does not work for instances created by your own code or for instances created by providers you have written. Am 24. April 2016 00:30:47 MESZ, schrieb Pablo perez : >So, If I understand what you said, Guice can only provide

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 i

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 call

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: 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 impos

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. They're

Re: How to implement guice injections with mutliple Java Programs?

2016-02-10 Thread Stephan Classen
Have a look at child injectors. https://google.github.io/guice/api-docs/latest/javadoc/index.html?com/google/inject/Injector.html Am 11. Februar 2016 02:34:29 MEZ, schrieb Yeah Yeah : >Hi, > > >Been scratching my head about this, i am building a REST API using >Jetty, >Jersey and Guice. >I curren

Re: Spam in digest emails

2016-01-02 Thread Stephan Classen
I'm subscribed to the list and get a mail for every post made (no diegests). I've also seen more spam recently. I count 14 entries to the guice list in my spam folder for December. All seem to come from the same source as they all look very similar. I can poste one of the messages if this helps.

Re: Return Singleton Queue in guice

2015-12-25 Thread Stephan Classen
Can you also post a snippet where you inject the queue. Maybe the reason lies there. Am 25. Dezember 2015 19:51:33 MEZ, schrieb Sneh Tekriwal : > > > > >I am using Google Guice for dependency injection and I require

Re: @Transactional doesn't work for instance produced by @Provides method

2015-11-20 Thread Stephan Classen
You could also check at the time the injector is created and use a conditional to decide what bindings to use. Have a look at the method Modules.override() [1] it allows you to override bindings with other bindings. This way you don't have to use conditionals in the modules. Here some pseudo c

Re: how to Inject the module dynamically like if version == "1.1" then inject 1.1 module else inject 1.0 module

2015-09-29 Thread Stephan Classen
You could make a third module which checks the version and then delegates all method calls to the either 1.0 or 1.1 Am 28. September 2015 06:29:57 WESZ, schrieb Amit Sonkar : >I am working on a struts2 project in which guice is used for dependency > >injection. Now i have a java project in which

Re: Standalone beans with init and tasks

2015-09-16 Thread Stephan Classen
Guice is a dependency injection framework. Its nothing more. The scenario 1 can be summarized as: "Run some code once at application startup." Then do it. Run the code at application startup. Don't try to make Guice run the code for you. i.e. in the dropwizard application class there is a metho

Re: Multiple implementations

2015-09-02 Thread Stephan Classen
No, I this is not possible. The injector injects the same class independent of the target. This means if there are no additional annotations it will always inject either A1 or A2 (depends on the configuration in the module) for IA. The same holds for the Bs. Am 2. September 2015 14:33:57 MESZ,

Re: Wicket 6.20, problem with injection in onSubmit

2015-08-05 Thread Stephan Classen
Wicket may serialize Form and Page objects. When deserializing them dependencies which aren't serializable will end up null. Am 5. August 2015 14:27:31 MESZ, schrieb Stepan Samarin : >Hello, > >There's a problem with injection when onSubmit of the Form is invoked. >Scenario is the following: >W

Re: guice support on transaction, dirty read

2015-07-08 Thread Stephan Classen
This is not the responsibility of guice. You can configure this in the JPA layer or in the JDBC connection. Guice only uses the java interface provided by JPA. Am 8. Juli 2015 18:35:59 MESZ, schrieb klc : >Hi > >Do Guice has support on dirty read with transaction? >I don't see this supported i

Re: MultiBinder - injecting Collection

2015-06-11 Thread Stephan Classen
4.0 has been released about a month ago On 06/11/2015 05:07 PM, Suma Shivaprasad wrote: Am using guice 3.0 . Is there any other way of injecting a set of interface implementations as provider apart from upgrading since the one having it is still in beta ? On Thursday, June 11, 2015 at 5:40:

Re: MultiBinder - injecting Collection

2015-06-11 Thread Stephan Classen
I think you need to inject Provider> typeChangeListeners On 06/11/2015 02:10 PM, Suma Shivaprasad wrote: Trying to inject a collection of providers which implement an interface but consistently getting issues with injection as below No implementation for java.util.Collection> was bound.

Re: inject factory created object?

2015-05-19 Thread Stephan Classen
You can bind the object in request scope. On 05/19/2015 12:43 PM, klc wrote: Hi all I have a servlet app that read a configuration file on settings of different services (>1000), like auto commit. And when a request come in, it use this configuration to create a per request context object for

Re: Is there a way to close/destruct object in guice 4?

2015-05-14 Thread Stephan Classen
Yes, but you have to be more specific if you want some concrete help Am 14. Mai 2015 11:25:52 MESZ, schrieb klc : >Hi Is there a way to destruct object in guice 4? > >I see guice fruit but i think it support guice 2. The object i'm >closing >are db, queue and etc. > >-- >You received this messag

Re: How to use an ExecutorService with a JpaPersistModule ?

2015-05-13 Thread Stephan Classen
    } >  } > >  @Transactional >  public void doTimeConsumingStuff(EntityManager em) {/* ... */} >} > > >Le 13 mai 2015 à 14:51:35, Stephan Classen (st.clas...@gmx.ch) a écrit: > >The persist framework takes care that every thread has its own entity >manager.

Re: How to use an ExecutorService with a JpaPersistModule ?

2015-05-13 Thread Stephan Classen
The persist framework takes care that every thread has its own entity manager. So you don't need to do this. Calling unitOfWork.end() will close the entity manager for you. So also no need to do this manually. The unitOfWork is a singleton. So you can inject it directly and don't need to use the

Re: How to use an ExecutorService with a JpaPersistModule ?

2015-05-13 Thread Stephan Classen
First of all: guice-persist has some known bugs and they haven't been fixed for a long time. It looks like the extension is no longer maintained. Have a look into http://onami.apache.org/persist/ It is concepionally build on guice persist and migrating existing code should be very easy. Regard

Re: How do I use static factory method instead of constructor?

2015-04-12 Thread Stephan Classen
I see two ways to achieve the same using no static factory methods. 1. As Ben already suggested, create a provider. You can even call a static factory method from the provider. Or you can inline the static factory method if it is only called from the provider. Bu

Re: Best way to implement factory with Guice

2015-03-16 Thread Stephan Classen
Don't inject the injector. Its almost always a code smell. Am 16. März 2015 14:57:13 MEZ, schrieb Laszlo Ferenczi : >Hi, > >There are many ways to solve this problem, one easy enough to >understand: > >@Inject >Provider crawlerOneProvider; > >@Inject >Provider crawlerTwo; > > >public Crawler getCr

Re: The never-ending beta of Guice 4

2015-03-13 Thread Stephan Classen
+1 I also wouldn't mind to have a version 4.15 or similar if you keep adding new features to guice. Am 14. März 2015 06:52:27 MEZ, schrieb Vyacheslav Rusakov : >+1 >I also feel uncomfortable that my libs use beta version. Besides its >almost >a year now since planned release date. > >пятница, 1

Re: Overriding a module and reference a parent implementation

2015-02-07 Thread Stephan Classen
Maybe filter was not the best choice of a name. So don't let yourself be tricket by this. At the end the interface method is: List getUsers(List users); And the concrete implementation is absolutely free to add, remove or replace users from the list. Am 7. Februar 2015 18:10:14 MEZ, schrieb "A

Re: Overriding a module and reference a parent implementation

2015-02-05 Thread Stephan Classen
So what you want is a chain like behavior where the order of the modules in the createInjector method determines the order in the chain. I don't think this is easily possible with the current guice extensions. Multibinder offers a Set and a Map binder. Neither of them preserves the ordering. Y

Re: Overriding a module and reference a parent implementation

2015-02-04 Thread Stephan Classen
One thing that will not work is injecting A into either ASub or AOtherSub. Because this will create an endless loop sinc A is bound to ASub resp. AOtherSub. You need to be more specific and either request ACore or introduce a name for the parent so you could inject (@Parent A) Am 4. Februar 201

Re: [3.0] Having the Provider provide a class with an Inject

2015-02-01 Thread Stephan Classen
There are several ways to do it. You can simply introduce logic in you modules which allows to configure the bindings at startup time. This is the simplest way but if the logic gets complexer it will also be hard to understand. You can group bindings which belong together into modules and then

Re: [3.0] Having the Provider provide a class with an Inject

2015-01-29 Thread Stephan Classen
Even tough you have a working solution now. It is not pretty and from my perspective hard to understand what is actually happening. So I am still wondering if you need to change the returned type during runtime or if the returned type gets fixed during startup of the application. Because if it i

Re: [3.0] Having the Provider provide a class with an Inject

2015-01-29 Thread Stephan Classen
Hi Will this configurable provider return the same concrete type of object during the whole live time of a running program? Or will the returned type change during runtime? Because if all you want to achieve is to be able to have mocks during unit test and real implementations during runtime

Re: Potential exception thrown by txn.begin() in JpaLocalTxnInterceptor is not caught

2015-01-21 Thread Stephan Classen
Regarding persist-extension see: https://groups.google.com/d/topic/google-guice/Dp9nWdmDbUs/discussion There are several know bugs. An alternative implementation exists (currently maintained by me): http://onami.apache.org/persist/ Cheers On 01/21/2015 04:49 AM, edouard.kai...@gmail.com wrote

  1   2   >