[jboss-cvs] jboss-seam/src/main/org/jboss/seam/persistence ...

Emmanuel Bernard emmanuel.bernard at jboss.com
Fri Sep 28 11:34:42 EDT 2007


  User: ebernard
  Date: 07/09/28 11:34:42

  Modified:    src/main/org/jboss/seam/persistence   
                        HibernatePersistenceProvider.java
                        HibernateSessionProxy.java
                        HibernateSessionProxyInterceptor.java
  Log:
  JBSEAM-1950 CCE when @In Session and HSearch is not present
  
  Revision  Changes    Path
  1.22      +32 -13    jboss-seam/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HibernatePersistenceProvider.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- HibernatePersistenceProvider.java	6 Sep 2007 18:05:18 -0000	1.21
  +++ HibernatePersistenceProvider.java	28 Sep 2007 15:34:42 -0000	1.22
  @@ -2,6 +2,7 @@
   
   import java.lang.reflect.Constructor;
   import java.lang.reflect.Method;
  +import java.lang.reflect.Field;
   import java.util.Map;
   import javax.persistence.EntityManager;
   import javax.transaction.Synchronization;
  @@ -50,6 +51,17 @@
      {
         try
         {
  +         String version = null;
  +         try {
  +            Class searchVersionClass = Class.forName("org.hibernate.search.Version");
  +            Field versionField = searchVersionClass.getDeclaredField("VERSION");
  +            version = (String) versionField.get(null);
  +         }
  +         catch (Exception e)
  +         {
  +            log.debug("no Hibernate Search, sorry :-(", e);
  +         }
  +         if (version != null) {
            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");
  @@ -62,6 +74,7 @@
            FULL_TEXT_ENTITYMANAGER_PROXY_CONSTRUCTOR = fullTextEntityManagerProxyClass.getDeclaredConstructor(fullTextEntityManagerClass);
            log.debug("Hibernate Search is available :-)");
         }
  +      }
         catch (Exception e)
         {
            log.debug("no Hibernate Search, sorry :-(", e);
  @@ -73,7 +86,7 @@
       * EL interpolation and implements FullTextSession if Hibernate
       * Search is available in the classpath.
       */
  -   static Session proxySession(Session session) throws Exception
  +   static Session proxySession(Session session)
      {
         if (FULL_TEXT_SESSION_PROXY_CONSTRUCTOR==null)
         {
  @@ -81,8 +94,14 @@
         }
         else
         {
  +         try {
            return (Session) FULL_TEXT_SESSION_PROXY_CONSTRUCTOR.newInstance( FULL_TEXT_SESSION_CONSTRUCTOR.invoke(null, session) );
         }
  +         catch(Exception e) {
  +            log.warn("Unable to wrap into a FullTextSessionProxy, regular SessionProxy returned", e);
  +            return new HibernateSessionProxy(session);
  +         }
  +      }
      }
      
      /**
  
  
  
  1.5       +3 -0      jboss-seam/src/main/org/jboss/seam/persistence/HibernateSessionProxy.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HibernateSessionProxy.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/HibernateSessionProxy.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- HibernateSessionProxy.java	8 Jul 2007 10:54:05 -0000	1.4
  +++ HibernateSessionProxy.java	28 Sep 2007 15:34:42 -0000	1.5
  @@ -50,6 +50,9 @@
   {
      private Session delegate;
   
  +   /**
  +    * Don't use that constructor directly, use HibernatePersistenceProvider.proxySession()
  +    */
      public HibernateSessionProxy(Session session)
      {
         delegate = session;
  
  
  
  1.2       +1 -1      jboss-seam/src/main/org/jboss/seam/persistence/HibernateSessionProxyInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HibernateSessionProxyInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/HibernateSessionProxyInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- HibernateSessionProxyInterceptor.java	13 Aug 2007 14:20:34 -0000	1.1
  +++ HibernateSessionProxyInterceptor.java	28 Sep 2007 15:34:42 -0000	1.2
  @@ -51,7 +51,7 @@
            Object object = ba.get(bean);
            if ( ! ( object instanceof HibernateSessionProxy) && object instanceof Session)
            {
  -            ba.set( bean, new HibernateSessionProxy( (Session) object ) );
  +            ba.set( bean, HibernatePersistenceProvider.proxySession( (Session) object ) );
            }
         }
      }
  
  
  



More information about the jboss-cvs-commits mailing list