[jboss-cvs] JBossAS SVN: r57425 - projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 4 13:12:38 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-10-04 13:12:35 -0400 (Wed, 04 Oct 2006)
New Revision: 57425
Modified:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXPDeployer.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/ObjectModelFactoryDeployer.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java
Log:
Expand the AbstractParsingDeployer to support propagation of an existing deployment type instance so that multiple deployers can incrementally build up the instance.
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java 2006-10-04 16:02:52 UTC (rev 57424)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java 2006-10-04 17:12:35 UTC (rev 57425)
@@ -28,7 +28,9 @@
import org.jboss.virtual.VirtualFile;
/**
- * AbstractParsingDeployer.
+ * AbstractParsingDeployer. Extends AbstractTypedDeployer to add a notion of obtaining an instance of the
+ * deploymentType by parsing a metadata file. Subclasses need to override
+ * parse(DeploymentUnit, VirtualFile) to define this behavior.
*
* @param <T> the expected type
* @author <a href="adrian at jboss.com">Adrian Brock</a>
@@ -51,8 +53,19 @@
{
return PARSER_DEPLOYER;
}
-
+
/**
+ * A flag indicating whether createMetaData should execute a parse even if a non-null metadata value exists.
+ *
+ * @return false if a parse should be performed only if there is no existing metadata value. True indicates
+ * that parse should be done regardless of an existing metadata value.
+ */
+ protected boolean allowsReparse()
+ {
+ return false;
+ }
+
+ /**
* Get some meta data
*
* @param unit the deployment unit
@@ -65,7 +78,7 @@
}
/**
- * Create some meta data
+ * Create some meta data. Calls createMetaData(unit, name, suffix, getDeploymentType().getName()).
*
* @param unit the deployment unit
* @param name the name
@@ -78,7 +91,8 @@
}
/**
- * Create some meta data
+ * Create some meta data. Invokes parse(unit, name, suffix) if there is not already a
+ * metadata
*
* @param unit the deployment unit
* @param name the name
@@ -90,16 +104,16 @@
{
// First see whether it already exists
T result = getMetaData(unit, key);
- if (result != null)
+ if (result != null && allowsReparse() == false)
return;
// Create it
try
{
if (suffix == null)
- result = parse(unit, name);
+ result = parse(unit, name, result);
else
- result = parse(unit, name, suffix);
+ result = parse(unit, name, suffix, result);
}
catch (Exception e)
{
@@ -122,14 +136,14 @@
* @return the metadata or null if it doesn't exist
* @throws Exception for any error
*/
- protected T parse(DeploymentUnit unit, String name) throws Exception
+ protected T parse(DeploymentUnit unit, String name, T root) throws Exception
{
// Try to find the metadata
VirtualFile file = unit.getMetaDataFile(name);
if (file == null)
return null;
- T result = parse(unit, file);
+ T result = parse(unit, file, root);
init(unit, result, file);
return result;
}
@@ -143,7 +157,7 @@
* @return the metadata or null if it doesn't exist
* @throws Exception for any error
*/
- protected T parse(DeploymentUnit unit, String name, String suffix) throws Exception
+ protected T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception
{
// Try to find the metadata
List<VirtualFile> files = unit.getMetaDataFiles(name, suffix);
@@ -156,7 +170,7 @@
VirtualFile file = files.get(0);
- T result = parse(unit, file);
+ T result = parse(unit, file, root);
init(unit, result, file);
return result;
}
@@ -169,7 +183,7 @@
* @return the metadata
* @throws Exception for any error
*/
- protected abstract T parse(DeploymentUnit unit, VirtualFile file) throws Exception;
+ protected abstract T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception;
/**
* Initialise the metadata
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXPDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXPDeployer.java 2006-10-04 16:02:52 UTC (rev 57424)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXPDeployer.java 2006-10-04 17:12:35 UTC (rev 57425)
@@ -142,7 +142,7 @@
* @return the metadata
* @throws Exception for any error
*/
- protected T parse(DeploymentUnit unit, VirtualFile file) throws Exception
+ protected T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception
{
Document document = doParse(unit, file);
return parse(unit, file, document);
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/ObjectModelFactoryDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/ObjectModelFactoryDeployer.java 2006-10-04 16:02:52 UTC (rev 57424)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/ObjectModelFactoryDeployer.java 2006-10-04 17:12:35 UTC (rev 57425)
@@ -61,7 +61,7 @@
* @return the metadata
* @throws Exception for any error
*/
- protected T parse(DeploymentUnit unit, VirtualFile file) throws Exception
+ protected T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception
{
if (file == null)
throw new IllegalArgumentException("Null file");
@@ -70,8 +70,7 @@
Object parsed = null;
try
{
- ObjectModelFactory factory = getObjectModelFactory();
- Object root = null;
+ ObjectModelFactory factory = getObjectModelFactory(root);
URL url = file.toURL();
parsed = unmarshaller.unmarshal(url.toString(), factory, root);
}
@@ -90,5 +89,5 @@
*
* @return the object model factory
*/
- protected abstract ObjectModelFactory getObjectModelFactory();
+ protected abstract ObjectModelFactory getObjectModelFactory(T root);
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java 2006-10-04 16:02:52 UTC (rev 57424)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java 2006-10-04 17:12:35 UTC (rev 57425)
@@ -65,7 +65,7 @@
* @return the metadata
* @throws Exception for any error
*/
- protected T parse(DeploymentUnit unit, VirtualFile file) throws Exception
+ protected T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception
{
if (file == null)
throw new IllegalArgumentException("Null file");
More information about the jboss-cvs-commits
mailing list