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

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

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

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

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

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

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

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

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 stepan.sama...@gmail.com: Hello, There's a problem with injection when onSubmit of the Form is invoked. Scenario

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 klchan.ka...@gmail.com: Hi Do Guice has support on dirty read with transaction? I don't

Re: MultiBinder - injecting CollectionProviderT

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

Re: MultiBinder - injecting CollectionProviderT

2015-06-11 Thread Stephan Classen
I think you need to inject ProviderSetTypesChangeListener 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

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 klchan.ka...@gmail.com: 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

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.

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

Re: How to use an ExecutorService with a JpaPersistModule ?

2015-05-13 Thread Stephan Classen
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. 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

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.

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 lferen...@gmail.com: Hi, There are many ways to solve this problem, one easy enough to understand: @Inject ProviderCrawlerOne crawlerOneProvider; @Inject ProviderCrawlerTwo

Re: The never-ending beta of Guice 4

2015-03-14 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 vya...@gmail.com: +1 I also feel uncomfortable that my libs use beta version. Besides its almost a year now since planned release date.

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: ListUser getUsers(ListUser 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,

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.

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

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

Re: Using Guice in a method that builds something using this

2014-12-22 Thread Stephan Classen
If I read the example correctly. B does not need A. It just provides a method to retrieve a new instance of A. So A and B should really be 2 separate classes. Am 23. Dezember 2014 03:10:12 MEZ, schrieb Tim Boudreau niftin...@gmail.com: What you have is a design problem. If A needs B to exist,

Re: Using Guice in a method that builds something using this

2014-12-19 Thread Stephan Classen
The thing you are looking for is called assisted injection. https://github.com/google/guice/wiki/AssistedInject But often when you need to pass runtime values to an object created with guice. The object is a mix between a data structure and a business object. Try to separate them and the

Re: Proper way and Scope to handle GUICE with Hibernate and @Transactional

2014-12-01 Thread Stephan Classen
Concerning the cost of singelton vs. default scopeI cannot give you an answer. Maybe you just go ahead and write some performance test for it and run 20 or so threads in a loop and inject the same class 100 times... But for the transaction: I always have them on the service layer. Now this is

Re: @ImplementedBy for tests?

2014-10-30 Thread Stephan Classen
Jukito has 5 main features - taking care of the boiler plate code to create the injector. - introducing a new scope TestSingleton which is similar to Singleton except that it is cleared after each test method. So you get a fresh instance for the every test method but within the test method the

Re: @ImplementedBy for tests?

2014-10-29 Thread Stephan Classen
Yes, you don't want to have dependencies on your test code. If all you need is injection of mocks then you may want to look at jukito as it can inject mocks for any dependency for which you havn't bound an implementation. Am 29.10.2014 02:52 schrieb Sam Berlin sber...@gmail.com:@ImplementedBy is

[ANNOUNCE] Apache Onami Persist 1.0.1

2014-10-24 Thread Stephan Classen
transactions. Release Notes: Bug [ONAMI-115] - PersistenceFilter should be bound in Singleton scope Improvement [ONAMI-116] - Prefer javax.inject.* over com.google.inject.* Have Fun, Stephan Classen, on behalf of the Apache Onami PMC -- You received this message because you are subscribed

Re: Creating a new injector, with new bindings, but keep all singletons?

2014-10-19 Thread Stephan Classen
You can also use custom scopes to change the returned instance depending on your logic. This may be a little cleaner than having too much logic in the providers. On 10/19/2014 06:55 PM, Nate Bauernfeind wrote: Do you ever run two tasks simultaneously? If not, perhaps you can create a special

Re: Is Guice 4 faster ?

2014-10-14 Thread Stephan Classen
We used Guice3.0 in an library which analyzes SQLs sent to the DB. The first version showed a heavy impact on execution time (queries were up to 4 times slower). We replaced almost all assisted inject with hand written factories and could remove about half of the

Re: How to inject an interface implementation based on annotations at runtime using Google Guice

2014-08-24 Thread Stephan Classen
Guice does not provide a way to bind conditionally. Any decission which is made at runtime must happen in your code. The only thing which I can think of that might help in this kind of situation are multibindings. Basically multibindings allow to bind many implementations of an interface. All

Re: bindConstant() and Private modules

2014-08-22 Thread Stephan Classen
expose().annotatedWith(key.getAnnotation()); Am 22.08.2014 07:39 schrieb kelv...@gmail.com:For some reason, this isn't working for me:public class MyModuleT extends PrivateModule { private final KeyT key; @Override protected void configure() {

Re: bindConstant() and Private modules

2014-08-22 Thread Stephan Classen
Sorry didn't read it properly the first time. requireBinding will only be evaluated when the injector was created successfuly. Since in your example with Integer the creation of the injector fails the requireBinding is never evaluated. In your example the generic type T must always be of the same

Re: Value Object: static factory or assisted injection ?

2014-08-22 Thread Stephan Classen
I personaly try to avoid DI for value objects. I might have factories if this is required but those will be hand written since they are usually non trivial. But most of the time I just instantiate them using new. Since they should not contain any business logic and expose their entire state by

Re: Module, Test and Mock

2014-08-21 Thread Stephan Classen
If you pass dependencies in you constructor which are not required for the test then your class has most likely too many responsibilities. If all your dependencies are required for the test you have to adapt the test any ways and should not worry about the compiler

Re: Module, Test and Mock

2014-08-21 Thread Stephan Classen
I dont think it is wrong to use it. But I don't see a need for it. If you are unit testing then you want only those bindings in your injector which are required for the test. Hence no need to override anything. If you are doing integration test then you want to have actual code executed and no

Re: Module, Test and Mock

2014-08-21 Thread Stephan Classen
, Stephan Classen st.clas...@gmx.ch wrote: I dont think it is wrong to use it. But I don't see a need for it. If you are unit testing then you want only those bindings in your injector which are required

[ANNOUNCE] Apache Onami Persist 1.0.0

2014-07-22 Thread Stephan Classen
transactions. http://onami.apache.org/persist/ Have Fun, Stephan Classen, on behalf of the Apache Onami PMC -- 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

Re: Using Spring and Guice together in a web application.

2014-05-29 Thread Stephan Classen
First of all. If you will still be using different spring libraries I would stick with spring DI. Whoever will be maintaining the application will need to read and understand the spring configuration anyway so there is not that much gain in migrating the DI framework to

  1   2   >