[jboss-dev-forums] [Design of JBoss Portal] - ObjectContextualizer - Cast to Hibernate Implementation Clas

louth do-not-reply at jboss.com
Thu Aug 31 09:50:21 EDT 2006


Hi,

With the recent JBoss Portal releases have run into a issue with a Hibernate extension we created because of a the class within the Portal that explicitly references an Hibernate implementation class rather than the standard interface. Can the following not be done via the standard configuration file.

public class ObjectContextualizer
{

   public Object context;

   public ObjectContextualizer(Object context)
   {
      this.context = context;
   }

   public void attach(SessionFactory sessionFactory)
   {
      EventListeners listeners = ((SessionFactoryImpl)sessionFactory).getEventListeners();
      PostLoadEventListener[] lels1 = listeners.getPostLoadEventListeners();
      PostLoadEventListener[] lels2 = new PostLoadEventListener[lels1.length + 1];
      System.arraycopy(lels1,  0, lels2, 1, lels1.length);
      lels2[0] = new PostLoadEventListener()
      {
         public void onPostLoad(PostLoadEvent postLoadEvent)
         {
            Object entity = postLoadEvent.getEntity();
            if (entity instanceof ContextObject)
            {
               ContextObject object = (ContextObject)entity;
               object.setContext(context);
            }
         }
      };
      listeners.setPostLoadEventListeners(lels2);
   }
}

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968628#3968628

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3968628



More information about the jboss-dev-forums mailing list