[jboss-cvs] JBossAS SVN: r65079 - in projects/microcontainer/trunk: deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 5 06:21:34 EDT 2007
Author: alesj
Date: 2007-09-05 06:21:34 -0400 (Wed, 05 Sep 2007)
New Revision: 65079
Modified:
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
Log:
Refactoring buildManagedObjects in Parsing deployer.
Modified: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java 2007-09-05 09:37:29 UTC (rev 65078)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java 2007-09-05 10:21:34 UTC (rev 65079)
@@ -58,7 +58,7 @@
/**
* Set the deployment types associated with this deployment.
*
- * @param set of deployment type names deployers have identified
+ * @param types set of deployment type names deployers have identified
* in this deployment.
*/
void setTypes(Set<String> types);
Modified: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java 2007-09-05 09:37:29 UTC (rev 65078)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java 2007-09-05 10:21:34 UTC (rev 65079)
@@ -50,6 +50,7 @@
/** Include the deployment file */
private boolean includeDeploymentFile = false;
+
/** Should the ManagedObjects be created for the output metadata */
private boolean buildManagedObject = false;
@@ -263,26 +264,33 @@
protected abstract T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception;
/**
- *
+ * Build managed object.
+ *
+ * @param unit the deployment unit
+ * @param managedObjects map of managed objects
+ * @throws DeploymentException for any deployment exception
*/
- public void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects)
- throws DeploymentException
+ public void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects) throws DeploymentException
{
- if (buildManagedObject == false)
- return;
+ if (buildManagedObject)
+ {
+ // we can check for Serializable w/o searching for attachment
+ if (Serializable.class.isAssignableFrom(getOutput()) == false)
+ {
+ log.debug("Skipping ManagedObject since T(" + getOutput() + ") is not Serializable");
+ return;
+ }
- T deployment = unit.getAttachment(getOutput());
- if ((deployment instanceof Serializable) == false)
- log.debug("Skipping ManagedObject since T("+getOutput()+") is not Serializable");
-
- Serializable instance = (Serializable) deployment;
- if (deployment != null)
- {
- ManagedObjectFactory factory = ManagedObjectFactoryBuilder.create();
- ManagedObject mo = factory.initManagedObject(instance, null, null);
- if (mo != null)
- managedObjects.put(mo.getName(), mo);
+ T deployment = unit.getAttachment(getOutput());
+ if (deployment != null)
+ {
+ // must be Serializable - see getAttachment method contract (expectedType.cast(result))
+ Serializable instance = (Serializable) deployment;
+ ManagedObjectFactory factory = ManagedObjectFactoryBuilder.create();
+ ManagedObject mo = factory.initManagedObject(instance, null, null);
+ if (mo != null)
+ managedObjects.put(mo.getName(), mo);
+ }
}
}
-
}
More information about the jboss-cvs-commits
mailing list