lajos       2005/03/21 21:05:48

  Modified:    modules/core/src/java/org/openejb/alt/config
                        ConfigurationFactory.java
  Log:

  Added ability, in per-webapp scenario, to pick up beans from both
  OpenEJB install directory as well as WEB-INB/beans. Determined by
  whether openejb.load-local-beans is set to "true" or not.
  
  Revision  Changes    Path
  1.7       +53 -2     
openejb1/modules/core/src/java/org/openejb/alt/config/ConfigurationFactory.java
  
  Index: ConfigurationFactory.java
  ===================================================================
  RCS file: 
/scm/openejb/openejb1/modules/core/src/java/org/openejb/alt/config/ConfigurationFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ConfigurationFactory.java 25 Oct 2004 12:34:38 -0000      1.6
  +++ ConfigurationFactory.java 22 Mar 2005 02:05:48 -0000      1.7
  @@ -1120,6 +1120,18 @@
       private String[] getJarLocations(Deployments[] deploy) {
   
           Vector jarList = new Vector(deploy.length);
  +     // tmpJarList is used to store jar file names, without paths
  +     // this is used when loading from different bean directories
  +     Vector tmpJarList = new Vector(deploy.length);
  +
  +     boolean loadFromBoth = false;
  +        String loadLocalBeans = (String) 
this.props.get("openejb.load-local-beans");
  +     if (loadLocalBeans != null && 
loadLocalBeans.compareToIgnoreCase("true") == 0) {
  +         String homeDir = (String) this.props.get("openejb.home");
  +         String baseDir = (String) this.props.get("openejb.base");
  +         if (homeDir != null && baseDir != null && !homeDir.equals(baseDir))
  +             loadFromBoth = true;
  +     }
   
           try {
   
  @@ -1140,6 +1152,7 @@
                       }
                       if (!jarList.contains(jar.getAbsolutePath())) {
                           jarList.add(jar.getAbsolutePath());
  +                     tmpJarList.add(jar.getName());
                       }
   
                       continue;
  @@ -1180,9 +1193,47 @@
   
                       if ( jarList.contains( jar.getAbsolutePath() ) ) 
continue;
                       jarList.add(jar.getAbsolutePath());
  +                 tmpJarList.add(jar.getName());
   
                   }
   
  +             if (loadFromBoth) {
  +                 // If openejb.base and openejb.home are both specified
  +                 // but are different, we would have already loaded from
  +                 // openejb.base. Now load from openejb.home to pick up
  +                 // any global beans.
  +
  +                 dir = null;
  +                    try {
  +                        dir = 
FileUtils.getHome(this.props).getFile(d.getDir(), false);
  +                    } catch (Exception ignoredAgain) {
  +                    }
  +
  +                 // Opps! Not a directory
  +                 if ( dir == null || !dir.isDirectory() ) continue;
  +
  +                 files = dir.list();
  +
  +                 if ( files == null ) {
  +                     continue;
  +                 }
  +
  +                 for (int x = 0; x < files.length; x++) {
  +
  +                     String f = files[x];
  +
  +                     if ( !f.endsWith(".jar") ) continue;
  +
  +                     //// Found a jar in the dir ////
  +
  +                     File jar = new File(dir, f);
  +
  +                     // Use our tmpJarList to make sure we don't load a
  +                     // jar deployed twice
  +                     if ( tmpJarList.contains( jar.getName() ) ) continue;
  +                     jarList.add(jar.getAbsolutePath());
  +                 }
  +                }
               }
           } catch (SecurityException se) {
               //Worthless security exception
  @@ -1496,4 +1547,4 @@
           this.openejbJar = openejbJar;
           this.jarURI = jar;
       }
  -}
  \ No newline at end of file
  +}
  
  
  

Reply via email to