[jboss-cvs] JBossAS SVN: r65069 - in projects/microcontainer/trunk: deployers-client-spi/src/main/org/jboss/deployers/client/spi and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 4 17:55:26 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-09-04 17:55:26 -0400 (Tue, 04 Sep 2007)
New Revision: 65069
Modified:
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java
projects/microcontainer/trunk/deployers-client/src/main/org/jboss/deployers/client/plugins/deployment/AbstractDeployment.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java
Log:
Add types support to the client Deployment
Modified: projects/microcontainer/trunk/deployers-client/src/main/org/jboss/deployers/client/plugins/deployment/AbstractDeployment.java
===================================================================
--- projects/microcontainer/trunk/deployers-client/src/main/org/jboss/deployers/client/plugins/deployment/AbstractDeployment.java 2007-09-04 21:55:25 UTC (rev 65068)
+++ projects/microcontainer/trunk/deployers-client/src/main/org/jboss/deployers/client/plugins/deployment/AbstractDeployment.java 2007-09-04 21:55:26 UTC (rev 65069)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.util.Set;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.spi.attachments.helpers.PredeterminedManagedObjectAttachmentsImpl;
@@ -37,11 +38,13 @@
public class AbstractDeployment extends PredeterminedManagedObjectAttachmentsImpl implements Deployment
{
/** The serialVersionUID */
- private static final long serialVersionUID = -5443148970623594183L;
+ private static final long serialVersionUID = 2;
/** The name of the deployment */
private String name;
-
+ /** The types associated with the deployment */
+ private Set<String> types;
+
/**
* Create a new AbstractDeployment.
*/
@@ -93,6 +96,15 @@
this.name = name;
}
+ public Set<String> getTypes()
+ {
+ return types;
+ }
+ public void setTypes(Set<String> types)
+ {
+ this.types = types;
+ }
+
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
super.readExternal(in);
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-04 21:55:25 UTC (rev 65068)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java 2007-09-04 21:55:26 UTC (rev 65069)
@@ -22,6 +22,7 @@
package org.jboss.deployers.client.spi;
import java.io.Serializable;
+import java.util.Set;
import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
@@ -46,4 +47,19 @@
* @return the name
*/
String getSimpleName();
+
+ /**
+ * Get the deployment types associated with this deployment.
+ *
+ * @return set of deployment type names deployers have identified
+ * in this deployment.
+ */
+ Set<String> getTypes();
+ /**
+ * Set the deployment types associated with this deployment.
+ *
+ * @param set of deployment type names deployers have identified
+ * in this deployment.
+ */
+ void setTypes(Set<String> types);
}
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java 2007-09-04 21:55:25 UTC (rev 65068)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java 2007-09-04 21:55:26 UTC (rev 65069)
@@ -43,7 +43,12 @@
public class TestManagedObjectDeployer extends AbstractDeployer implements ManagedObjectCreator
{
public static TestAttachment lastAttachment;
-
+
+ public TestManagedObjectDeployer()
+ {
+ setType("TestManagedObjectDeployer");
+ }
+
public void deploy(DeploymentUnit unit) throws DeploymentException
{
lastAttachment = unit.getAttachment(TestAttachment.class);
@@ -53,6 +58,7 @@
lastAttachment.setProperty("string1", "initialString1");
lastAttachment.setProperty("string2", "initialString2");
unit.addAttachment(TestAttachment.class, lastAttachment);
+ unit.getTypes().add(getType());
}
}
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java 2007-09-04 21:55:25 UTC (rev 65068)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java 2007-09-04 21:55:26 UTC (rev 65069)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -80,7 +81,12 @@
Deployment context = createSimpleDeployment("deploy");
main.addDeployment(context);
main.process();
-
+
+ // Check the deployment types
+ HashSet<String> expectedTypes = new HashSet<String>();
+ expectedTypes.add("TestManagedObjectDeployer");
+ assertEquals(expectedTypes, context.getTypes());
+
// Check the default settings
assertNotNull(deployer.lastAttachment);
assertEquals("initialString1", deployer.lastAttachment.getProperty("string1"));
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-04 21:55:25 UTC (rev 65068)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java 2007-09-04 21:55:26 UTC (rev 65069)
@@ -21,17 +21,26 @@
*/
package org.jboss.deployers.spi.deployer.helpers;
+import java.io.Serializable;
+import java.util.Map;
+
import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
/**
- * AbstractParsingDeployerWithOutput.
+ * AbstractParsingDeployerWithOutput.
*
* @param <T> the type of output
* @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
* @version $Revision: 1.1 $
*/
public abstract class AbstractParsingDeployerWithOutput<T> extends AbstractParsingDeployer
+ implements ManagedObjectCreator
{
/** The metadata file name */
private String name;
@@ -41,6 +50,8 @@
/** Include the deployment file */
private boolean includeDeploymentFile = false;
+ /** Should the ManagedObjects be created for the output metadata */
+ private boolean buildManagedObject = false;
/**
* Create a new AbstractParsingDeployerWithOutput.
@@ -122,6 +133,16 @@
this.includeDeploymentFile = includeDeploymentFile;
}
+ public boolean isBuildManagedObject()
+ {
+ return buildManagedObject;
+ }
+
+ public void setBuildManagedObject(boolean buildManagedObject)
+ {
+ this.buildManagedObject = buildManagedObject;
+ }
+
/**
* A flag indicating whether createMetaData should execute a parse even if a non-null metadata value exists.
*
@@ -240,4 +261,28 @@
* @throws Exception for any error
*/
protected abstract T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception;
+
+ /**
+ *
+ */
+ public void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects)
+ throws DeploymentException
+ {
+ if (buildManagedObject == false)
+ 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);
+ }
+ }
+
}
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java 2007-09-04 21:55:25 UTC (rev 65068)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java 2007-09-04 21:55:26 UTC (rev 65069)
@@ -417,8 +417,9 @@
if (deployment == null)
throw new IllegalArgumentException("Null deployment");
this.deployment = deployment;
+ this.deployment.setTypes(getTypes());
}
-
+
public DeploymentUnit getDeploymentUnit()
{
if (unit == null)
More information about the jboss-cvs-commits
mailing list