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
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
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.
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
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:
-
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
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
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
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
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()
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.
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
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
>{
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
- 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:
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
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
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
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
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
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
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
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
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
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
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 --
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
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...
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
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 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
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
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
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
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
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:
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.
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() {
>
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,
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
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
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
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
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
101 - 159 of 159 matches
Mail list logo