[seam-commits] Seam SVN: r9102 - in trunk/src: main/org/jboss/seam/deployment and 2 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Sep 22 14:45:27 EDT 2008
Author: pete.muir at jboss.org
Date: 2008-09-22 14:45:26 -0400 (Mon, 22 Sep 2008)
New Revision: 9102
Added:
trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java
Modified:
trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java
trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java
trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
trunk/src/main/org/jboss/seam/deployment/DotPageDotXmlDeploymentHandler.java
trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
trunk/src/main/org/jboss/seam/deployment/Scanner.java
trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java
trunk/src/main/org/jboss/seam/deployment/URLScanner.java
trunk/src/main/org/jboss/seam/init/Initialization.java
trunk/src/main/org/jboss/seam/navigation/Pages.java
Log:
JBSEAM-3435
Modified: trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java
===================================================================
--- trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/debug/org/jboss/seam/debug/hot/HotDeployFilter.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -3,7 +3,6 @@
import static org.jboss.seam.ScopeType.APPLICATION;
import static org.jboss.seam.annotations.Install.BUILT_IN;
-import java.io.File;
import java.io.IOException;
import javax.servlet.FilterChain;
@@ -19,11 +18,9 @@
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.annotations.web.Filter;
import org.jboss.seam.core.Init;
-import org.jboss.seam.exception.Exceptions;
import org.jboss.seam.init.Initialization;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
-import org.jboss.seam.navigation.Pages;
import org.jboss.seam.web.AbstractFilter;
@Name("org.jboss.seam.debug.hotDeployFilter")
@@ -40,62 +37,13 @@
throws IOException, ServletException
{
Init init = (Init) getServletContext().getAttribute( Seam.getComponentName(Init.class) );
- if ( init!=null && init.hasHotDeployableComponents() )
+ if ( init!=null)
{
- for ( File file: init.getHotDeployPaths() )
- {
- if ( scan(request, init, file) )
- {
- Seam.clearComponentNameCache();
- new Initialization( getServletContext() ).redeploy( (HttpServletRequest) request );
- break;
- }
- }
+ new Initialization( getServletContext() ).redeploy( (HttpServletRequest) request );
}
-
- //TODO: check the timestamp, for a minor optimization
- // instead
- Pages pages = (Pages) getServletContext().getAttribute(Seam.getComponentName(Pages.class));
- if (pages!= null) {
- pages.initialize();
- }
-
- getServletContext().removeAttribute( Seam.getComponentName(Exceptions.class) );
-
- //TODO: is there anything we should remove from the session scope?
- /*HttpSession session = ( (HttpServletRequest) request ).getSession(false);
- if (session!=null)
- {
- session.removeAttribute( ... );
- }*/
-
chain.doFilter(request, response);
}
- private boolean scan(ServletRequest request, Init init, File file)
- {
- if ( file.isFile() )
- {
- if ( !file.exists() || ( file.lastModified() > init.getTimestamp() ) )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( "file updated: " + file.getName() );
- }
- return true;
- }
- }
- else if ( file.isDirectory() )
- {
- for ( File f: file.listFiles() )
- {
- if ( scan(request, init, f) )
- {
- return true;
- }
- }
- }
- return false;
- }
+
}
Modified: trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -34,5 +34,10 @@
{
return deploymentStrategy;
}
+
+ public long getTimestamp()
+ {
+ return Long.MAX_VALUE;
+ }
}
Modified: trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -11,12 +11,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;
@@ -36,9 +35,6 @@
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;
/**
@@ -189,20 +185,6 @@
*/
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());
@@ -327,19 +309,9 @@
this.files = files;
}
- public void addExclude(String path)
+ public long getTimestamp()
{
- 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);
- }
+ return getScanner().getTimestamp();
}
+
}
Modified: trunk/src/main/org/jboss/seam/deployment/DotPageDotXmlDeploymentHandler.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/DotPageDotXmlDeploymentHandler.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/deployment/DotPageDotXmlDeploymentHandler.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -54,9 +54,9 @@
{
if (Contexts.isEventContextActive())
{
- if (Contexts.getEventContext().isSet(HotDeploymentStrategy.NAME))
+ if (Contexts.getEventContext().isSet(WarRootDeploymentStrategy.NAME))
{
- DeploymentStrategy deploymentStrategy = (DeploymentStrategy) Contexts.getEventContext().get(StandardDeploymentStrategy.NAME);
+ DeploymentStrategy deploymentStrategy = (DeploymentStrategy) Contexts.getEventContext().get(WarRootDeploymentStrategy.NAME);
Object deploymentHandler = deploymentStrategy.getDeploymentHandlers().get(NAME);
if (deploymentHandler != null)
{
@@ -71,25 +71,4 @@
}
}
- public static DotPageDotXmlDeploymentHandler hotInstance()
- {
- if (Contexts.isEventContextActive())
- {
- DeploymentStrategy deploymentStrategy = (DeploymentStrategy) Contexts.getEventContext().get(HotDeploymentStrategy.NAME);
- if (deploymentStrategy != null)
- {
- Object deploymentHandler = deploymentStrategy.getDeploymentHandlers().get(NAME);
- if (deploymentHandler != null)
- {
- return (DotPageDotXmlDeploymentHandler) deploymentHandler;
- }
- }
- return null;
- }
- else
- {
- throw new IllegalStateException("Event context not active");
- }
- }
-
}
Modified: trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -50,6 +50,8 @@
private ComponentDeploymentHandler componentDeploymentHandler;
private AnnotationDeploymentHandler annotationDeploymentHandler;
+
+ private long timestamp = 0L;
private ClassLoader classLoader;
@@ -95,7 +97,7 @@
return classLoader != null;
}
- public boolean isHotDeployClasslLoaderEnabled()
+ public boolean isHotDeployClassLoaderEnabled()
{
return hotDeployClassLoader != null;
}
Modified: trunk/src/main/org/jboss/seam/deployment/Scanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/Scanner.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/deployment/Scanner.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -31,4 +31,6 @@
*/
public DeploymentStrategy getDeploymentStrategy();
+ public long getTimestamp();
+
}
Modified: trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -56,7 +56,6 @@
getDeploymentHandlers().put(NamespaceDeploymentHandler.NAME, namespaceDeploymentHandler);
annotationDeploymentHandler = new AnnotationDeploymentHandler(getPropertyValues(AnnotationDeploymentHandler.ANNOTATIONS_KEY), classLoader);
getDeploymentHandlers().put(AnnotationDeploymentHandler.NAME, annotationDeploymentHandler);
- getDeploymentHandlers().put(DotPageDotXmlDeploymentHandler.NAME, new DotPageDotXmlDeploymentHandler());
}
@Override
Modified: trunk/src/main/org/jboss/seam/deployment/URLScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/URLScanner.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/deployment/URLScanner.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -28,6 +28,8 @@
{
private static final LogProvider log = Logging.getLogProvider(URLScanner.class);
+ private long timestamp;
+
public URLScanner(DeploymentStrategy deploymentStrategy)
{
super(deploymentStrategy);
@@ -111,6 +113,7 @@
try
{
log.debug("archive: " + file);
+ touchTimestamp(file);
ZipFile zip = new ZipFile(file);
Enumeration<? extends ZipEntry> entries = zip.entries();
while ( entries.hasMoreElements() )
@@ -138,9 +141,24 @@
}
else
{
+ touchTimestamp(file);
handleItem(newPath);
}
}
}
+ private void touchTimestamp(File file)
+ {
+ if (file.lastModified() > timestamp)
+ {
+ timestamp = file.lastModified();
+ }
+ }
+
+ @Override
+ public long getTimestamp()
+ {
+ return timestamp;
+ }
+
}
Added: trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java (rev 0)
+++ trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -0,0 +1,58 @@
+package org.jboss.seam.deployment;
+
+import java.io.File;
+
+/**
+ * A special deployment strategy that can be used to scan the war root. This
+ * is treated as a special case.
+ *
+ * @author pmuir
+ *
+ */
+public class WarRootDeploymentStrategy extends DeploymentStrategy
+{
+
+ private ClassLoader classLoader;
+
+ private File[] warRoot;
+
+ public static final String HANDLERS_KEY = "org.jboss.seam.deployment.deploymentHandlers";
+
+ public static final String NAME = "warRootDeploymentStrategy";
+
+ public WarRootDeploymentStrategy(ClassLoader classLoader, File warRoot)
+ {
+ this.classLoader = classLoader;
+ this.warRoot = new File[1];
+ this.warRoot[0] = warRoot;
+ getDeploymentHandlers().put(DotPageDotXmlDeploymentHandler.NAME, new DotPageDotXmlDeploymentHandler());
+ }
+
+ @Override
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ @Override
+ protected String getDeploymentHandlersKey()
+ {
+ return HANDLERS_KEY;
+ }
+
+ @Override
+ public void handle(String name)
+ {
+ if (!(name.startsWith("WEB-INF") || name.startsWith("/WEB-INF")))
+ {
+ super.handle(name);
+ }
+ }
+
+ @Override
+ public void scan()
+ {
+ getScanner().scanDirectories(warRoot);
+ }
+
+}
Property changes on: trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -5,7 +5,6 @@
*/
package org.jboss.seam.init;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -42,10 +41,10 @@
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;
+import org.jboss.seam.deployment.WarRootDeploymentStrategy;
+import org.jboss.seam.exception.Exceptions;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.navigation.Pages;
@@ -82,9 +81,10 @@
private StandardDeploymentStrategy standardDeploymentStrategy;
private HotDeploymentStrategy hotDeploymentStrategy;
+ private WarRootDeploymentStrategy warRootDeploymentStrategy;
- private File warRootDirectory;
private File hotDeployDirectory;
+ private File warRoot;
private Set<String> nonPropertyAttributes = new HashSet<String>();
@@ -103,14 +103,13 @@
public Initialization(ServletContext servletContext)
{
this.servletContext = servletContext;
- this.warRootDirectory = getRealFile(servletContext, "/");
+ this.warRoot = getRealFile(servletContext, "/");
this.hotDeployDirectory = getRealFile(servletContext, HotDeploymentStrategy.DEFAULT_HOT_DEPLOYMENT_DIRECTORY_PATH);
}
public Initialization create()
{
standardDeploymentStrategy = new StandardDeploymentStrategy(Thread.currentThread().getContextClassLoader());
- addWarRoot(standardDeploymentStrategy);
standardDeploymentStrategy.scan();
addNamespaces();
initComponentsFromXmlDocument("/WEB-INF/components.xml");
@@ -121,13 +120,6 @@
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()
{
@@ -619,7 +611,8 @@
hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader());
scanForComponents();
addComponent( new ComponentDescriptor(Init.class), Contexts.getApplicationContext());
- Init init = (Init) Component.getInstance(Init.class, ScopeType.APPLICATION);
+ Init init = (Init) Component.getInstance(Init.class, ScopeType.APPLICATION);
+ init.setHotDeployPaths( hotDeploymentStrategy.getHotDeploymentPaths() );
ComponentDescriptor desc = findDescriptor(Jbpm.class);
if (desc != null && desc.isInstalled())
{
@@ -629,22 +622,24 @@
init.setTimestamp( System.currentTimeMillis() );
addSpecialComponents(init);
+ // Add the war root deployment
+ warRootDeploymentStrategy = new WarRootDeploymentStrategy(Thread.currentThread().getContextClassLoader(), warRoot);
+ warRootDeploymentStrategy.scan();
+
// 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);
+ Contexts.getEventContext().set(WarRootDeploymentStrategy.NAME, warRootDeploymentStrategy);
if (hotDeploymentStrategy.isEnabled())
{
hotDeploymentStrategy.scan();
- if (hotDeploymentStrategy.isHotDeployClasslLoaderEnabled())
+ if (hotDeploymentStrategy.isHotDeployClassLoaderEnabled())
{
installHotDeployableComponents();
}
- // TODO Hack
- hotDeploymentStrategy.getFiles().add(warRootDirectory);
- init.setHotDeployPaths( hotDeploymentStrategy.getHotDeploymentPaths() );
}
installComponents(init);
@@ -661,38 +656,53 @@
public Initialization redeploy(HttpServletRequest request)
{
- log.info("redeploying");
ServletLifecycle.beginReinitialization(request);
- Init init = Init.instance();
- for ( String name: init.getHotDeployableComponents() )
+ hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader());
+ if (hotDeploymentStrategy.isEnabled())
{
- Component component = Component.forName(name);
- if (component!=null)
+ hotDeploymentStrategy.scan();
+ Init init = Init.instance();
+
+ if (init.getTimestamp() < hotDeploymentStrategy.getTimestamp())
{
- ScopeType scope = component.getScope();
- if ( scope!=ScopeType.STATELESS && scope.isContextActive() )
+ log.info("redeploying");
+ Seam.clearComponentNameCache();
+ for ( String name: init.getHotDeployableComponents() )
{
- scope.getContext().remove(name);
+ Component component = Component.forName(name);
+ if (component!=null)
+ {
+ ScopeType scope = component.getScope();
+ if ( scope!=ScopeType.STATELESS && scope.isContextActive() )
+ {
+ scope.getContext().remove(name);
+ }
+ init.removeObserverMethods(component);
+ }
+ Contexts.getApplicationContext().remove(name + COMPONENT_SUFFIX);
}
- init.removeObserverMethods(component);
+
+ if (hotDeploymentStrategy.isHotDeployClassLoaderEnabled())
+ {
+ installHotDeployableComponents();
+ }
+ Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
+ init.setTimestamp( System.currentTimeMillis() );
+ installComponents(init);
+ log.info("done redeploying");
}
- Contexts.getApplicationContext().remove(name + COMPONENT_SUFFIX);
+
+ WarRootDeploymentStrategy warRootDeploymentStrategy = new WarRootDeploymentStrategy(Thread.currentThread().getContextClassLoader(), warRoot);
+ warRootDeploymentStrategy.scan();
+ Contexts.getEventContext().set(WarRootDeploymentStrategy.NAME, warRootDeploymentStrategy);
+ Pages pages = Pages.instance();
+ if (pages!= null) {
+ pages.initialize();
+ }
+
+ Contexts.getApplicationContext().remove(Seam.getComponentName(Exceptions.class));
}
- //TODO open the ability to reuse the classloader by looking at the components class classloaders
- hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader());
- addWarRoot(hotDeploymentStrategy);
- hotDeploymentStrategy.scan();
- if (hotDeploymentStrategy.isHotDeployClasslLoaderEnabled())
- {
- installHotDeployableComponents();
- }
- Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
- Pages.instance().setHotDotPageDotXmlFileNames(DotPageDotXmlDeploymentHandler.hotInstance().getFiles());
- init.setTimestamp( System.currentTimeMillis() );
- init.setHotDeployPaths(hotDeploymentStrategy.getHotDeploymentPaths());
- installComponents(init);
ServletLifecycle.endInitialization();
- log.info("done redeploying");
return this;
}
Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-09-22 18:24:28 UTC (rev 9101)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-09-22 18:45:26 UTC (rev 9102)
@@ -84,11 +84,8 @@
private Map<String, Page> pagesByViewId;
private Map<String, List<Page>> pageStacksByViewId;
- private Map<String, ConversationIdParameter> conversations;
+ private Map<String, ConversationIdParameter> conversations;
- private Set<String> dotPageDotXmlFileNames;
- private Set<String> hotDotPageDotXmlFileNames;
-
private String[] resources = { "/WEB-INF/pages.xml" };
private SortedSet<String> wildcardViewIds = new TreeSet<String>(
@@ -106,12 +103,6 @@
@Create
public void create()
{
- dotPageDotXmlFileNames = new HashSet<String>();
- hotDotPageDotXmlFileNames = new HashSet<String>();
- if (DotPageDotXmlDeploymentHandler.instance() != null)
- {
- dotPageDotXmlFileNames = DotPageDotXmlDeploymentHandler.instance().getFiles();
- }
initialize();
}
@@ -132,8 +123,11 @@
parse(stream);
}
}
-
- parsePages(hotDotPageDotXmlFileNames, dotPageDotXmlFileNames);
+
+ if (DotPageDotXmlDeploymentHandler.instance() != null)
+ {
+ parsePages(DotPageDotXmlDeploymentHandler.instance().getFiles());
+ }
}
private void parsePages(Set<String> ...fileNames)
@@ -1691,19 +1685,8 @@
getCurrentViewId().startsWith("/debug.");
}
-
public Collection<String> getKnownViewIds() {
return pagesByViewId.keySet();
}
- public Set<String> getHotDotPageDotXmlFileNames()
- {
- return hotDotPageDotXmlFileNames;
- }
-
- public void setHotDotPageDotXmlFileNames(Set<String> hotDotPageDotXmlFileNames)
- {
- this.hotDotPageDotXmlFileNames = hotDotPageDotXmlFileNames;
- }
-
}
More information about the seam-commits
mailing list