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

Gavin King gavin.king at jboss.com
Tue Mar 6 15:42:42 EST 2007


  User: gavin   
  Date: 07/03/06 15:42:42

  Modified:    src/main/org/jboss/seam/intercept 
                        SessionBeanInterceptor.java
  Log:
  just in case container does some funnny serialization of PCs
  
  Revision  Changes    Path
  1.15      +15 -4     jboss-seam/src/main/org/jboss/seam/intercept/SessionBeanInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SessionBeanInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/SessionBeanInterceptor.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- SessionBeanInterceptor.java	25 Feb 2007 23:15:06 -0000	1.14
  +++ SessionBeanInterceptor.java	6 Mar 2007 20:42:42 -0000	1.15
  @@ -62,6 +62,7 @@
      @PostActivate
      public void postActivate(InvocationContext invocation)
      {
  +      proxyPersistenceContexts( invocation.getTarget() ); //just in case the container does some special handling of PC serialization
         invokeAndHandle( new EJBInvocationContext(invocation), EventType.POST_ACTIVATE);
      }
      
  @@ -113,17 +114,27 @@
            initNonSeamComponent();
         }
         
  +      proxyPersistenceContexts(bean);
  +      
  +      postConstruct(bean);
  +      invokeAndHandle( new EJBInvocationContext(invocation), EventType.POST_CONSTRUCT );
  +   }
  +
  +   //TODO: really we should do this stuff in a Seam interceptor, I suppose
  +   private void proxyPersistenceContexts(Object bean)
  +   {
         if ( isSeamComponent() )
         {
            //wrap any @PersistenceContext attributes in our proxy
            for ( BijectedAttribute ba: getComponent().getPersistenceContextAttributes() )
            {
  -            ba.set( bean, new EntityManagerProxy( (EntityManager) ba.get(bean) ) );
  +            EntityManager entityManager = (EntityManager) ba.get(bean);
  +            if ( ! (entityManager instanceof EntityManagerProxy ) )
  +            {
  +               ba.set( bean, new EntityManagerProxy( entityManager ) );
  +            }
            }
         }
  -      
  -      postConstruct(bean);
  -      invokeAndHandle( new EJBInvocationContext(invocation), EventType.POST_CONSTRUCT );
      }
   
   }
  
  
  



More information about the jboss-cvs-commits mailing list