[jboss-cvs] jboss-seam/src/main/org/jboss/seam/deployment ...
Peter Muir
peter at bleepbleep.org.uk
Mon Jan 14 07:26:14 EST 2008
User: pmuir
Date: 08/01/14 07:26:14
Modified: src/main/org/jboss/seam/deployment
AbstractScanner.java DeploymentHandler.java
GroovyHotDeploymentStrategy.java
AbstractDeploymentHandler.java Scanner.java
NamespaceDeploymentHandler.java
ComponentDeploymentHandler.java
DeploymentStrategy.java URLScanner.java
GroovyDeploymentHandler.java
HotDeploymentStrategy.java
Added: src/main/org/jboss/seam/deployment
StandardDeploymentStrategy.java
Removed: src/main/org/jboss/seam/deployment
SimpleDeploymentStrategy.java
Log:
Tidy up and javadoc
Revision Changes Path
1.2 +2 -0 jboss-seam/src/main/org/jboss/seam/deployment/AbstractScanner.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractScanner.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/AbstractScanner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AbstractScanner.java 14 Jan 2008 11:29:48 -0000 1.1
+++ AbstractScanner.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -6,6 +6,8 @@
import org.jboss.seam.log.Logging;
/**
+ * Abstract base class for {@link Scanner} providing common functionality
+ *
* @author Pete Muir
*
*/
1.2 +10 -0 jboss-seam/src/main/org/jboss/seam/deployment/DeploymentHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DeploymentHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/DeploymentHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DeploymentHandler.java 14 Jan 2008 11:29:48 -0000 1.1
+++ DeploymentHandler.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -1,10 +1,20 @@
package org.jboss.seam.deployment;
/**
+ * A deployment handler is responsible for processing found resources
+ *
+ * All deployment handlers should specify a unique name under which they
+ * will be registered with the {@link DeploymentStrategy}
+ *
* @author Pete Muir
*
*/
public interface DeploymentHandler
{
+ /**
+ * Handle a resource
+ * @param name The path to the resource
+ * @param classLoader The ClassLoader on which the resource was found
+ */
public void handle(String name, ClassLoader classLoader);
}
1.2 +8 -0 jboss-seam/src/main/org/jboss/seam/deployment/GroovyHotDeploymentStrategy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: GroovyHotDeploymentStrategy.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/GroovyHotDeploymentStrategy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- GroovyHotDeploymentStrategy.java 14 Jan 2008 11:29:48 -0000 1.1
+++ GroovyHotDeploymentStrategy.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -11,6 +11,8 @@
/**
+ * A deployment strategy for hot deploying Seam groovy components
+ *
* @author Pete Muir
*
*/
@@ -23,6 +25,12 @@
private GroovyDeploymentHandler groovyDeploymentHandler;
+ /**
+ * @param classLoader The parent classloader of the hot deployment classloader
+ * @param hotDeployDirectory The directory in which hot deployable java and
+ * groovy Seam components are placed
+ *
+ */
public GroovyHotDeploymentStrategy(ClassLoader classLoader, File hotDeployDirectory)
{
super(classLoader, hotDeployDirectory);
1.2 +21 -11 jboss-seam/src/main/org/jboss/seam/deployment/AbstractDeploymentHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractDeploymentHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/AbstractDeploymentHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AbstractDeploymentHandler.java 14 Jan 2008 11:29:48 -0000 1.1
+++ AbstractDeploymentHandler.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -10,18 +10,25 @@
import javassist.bytecode.annotation.MemberValue;
/**
+ * Abstract base class for {@link DeploymentHandler} providing common functionality
+ *
* @author Pete Muir
*
*/
public abstract class AbstractDeploymentHandler implements DeploymentHandler
{
-
- public static String filenameToClassname(String filename)
+ /**
+ * Convert a path to a class file to a class name
+ */
+ protected static String filenameToClassname(String filename)
{
return filename.substring( 0, filename.lastIndexOf(".class") )
.replace('/', '.').replace('\\', '.');
}
+ /**
+ * Get a Javassist {@link ClassFile} for a given class name from the classLoader
+ */
protected ClassFile getClassFile(String name, ClassLoader classLoader) throws IOException
{
InputStream stream = classLoader.getResourceAsStream(name);
@@ -38,9 +45,12 @@
}
}
- protected boolean hasAnnotation(ClassFile cf, Class<? extends Annotation> annotationType)
+ /**
+ * Check if the Javassist {@link ClassFile} has the specfied annotation
+ */
+ protected boolean hasAnnotation(ClassFile classFile, Class<? extends Annotation> annotationType)
{
- AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
+ AnnotationsAttribute visible = (AnnotationsAttribute) classFile.getAttribute( AnnotationsAttribute.visibleTag );
if ( visible != null )
{
return visible.getAnnotation( annotationType.getName() ) != null;
@@ -48,9 +58,13 @@
return false;
}
- protected String getAnnotationValue(ClassFile cf, Class<? extends Annotation> annotationType, String memberName)
+ /**
+ * Get the value of the annotation on the Javassist {@link ClassFile}, or null
+ * if the class doesn't have that annotation
+ */
+ protected String getAnnotationValue(ClassFile classFile, Class<? extends Annotation> annotationType, String memberName)
{
- AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
+ AnnotationsAttribute visible = (AnnotationsAttribute) classFile.getAttribute( AnnotationsAttribute.visibleTag );
if ( visible != null )
{
javassist.bytecode.annotation.Annotation annotation = visible.getAnnotation( annotationType.getName() );
@@ -70,11 +84,7 @@
}
}
- public static String filenameToPackage(String filename)
- {
- return filename.substring( 0, filename.lastIndexOf(".class") )
- .replace('/', '.').replace('\\', '.');
- }
+
}
1.33 +21 -1 jboss-seam/src/main/org/jboss/seam/deployment/Scanner.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Scanner.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/Scanner.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- Scanner.java 14 Jan 2008 11:29:48 -0000 1.32
+++ Scanner.java 14 Jan 2008 12:26:14 -0000 1.33
@@ -1,16 +1,36 @@
package org.jboss.seam.deployment;
/**
+ * The Scanner is used to find resources to be processed by Seam
+ *
+ * The processing is done by {@link DeploymentHandler}s
+ *
* @author Pete Muir
*
*/
public interface Scanner
{
-
+ /**
+ * Scan the "scannable" classloader.
+ *
+ * Method should scan the {@link DeploymentStrategy#getScannableClassLoader()}
+ * and pass all found resources to {@link DeploymentStrategy#handle(String)}
+ * to be processed by any registered deployment handlers
+ */
public void scanClassLoader();
+ /**
+ * Scan any classloader containing the given resource.
+ *
+ * Method should scan any classloader containing {@link DeploymentStrategy#getResourceNames()}
+ * and pass all found resources to {@link DeploymentStrategy#handle(String)}
+ * to be processed by any registered deployment handlers
+ */
public void scanResources();
+ /**
+ * Get the deployment strategy this scanner is used by
+ */
public DeploymentStrategy getDeploymentStrategy();
}
1.2 +3 -1 jboss-seam/src/main/org/jboss/seam/deployment/NamespaceDeploymentHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NamespaceDeploymentHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/NamespaceDeploymentHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- NamespaceDeploymentHandler.java 14 Jan 2008 11:29:48 -0000 1.1
+++ NamespaceDeploymentHandler.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -9,6 +9,8 @@
import org.jboss.seam.log.Logging;
/**
+ * A deployment handler for namespaces
+ *
* @author Pete Muir
*
*/
1.2 +14 -2 jboss-seam/src/main/org/jboss/seam/deployment/ComponentDeploymentHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ComponentDeploymentHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/ComponentDeploymentHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ComponentDeploymentHandler.java 14 Jan 2008 11:29:48 -0000 1.1
+++ ComponentDeploymentHandler.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -13,12 +13,18 @@
import org.jboss.seam.log.Logging;
/**
+ * The {@link ComponentDeploymentHandler} process Seam components, both
+ * annotated with {@link org.jboss.seam.annotations.Name} and specified in
+ * components.xml
+ *
* @author Pete Muir
*
*/
public class ComponentDeploymentHandler extends AbstractDeploymentHandler
{
-
+ /**
+ * Name under which this {@link DeploymentHandler} is registered
+ */
public static final String NAME = "org.jboss.seam.deployment.ComponentDeploymentHandler";
private static final LogProvider log = Logging.getLogProvider(ComponentDeploymentHandler.class);
@@ -34,18 +40,24 @@
}
/**
- * Returns only Seam components (ie: classes annotated with @Name)
+ * Get annotated Seam components
*/
public Set<Class<Object>> getClasses()
{
return Collections.unmodifiableSet(classes);
}
+ /**
+ * Get paths to components.xml files
+ */
public Set<String> getResources()
{
return Collections.unmodifiableSet(resources);
}
+ /**
+ * @see DeploymentHandler#handle(String, ClassLoader)
+ */
public void handle(String name, ClassLoader classLoader)
{
if (name.endsWith(".class"))
1.2 +50 -2 jboss-seam/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DeploymentStrategy.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/DeploymentStrategy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DeploymentStrategy.java 14 Jan 2008 11:29:48 -0000 1.1
+++ DeploymentStrategy.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -14,6 +14,9 @@
import org.jboss.seam.log.Logging;
/**
+ * A {@link DeploymentStrategy} coordinates the deploy of resources for a Seam
+ * application.
+ *
* @author Pete Muir
*
*/
@@ -31,10 +34,32 @@
this.deploymentHandlers = new HashMap<String, DeploymentHandler>();
}
- public abstract void scan();
+ /**
+ * Do the scan for resources
+ *
+ * If {@link #getResourceNames()} are specified, then {@link Scanner#scanResources()}
+ * will be used, otherwise {@link Scanner#scanClassLoader()} will be used.
+ */
+ public void scan()
+ {
+ if (getResourceNames() == null)
+ {
+ getScanner().scanClassLoader();
+ }
+ else
+ {
+ getScanner().scanResources();
+ }
+ }
+ /**
+ * Get the resource names which this {@link DeploymentStrategy} will scan for.
+ */
public abstract String[] getResourceNames();
+ /**
+ * Get the scanner being used
+ */
protected Scanner getScanner()
{
if (scanner == null)
@@ -44,15 +69,38 @@
return scanner;
}
+ /**
+ * Get the classloader to use
+ */
public abstract ClassLoader getClassLoader();
- public abstract ClassLoader getScannableClassLoader();
+ /**
+ * Sometimes the main classloader cannot be scanned, so a scannable
+ * classloader can be provided
+ *
+ * By default the classloader specified in {@link #getClassLoader()}
+ */
+ public ClassLoader getScannableClassLoader()
+ {
+ return getClassLoader();
+ }
+ /**
+ * Get (or modify) any registered {@link DeploymentHandler}s
+ *
+ * Implementations of {@link DeploymentStrategy} may add default
+ * {@link DeploymentHandler}s
+ */
public Map<String, DeploymentHandler> getDeploymentHandlers()
{
return this.deploymentHandlers;
}
+ /**
+ * Handle a resource using any registered {@link DeploymentHandler}s
+ *
+ * @param name Path to a resource to handle
+ */
public void handle(String name)
{
for (String key: getDeploymentHandlers().keySet())
1.2 +1 -2 jboss-seam/src/main/org/jboss/seam/deployment/URLScanner.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: URLScanner.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/URLScanner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- URLScanner.java 14 Jan 2008 11:29:48 -0000 1.1
+++ URLScanner.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -15,8 +15,7 @@
import org.jboss.seam.log.Logging;
/**
- * Abstract class for scanning archives in the
- * Seam classpath.
+ * Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
*
* @author Thomas Heute
* @author Gavin King
1.2 +9 -0 jboss-seam/src/main/org/jboss/seam/deployment/GroovyDeploymentHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: GroovyDeploymentHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/GroovyDeploymentHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- GroovyDeploymentHandler.java 14 Jan 2008 11:29:48 -0000 1.1
+++ GroovyDeploymentHandler.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -17,6 +17,8 @@
import org.jboss.seam.log.Logging;
/**
+ * A deployment handler for (uncompiled) Groovy Seam components
+ *
* @author Pete Muir
*
*/
@@ -31,12 +33,19 @@
private Set<Class<Object>> classes;
+ /**
+ *
+ * @param groovyFileExtension The extension to use for the groovy file
+ */
public GroovyDeploymentHandler(String groovyFileExtension)
{
this.groovyFileExtension = groovyFileExtension;
this.classes = new HashSet<Class<Object>>();
}
+ /**
+ * Get all the Groovy Seam Components this handler has handled
+ */
public Set<Class<Object>> getClasses()
{
return Collections.unmodifiableSet(classes);
1.2 +28 -13 jboss-seam/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HotDeploymentStrategy.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- HotDeploymentStrategy.java 14 Jan 2008 11:29:48 -0000 1.1
+++ HotDeploymentStrategy.java 14 Jan 2008 12:26:14 -0000 1.2
@@ -10,12 +10,16 @@
import org.jboss.seam.util.Reflections;
/**
+ * A deployment strategy for hot deployable Java Seam components
+ *
* @author Pete Muir
*
*/
public class HotDeploymentStrategy extends DeploymentStrategy
{
-
+ /**
+ * The default path at which hot deployable Seam components are placed
+ */
public static final String HOT_DEPLOYMENT_DIRECTORY_PATH = "WEB-INF/dev";
private ClassLoader hotDeployClassLoader;
@@ -24,6 +28,11 @@
private ComponentDeploymentHandler componentDeploymentHandler;
+ /**
+ * @param classLoader The parent classloader of the hot deployment classloader
+ * @param hotDeployDirectory The directory in which hot deployable Seam
+ * components are placed
+ */
public HotDeploymentStrategy(ClassLoader classLoader, File hotDeployDirectory)
{
initHotDeployClassLoader(classLoader, hotDeployDirectory);
@@ -50,16 +59,31 @@
}
}
+ /**
+ * Get all hot deployable paths
+ */
public File[] getHotDeploymentPaths()
{
return hotDeploymentPaths;
}
+ /**
+ * Return true if the component is from a hot deployment classloader
+ */
public boolean isFromHotDeployClassLoader(Class componentClass)
{
return componentClass.getClassLoader() == hotDeployClassLoader;
}
+ /**
+ * Dynamically instantiate a {@link HotDeploymentStrategy}
+ *
+ * Needed to prevent dependency on optional librarires
+ * @param className The strategy to use
+ * @param classLoader The classloader to use with this strategy
+ * @param hotDeployDirectory The directory which contains hot deployable
+ * Seam components
+ */
public static HotDeploymentStrategy createInstance(String className, ClassLoader classLoader, File hotDeployDirectory)
{
try
@@ -86,20 +110,11 @@
return null;
}
- @Override
- public ClassLoader getScannableClassLoader()
- {
- return getClassLoader();
- }
-
+ /**
+ * Get all Components which the strategy has scanned and handled
+ */
public Set<Class<Object>> getScannedComponentClasses()
{
return componentDeploymentHandler.getClasses();
}
-
- @Override
- public void scan()
- {
- getScanner().scanClassLoader();
- }
}
1.1 date: 2008/01/14 12:26:14; author: pmuir; state: Exp;jboss-seam/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java
Index: StandardDeploymentStrategy.java
===================================================================
package org.jboss.seam.deployment;
import java.util.Set;
/**
* The standard deployment strategy used with Seam, deploys non-hot-deployable
* Seam components and namespaces
*
* @author Pete Muir
*
*/
public class StandardDeploymentStrategy extends DeploymentStrategy
{
private ClassLoader classLoader;
public static final String[] RESOURCE_NAMES = {"seam.properties", "META-INF/seam.properties", "META-INF/components.xml"};
private ComponentDeploymentHandler componentDeploymentHandler;
private NamespaceDeploymentHandler namespaceDeploymentHandler;
/**
* @param classLoader The classloader used to load and handle resources
*/
public StandardDeploymentStrategy(ClassLoader classLoader)
{
this.classLoader = Thread.currentThread().getContextClassLoader();
componentDeploymentHandler = new ComponentDeploymentHandler();
getDeploymentHandlers().put(ComponentDeploymentHandler.NAME, componentDeploymentHandler);
namespaceDeploymentHandler = new NamespaceDeploymentHandler();
getDeploymentHandlers().put(NamespaceDeploymentHandler.NAME, namespaceDeploymentHandler);
}
@Override
public ClassLoader getClassLoader()
{
return classLoader;
}
@Override
public String[] getResourceNames()
{
return RESOURCE_NAMES;
}
/**
* Get all scanned and handled annotated components known to this strategy
*/
public Set<Class<Object>> getScannedComponentClasses()
{
return componentDeploymentHandler.getClasses();
}
/**
* Get all scanned and handled components.xml files
*/
public Set<String> getScannedComponentResources()
{
return componentDeploymentHandler.getResources();
}
/**
* Get all scanned and handled Seam namespaces
*/
public Set<Package> getScannedNamespaces()
{
return namespaceDeploymentHandler.getPackages();
}
}
More information about the jboss-cvs-commits
mailing list