Author: dain
Date: Thu Oct 18 18:53:03 2007
New Revision: 586221

URL: http://svn.apache.org/viewvc?rev=586221&view=rev
Log:
Hooked Tomcat deployment to deploy other module types in webapps dir

Modified:
    openejb/trunk/openejb3/assembly/openejb-tomcat/maven.xml
    openejb/trunk/openejb3/assembly/openejb-tomcat/pom.xml
    
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ContextListener.java
    
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/GlobalListenerSupport.java
    
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatWebAppBuilder.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceUnitInfo.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/maven.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/maven.xml?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/maven.xml (original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/maven.xml Thu Oct 18 
18:53:03 2007
@@ -190,18 +190,19 @@
       <unjar src="${basedir}/target/openejb-tomcat-${openejb.version}.war" 
dest="${tomcat.webapps}/openejb"/>
     </goal>
 
-    <goal name="setup:itests">
+    <goal name="setup:itests:ejb-jar">
       <j:set var="targetDir" value="${basedir}/target/"/>
-      <j:set var="itests.jar" 
value="openejb-tomcat-${openejb.version}-test.jar"/>
-      <mkdir dir="${tomcat.home}/apps"/>
+      <j:set var="itests.jar" 
value="openejb-itests-beans-${openejb.version}.jar"/>
 
       <u:file var="fileAsFile" name="${tomcat.home}/apps/${itests.jar}"/>
       <j:if test="${!(fileAsFile.exists())}">
-        <copy file="${targetDir}/${itests.jar}" todir="${tomcat.home}/apps" />
+        <copy file="${targetDir}/${itests.jar}" todir="${tomcat.home}/webapps" 
/>
       </j:if>
+
+      <copy file="${targetDir}/junit-4.1.jar" todir="${tomcat.home}/lib"/>
     </goal>
 
-    <goal name="setup:itests-war">
+    <goal name="setup:itests:war">
       <j:set var="targetDir" value="${basedir}/target/"/>
       <j:set var="itests.war" 
value="openejb-itests-web-${openejb.version}.war"/>
 
@@ -211,6 +212,17 @@
       </j:if>
     </goal>
 
+    <goal name="setup:itests:ear">
+      <j:set var="targetDir" value="${basedir}/target/"/>
+      <j:set var="itests.jar" 
value="openejb-itests-beans-${openejb.version}.jar"/>
+
+      <mkdir dir="${tomcat.home}/webapps/itests.ear"/>
+      <copy file="${targetDir}/${itests.jar}" 
toFile="${tomcat.home}/webapps/itests.ear/itests.jar" />
+
+      <mkdir dir="${tomcat.home}/webapps/itests.ear/lib"/>
+      <copy file="${targetDir}/junit-4.1.jar" 
todir="${tomcat.home}/webapps/itests.ear/lib"/>
+    </goal>
+
     <goal name="setup:ejb-examples">
       <mkdir dir="${tomcat.home}/webapps/ejb-examples"/>
       <unjar 
src="${user.home}/.m2/repository/org/apache/openejb/ejb-examples/1.0-SNAPSHOT/ejb-examples-1.0-SNAPSHOT.war"
 dest="${tomcat.home}/webapps/ejb-examples"/>
@@ -224,7 +236,7 @@
       <attainGoal name="tomcat6"/>
       <attainGoal name="setup:tomcat"/>
       <attainGoal name="setup:loader-webapp"/>
-      <attainGoal name="setup:itests-war"/>
+      <attainGoal name="setup:itests:war"/>
       <attainGoal name="setup:ejb-examples"/>
       <attainGoal name="start:tomcat"/>
     </goal>
@@ -233,7 +245,7 @@
       <attainGoal name="tomcat6"/>
       <attainGoal name="setup:tomcat"/>
       <attainGoal name="setup:loader-webapp"/>
-      <attainGoal name="setup:itests-war"/>
+      <attainGoal name="setup:itests:war"/>
       <attainGoal name="setup:ejb-examples"/>
       <attainGoal name="start:tomcat-debug"/>
     </goal>
@@ -241,7 +253,7 @@
     <goal name="test:tomcat">
       <attainGoal name="setup:tomcat"/>
       <attainGoal name="setup:loader-webapp"/>
-      <attainGoal name="setup:itests-war"/>
+      <attainGoal name="setup:itests:war"/>
       <attainGoal name="start:tomcat"/>
       <java 
jar="target/openejb-itests-standalone-client-${openejb.version}.jar" fork="yes">
         <!--<sysproperty key="openejb.home" 
value="target/openejb-${openejb.version}"/>-->

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/pom.xml?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/pom.xml (original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/pom.xml Thu Oct 18 18:53:03 
2007
@@ -71,6 +71,18 @@
                   <type>war</type>
                   <outputDirectory>${project.build.directory}</outputDirectory>
                 </artifactItem>
+                <artifactItem>
+                  <groupId>org.apache.openejb</groupId>
+                  <artifactId>openejb-itests-beans</artifactId>
+                  <version>${version}</version>
+                  <outputDirectory>${project.build.directory}</outputDirectory>
+                </artifactItem>
+                <artifactItem>
+                  <groupId>junit</groupId>
+                  <artifactId>junit</artifactId>
+                  <version>4.1</version>
+                  <outputDirectory>${project.build.directory}</outputDirectory>
+                </artifactItem>
               </artifactItems>
             </configuration>
           </execution>

Modified: 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ContextListener.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ContextListener.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ContextListener.java
 (original)
+++ 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ContextListener.java
 Thu Oct 18 18:53:03 2007
@@ -19,6 +19,7 @@
 
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardServer;
+import org.apache.catalina.core.StandardHost;
 
 public interface ContextListener {
     void init(StandardContext context);
@@ -31,4 +32,6 @@
     void destroy(StandardContext context);
 
     void afterStop(StandardServer standardServer);
+
+    void checkHost(StandardHost standardHost);
 }

Modified: 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/GlobalListenerSupport.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/GlobalListenerSupport.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/GlobalListenerSupport.java
 (original)
+++ 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/GlobalListenerSupport.java
 Thu Oct 18 18:53:03 2007
@@ -67,6 +67,12 @@
             } else if (Lifecycle.DESTROY_EVENT.equals(type)) {
                 contextListener.destroy(standardContext);
             }
+        } else if (source instanceof StandardHost) {
+            StandardHost standardHost = (StandardHost) source;
+            String type = event.getType();
+            if (Lifecycle.PERIODIC_EVENT.equals(type)) {
+                contextListener.checkHost(standardHost);
+            }
         } else if (source instanceof StandardServer) {
             StandardServer standardServer = (StandardServer) source;
             String type = event.getType();
@@ -126,6 +132,7 @@
 
     private void hostAdded(StandardHost host) {
         addContextListener(host);
+        host.addLifecycleListener(this);
         for (Container child : host.findChildren()) {
             if (child instanceof StandardContext) {
                 StandardContext context = (StandardContext) child;

Modified: 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatWebAppBuilder.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatWebAppBuilder.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatWebAppBuilder.java
 (original)
+++ 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatWebAppBuilder.java
 Thu Oct 18 18:53:03 2007
@@ -25,6 +25,7 @@
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.core.StandardServer;
+import org.apache.catalina.core.ContainerBase;
 import org.apache.catalina.deploy.ContextEnvironment;
 import org.apache.catalina.deploy.ContextResource;
 import org.apache.catalina.deploy.ContextResourceLink;
@@ -40,6 +41,8 @@
 import org.apache.openejb.assembler.classic.UniqueDefaultLinkResolver;
 import org.apache.openejb.assembler.classic.WebAppBuilder;
 import org.apache.openejb.assembler.classic.WebAppInfo;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.ConnectorInfo;
 import org.apache.openejb.config.AnnotationDeployer;
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.ConfigurationFactory;
@@ -72,6 +75,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.HashMap;
+import java.util.Iterator;
 
 public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener {
     private static final Logger logger = 
Logger.getInstance(LogCategory.OPENEJB.createChild("tomcat"), 
"org.apache.openejb.util.resources");
@@ -80,6 +85,9 @@
     private final GlobalListenerSupport globalListenerSupport;
     private final ConfigurationFactory configurationFactory;
     private final Map<String,HostConfig> deployers = new 
TreeMap<String,HostConfig>();
+    // todo merge this map witth the infos map above
+    private final Map<String,DeployedApplication> deployedApps = new 
TreeMap<String,DeployedApplication>();
+    private final DeploymentLoader deploymentLoader;
     private Assembler assembler;
 
     public TomcatWebAppBuilder() {
@@ -112,6 +120,7 @@
         // }
 
         configurationFactory = new ConfigurationFactory();
+        deploymentLoader = new DeploymentLoader();
         assembler = (Assembler) 
SystemInstance.get().getComponent(org.apache.openejb.spi.Assembler.class);
     }
 
@@ -210,6 +219,7 @@
 
                     LinkResolver<EntityManagerFactory> emfLinkResolver = new 
UniqueDefaultLinkResolver<EntityManagerFactory>();
                     assembler.createApplication(contextInfo.appInfo, 
emfLinkResolver, standardContext.getLoader().getClassLoader());
+                    // todo add watched resources to context
                     contextInfo.emfLinkResolver = emfLinkResolver;
                 } catch (Exception e) {
                     logger.error("Unable to deploy collapsed ear in war " + 
standardContext.getPath() + ": Exception: " + e.getMessage(), e);
@@ -299,6 +309,103 @@
         }
     }
 
+    public void checkHost(StandardHost standardHost) {
+        if (standardHost.getAutoDeploy()) {
+            // Undeploy any modified application
+            for (Iterator<Map.Entry<String, DeployedApplication>> iterator = 
deployedApps.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry<String, DeployedApplication> entry = iterator.next();
+                DeployedApplication deployedApplication = entry.getValue();
+                if (deployedApplication.isModified()) {
+                    try {
+                        
assembler.destroyApplication(deployedApplication.appInfo.jarPath);
+                    } catch (Exception e) {
+                        logger.error("Unable to application " + 
deployedApplication.appInfo.jarPath + ": Exception: " + e.getMessage(), e);
+                    }
+                    iterator.remove();
+                }
+            }
+
+            // Deploy new applications
+            File appBase = appBase(standardHost);
+            File[] files = appBase.listFiles();
+            for (File file : files) {
+                String name = file.getName();
+                if (name.toLowerCase().endsWith(".war") || name.equals("ROOT") 
|| name.equalsIgnoreCase("META-INF") || name.equalsIgnoreCase("WEB-INF")) 
continue;
+                if (file.isDirectory() && new File(file, "WEB-INF").exists()) 
continue;
+                if (isDeployed(file, standardHost)) continue;
+
+                AppInfo appInfo = null;
+                try {
+                    file = file.getCanonicalFile().getAbsoluteFile();
+
+                    AppModule appModule = deploymentLoader.load(file);
+
+                    // Ignore any standalone web modules - this happens when 
the app is unpaked and doesn't have a WEB-INF dir
+                    if (appModule.getDeploymentModule().size() == 1 && 
appModule.getWebModules().size() == 1) {
+                        WebModule webModule = 
appModule.getWebModules().iterator().next();
+                        if 
(file.getAbsolutePath().equals(webModule.getJarLocation())) {
+                            continue;
+                        }
+                    }
+
+                    // if this is an unpacked dir, tomcat will pick it up as a 
webapp so undeploy it first
+                    if (file.isDirectory()) {
+                        ContainerBase context = (ContainerBase) 
standardHost.findChild("/" + name);
+                        if (context != null) {
+                            try {
+                                standardHost.removeChild(context);
+                            } catch (Throwable t) {
+                                logger.warning("Error undeploying wep 
application from Tomcat  " + name, t);
+                            }
+                            try {
+                                context.destroy();
+                            } catch (Throwable t) {
+                                logger.warning("Error destroying Tomcat web 
context " + name, t);
+                            }
+                        }
+                    }
+
+                    // tell web modules to deploy using this host
+                    for (WebModule webModule : appModule.getWebModules()) {
+                        webModule.setHost(standardHost.getName());
+                    }
+
+                    appInfo = 
configurationFactory.configureApplication(appModule);
+                    assembler.createApplication(appInfo);
+                } catch (Throwable e) {
+                    logger.warning("Error deploying application " + 
file.getAbsolutePath(), e);
+                }
+                deployedApps.put(file.getAbsolutePath(), new 
DeployedApplication(file, appInfo));
+            }
+        }
+    }
+
+    private boolean isDeployed(File file, StandardHost standardHost) {
+        if (deployedApps.containsKey(file.getAbsolutePath())) {
+            return true;
+        }
+
+        // check if this is a deployed web application
+        String name = "/" + file.getName();
+
+        // ROOT context is a special case
+        if (name.equals("/ROOT")) name = "";
+
+        return file.isFile() && standardHost.findChild(name) != null;
+    }
+
+    protected File appBase(StandardHost standardHost) {
+        File file = new File(standardHost.getAppBase());
+        if (!file.isAbsolute()) {
+            file = new File(System.getProperty("catalina.base"), 
standardHost.getAppBase());
+        }
+        try {
+            file= file.getCanonicalFile();
+        } catch (IOException e) {
+        }
+        return file;
+    }
+
     private AppModule loadApplication(StandardContext standardContext) {
         // create the web module
         WebModule webModule = createWebModule(standardContext);
@@ -510,5 +617,51 @@
         public StandardContext standardContext;
         public HostConfig deployer;
         public LinkResolver<EntityManagerFactory> emfLinkResolver;
+    }
+
+    private static class DeployedApplication {
+        private AppInfo appInfo;
+        private final Map<File,Long> watchedResource = new 
HashMap<File,Long>();
+
+        public DeployedApplication(File base, AppInfo appInfo) {
+            this.appInfo = appInfo;
+            watchedResource.put(base, base.lastModified());
+            if (appInfo != null) {
+                for (String resource : appInfo.watchedResources) {
+                    File file = new File(resource);
+                    watchedResource.put(file, file.lastModified());
+                }
+                for (EjbJarInfo info : appInfo.ejbJars) {
+                    for (String resource : info.watchedResources) {
+                        File file = new File(resource);
+                        watchedResource.put(file, file.lastModified());
+                    }
+                }
+                for (WebAppInfo info : appInfo.webApps) {
+                    for (String resource : info.watchedResources) {
+                        File file = new File(resource);
+                        watchedResource.put(file, file.lastModified());
+                    }
+                }
+                for (ConnectorInfo info : appInfo.connectors) {
+                    for (String resource : info.watchedResources) {
+                        File file = new File(resource);
+                        watchedResource.put(file, file.lastModified());
+                    }
+                }
+            }
+        }
+
+        public boolean isModified() {
+            for (Map.Entry<File, Long> entry : watchedResource.entrySet()) {
+                File file = entry.getKey();
+                long lastModified = entry.getValue();
+                if ((!file.exists() && lastModified != 0L) ||
+                        (file.lastModified() != lastModified)) {
+                    return true;
+                }
+            }
+            return false;
+        }
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
 Thu Oct 18 18:53:03 2007
@@ -18,6 +18,8 @@
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Set;
+import java.util.TreeSet;
 
 /**
  * @version $Rev$ $Date$
@@ -30,5 +32,6 @@
     public final List<WebAppInfo> webApps = new ArrayList<WebAppInfo>();
     public final List<PersistenceUnitInfo> persistenceUnits = new 
ArrayList<PersistenceUnitInfo>();
     public final List<String> libs = new ArrayList<String>();
+    public final Set<String> watchedResources = new TreeSet<String>();
     public String cmpMappingsXml;
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java
 Thu Oct 18 18:53:03 2007
@@ -18,6 +18,8 @@
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Set;
+import java.util.TreeSet;
 
 public class ClientInfo extends InfoObject {
 
@@ -29,6 +31,7 @@
     public String moduleId;
     public String mainClass;
     public String callbackHandler;
+    public final Set<String> watchedResources = new TreeSet<String>();
 
     public JndiEncInfo jndiEnc;
 

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java
 Thu Oct 18 18:53:03 2007
@@ -19,6 +19,8 @@
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Set;
+import java.util.TreeSet;
 
 public class ConnectorInfo extends InfoObject {
 
@@ -29,6 +31,7 @@
     public String largeIcon;
     public String moduleId;
     public final List<String> libs = new ArrayList<String>();
+    public final Set<String> watchedResources = new TreeSet<String>();
 
     public ResourceInfo resourceAdapter;
     public List<ResourceInfo> outbound = new ArrayList<ResourceInfo>();

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
 Thu Oct 18 18:53:03 2007
@@ -19,6 +19,8 @@
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
 public class EjbJarInfo extends InfoObject {
     public final Properties properties = new Properties();
@@ -34,4 +36,5 @@
     public final List<InterceptorBindingInfo> interceptorBindings = new 
ArrayList<InterceptorBindingInfo>();
     public final List<MethodInfo> excludeList = new ArrayList<MethodInfo>();
     public final List<ApplicationExceptionInfo> applicationException = new 
ArrayList<ApplicationExceptionInfo>();
+    public final Set<String> watchedResources = new TreeSet<String>();
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceUnitInfo.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceUnitInfo.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceUnitInfo.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceUnitInfo.java
 Thu Oct 18 18:53:03 2007
@@ -19,6 +19,8 @@
 import java.util.List;
 import java.util.Properties;
 import java.util.ArrayList;
+import java.util.Set;
+import java.util.TreeSet;
 
 public class PersistenceUnitInfo extends InfoObject {
     public String name;
@@ -32,5 +34,5 @@
     public boolean excludeUnlistedClasses;
     public final Properties properties = new Properties();
     public String persistenceUnitRootUrl;
-
+    public final Set<String> watchedResources = new TreeSet<String>();
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java
 Thu Oct 18 18:53:03 2007
@@ -17,6 +17,9 @@
  */
 package org.apache.openejb.assembler.classic;
 
+import java.util.Set;
+import java.util.TreeSet;
+
 public class WebAppInfo extends InfoObject {
 
     public String codebase;
@@ -27,6 +30,7 @@
     public String moduleId;
     public String host;
     public String contextRoot;
+    public final Set<String> watchedResources = new TreeSet<String>();
 
     public JndiEncInfo jndiEnc;
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
 Thu Oct 18 18:53:03 2007
@@ -21,6 +21,9 @@
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Collection;
+import java.util.Set;
+import java.util.TreeSet;
 import java.io.File;
 
 import org.apache.openejb.jee.jpa.EntityMappings;
@@ -42,6 +45,7 @@
     private EntityMappings cmpMappings;
     private final Map<String,Object> altDDs = new HashMap<String,Object>();
     private final String moduleId;
+    private final Set<String> watchedResources = new TreeSet<String>();
 
     public AppModule(ClassLoader classLoader, String jarLocation) {
         this.classLoader = classLoader;
@@ -152,5 +156,18 @@
 
     public List<WebModule> getWebModules() {
         return webModules;
+    }
+
+    public Set<String> getWatchedResources() {
+        return watchedResources;
+    }
+
+    public Collection<DeploymentModule> getDeploymentModule() {
+        ArrayList<DeploymentModule> modules = new 
ArrayList<DeploymentModule>();
+        modules.addAll(ejbModules);
+        modules.addAll(webModules);
+        modules.addAll(connectorModules);
+        modules.addAll(clientModules);
+        return modules;
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java
 Thu Oct 18 18:53:03 2007
@@ -20,6 +20,8 @@
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
+import java.util.TreeSet;
 import java.io.File;
 
 /**
@@ -33,6 +35,7 @@
     private String mainClass;
     private final Map<String,Object> altDDs = new HashMap<String,Object>();
     private final String moduleId;
+    private final Set<String> watchedResources = new TreeSet<String>();
 
     public ClientModule(ApplicationClient applicationClient, ClassLoader 
classLoader, String jarLocation, String mainClass, String moduleId) {
         this.applicationClient = applicationClient;
@@ -95,5 +98,9 @@
 
     public void setMainClass(String mainClass) {
         this.mainClass = mainClass;
+    }
+
+    public Set<String> getWatchedResources() {
+        return watchedResources;
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
 Thu Oct 18 18:53:03 2007
@@ -369,6 +369,7 @@
             for (PersistenceUnit persistenceUnit : 
persistence.getPersistenceUnit()) {
                 PersistenceUnitInfo info = new PersistenceUnitInfo();
                 info.name = persistenceUnit.getName();
+                
info.watchedResources.addAll(persistenceModule.getWatchedResources());
                 info.persistenceUnitRootUrl = rootUrl;
                 info.provider = persistenceUnit.getProvider();
                 info.transactionType = 
persistenceUnit.getTransactionType().toString();
@@ -410,6 +411,7 @@
             clientInfo.mainClass = clientModule.getMainClass();
             clientInfo.callbackHandler = 
applicationClient.getCallbackHandler();
             clientInfo.moduleId = getClientModuleId(clientModule);
+            
clientInfo.watchedResources.addAll(clientModule.getWatchedResources());
 
             JndiEncInfoBuilder jndiEncInfoBuilder = new 
JndiEncInfoBuilder(appInfo.ejbJars);
             clientInfo.jndiEnc = jndiEncInfoBuilder.build(applicationClient, 
clientModule.getJarLocation(), clientInfo.moduleId);
@@ -429,6 +431,7 @@
             connectorInfo.displayName = connector.getDisplayName();
             connectorInfo.codebase = connectorModule.getJarLocation();
             connectorInfo.moduleId = connectorModule.getModuleId();
+            
connectorInfo.watchedResources.addAll(connectorModule.getWatchedResources());
 
             List<URL> libraries = connectorModule.getLibraries();
             for (URL url : libraries) {
@@ -562,7 +565,8 @@
             webAppInfo.displayName = webApp.getDisplayName();
             webAppInfo.codebase = webModule.getJarLocation();
             webAppInfo.moduleId = webModule.getModuleId();
-            
+            
webAppInfo.watchedResources.addAll(webModule.getWatchedResources());
+
             webAppInfo.host = webModule.getHost();
             webAppInfo.contextRoot = webModule.getContextRoot();
 
@@ -572,6 +576,7 @@
         }
 
         appInfo.jarPath = appModule.getJarLocation();
+        appInfo.watchedResources.addAll(appModule.getWatchedResources());
         List<URL> additionalLibraries = appModule.getAdditionalLibraries();
         for (URL url : additionalLibraries) {
             File file = new File(url.getPath());

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java
 Thu Oct 18 18:53:03 2007
@@ -23,6 +23,8 @@
 import java.util.Map;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Set;
+import java.util.TreeSet;
 import java.net.URL;
 
 /**
@@ -37,6 +39,7 @@
     private String jarLocation;
     private final String moduleId;
     private final List<URL> libraries = new ArrayList<URL>();
+    private final Set<String> watchedResources = new TreeSet<String>();
 
     public ConnectorModule(Connector connector, ClassLoader classLoader, 
String jarLocation, String moduleId) {
         this.connector = connector;
@@ -100,5 +103,9 @@
 
     public List<URL> getLibraries() {
         return libraries;
+    }
+
+    public Set<String> getWatchedResources() {
+        return watchedResources;
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
 Thu Oct 18 18:53:03 2007
@@ -238,6 +238,10 @@
                 AppModule appModule = new AppModule(appClassLoader, 
appDir.getAbsolutePath());
                 appModule.getAdditionalLibraries().addAll(extraLibs);
                 appModule.getAltDDs().putAll(appDescriptors);
+                appModule.getWatchedResources().add(appDir.getAbsolutePath());
+                if (applicationXmlUrl != null) {
+                    
appModule.getWatchedResources().add(applicationXmlUrl.getPath());
+                }
 
                 // EJB modules
                 for (String moduleName : ejbModules.keySet()) {
@@ -248,13 +252,18 @@
                         Map<String, URL> descriptors = getDescriptors(ejbUrl);
 
                         EjbJar ejbJar = null;
-                        if (descriptors.containsKey("ejb-jar.xml")){
-                            ejbJar = 
ReadDescriptors.readEjbJar(descriptors.get("ejb-jar.xml"));
+                        URL ejbJarXmlUrl = descriptors.get("ejb-jar.xml");
+                        if (ejbJarXmlUrl != null){
+                            ejbJar = ReadDescriptors.readEjbJar(ejbJarXmlUrl);
                         }
 
                         EjbModule ejbModule = new EjbModule(appClassLoader, 
moduleName, ejbFile.getAbsolutePath(), ejbJar, null);
 
                         ejbModule.getAltDDs().putAll(descriptors);
+                        
ejbModule.getWatchedResources().add(ejbFile.getAbsolutePath());
+                        if (ejbJarXmlUrl != null && 
"file".equals(ejbJarXmlUrl.getProtocol())) {
+                            
ejbModule.getWatchedResources().add(ejbJarXmlUrl.getPath());
+                        }
 
                         appModule.getEjbModules().add(ejbModule);
                     } catch (OpenEJBException e) {
@@ -277,13 +286,18 @@
                         Map<String, URL> descriptors = 
getDescriptors(clientUrl);
 
                         ApplicationClient applicationClient = null;
-                        if (descriptors.containsKey("application-client.xml")){
-                            applicationClient = 
ReadDescriptors.readApplicationClient(descriptors.get("application-client.xml"));
+                        URL clientXmlUrl = 
descriptors.get("application-client.xml");
+                        if (clientXmlUrl != null){
+                            applicationClient = 
ReadDescriptors.readApplicationClient(clientXmlUrl);
                         }
 
                         ClientModule clientModule = new 
ClientModule(applicationClient, appClassLoader, clientFile.getAbsolutePath(), 
mainClass, moduleName);
 
                         clientModule.getAltDDs().putAll(descriptors);
+                        
clientModule.getWatchedResources().add(clientFile.getAbsolutePath());
+                        if (clientXmlUrl != null && 
"file".equals(clientXmlUrl.getProtocol())) {
+                            
clientModule.getWatchedResources().add(clientXmlUrl.getPath());
+                        }
 
                         appModule.getClientModules().add(clientModule);
                     } catch (Exception e) {
@@ -329,13 +343,18 @@
             // read the ejb-jar.xml file
             Map<String, URL> descriptors = getDescriptors(baseUrl);
             EjbJar ejbJar = null;
-            if (descriptors.containsKey("ejb-jar.xml")){
-                ejbJar = 
ReadDescriptors.readEjbJar(descriptors.get("ejb-jar.xml"));
+            URL ejbJarXmlUrl = descriptors.get("ejb-jar.xml");
+            if (ejbJarXmlUrl != null){
+                ejbJar = ReadDescriptors.readEjbJar(ejbJarXmlUrl);
             }
 
             // create the EJB Module
             EjbModule ejbModule = new EjbModule(classLoader, 
jarFile.getAbsolutePath(), ejbJar, null);
             ejbModule.getAltDDs().putAll(descriptors);
+            ejbModule.getWatchedResources().add(jarFile.getAbsolutePath());
+            if (ejbJarXmlUrl != null && 
"file".equals(ejbJarXmlUrl.getProtocol())) {
+                ejbModule.getWatchedResources().add(ejbJarXmlUrl.getPath());
+            }
 
             // wrap the EJB Module with an Application Module
             AppModule appModule = new AppModule(classLoader, 
ejbModule.getJarLocation());
@@ -384,8 +403,9 @@
         }
 
         WebApp webApp = null;
-        if (descriptors.containsKey("web.xml")){
-            webApp = ReadDescriptors.readWebApp(descriptors.get("web.xml"));
+        URL webXmlUrl = descriptors.get("web.xml");
+        if (webXmlUrl != null){
+            webApp = ReadDescriptors.readWebApp(webXmlUrl);
         }
 
         // if this is a standalone module (no-context root), and webApp.getId 
is set then that is the module name
@@ -422,6 +442,11 @@
         // create web module
         WebModule webModule = new WebModule(webApp, contextRoot, 
warClassLoader, warFile.getAbsolutePath(), moduleName);
         webModule.getAltDDs().putAll(descriptors);
+        webModule.getWatchedResources().add(warPath);
+        webModule.getWatchedResources().add(warFile.getAbsolutePath());
+        if (webXmlUrl != null && "file".equals(webXmlUrl.getProtocol())) {
+            webModule.getWatchedResources().add(webXmlUrl.getPath());
+        }
 
         // find all tag libs
         addTagLibraries(webModule);
@@ -472,6 +497,9 @@
         for (URL location : tldLocations) {
             TldTaglib taglib = ReadDescriptors.readTldTaglib(location);
             webModule.getTaglibs().add(taglib);
+            if ("file".equals(location.getProtocol())) {
+                webModule.getWatchedResources().add(location.getPath());
+            }
         }
     }
 
@@ -604,8 +632,9 @@
         // read the ra.xml file
         Map<String, URL> descriptors = getDescriptors(baseUrl);
         Connector connector = null;
-        if (descriptors.containsKey("ra.xml")){
-            connector = 
ReadDescriptors.readConnector(descriptors.get("ra.xml"));
+        URL rarXmlUrl = descriptors.get("ra.xml");
+        if (rarXmlUrl != null){
+            connector = ReadDescriptors.readConnector(rarXmlUrl);
         }
 
         // find the nested jar files
@@ -629,6 +658,12 @@
         ConnectorModule connectorModule = new ConnectorModule(connector, 
appClassLoader, rarPath, moduleId);
         connectorModule.getAltDDs().putAll(descriptors);
         connectorModule.getLibraries().addAll(classPath);
+        connectorModule.getWatchedResources().add(rarPath);
+        connectorModule.getWatchedResources().add(rarFile.getAbsolutePath());
+        if (rarXmlUrl != null && "file".equals(rarXmlUrl.getProtocol())) {
+            connectorModule.getWatchedResources().add(rarXmlUrl.getPath());
+        }
+
         return connectorModule;
     }
 
@@ -745,7 +780,10 @@
 
         Map<String, URL> descriptors = finder.getResourcesMap("META-INF");
 
-        if (descriptors.containsKey("application.xml") || 
baseUrl.getPath().endsWith(".ear")) {
+        String path = baseUrl.getPath();
+        if (path.endsWith("/")) path = path.substring(0, path.length() - 1);
+        
+        if (descriptors.containsKey("application.xml") || 
path.endsWith(".ear")) {
             return AppModule.class;
         }
 
@@ -757,12 +795,12 @@
             return ClientModule.class;
         }
 
-        if (descriptors.containsKey("ra.xml") || 
baseUrl.getPath().endsWith(".rar")) {
+        if (descriptors.containsKey("ra.xml") || path.endsWith(".rar")) {
             return ConnectorModule.class;
         }
 
         Map<String, URL> webDescriptors = getWebDescriptors(getFile(baseUrl));
-        if (webDescriptors.containsKey("web.xml") || 
baseUrl.getPath().endsWith(".war")) {
+        if (webDescriptors.containsKey("web.xml") || path.endsWith(".war")) {
             return WebModule.class;
         }
 

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
 Thu Oct 18 18:53:03 2007
@@ -17,6 +17,7 @@
 package org.apache.openejb.config;
 
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @version $Rev$ $Date$
@@ -32,4 +33,5 @@
 
     ValidationContext getValidation();
 
+    Set<String> getWatchedResources();
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
 Thu Oct 18 18:53:03 2007
@@ -74,7 +74,6 @@
 import org.apache.openejb.jee.ApplicationException;
 import org.apache.openejb.jee.oejb3.EjbDeployment;
 import org.apache.openejb.jee.oejb3.ResourceLink;
-import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.Messages;
@@ -128,6 +127,7 @@
         if (ejbJar.moduleId == null) {
             ejbJar.moduleId = new 
File(ejbJar.jarPath).getName().replaceFirst(".jar$","");
         }
+        ejbJar.watchedResources.addAll(jar.getWatchedResources());
 
         ejbJar.properties.putAll(jar.getOpenejbJar().getProperties());
 
@@ -179,15 +179,6 @@
             initRelationships(jar, infos);
         }
 
-        if 
(!"tomcat-webapp".equals(SystemInstance.get().getProperty("openejb.loader"))) {
-//            try {
-//                File jarFile = new File(jar.getJarURI());
-//
-//                
SystemInstance.get().getClassPath().addJarToPath(jarFile.toURL());
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//            }
-        }
         return ejbJar;
     }
 

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
 Thu Oct 18 18:53:03 2007
@@ -23,6 +23,8 @@
 import java.io.File;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
+import java.util.TreeSet;
 
 /**
  * Class is to remain "dumb" and should not have deployment logic added to it.
@@ -39,6 +41,7 @@
     private OpenejbJar openejbJar;
     private String moduleId;
     private final Map<String,Object> altDDs = new HashMap<String,Object>();
+    private final Set<String> watchedResources = new TreeSet<String>();
 
     public EjbModule(EjbJar ejbJar){
         this(Thread.currentThread().getContextClassLoader(), null, ejbJar, 
null);
@@ -125,5 +128,9 @@
 
     public void setOpenejbJar(OpenejbJar openejbJar) {
         this.openejbJar = openejbJar;
+    }
+
+    public Set<String> getWatchedResources() {
+        return watchedResources;
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceModule.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceModule.java
 Thu Oct 18 18:53:03 2007
@@ -18,9 +18,13 @@
 
 import org.apache.openejb.jee.jpa.unit.Persistence;
 
+import java.util.Set;
+import java.util.TreeSet;
+
 public class PersistenceModule {
     private String rootUrl;
     private Persistence persistence;
+    private final Set<String> watchedResources = new TreeSet<String>();
 
     public PersistenceModule(String rootUrl, Persistence persistence) {
         this.rootUrl = rootUrl;
@@ -41,5 +45,9 @@
 
     public void setPersistence(Persistence persistence) {
         this.persistence = persistence;
+    }
+
+    public Set<String> getWatchedResources() {
+        return watchedResources;
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
 Thu Oct 18 18:53:03 2007
@@ -81,18 +81,22 @@
 
         List<URL> persistenceUrls = (List<URL>) 
appModule.getAltDDs().get("persistence.xml");
         if (persistenceUrls != null) {
-            for (URL url1 : persistenceUrls) {
-                String moduleName1 = 
url1.toExternalForm().replaceFirst("!/?META-INF/persistence.xml$", "");
-                moduleName1 = 
moduleName1.replaceFirst("/?META-INF/persistence.xml$", "/");
-                if (moduleName1.startsWith("jar:")) moduleName1 = 
moduleName1.substring("jar:".length());
-                if (moduleName1.startsWith("file:")) moduleName1 = 
moduleName1.substring("file:".length());
+            for (URL persistenceUrl : persistenceUrls) {
+                String moduleName = 
persistenceUrl.toExternalForm().replaceFirst("!/?META-INF/persistence.xml$", 
"");
+                moduleName = 
moduleName.replaceFirst("/?META-INF/persistence.xml$", "/");
+                if (moduleName.startsWith("jar:")) moduleName = 
moduleName.substring("jar:".length());
+                if (moduleName.startsWith("file:")) moduleName = 
moduleName.substring("file:".length());
 //                if (moduleName1.endsWith("/")) moduleName1 = 
moduleName1.substring(0, moduleName1.length() - 1);
                 try {
-                    Persistence persistence = 
JaxbPersistenceFactory.getPersistence(url1);
-                    PersistenceModule persistenceModule = new 
PersistenceModule(moduleName1, persistence);
+                    Persistence persistence = 
JaxbPersistenceFactory.getPersistence(persistenceUrl);
+                    PersistenceModule persistenceModule = new 
PersistenceModule(moduleName, persistence);
+                    persistenceModule.getWatchedResources().add(moduleName);
+                    if ("file".equals(persistenceUrl.getProtocol())) {
+                        
persistenceModule.getWatchedResources().add(persistenceUrl.getPath());
+                    }
                     appModule.getPersistenceModules().add(persistenceModule);
                 } catch (Exception e1) {
-                    DeploymentLoader.logger.error("Unable to load Persistence 
Unit from EAR: " + appModule.getJarLocation() + ", module: " + moduleName1 + ". 
Exception: " + e1.getMessage(), e1);
+                    DeploymentLoader.logger.error("Unable to load Persistence 
Unit from EAR: " + appModule.getJarLocation() + ", module: " + moduleName + ". 
Exception: " + e1.getMessage(), e1);
                 }
             }
         }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
 Thu Oct 18 18:53:03 2007
@@ -23,6 +23,8 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Set;
+import java.util.TreeSet;
 import java.io.File;
 
 /**
@@ -39,6 +41,7 @@
     private String jarLocation;
     private final String moduleId;
     private final List<TldTaglib> taglibs = new ArrayList<TldTaglib>();
+    private final Set<String> watchedResources = new TreeSet<String>();
 
     public WebModule(WebApp webApp, String contextRoot, ClassLoader 
classLoader, String jarLocation, String moduleId) {
         this.webApp = webApp;
@@ -128,5 +131,9 @@
 
     public List<TldTaglib> getTaglibs() {
         return taglibs;
+    }
+
+    public Set<String> getWatchedResources() {
+        return watchedResources;
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java?rev=586221&r1=586220&r2=586221&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java
 Thu Oct 18 18:53:03 2007
@@ -28,6 +28,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 /**
  * @version $Rev$ $Date$
@@ -77,6 +78,11 @@
             if (List.class.isAssignableFrom(type)) {
                 type = getGenericType(field);
                 assertNotNull("Lists must have a generic type: " + simpleName 
+ "." + field.getName(), type);
+            }
+
+            if (Set.class.isAssignableFrom(type)) {
+                type = getGenericType(field);
+                assertNotNull("Sets must have a generic type: " + simpleName + 
"." + field.getName(), type);
             }
 
             if (type.isPrimitive()) {


Reply via email to