.classpath
| 5
modules/enterprise/server/pom.xml
| 1
modules/enterprise/server/startup-subsystem/pom.xml
| 123 +++++++
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java
| 158 ++++++++++
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java
| 95 ++++++
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemDefinition.java
| 48 +++
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemRemove.java
| 62 +++
modules/enterprise/server/startup-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension
| 1
modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml
| 27 +
modules/enterprise/server/startup-subsystem/src/main/resources/org/rhq/enterprise/startup/LocalDescriptions.properties
| 3
modules/enterprise/server/startup-subsystem/src/main/resources/schema/rhq-startup-subsystem.xsd
| 25 +
modules/enterprise/server/startup-subsystem/src/main/scripts/module-assembly.xml
| 37 ++
modules/enterprise/server/startup-subsystem/src/test/java/org/rhq/enterprise/startup/SubsystemXmlParsingTest.java
| 66 ++++
pom.xml
| 35 ++
14 files changed, 686 insertions(+)
New commits:
commit 0af8d0ac510656b288089f11415d2d0ff0b00d1e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Nov 1 16:05:57 2012 -0400
introduce a new "startup-subsystem" extension module for AS7. This currently
is not used, but will eventually be the mechanism by which the ear will be deployed.
diff --git a/.classpath b/.classpath
index d8ecdc6..1c3a946 100644
--- a/.classpath
+++ b/.classpath
@@ -65,6 +65,8 @@
<classpathentry kind="src"
path="modules/enterprise/server/sars/agent-sar/src/main/java"/>
<classpathentry kind="src"
path="modules/enterprise/server/safe-invoker/src/main/java"/>
<classpathentry kind="src"
path="modules/enterprise/server/safe-invoker/src/test/java"/>
+ <classpathentry kind="src"
path="modules/enterprise/server/startup-subsystem/src/main/java"/>
+ <classpathentry kind="src"
path="modules/enterprise/server/startup-subsystem/src/test/java"/>
<classpathentry kind="src"
path="modules/enterprise/server/container-lib/src/main/java"/>
<classpathentry kind="src"
path="modules/enterprise/server/plugins/ant-bundle/src/main/java"/>
<classpathentry kind="src"
path="modules/enterprise/server/plugins/filetemplate-bundle/src/main/java"/>
@@ -287,6 +289,9 @@
<classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/jboss-dmr/1.1.1.Final/jboss-dmr-1.1.1.Final.jar"/>
<classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/as/jboss-as-naming/7.1.1.Final/jboss-as-naming-7.1.1.Final.jar"/>
<classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/as/jboss-as-server/7.1.1.Final/jboss-as-server-7.1.1.Final.jar"/>
+ <classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/staxmapper/1.1.0.Final/staxmapper-1.1.0.Final.jar"/>
+ <classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/modules/jboss-modules/1.1.1.GA/jboss-modules-1.1.1.GA.jar"/>
+ <classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/as/jboss-as-subsystem-test/7.1.1.Final/jboss-as-subsystem-test-7.1.1.Final.jar"/>
<classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/as/jboss-as-controller/7.1.1.Final/jboss-as-controller-7.1.1.Final.jar"/>
<classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/as/jboss-as-controller-client/7.1.1.Final/jboss-as-controller-client-7.1.1.Final.jar"/>
<classpathentry exported="true" kind="var"
path="M2_REPO/org/jboss/resteasy/resteasy-links/2.3.2.Final/resteasy-links-2.3.2.Final.jar"/>
diff --git a/modules/enterprise/server/pom.xml b/modules/enterprise/server/pom.xml
index bd3e77b..db001bd 100644
--- a/modules/enterprise/server/pom.xml
+++ b/modules/enterprise/server/pom.xml
@@ -30,6 +30,7 @@
<module>sars</module>
<module>plugins</module>
<module>ear</module>
+ <module>startup-subsystem</module>
<module>safe-invoker</module>
<module>client-api</module>
<module>itests</module>
diff --git a/modules/enterprise/server/startup-subsystem/pom.xml
b/modules/enterprise/server/startup-subsystem/pom.xml
new file mode 100644
index 0000000..2a5df22
--- /dev/null
+++ b/modules/enterprise/server/startup-subsystem/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-parent</artifactId>
+ <version>4.6.0-SNAPSHOT</version>
+ <relativePath>../../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>rhq-enterprise-server-startup-subsystem</artifactId>
+
+ <name>RHQ Server Startup AS7 Subsystem</name>
+
+ <properties>
+ <!-- this is used to replace the variable in module.xml -->
+ <moduleName>${project.groupId}.${project.artifactId}</moduleName>
+ </properties>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-ear</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.rhq</groupId>
+
<artifactId>rhq-enterprise-server-ear</artifactId>
+ <type>ear</type>
+ <destFileName>rhq.ear</destFileName>
+ </artifactItem>
+ </artifactItems>
+
<outputDirectory>${project.build.directory}/deployments</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+
<descriptor>src/main/scripts/module-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>module-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.modules</groupId>
+ <artifactId>jboss-modules</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>staxmapper</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-ee</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- our startup subsystem will be deploying this -->
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-ear</artifactId>
+ <version>${project.version}</version>
+ <type>ear</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- test deps -->
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-subsystem-test</artifactId>
+ <version>${jboss.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java
new file mode 100644
index 0000000..5354e7e
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java
@@ -0,0 +1,158 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.startup;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIBE;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
+
+import java.util.List;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+
+import org.jboss.as.controller.Extension;
+import org.jboss.as.controller.ExtensionContext;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.SubsystemRegistration;
+import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
+import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
+import org.jboss.as.controller.parsing.ExtensionParsingContext;
+import org.jboss.as.controller.parsing.ParseUtils;
+import org.jboss.as.controller.persistence.SubsystemMarshallingContext;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.dmr.ModelNode;
+import org.jboss.staxmapper.XMLElementReader;
+import org.jboss.staxmapper.XMLElementWriter;
+import org.jboss.staxmapper.XMLExtendedStreamReader;
+import org.jboss.staxmapper.XMLExtendedStreamWriter;
+
+/**
+ * A JBoss AS7 subsystem extension that starts up the RHQ deployment applications.
+ *
+ * @author Ian Springer
+ * @author John Mazzitelli
+ */
+
+public class StartupExtension implements Extension {
+
+ // The namespace used for the subsystem XML element
+ public static final String NAMESPACE = "urn:org.rhq:startup:1.0";
+ // The name of our subsystem within the model
+ public static final String SUBSYSTEM_NAME = "rhq-startup";
+ // The path of our subsystem within the model
+ static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM,
SUBSYSTEM_NAME);
+
+ // the deployments we are managing
+ static final String DEPLOYMENT_APP_EAR = "rhq.ear";
+
+ // our management API version
+ private static final int API_MAJOR_VERSION = 1;
+ private static final int API_MINOR_VERSION = 0;
+
+ // location in the classloader of the description messages
+ private static final String RESOURCE_NAME =
StartupExtension.class.getPackage().getName() + ".LocalDescriptions";
+
+ // used to read and write the XML of our subsystem config
+ private static final StartupSubsystemParser parser = new StartupSubsystemParser();
+
+ static StandardResourceDescriptionResolver getResourceDescriptionResolver(final
String... keyPrefix) {
+ StringBuilder prefix = new StringBuilder(SUBSYSTEM_NAME);
+ for (String kp : keyPrefix) {
+ prefix.append('.').append(kp);
+ }
+ return new StandardResourceDescriptionResolver(prefix.toString(), RESOURCE_NAME,
+ StartupExtension.class.getClassLoader(), true, false);
+ }
+
+ @Override
+ public void initializeParsers(ExtensionParsingContext context) {
+ context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE, parser);
+ }
+
+ @Override
+ public void initialize(ExtensionContext context) {
+ // register subsystem with its model version
+ final SubsystemRegistration subsystem;
+ subsystem = context.registerSubsystem(SUBSYSTEM_NAME, API_MAJOR_VERSION,
API_MINOR_VERSION);
+
+ // register subsystem model with subsystem definition that defines all attributes
and operations
+ final ManagementResourceRegistration registration;
+ registration =
subsystem.registerSubsystemModel(StartupSubsystemDefinition.INSTANCE);
+
+ // register describe operation
+ registration.registerOperationHandler(DESCRIBE,
GenericSubsystemDescribeHandler.INSTANCE,
+ GenericSubsystemDescribeHandler.INSTANCE, false,
OperationEntry.EntryType.PRIVATE);
+
+ // register the object that persists our subsystem XML config
+ subsystem.registerXMLElementWriter(parser);
+ }
+
+ /**
+ * The subsystem reader/writer, which uses STAX to read and write the subsystem XML.
+ */
+ private static class StartupSubsystemParser implements XMLStreamConstants,
XMLElementReader<List<ModelNode>>,
+ XMLElementWriter<SubsystemMarshallingContext> {
+
+ @Override
+ public void readElement(XMLExtendedStreamReader reader, List<ModelNode>
list) throws XMLStreamException {
+ // Parse the 'subsystem' element...
+ ParseUtils.requireNoAttributes(reader);
+
+ // (I think we are required to add this)
+ list.add(createAddSubsystemOperation());
+
+ // // Read the child elements
+ // while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
+ // if (reader.getLocalName().equals("some-xml-element-name"))
{
+ // status = reader.getElementText();
+ // } else {
+ // throw ParseUtils.unexpectedElement(reader);
+ // }
+ // }
+ ParseUtils.requireNoContent(reader);
+
+ return;
+ }
+
+ private static ModelNode createAddSubsystemOperation() {
+ final ModelNode subsystem = new ModelNode();
+ subsystem.get(OP).set(ADD);
+ subsystem.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME);
+ return subsystem;
+ }
+
+ @Override
+ public void writeContent(XMLExtendedStreamWriter writer,
SubsystemMarshallingContext context) throws XMLStreamException {
+ //TODO seems to be a problem with empty elements
+ //context.startSubsystemElement(StartupExtension.NAMESPACE, true); //
<subsystem/>
+ context.startSubsystemElement(StartupExtension.NAMESPACE, false); //
<subsystem>
+
+ // writer.writeStartElement("some-xml-element-name"); //
<xml-element-name>
+ // writer.writeCharacters(something);
+ // writer.writeEndElement(); // </xml-element-name>
+
+ writer.writeEndElement(); // </subsystem>
+ }
+ }
+
+}
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java
new file mode 100644
index 0000000..c3f28ed
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.startup;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONTENT;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ENABLED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PERSISTENT;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL;
+
+import java.net.URL;
+
+import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.OperationStepHandler;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.operations.common.Util;
+import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
+import org.jboss.as.controller.registry.Resource;
+import org.jboss.dmr.ModelNode;
+import org.jboss.modules.Module;
+
+/**
+ * Handler responsible for adding the subsystem resource to the model
+ *
+ * @author John Mazzitelli
+ */
+class StartupSubsystemAdd extends AbstractAddStepHandler {
+
+ static final StartupSubsystemAdd INSTANCE = new StartupSubsystemAdd();
+
+ @Override
+ protected void populateModel(OperationContext context, ModelNode operation, Resource
resource)
+ throws OperationFailedException {
+
+ try {
+ if (requiresRuntime(context)) { // only add the step if we are going to
actually deploy the ear
+ PathAddress deploymentAddress =
PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,
+ StartupExtension.DEPLOYMENT_APP_EAR));
+ ModelNode op = Util.getEmptyOperation(ADD,
deploymentAddress.toModelNode());
+ op.get(ENABLED).set(true);
+ op.get(PERSISTENT).set(false); // prevents writing this deployment out to
standalone.xml
+
+ Module module = Module.forClass(getClass());
+
+ URL url =
module.getExportedResource(StartupExtension.DEPLOYMENT_APP_EAR);
+ String urlString = url.toExternalForm();
+
+ ModelNode contentItem = new ModelNode();
+ contentItem.get(URL).set(urlString);
+
+ op.get(CONTENT).add(contentItem);
+
+ ImmutableManagementResourceRegistration rootResourceRegistration;
+ rootResourceRegistration = context.getRootResourceRegistration();
+ OperationStepHandler handler =
rootResourceRegistration.getOperationHandler(deploymentAddress, ADD);
+
+ context.addStep(op, handler, OperationContext.Stage.MODEL);
+ return;
+ }
+ } catch (Exception e) {
+ throw new OperationFailedException("The RHQ EAR failed to be
deployed", e);
+ }
+ }
+
+ @Override
+ protected void populateModel(ModelNode operation, ModelNode model) throws
OperationFailedException {
+ // We overrode the code that calls this method
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected boolean requiresRuntimeVerification() {
+ return false;
+ }
+}
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemDefinition.java
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemDefinition.java
new file mode 100644
index 0000000..392fea2
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemDefinition.java
@@ -0,0 +1,48 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.startup;
+
+import org.jboss.as.controller.SimpleResourceDefinition;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
+
+/**
+ * Definition of the rhq-startup resource.
+ *
+ * @author Ian Springer
+ * @author John Mazzitelli
+ */
+public class StartupSubsystemDefinition extends SimpleResourceDefinition {
+
+ public static final StartupSubsystemDefinition INSTANCE = new
StartupSubsystemDefinition();
+
+ private StartupSubsystemDefinition() {
+ super(StartupExtension.SUBSYSTEM_PATH,
StartupExtension.getResourceDescriptionResolver(),
+ StartupSubsystemAdd.INSTANCE, StartupSubsystemRemove.INSTANCE);
+ }
+
+ @Override
+ public void registerOperations(ManagementResourceRegistration resourceRegistration)
{
+ super.registerOperations(resourceRegistration);
+ }
+
+ @Override
+ public void registerAttributes(ManagementResourceRegistration resourceRegistration)
{
+ super.registerAttributes(resourceRegistration);
+ }
+}
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemRemove.java
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemRemove.java
new file mode 100644
index 0000000..2595547
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemRemove.java
@@ -0,0 +1,62 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.startup;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
+
+import org.jboss.as.controller.AbstractRemoveStepHandler;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.OperationStepHandler;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.operations.common.Util;
+import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * Handler responsible for removing the deployments.
+ *
+ * @author John Mazzitelli
+ */
+class StartupSubsystemRemove extends AbstractRemoveStepHandler {
+
+ static final StartupSubsystemRemove INSTANCE = new StartupSubsystemRemove();
+
+ private StartupSubsystemRemove() {
+ }
+
+ @Override
+ protected void performRemove(OperationContext context, ModelNode operation, ModelNode
model)
+ throws OperationFailedException {
+
+ // Add a step to remove the the deployments
+ if (requiresRuntime(context)) { // only add the step if we are going to actually
undeploy the ear
+ PathAddress deploymentAddress =
PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,
+ StartupExtension.DEPLOYMENT_APP_EAR));
+ ModelNode op = Util.getEmptyOperation(REMOVE,
deploymentAddress.toModelNode());
+ ImmutableManagementResourceRegistration rootResourceRegistration =
context.getRootResourceRegistration();
+ OperationStepHandler handler =
rootResourceRegistration.getOperationHandler(deploymentAddress, REMOVE);
+ context.addStep(op, handler, OperationContext.Stage.MODEL);
+ }
+ super.performRemove(context, operation, model);
+ }
+
+}
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension
b/modules/enterprise/server/startup-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension
new file mode 100644
index 0000000..9254be7
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension
@@ -0,0 +1 @@
+org.rhq.enterprise.startup.StartupExtension
\ No newline at end of file
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml
b/modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml
new file mode 100644
index 0000000..307029d
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<module xmlns="urn:jboss:module:1.0" name="${moduleName}">
+
+ <resources>
+ <resource-root path="${project.build.finalName}.jar"/>
+ <resource-root path="deployments"/>
+ </resources>
+
+ <dependencies>
+ <!-- modules required by any subsystem -->
+ <module name="javax.api"/>
+ <module name="org.jboss.staxmapper"/>
+ <module name="org.jboss.as.controller"/>
+ <module name="org.jboss.as.server"/>
+ <module name="org.jboss.modules"/>
+ <module name="org.jboss.msc"/>
+ <module name="org.jboss.logging"/>
+ <module name="org.jboss.vfs"/>
+
+ <!-- additional modules that this subsystem depends on -->
+ <module name="org.jboss.metadata"/>
+ <module name="org.jboss.as.ee"/>
+ <module name="org.jboss.as.web"/>
+ </dependencies>
+
+</module>
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/resources/org/rhq/enterprise/startup/LocalDescriptions.properties
b/modules/enterprise/server/startup-subsystem/src/main/resources/org/rhq/enterprise/startup/LocalDescriptions.properties
new file mode 100644
index 0000000..b9179ba
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/resources/org/rhq/enterprise/startup/LocalDescriptions.properties
@@ -0,0 +1,3 @@
+rhq-startup=RHQ Startup Subsystem
+rhq-startup.add=Operation Adds subsystem
+rhq-startup.remove=Operation Removes subsystem
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/resources/schema/rhq-startup-subsystem.xsd
b/modules/enterprise/server/startup-subsystem/src/main/resources/schema/rhq-startup-subsystem.xsd
new file mode 100644
index 0000000..d067aca
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/main/resources/schema/rhq-startup-subsystem.xsd
@@ -0,0 +1,25 @@
+<xsd:schema
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:org.rhq:startup:1.0"
+ xmlns="urn:org.rhq:startup:1.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <!-- The subsystem root element -->
+ <xsd:element name="subsystem" type="subsystemType"/>
+
+ <xsd:complexType name="subsystemType">
+ <!--
+ <xsd:sequence>
+ <xsd:element name="status" type="xsd:string"
maxOccurs="1" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Indicates the status of the deployment.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ -->
+ </xsd:complexType>
+</xsd:schema>
diff --git
a/modules/enterprise/server/startup-subsystem/src/main/scripts/module-assembly.xml
b/modules/enterprise/server/startup-subsystem/src/main/scripts/module-assembly.xml
new file mode 100644
index 0000000..cca4581
--- /dev/null
+++ b/modules/enterprise/server/startup-subsystem/src/main/scripts/module-assembly.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<assembly>
+ <id>module-assembly</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <baseDirectory>${project.build.finalName}-module</baseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.outputDirectory}/module</directory>
+ <outputDirectory>/org/rhq/${artifactId}</outputDirectory>
+ <includes>
+ <include>main/module.xml</include>
+ </includes>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>/org/rhq/${artifactId}/main</outputDirectory>
+ <includes>
+ <include>${project.build.finalName}.jar</include>
+ </includes>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}/deployments</directory>
+
<outputDirectory>/org/rhq/${artifactId}/main/deployments</outputDirectory>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
+ </fileSet>
+ </fileSets>
+</assembly>
+
diff --git
a/modules/enterprise/server/startup-subsystem/src/test/java/org/rhq/enterprise/startup/SubsystemXmlParsingTest.java
b/modules/enterprise/server/startup-subsystem/src/test/java/org/rhq/enterprise/startup/SubsystemXmlParsingTest.java
new file mode 100644
index 0000000..497810e
--- /dev/null
+++
b/modules/enterprise/server/startup-subsystem/src/test/java/org/rhq/enterprise/startup/SubsystemXmlParsingTest.java
@@ -0,0 +1,66 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.startup;
+
+import java.io.IOException;
+
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
+
+/**
+ * Test for parsing of the subsystem XML.
+ *
+ * @author Ian Springer
+ * @author John Mazzitelli
+ */
+@Test(enabled = false)
+// TODO: can't get the XML test to pass, but I can't see why it fails
+public class SubsystemXmlParsingTest extends AbstractSubsystemBaseTest {
+
+ public SubsystemXmlParsingTest() {
+ super(StartupExtension.SUBSYSTEM_NAME, new StartupExtension());
+ }
+
+ @Override
+ @BeforeTest
+ public void initializeParser() throws Exception {
+ super.initializeParser();
+ }
+
+ @Override
+ public void testSubsystem() throws Exception {
+ super.testSubsystem();
+ }
+
+ @Override
+ @AfterTest
+ public void cleanup() throws Exception {
+ super.cleanup();
+ }
+
+ @Override
+ protected String getSubsystemXml() throws IOException {
+ return "<subsystem xmlns=\"" + StartupExtension.NAMESPACE +
"\">" //
+ + "</subsystem>";
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 7b33a1a..627dc57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,6 +91,9 @@
<jboss-transaction-api.version>1.0.0.Final</jboss-transaction-api.version>
<picketbox.version>4.0.7.Final</picketbox.version>
<resteasy.version>2.3.2.Final</resteasy.version>
+ <jboss-staxmapper.version>1.1.0.Final</jboss-staxmapper.version>
+ <jboss-modules.version>1.1.1.GA</jboss-modules.version>
+ <jboss-dmr.version>1.1.1.Final</jboss-dmr.version>
<!-- Not Provided - some of these are needed by the agent -->
<jboss-annotations.version>4.2.3.GA</jboss-annotations.version>
@@ -326,6 +329,32 @@
<version>${jboss-jts.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.modules</groupId>
+ <artifactId>jboss-modules</artifactId>
+ <version>${jboss-modules.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-dmr</artifactId>
+ <version>${jboss-dmr.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller</artifactId>
+ <version>${jboss.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <version>${jboss.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-ee</artifactId>
+ <version>${jboss.version}</version>
+ </dependency>
+
<!-- see BZ-820629 and CVE-2009-2625 for why this is needed -->
<dependency>
<groupId>xerces</groupId>
@@ -545,6 +574,12 @@
</dependency>
<dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>staxmapper</artifactId>
+ <version>${jboss-staxmapper.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.picketbox</groupId>
<artifactId>picketbox</artifactId>
<version>${picketbox.version}</version>