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 Provider<EntityManager> before a call to
PersistService.start()
I do think, that a custom filter is the way to go.
- Either use a second filter (after PersistFilter) to do the work.
- Or write you own PersistFilter.
I usually have several filters in a chain where each filter has a
specific purpose and will initialize a part of the software.
On 07/02/2013 09:50 AM, Xavier Dury wrote:
Hi,
I'm using guice-persist, guice-servlet and hibernate-search in my
application.
For testing purposes, I am using an in-memory database (which gets
automatically populated with hibernate) and would like to index this
database for hibernate-search.
My problem is the following: PersistService is not started until
GuiceFilter is initialized (init() method called), so I can't get a
(FullText)EntityManager until that moment. That means I cannot trigger
the database indexing just by requiring injection of EntityManager in
ony of my guice modules because that will occur before the
PersistService has been started. And If I try to start the
PersistService myself, I get an error later saying it has already been
started.
As workaround, I've added a guice-managed filter (after PersistFilter)
that will perform the index processing in its init(FilterConfig)
method but I don't like to do that very much.
I can see 2 possible solutions to that problem:
* allow PersistService.start() to be called multiple times (as
stated by the javadoc), this is a recurring problem
* have a way to call custom code after GuiceFilter initialization.
Does anybody know another/better way?
Thanks,
Xavier
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.