Re: Guice persitence - EntityManager used by multiple Threads

2012-08-27 Thread Stephan Classen
You should not inject the EntityManager directly. Instead you should inject a ProvoderEntityManager and then use get() to obtain the EntityManager just when you need it. The implementation of ProviderEntityManager uses a ThreadLocal to ensure that every thread has its own instance of

Re: JSE architecture to inject DAO's members

2012-08-29 Thread Stephan Classen
I think you are on a wrong track. You only create one Injector instance for an application and you only start the persistence service once. What you have to do is: - Don't inject EntityManager into your DAO but inject ProviderEntiyManager. The EntityManager is

Re: JSE architecture to inject DAO's members

2012-08-30 Thread Stephan Classen
is a desktop application...I think not giving in to use PersistFilter with JSE application Arthur P. Gregrio +55 45 9958-0302 @gregorioarthur www.arthurgregorio.eti.br 2012/8/29 Stephan

Re: JSE architecture to inject DAO's members

2012-08-30 Thread Stephan Classen
Sorry I was unconcentrated. The correct annotation is @Transactional not @Transaction -- You received this message because you are subscribed to the Google Groups google-guice group. To post to this group, send email to google-guice@googlegroups.com. To unsubscribe from this group, send email

Re: transaction-per-request using guice persist

2012-09-19 Thread Stephan Classen
For me the code looks good. What do you need the ProviderEntityManger for? To test if the @Transactional has an effect or not you can place a breakpoint in JpaLocalTxnInterceptor in the method invoke(). If your code hits this method a transaction will be started (if

Re: guice-persist and JPA: working with multiple EntityManagerFactory instances based on same persistence-unit

2012-09-26 Thread Stephan Classen
Ok I'm not sure I understand completely what you need. But here is my first proposal: Write your own PersistFilter (see below) and use EntityManager.setProperty to set the request specific properties. @Singleton public final class MyPersistFilter implements Filter { private final

Re: guice-persist and JPA: working with multiple EntityManagerFactory instances based on same persistence-unit

2012-09-28 Thread Stephan Classen
Its possible but its way more complicated. In Fact the ProviderEntityManager, UnitOfWork and PersistService are all implemented in the single class JpaPersistService. And the JpaPersistService has a static inner class which is the ProviderEntityManagerFactory which

Re: Problem with Guice Persistence

2012-09-30 Thread Stephan Classen
Hi Nicolas Your probelm is not related to guice. guice-persist calls EntityManager.createEntityManager() During the execution of this method you get an AccessControlException have a look at:

Re: injecting contextual parameters - newbie alert

2012-10-11 Thread Stephan Classen
By default guice binds everything into a global "scope" (note this is not a scope in the sence guice uses this word). If you want to have a module scope you should extend PrivateModule and use the expose() method to expose bindings to the global scope. If you do

Re: Aspect logging in Guice?

2012-10-11 Thread Stephan Classen
You can write your own matche and use it instead of passing Matchers.any(). Or if it is ok for you to annotate the methods which you want to intercept you can use the existing Matchers.annotatedWith(...) On 10/10/2012 05:37 AM, Rob Withers wrote:

Re: Aspect logging in Guice?

2012-10-15 Thread Stephan Classen
From: google-guice@googlegroups.com [mailto:google-guice@googlegroups.com] On Behalf Of Stephan Classen Sent: Thursday, October 11, 2012 2:46 AM To: google-guice@googlegroups.com

Re: methodInterceptor not resolving it dependencies

2012-11-15 Thread Stephan Classen
how about posting your interceptor code so we can have a look at it? On 11/16/2012 03:13 AM, transmeta01 wrote: I have a method interceptor that has a number of dependencies (all guice managed objects), as explained in http://code.google.com/p/google-guice/wiki/AOP the use of requestInjection

Re: ANN: guice-jpa - Support of multiple datasources and JTA

2013-01-13 Thread Stephan Classen
Cool if you give it a try. Can you tell me what version of tomcat and what databases (H2, Oracle, MySQL, ...) you are using? I haven't used plain tomcat before but this sounds like a good time to get some hands on experience. On 01/12/2013 07:45 PM,

Re: New guice svn/git repository?

2013-02-07 Thread Stephan Classen
I agree. The community is very active in the google group, but on the issue tracker nothing happens. I would be great if issues would be treated as important as an entry in the google group. What also would help to understand the state of guice development for

Re: Problems implementing Guice / DI the proper way - I end up with allot of factories

2013-02-22 Thread Stephan Classen
You could move the call to the ConnectionFactory to the HttpClientImpl: class WebCrawler { private final HttpClientFactory httpClientFactory; @Inject public WebCrawler(HttpClientFactory httpFactory) {...} public

Re: Guice with JavaFX

2013-02-25 Thread Stephan Classen
I just started using JavaFX last week and have not yet combined it with guice. But as far as I can tell most of the JavaFX classes have a default constructor and should therefore be easely injectable. What exactly are you trying to inject and do you plan on using a mocking framework to inject

Re: Help with the basics - Injecting field in a new class

2013-04-11 Thread Stephan Classen
If your factory method has no arguments it is easier to remove the factory and have guice inject a ProviderMyClass instead of the factory see: http://code.google.com/p/google-guice/wiki/InjectingProviders On 04/11/2013 04:33 AM, Newbie McBozo wrote: Thanks for your help guys, I figured it

Re: Unexpected multiple instantiation of Singleton

2013-05-23 Thread Stephan Classen
My first guess is that there are more than one injector around: - you create a second injector in your servlet config? - you have somewhere a static reference to the injector which is not reset when a second test is run hope this helps On

Re: FactoryModuleBuilder and chained assisted injects

2013-06-20 Thread Stephan Classen
Guice does just in time binding if it encounters an injection point which requests a type not bound. Guice will look for an Constructor with @Inject annotation or a default constructor in that type. When it encounters a matching constructor it will add just in time a binding to the injector.

Re: FactoryModuleBuilder and chained assisted injects

2013-06-21 Thread Stephan Classen
an instance of A. A does not have a default constructor and I havent specified a provider or a binding for ISOCountry. On Thu, Jun 20, 2013 at 2:26 AM, Stephan Classen st.clas...@gmx.ch mailto:st.clas...@gmx.ch wrote: Guice does just in time binding if it encounters an injection point

Re: FactoryModuleBuilder and chained assisted injects

2013-06-22 Thread Stephan Classen
onstructor. On Fri, Jun 21, 2013 at 4:36 AM, Stephan Classen st.clas

Re: A basic concept I still don't understand well with Guice

2013-06-24 Thread Stephan Classen
There is a method requireBinding(Class) which lets causes the creation of the Injector to fail if the binding is missing. On 06/24/2013 07:45 AM, Dirk Olmes wrote: On 06/23/2013 11:56 PM, electrot...@gmail.com wrote: I feel this is probably a newbie question.. But I have to admit I'm not

Re: Make use of PersistService after deployment

2013-07-02 Thread Stephan Classen
First of all, just to make this clear: - You cannot inject an EntityManager before PersistService.start() has been called. If you do so you will get an exception. - You can inject a ProviderEntityManager before a call to PersistService.start() I do think, that a custom filter is the way to

Re: Injection by condition

2013-09-19 Thread Stephan Classen
If I understood your question correctly, the answer is no. There is no way to do this. But to make sure I didn't miss read your question: - AbstractRepo requires MTUnitOfWork - MTUnitOfWork requires MTPersistServiceImpl - MTPersistServiceImpl requires @Named(PersistConsts.JPA_UNIT_NAME) What

Re: creating instance using injector without passing module info again.

2013-10-08 Thread Stephan Classen
When you are using Guice in unit test I recommend you look at a testing framework which uses Guice. https://github.com/ArcBees/Jukito http://onami.apache.org/test/ On 10/08/2013 10:56 AM, kumar santosh wrote: 1. I have class AModule where we are binding are the dependencies. 2. In class

Re: @Transactional does not commit...

2013-10-18 Thread Stephan Classen
could you place a break point inside the persistUser() method and check the callstack to see if there is a JpaLocalTxnInterceptor. This class is responsible for handling the @Transactional annotation. On 10/18/2013 11:06 AM, Dirk Vranckaert wrote: I'm building a backend application for one of

Re: @Transactional does not commit...

2013-10-18 Thread Stephan Classen
I think the problem is that the instance is not created by guice. as Thomas mentioned the @Transactional only works on instances created by guice. From you callstack it looks like the instance could be created by jersey. To clarify this could you paste the code of TestEndpoint.class Thanks

Re: Guice + Mockito

2013-11-04 Thread Stephan Classen
see: https://groups.google.com/forum/#!topic/google-guice/NEkahqnpY4k On 11/04/2013 05:09 PM, Ari King wrote: How can I mock injected dependencies in JUnit tests? Thanks. -- You received this message because you are subscribed to the Google Groups google-guice group. To unsubscribe from this

Re: Module re-writing doesn't work well with module de-duplication

2013-11-04 Thread Stephan Classen
I experienced a similar issue where in some test case a module was installed twice. This worked fine until I added a AssistedInjection binding which caused a whole bunch of tests to fail with an binding already exists error. Fixing it in my code was simple since it only involved unit tests and

Re: Discussion: Some questions and concerns about Dependency Injection

2013-11-11 Thread Stephan Classen
As Sam mentioned. It is absolutely possible (and my prefered way) to inject all dependencies into the constructor. This way the class can easily be created without DI in a unit test. And take a look at assisted injection. On 11/11/2013 04:35 PM, Sam Berlin wrote: Hi Alan, some thoughts

Re: how to reuse a configuration all over the code when necessary

2013-11-16 Thread Stephan Classen
creating an injector is not the cheapest operation. guice is ment to create an injector at startup and then reuse this single injector during the entire lifetime of the application On 11/16/2013 01:08 PM, Maatary Okouya wrote: Yes indeed, whenever I need it and I am fine with that, the

Re: @Transactional commit issue

2013-11-20 Thread Stephan Classen
The @Transactional annotation uses aop method interception (see JpaLocalTxnInterceptor). This means the annotation works only when all of the following is true: - The concrete instance was created by Guice and not by anybody else (other framework or calling new) - the annotated method is

Re: Adding the same class multiple times into multibinder with different binding parameters.

2013-11-21 Thread Stephan Classen
you can achieve the same result with private modules. Then you don't have to create the dummy classes. see: https://groups.google.com/forum/#!topic/google-guice/h70a9pwD6_g On 11/21/2013 10:25 PM, Jia Pu wrote: I did try to achieve my goal using annotation. It works. But I wonder if there's

Re: @Transactional commit issue

2013-12-05 Thread Stephan Classen
So far I always bound the persistence in a ServletModule (don't knwo why, just never did it any other way). But having read the entire persistence code at least twice I cannot remember anything about request scope. The only piece of code related to the servlet extension

Re: Strange error message while binding.

2013-12-17 Thread Stephan Classen
could you post the configure method of your CoreModule On 12/17/2013 12:14 PM, Jochen Wiedmann wrote: Hi, in a module, I get the error message: com.google.inject.CreationException: Guice creation errors: 1) No implementation for com.foo.PropertyFactoryImpl was bound. at

Re: Binding to a provider instance

2014-01-10 Thread Stephan Classen
There is not bind(XXX).toProviderInstance(YYY) Instead you can directly use the following: Foo someInstance = new Foo(); binder.bind(IFoo.class).toInstance(someInstance); On 01/10/2014 10:50 AM, Jochen Wiedmann wrote: Hi, I am currently converting an existing application to Guice. To

Re: How much time does google have to fixe larger issues for 4.0?

2014-01-21 Thread Stephan Classen
Since the hollidays are over and everybody is back to work: any update on this? does somebody at google want to maintain the persist extension? On 12/19/2013 06:31 PM, Christian Gruber wrote: So that's not entirely true anymore. We have a few folks using it internally. I had originally been

Re: Bind an abstract class with its implementation using Guice.

2014-02-05 Thread Stephan Classen
According to the documentation: constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied

Re: How much time does google have to fixe larger issues for 4.0?

2014-02-09 Thread Stephan Classen
Still no news? anybody??? On 01/21/2014 10:29 PM, Stephan Classen wrote: Since the hollidays are over and everybody is back to work: any update on this? does somebody at google want to maintain the persist extension? On 12/19/2013 06:31 PM, Christian Gruber wrote: So that's not entirely

Re: How much time does google have to fixe larger issues for 4.0?

2014-02-09 Thread Stephan Classen
not clear at this point. I've been out most of the last week and a bit, so I'll try to get discussions restarted. c. On 9 Feb 2014, at 12:09, Stephan Classen wrote: Still no news? anybody??? On 01/21/2014 10:29 PM, Stephan Classen wrote: Since the hollidays are over and everybody is back

Re: Coding for Multiple Implementaions for a service without named annotaions in GUICE

2014-02-24 Thread Stephan Classen
If you feel uncomfortable injecting the concrete instances you can delegate the responsibility to choose the correct instance to a provider/helper. The provider gets all concrete instances injected and has a method getServiceFor(...) which returns the correct instance. You have to pass to the

Re: Coding for Multiple Implementaions for a service without named annotaions in GUICE

2014-02-25 Thread Stephan Classen
public class OrganizationServiceProvider { private final OrganizationServiceImpl orgService; private final OrgDeatilsServiceImpl orgDetailService; @Inject OrganizationServiceProvider(final OrganizationServiceImpl orgService, final OrgDeatilsServiceImpl orgDetailService) {

Re: Coding for Multiple Implementaions for a service without named annotaions in GUICE

2014-02-26 Thread Stephan Classen
Question1 - 10+ implementations: If you have lots of implementation or you have a plugin like architecture where new implementations may be added after your main component has already been released then my proposed solution would not scale. If you are in such a situation

Order of interceptors of a method

2014-03-24 Thread Stephan Classen
Hi In a project we need the interceptors of a method to be in a specific order. Does Guice make any statement about the order in which the interceptors are executed? -- You received this message because you are subscribed to the Google Groups google-guice group. To unsubscribe from this group

Re: Order of interceptors of a method

2014-03-24 Thread Stephan Classen
to load (and consequently contribute to the injector) and which not. On 03/24/2014 02:15 PM, Robert Voliva wrote: https://google-guice.googlecode.com/git/javadoc/com/google/inject/Binder.html Checkout the Javadoc for the bindInterceptor method. On Mon, Mar 24, 2014 at 3:13 AM, Stephan Classen

Re: Order of interceptors of a method

2014-03-24 Thread Stephan Classen
: https://code.google.com/p/google-guice/wiki/AOP#Injecting_Interceptors On Mon, Mar 24, 2014 at 8:59 AM, Stephan Classen st.clas...@gmx.ch mailto:st.clas...@gmx.ch wrote: Ok, I have to be more specific :) The application is modular. So the different interceptors are located

Re: Order of interceptors of a method

2014-03-24 Thread Stephan Classen
? On Mon, Mar 24, 2014 at 10:09 AM, Stephan Classen st.clas...@gmx.ch wrote: For me set and map do not have a guaranteed order. so i don't think the outcome of this approach is what i hope

Re: Order of interceptors of a method

2014-03-24 Thread Stephan Classen
, 2014 at 11:32 AM, Stephan Classen st.clas...@gmx.ch wrote: So you say guice does not make any statement about the order of interceptors if they are not bound within the same call to bindInterceptor

Re: Intercept bean creation

2014-04-01 Thread Stephan Classen
You could use setter injection and have the properties injected into the bean. On 04/01/2014 10:03 AM, Jochen Wiedmann wrote: Hi, I'd like to be able to set certain properties when (or immediately after) a bean is created by Guice. Is that possible? How? Thanks, Jochen -- You received

Re: Providing Injection in Classes built by Java Validation (JSR 303)

2014-04-02 Thread Stephan Classen
We do it like this, but i don't understand fully why it is working :) class SomeGuiceModule { protected void configure() { bind(Valdiator.class).to(ValidatorProvider.class); } } /** * This provider returns a

Reevaluation of Issue 88 for Guice 4.0

2014-04-03 Thread Stephan Classen
If you are still open for feature requests for the 4.0 release: I d like to have issue 88 [1] to be reevaluated. Specifically I would like to have the following methods in the AbstractModule: void bindInterceptor( Matcher? super Class? classMatcher, Matcher? super Method

Re: How or where to do conditional injection

2014-04-04 Thread Stephan Classen
This is usually a thing you don't do with dependency injection. Creating a concrete instance depending on some input is what you usually do with a factory pattern [1]. What you could do in guice is: use multibinders to bind multiple implementations of the

Re: Binding a named class without interface

2014-04-09 Thread Stephan Classen
pBinder.bind(myPojoClass).annotatedWith(Names.named("blubb").in(Scopes.SINGLETON); On 04/09/2014 09:21 AM, Jochen Wiedmann wrote: Hi, I know that I can do something like    final ClassPojoClass myPojoClass;

Re: How can I inject a value known by dependent to the dependency

2014-04-10 Thread Stephan Classen
What you are looking for is assisted injection: http://code.google.com/p/google-guice/wiki/AssistedInject On 04/10/2014 11:27 AM, Tuan BUI ANH wrote: Dear all, Firstly, sorry for my bad English as it's not my native. I started to learnt to use Guice in my project recently. My question is:

Re: Injecting Singleton into Runnable Instances

2014-04-20 Thread Stephan Classen
Hi Vlad Ok not sure if I understood everything you asked. But we will get you there. I assume that your code looks something like this: public static void main(String[] args) {     // ...     pool = new ThreadPoolExecutor();     pool.run(new

Re: Injecting Singleton into Runnable Instances

2014-04-21 Thread Stephan Classen
Yes I left the factory out to keep my post a little shorter. Your example is just what I wanted to refere to. Am 21.04.2014 05:47 schrieb =?UTF-8?Q?C=C3=A9dric_Beust_=E2=99=94?= ced...@beust.com:On Sun, Apr 20, 2014 at 12:05 PM, Stephan Classen st.clas...@gmx.ch wrote: Here

Re: JPA entitymanager reused over multiple threads

2014-05-07 Thread Stephan Classen
Guice perstist has a feature which is rather unusual und causes some problems. I think you might just be hitting it. When you request an entity manager outside of a unit of work guice persist will implicitly start the unit of work for you. Unfortunately the isActive() on UnitOfWork is package

Re: What is the best way to manage security with guice?

2014-05-08 Thread Stephan Classen
None. Guice is a pure dependency injection library. Spring offers many features including dependency injection, security, and many more. If you decide to use Guice you are free to use any security library you want (including spring security). On

Re: Custom JIT injections

2014-05-12 Thread Stephan Classen
Hi I tried once to accomplish a similar thing for testing and did not find a solution. If your code base does not change during runtime (i.e: there are no plugins which can be dynamically loaded and unloaded) you could use inspection to analyze the code base and

Re: Guice Persist - Setting Transaction Isolation Level

2014-05-27 Thread Stephan Classen
There is currently no such feature in guice persist. I'm not even sure if you can do this on a per transaction basis. It may depend on you DB if this is supported or if it can only be set per connection. On 05/27/2014 02:35 PM, Robert Butera wrote: Hi, Am using Guice Persist and would like

Re: idle thought: host code on github instead?

2014-05-27 Thread Stephan Classen
+1 But how would you get changes from github back into the internal source control? Am 27.05.2014 22:31 schrieb Sam Berlin sber...@gmail.com:What do folks think of the idea?  Itd make accepting patches easier (with pull requests, etc), and Im sure theres other benefits for folks using the code

Re: Guice Persist - Setting Transaction Isolation Level

2014-05-28 Thread Stephan Classen
If you want you can have a look at http://onami.apache.org/persist/ The code is final and will be released in the next few weeks. It supports multiple persistence units and fixes some of the known issues of guice-persist. On 05/28/2014 01:34 PM,

Re: Guice Vaadin Request

2014-05-28 Thread Stephan Classen
Creating the injector can be rather expensive. You may consider either of the following: - Create child injectors instead of the main injector for every request. - Use RequestScope (see: https://code.google.com/p/google-guice/wiki/Scopes) to have an

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

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

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: How to get guice to provide a unique instance with a provider?

2014-08-24 Thread Stephan Classen
I never used provide methods, but you can add the @Singleton annotation to the provided class. Am 24.08.2014 16:57 schrieb Maatary Okouya maatarioko...@gmail.com:I have the following on the guice website with few explanation: @Provides @Singleton TransactionLog provideTransactionLog() { ... }Is

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

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

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

  1   2   >