[seam-commits] Seam SVN: r8868 - in trunk/src/main/org/jboss/seam: init and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Sep 1 10:46:56 EDT 2008
Author: pete.muir at jboss.org
Date: 2008-09-01 10:46:56 -0400 (Mon, 01 Sep 2008)
New Revision: 8868
Modified:
trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
trunk/src/main/org/jboss/seam/init/Initialization.java
Log:
JBSEAM-3323
Modified: trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java 2008-09-01 14:46:16 UTC (rev 8867)
+++ trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java 2008-09-01 14:46:56 UTC (rev 8868)
@@ -10,9 +10,11 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
@@ -33,6 +35,9 @@
private List<File> files = new ArrayList<File>();
+ private Set<String> excludes = new HashSet<String>();
+ private Set<String> wildCardExcludes = new HashSet<String>();
+
private Map<String, DeploymentHandler> deploymentHandlers;
/**
@@ -172,6 +177,20 @@
*/
public void handle(String name)
{
+ for (String exclude: excludes)
+ {
+ if (name.equals(exclude))
+ {
+ return;
+ }
+ }
+ for (String exclude: wildCardExcludes)
+ {
+ if (name.startsWith(exclude))
+ {
+ return;
+ }
+ }
for (String key: getDeploymentHandlers().keySet())
{
getDeploymentHandlers().get(key).handle(name, getClassLoader());
@@ -296,4 +315,19 @@
this.files = files;
}
+ public void addExclude(String path)
+ {
+ if (path == null)
+ {
+ throw new NullPointerException("Cannot exclude a null path");
+ }
+ if (path.endsWith("*"))
+ {
+ wildCardExcludes.add(path.substring(0, path.length() - 1));
+ }
+ else
+ {
+ excludes.add(path);
+ }
+ }
}
Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java 2008-09-01 14:46:16 UTC (rev 8867)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java 2008-09-01 14:46:56 UTC (rev 8868)
@@ -42,6 +42,7 @@
import org.jboss.seam.contexts.ServletLifecycle;
import org.jboss.seam.core.Expressions;
import org.jboss.seam.core.Init;
+import org.jboss.seam.deployment.DeploymentStrategy;
import org.jboss.seam.deployment.DotPageDotXmlDeploymentHandler;
import org.jboss.seam.deployment.HotDeploymentStrategy;
import org.jboss.seam.deployment.StandardDeploymentStrategy;
@@ -109,7 +110,7 @@
public Initialization create()
{
standardDeploymentStrategy = new StandardDeploymentStrategy(Thread.currentThread().getContextClassLoader());
- standardDeploymentStrategy.getFiles().add(warRootDirectory);
+ addWarRoot(standardDeploymentStrategy);
standardDeploymentStrategy.scan();
addNamespaces();
initComponentsFromXmlDocument("/WEB-INF/components.xml");
@@ -120,6 +121,13 @@
initJndiProperties();
return this;
}
+
+ private void addWarRoot(DeploymentStrategy deploymentStrategy)
+ {
+ deploymentStrategy.getFiles().add(warRootDirectory);
+ deploymentStrategy.addExclude("WEB-INF/classes/*");
+ deploymentStrategy.addExclude("/WEB-INF/classes/*");
+ }
private void initComponentsFromXmlDocuments()
{
@@ -604,7 +612,7 @@
}
ServletLifecycle.beginInitialization();
Contexts.getApplicationContext().set(Component.PROPERTIES, properties);
- createHotDeployment(Thread.currentThread().getContextClassLoader());
+ hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader());
scanForComponents();
addComponent( new ComponentDescriptor(Init.class), Contexts.getApplicationContext());
Init init = (Init) Component.getInstance(Init.class, ScopeType.APPLICATION);
@@ -624,12 +632,17 @@
// Make the deployment strategies available in the contexts. This gives
// access to custom deployment handlers for processing custom annotations
// etc.
-
Contexts.getEventContext().set(StandardDeploymentStrategy.NAME, standardDeploymentStrategy);
Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
installComponents(init);
+ if (hotDeploymentStrategy != null)
+ {
+ hotDeploymentStrategy.scan();
+ installHotDeployableComponents();
+ }
+
for (String globalImport: globalImports)
{
init.importNamespace(globalImport);
@@ -660,7 +673,10 @@
Contexts.getApplicationContext().remove(name + COMPONENT_SUFFIX);
}
//TODO open the ability to reuse the classloader by looking at the components class classloaders
- createHotDeployment(Thread.currentThread().getContextClassLoader(), warRootDirectory);
+ hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader());
+ addWarRoot(hotDeploymentStrategy);
+ hotDeploymentStrategy.scan();
+ installHotDeployableComponents();
Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
// Add the WAR root to the hot deploy path to pick up .page.xml
Pages.instance().setHotDotPageDotXmlFileNames(DotPageDotXmlDeploymentHandler.hotInstance().getFiles());
@@ -680,27 +696,25 @@
}
}
- private void createHotDeployment(ClassLoader classLoader, File ... directories)
+ private HotDeploymentStrategy createHotDeployment(ClassLoader classLoader)
{
if ( isDebugEnabled() && hotDeployDirectory != null )
{
if (isGroovyPresent())
{
log.debug("Using Java + Groovy hot deploy");
- hotDeploymentStrategy = HotDeploymentStrategy.createInstance("org.jboss.seam.deployment.GroovyHotDeploymentStrategy", classLoader, hotDeployDirectory);
+ return HotDeploymentStrategy.createInstance("org.jboss.seam.deployment.GroovyHotDeploymentStrategy", classLoader, hotDeployDirectory);
}
else
{
log.debug("Using Java hot deploy");
- hotDeploymentStrategy = new HotDeploymentStrategy(classLoader, hotDeployDirectory);
+ return new HotDeploymentStrategy(classLoader, hotDeployDirectory);
}
- for (File file : directories)
- {
- hotDeploymentStrategy.getFiles().add(file);
- }
- hotDeploymentStrategy.scan();
- installHotDeployableComponents();
}
+ else
+ {
+ return null;
+ }
}
private static File getRealFile(ServletContext servletContext, String path)
More information about the seam-commits
mailing list