[jboss-cvs] jboss-seam/src/main/org/jboss/seam/persistence ...
Gavin King
gavin.king at jboss.com
Fri Jun 22 00:10:07 EDT 2007
User: gavin
Date: 07/06/22 00:10:07
Modified: src/main/org/jboss/seam/persistence
ManagedHibernateSession.java
Log:
integrate Hibernate Search
Revision Changes Path
1.6 +34 -7 jboss-seam/src/main/org/jboss/seam/persistence/ManagedHibernateSession.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ManagedHibernateSession.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/ManagedHibernateSession.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ManagedHibernateSession.java 20 Jun 2007 21:44:41 -0000 1.5
+++ ManagedHibernateSession.java 22 Jun 2007 04:10:07 -0000 1.6
@@ -1,7 +1,9 @@
-//$Id: ManagedHibernateSession.java,v 1.5 2007/06/20 21:44:41 gavin Exp $
+//$Id: ManagedHibernateSession.java,v 1.6 2007/06/22 04:10:07 gavin Exp $
package org.jboss.seam.persistence;
import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -10,7 +12,6 @@
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
import org.hibernate.FlushMode;
import org.hibernate.Session;
@@ -25,9 +26,9 @@
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
-import org.jboss.seam.core.TransactionListener;
-import org.jboss.seam.core.Mutable;
import org.jboss.seam.core.AbstractTransactionListener;
+import org.jboss.seam.core.Mutable;
+import org.jboss.seam.core.TransactionListener;
import org.jboss.seam.core.Expressions.ValueExpression;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
@@ -60,6 +61,25 @@
private transient boolean synchronizationRegistered;
+ private static Constructor FULL_TEXT_SESSION_PROXY_CONSTRUCTOR;
+ private static Method FULL_TEXT_SESSION_CONSTRUCTOR;
+ static
+ {
+ try
+ {
+ Class searchClass = Class.forName("org.hibernate.search.Search");
+ FULL_TEXT_SESSION_CONSTRUCTOR = searchClass.getDeclaredMethod("createFullTextSession", Session.class);
+ Class fullTextSessionProxyClass = Class.forName("org.jboss.seam.persistence.FullTextHibernateSessionProxy");
+ Class fullTextSessionClass = Class.forName("org.hibernate.search.FullTextSession");
+ FULL_TEXT_SESSION_PROXY_CONSTRUCTOR = fullTextSessionProxyClass.getDeclaredConstructor(fullTextSessionClass);
+ log.info("Hibernate Search is available :-)");
+ }
+ catch (Exception e)
+ {
+ log.info("no Hibernate Search, sorry :-(", e);
+ }
+ }
+
public boolean clearDirty()
{
return true;
@@ -77,10 +97,17 @@
PersistenceContexts.instance().touch(componentName);
}
- private void initSession()
+ private void initSession() throws Exception
{
session = getSessionFactoryFromJndiOrValueBinding().openSession();
+ if (FULL_TEXT_SESSION_PROXY_CONSTRUCTOR==null)
+ {
session = new HibernateSessionProxy(session);
+ }
+ else
+ {
+ session = (Session) FULL_TEXT_SESSION_PROXY_CONSTRUCTOR.newInstance( FULL_TEXT_SESSION_CONSTRUCTOR.invoke(null, session) );
+ }
setSessionFlushMode( PersistenceContexts.instance().getFlushMode() );
for (Filter f: filters)
{
@@ -107,7 +134,7 @@
}
@Unwrap
- public Session getSession() throws SystemException
+ public Session getSession() throws Exception
{
if (session==null) initSession();
More information about the jboss-cvs-commits
mailing list