-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: A suggestion for hibernate jmx:auto scan hbm files
PostPosted: Sat Apr 01, 2006 6:52 am 
Newbie

Joined: Mon Feb 27, 2006 11:24 am
Posts: 8
In hibernate3.x ,hibernate provider a way to publish sessionFactory in jndi tree through jmx .
But it does not do best.
I think if it support auto san the hbm files in the jar or ear/war ,will be better and gracer.

Jboss hibernate jmx doest provider this feature.
why not learn from them?

the following code is how Jboss hibernate jmx service to scan hbm file:
Code:
  /**
    * Scan the current context's classloader to locate any potential sources of Hibernate mapping files.
    *
    * @throws DeploymentException
    */
   private void scanForMappings() throws DeploymentException
   {
      // Won't this cause problems if start() is called from say the console?
      // a way around is to locate our DeploymentInfo and grab its ucl attribute
      // for use here.
      URL[] urls = null;
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      if (cl instanceof RepositoryClassLoader)
      {
         urls = ((RepositoryClassLoader)cl).getClasspath();
      }
      else if (cl instanceof URLClassLoader)
      {
         urls = ((URLClassLoader)cl).getURLs();
      }
      else
      {
         throw new DeploymentException("Unable to determine urls from classloader [" + cl + "]");
      }

      // Search the urls for each of the classpath entries for any containing
      // hibernate mapping files or archives
      for (int i = 0; i < urls.length; i++)
      {
         final File entry = new File(urls[i].getFile());
         log.trace("checking classpath entry [" + entry + "]");
         if (!entry.exists())
         {
            continue;
         }

         if (!entry.isDirectory())
         {
            // This entry is not a directory, meaning it is a file of
            // some sort.  If it is an archive, we are interested in it...
            if (isArchive(entry))
            {
               log.trace("classpath entry was an archive file...");
               archiveClasspathUrls.add(entry);
            }
            else
            {
               log.trace("classpath entry was a non-archive file...");
            }
         }
         else
         {
            log.trace("classpath entry was a directory...");

            // we have a directory, add it to the list of directory classpath urls
            directoryClasspathUrls.add(entry);
         }
      }
   }





but hibernate can not do the same as jboss hibenate jmx do.
Because there are difference between the classloaders in different server platform.

Maybe reading jar file or directory and filter the hbm.xml is more feasible.

what about your opinion?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.