Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MODE-1784 - Added a <webapp/> element to the ModeShape AS7 subsystem …

…which allows any web application packaged under the "deployments" folder of the ModeShape main module, to be deployed by the subsystem. This replaces the previous "static" way of copying web applications directly from the kit in the servers "deployments" directory.
  • Loading branch information...
commit 6333ac26d8403e524949d4c470e2e9a7aca4010e 1 parent 4283931
@hchiorean hchiorean authored
Showing with 434 additions and 13 deletions.
  1. +3 −2 deploy/jbossas/kit/jboss-eap61/modules/system/layers/base/org/modeshape/main/module.xml
  2. +5 −0 deploy/jbossas/kit/jboss-eap61/standalone/configuration/standalone-modeshape.xml
  3. 0  deploy/jbossas/kit/jboss-eap61/standalone/deployments/modeshape-cmis.war.dodeploy
  4. 0  deploy/jbossas/kit/jboss-eap61/standalone/deployments/modeshape-rest.war.dodeploy
  5. 0  deploy/jbossas/kit/jboss-eap61/standalone/deployments/modeshape-webdav.war.dodeploy
  6. +118 −0 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/AddWebApp.java
  7. +3 −1 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/Attribute.java
  8. +1 −0  deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/Element.java
  9. +5 −0 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeExtension.java
  10. +42 −1 ...odeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeSubsystemXMLReader_1_0.java
  11. +24 −4 ...as/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeSubsystemXMLWriter.java
  12. +51 −0 ...bossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeWebAppResource.java
  13. +15 −0 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModelAttributes.java
  14. +4 −0 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModelKeys.java
  15. +67 −0 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveWebApp.java
  16. +38 −0 ...as/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/WebAppWriteAttributeHandler.java
  17. +8 −0 ...s/modeshape-jbossas-subsystem/src/main/resources/org/modeshape/jboss/subsystem/LocalDescriptions.properties
  18. +26 −1 deploy/jbossas/modeshape-jbossas-subsystem/src/main/resources/schema/modeshape_1_0.xsd
  19. +5 −0 ...sas/modeshape-jbossas-subsystem/src/test/java/org/modeshape/jboss/subsystem/ModeShapeConfigurationTest.java
  20. +9 −0 ...as/modeshape-jbossas-subsystem/src/test/resources/org/modeshape/jboss/subsystem/modeshape-webapp-config.xml
  21. +5 −0 ...ssas-integration-tests/src/main/resources/kit/jboss-eap61/standalone/configuration/standalone-modeshape.xml
  22. +2 −1  integration/modeshape-jbossas-kit-tests/pom.xml
  23. +3 −3 modeshape-assembly-descriptors/src/main/resources/assemblies/jbosseap-61-dist.xml
View
5 deploy/jbossas/kit/jboss-eap61/modules/system/layers/base/org/modeshape/main/module.xml
@@ -24,10 +24,11 @@
<module xmlns="urn:jboss:module:1.2" name="org.modeshape">
<resources>
<resource-root path="modeshape-jcr-${project.version}.jar"/>
- <resource-root path="conf"/>
- <resource-root path="res"/>
<resource-root path="modeshape-jbossas-subsystem-${project.version}.jar"/>
<resource-root path="modeshape-schematic-${project.version}.jar"/>
+ <resource-root path="conf"/>
+ <resource-root path="res"/>
+ <resource-root path="deployments"/>
</resources>
<dependencies>
View
5 deploy/jbossas/kit/jboss-eap61/standalone/configuration/standalone-modeshape.xml
@@ -205,6 +205,11 @@
</cache-container>
</subsystem>
<subsystem xmlns="urn:jboss:domain:modeshape:1.0">
+ <!--The list of web applications that is packaged inside the kit and should be deployed when the subsystem starts up-->
+ <webapp name="modeshape-rest.war"/>
+ <webapp name="modeshape-cmis.war"/>
+ <webapp name="modeshape-webdav.war"/>
+
<!-- A sample repository that uses the "sample" cache in the "modeshape" container. All content, binary values,
and indexes are stored within the server's data directory. This is the simplest way to configure a repository
that uses defaults for everything; feel free to change and specify other configuration options. -->
View
0  deploy/jbossas/kit/jboss-eap61/standalone/deployments/modeshape-cmis.war.dodeploy
No changes.
View
0  deploy/jbossas/kit/jboss-eap61/standalone/deployments/modeshape-rest.war.dodeploy
No changes.
View
0  deploy/jbossas/kit/jboss-eap61/standalone/deployments/modeshape-webdav.war.dodeploy
No changes.
View
118 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/AddWebApp.java
@@ -0,0 +1,118 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.jboss.subsystem;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.AttributeDefinition;
+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.descriptions.ModelDescriptionConstants;
+import org.jboss.as.controller.operations.common.Util;
+import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
+import org.jboss.dmr.ModelNode;
+import org.jboss.modules.Module;
+
+/**
+ * {@link AbstractAddStepHandler} which is triggered each time an <webapp/> element is found in the ModeShape subsystem.
+ *
+ * @author Horia Chiorean (hchiorea@redhat.com)
+ */
+class AddWebApp extends AbstractAddStepHandler {
+
+ static final AddWebApp INSTANCE = new AddWebApp();
+
+ @Override
+ protected void populateModel( OperationContext context,
+ ModelNode operation,
+ org.jboss.as.controller.registry.Resource resource ) throws OperationFailedException {
+ resource.getModel().setEmptyObject();
+
+ if (requiresRuntime(context)) {
+ boolean autoDeploy = attribute(context, resource.getModel(), ModelAttributes.AUTO_DEPLOY).asBoolean();
+ if (!autoDeploy) {
+ return;
+ }
+
+ ModelNode address = operation.require(ModelDescriptionConstants.OP_ADDR);
+ PathAddress pathAddress = PathAddress.pathAddress(address);
+ String webappName = pathAddress.getLastElement().getValue();
+ boolean exploded = attribute(context, resource.getModel(), ModelAttributes.EXPLODED).asBoolean();
+
+ PathAddress deploymentAddress = PathAddress.pathAddress(PathElement.pathElement(
+ ModelDescriptionConstants.DEPLOYMENT, webappName));
+ ModelNode op = Util.createOperation(ModelDescriptionConstants.ADD, deploymentAddress);
+ op.get(ModelDescriptionConstants.ENABLED).set(true);
+ op.get(ModelDescriptionConstants.PERSISTENT).set(false); // prevents writing this deployment out to standalone.xml
+
+ Module module = Module.forClass(getClass());
+ URL url = module.getExportedResource(webappName);
+ ModelNode contentItem = new ModelNode();
+
+ if (exploded) {
+ String urlString = null;
+ try {
+ urlString = new File(url.toURI()).getAbsolutePath();
+ } catch (URISyntaxException e) {
+ throw new OperationFailedException(e.getMessage(), e);
+ }
+ contentItem.get(ModelDescriptionConstants.PATH).set(urlString);
+ contentItem.get(ModelDescriptionConstants.ARCHIVE).set(false);
+ } else {
+ contentItem.set(ModelDescriptionConstants.URL).set(url.toExternalForm());
+ }
+
+ op.get(ModelDescriptionConstants.CONTENT).add(contentItem);
+
+ ImmutableManagementResourceRegistration rootResourceRegistration = context.getRootResourceRegistration();
+ OperationStepHandler handler = rootResourceRegistration.getOperationHandler(deploymentAddress,
+ ModelDescriptionConstants.ADD);
+ context.addStep(op, handler, OperationContext.Stage.MODEL);
+ }
+ }
+
+ private ModelNode attribute( OperationContext context,
+ ModelNode model,
+ AttributeDefinition defn ) throws OperationFailedException {
+ assert defn.getDefaultValue() != null && defn.getDefaultValue().isDefined();
+ return defn.resolveModelAttribute(context, model);
+ }
+
+ @Override
+ protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
+ // We overrode the code that calls this method
+ throw new UnsupportedOperationException();
+ }
+
+ protected boolean requiresRuntimeVerification() {
+ return false;
+ }
+
+}
View
4 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/Attribute.java
@@ -93,7 +93,9 @@
WORKSPACE_NAMES("workspace-names"),
CACHE_TTL_SECONDS("cacheTtlSeconds"),
QUERYABLE("queryable"),
- READONLY("readonly");
+ READONLY("readonly"),
+ EXPLODED("exploded"),
+ AUTO_DEPLOY("auto-deploy");
private final String name;
View
1  deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/Element.java
@@ -48,6 +48,7 @@
PROPERTY("property"),
RAM_INDEX_STORAGE("ram-index-storage"),
REPOSITORY("repository"),
+ WEBAPP("webapp"),
SEQUENCER("sequencer"),
SEQUENCERS("sequencers"),
TEXT_EXTRACTORS("text-extractors"),
View
5 .../jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeExtension.java
@@ -45,6 +45,7 @@
private static final String RESOURCE_NAME = ModeShapeExtension.class.getPackage().getName() + ".LocalDescriptions";
static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);
+ static final PathElement WEBAPP_PATH = PathElement.pathElement(ModelKeys.WEBAPP);
static final PathElement REPOSITORY_PATH = PathElement.pathElement(ModelKeys.REPOSITORY);
static final PathElement SEQUENCER_PATH = PathElement.pathElement(ModelKeys.SEQUENCER);
static final PathElement SOURCE_PATH = PathElement.pathElement(ModelKeys.SOURCE);
@@ -93,6 +94,10 @@ public void initialize( ExtensionContext context ) {
registration.registerXMLElementWriter(new ModeShapeSubsystemXMLWriter());
// ModeShape system, with children repositories.
final ManagementResourceRegistration modeShapeSubsystem = registration.registerSubsystemModel(ModeShapeRootResource.INSTANCE);
+
+ //Webapp submodel
+ modeShapeSubsystem.registerSubModel(ModeShapeWebAppResource.INSTANCE);
+
// Repository submodel
final ManagementResourceRegistration repositorySubmodel = modeShapeSubsystem.registerSubModel(ModeShapeRepositoryResource.INSTANCE);
View
43 ...shape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeSubsystemXMLReader_1_0.java
@@ -58,6 +58,7 @@ public void readElement( final XMLExtendedStreamReader reader,
requireNoAttributes(reader);
final List<ModelNode> repositories = new ArrayList<ModelNode>();
+ final List<ModelNode> webapps = new ArrayList<ModelNode>();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
if (reader.isStartElement()) {
@@ -69,6 +70,10 @@ public void readElement( final XMLExtendedStreamReader reader,
case REPOSITORY:
parseRepository(reader, subsystem, repositories);
break;
+ case WEBAPP: {
+ parseWebApp(reader, subsystem, webapps);
+ break;
+ }
default:
throw ParseUtils.unexpectedElement(reader);
}
@@ -79,8 +84,44 @@ public void readElement( final XMLExtendedStreamReader reader,
}
}
+ list.addAll(webapps);
list.addAll(repositories);
+ }
+ private void parseWebApp( final XMLExtendedStreamReader reader,
+ final ModelNode address,
+ final List<ModelNode> webapps ) throws XMLStreamException {
+ final ModelNode webappAddress = address.clone();
+ final ModelNode webapp = Util.getEmptyOperation(ModelDescriptionConstants.ADD, webappAddress);
+
+ String webappName = null;
+ for (int i = 0; i < reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ Attribute attribute = Attribute.forName(attrName);
+ switch (attribute) {
+ case NAME: {
+ webappName = attrValue;
+ webappAddress.add(ModelKeys.WEBAPP, webappName);
+ webappAddress.protect();
+ webapp.get(OP).set(ADD);
+ webapp.get(OP_ADDR).set(webappAddress);
+ webapps.add(webapp);
+ break;
+ }
+ case EXPLODED: {
+ ModelAttributes.EXPLODED.parseAndSetParameter(attrValue, webapp, reader);
+ break;
+ }
+ case AUTO_DEPLOY: {
+ ModelAttributes.AUTO_DEPLOY.parseAndSetParameter(attrValue, webapp, reader);
+ break;
+ }
+ default:
+ throw ParseUtils.unexpectedAttribute(reader, i);
+ }
+ }
+ requireNoElements(reader);
}
private void parseRepository( final XMLExtendedStreamReader reader,
@@ -99,7 +140,7 @@ private void parseRepository( final XMLExtendedStreamReader reader,
switch (attribute) {
case NAME:
repositoryName = attrValue;
- repositoryAddress.add("repository", attrValue); //$NON-NLS-1$
+ repositoryAddress.add(ModelKeys.REPOSITORY, attrValue); //$NON-NLS-1$
repositoryAddress.protect();
repository.get(OP).set(ADD);
repository.get(OP_ADDR).set(repositoryAddress);
View
28 ...modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeSubsystemXMLWriter.java
@@ -48,15 +48,35 @@ public void writeContent( XMLExtendedStreamWriter writer,
context.startSubsystemElement(Namespace.CURRENT.getUri(), false);
ModelNode model = context.getModelNode();
if (model.isDefined()) {
- for (Property entry : model.get(ModelKeys.REPOSITORY).asPropertyList()) {
- String repositoryName = entry.getName();
- ModelNode repository = entry.getValue();
- writeRepositoryConfiguration(writer, repository, repositoryName);
+ if (model.hasDefined(ModelKeys.REPOSITORY)) {
+ for (Property entry : model.get(ModelKeys.REPOSITORY).asPropertyList()) {
+ String repositoryName = entry.getName();
+ ModelNode repository = entry.getValue();
+ writeRepositoryConfiguration(writer, repository, repositoryName);
+ }
+ }
+
+ if (model.hasDefined(ModelKeys.WEBAPP)) {
+ for (Property entry : model.get(ModelKeys.WEBAPP).asPropertyList()) {
+ String webappName = entry.getName();
+ ModelNode webapp = entry.getValue();
+ writeWebAppConfiguration(writer, webapp, webappName);
+ }
}
}
writer.writeEndElement(); // End of subsystem element
}
+ private void writeWebAppConfiguration( XMLExtendedStreamWriter writer,
+ ModelNode webapp,
+ String repositoryName ) throws XMLStreamException {
+ writer.writeStartElement(Element.WEBAPP.getLocalName());
+ writer.writeAttribute(Attribute.NAME.getLocalName(), repositoryName);
+ ModelAttributes.EXPLODED.marshallAsAttribute(webapp, false, writer);
+ ModelAttributes.AUTO_DEPLOY.marshallAsAttribute(webapp, false, writer);
+ writer.writeEndElement();
+ }
+
private void writeRepositoryConfiguration( XMLExtendedStreamWriter writer,
ModelNode repository,
String repositoryName ) throws XMLStreamException {
View
51 ...sas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeWebAppResource.java
@@ -0,0 +1,51 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.jboss.subsystem;
+
+import org.jboss.as.controller.SimpleResourceDefinition;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
+
+/**
+ * {@link SimpleResourceDefinition} which defined the web app resource.
+ *
+ * @author Horia Chiorean (hchiorea@redhat.com)
+ */
+class ModeShapeWebAppResource extends SimpleResourceDefinition {
+
+ final static ModeShapeWebAppResource INSTANCE = new ModeShapeWebAppResource();
+
+ private ModeShapeWebAppResource() {
+ super(ModeShapeExtension.WEBAPP_PATH,
+ ModeShapeExtension.getResourceDescriptionResolver(ModelKeys.WEBAPP),
+ AddWebApp.INSTANCE,
+ RemoveWebApp.INSTANCE);
+ }
+
+ @Override
+ public void registerAttributes( ManagementResourceRegistration resourceRegistration ) {
+ super.registerAttributes(resourceRegistration);
+ WebAppWriteAttributeHandler.INSTANCE.registerAttributes(resourceRegistration);
+ }
+}
View
15 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModelAttributes.java
@@ -792,8 +792,23 @@ public void validateParameter( String parameterName,
FieldName.USE_ANONYMOUS_ON_FAILED_LOGINS)
.build();
+ public static final SimpleAttributeDefinition EXPLODED = new MappedAttributeDefinitionBuilder(ModelKeys.EXPLODED, ModelType.BOOLEAN)
+ .setXmlName(Attribute.EXPLODED.getLocalName())
+ .setAllowExpression(false)
+ .setAllowNull(true)
+ .setDefaultValue(new ModelNode().set(true))
+ .build();
+
+ public static final SimpleAttributeDefinition AUTO_DEPLOY = new MappedAttributeDefinitionBuilder(ModelKeys.AUTO_DEPLOY, ModelType.BOOLEAN)
+ .setXmlName(Attribute.AUTO_DEPLOY.getLocalName())
+ .setAllowExpression(false)
+ .setAllowNull(true)
+ .setDefaultValue(new ModelNode().set(true))
+ .build();
public static final AttributeDefinition[] SUBSYSTEM_ATTRIBUTES = {};
+ public static final AttributeDefinition[] WEBAPP_ATTRIBUTES = {EXPLODED, AUTO_DEPLOY};
+
public static final AttributeDefinition[] REPOSITORY_ATTRIBUTES = {CACHE_NAME, CACHE_CONTAINER, JNDI_NAME, ENABLE_MONITORING,
ENABLE_QUERIES, SECURITY_DOMAIN, ANONYMOUS_ROLES, ANONYMOUS_USERNAME, USE_ANONYMOUS_IF_AUTH_FAILED, NODE_TYPES,
DEFAULT_WORKSPACE, PREDEFINED_WORKSPACE_NAMES, ALLOW_WORKSPACE_CREATION, WORKSPACES_CACHE_CONTAINER,
View
4 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModelKeys.java
@@ -29,6 +29,7 @@
public class ModelKeys {
static final String REPOSITORY = "repository";
+ static final String WEBAPP = "webapp";
static final String ACCESS_TYPE = "access-type";
static final String ALLOW_WORKSPACE_CREATION = "allow-workspace-creation";
@@ -143,4 +144,7 @@
static final String CACHE_TTL_SECONDS = "cacheTtlSeconds";
static final String QUERYABLE = "queryable";
static final String READONLY = "readonly";
+
+ static final String EXPLODED = "exploded";
+ static final String AUTO_DEPLOY = "auto-deploy";
}
View
67 deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveWebApp.java
@@ -0,0 +1,67 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.jboss.subsystem;
+
+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.descriptions.ModelDescriptionConstants;
+import org.jboss.as.controller.operations.common.Util;
+import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * {@link org.jboss.as.controller.AbstractRemoveStepHandler} which is triggered each time an <webapp/> element is removed from the ModeShape subsystem.
+ *
+ * @author Horia Chiorean (hchiorea@redhat.com)
+ */
+class RemoveWebApp extends AbstractRemoveStepHandler {
+
+ static final RemoveWebApp INSTANCE = new RemoveWebApp();
+
+ @Override
+ protected void performRemove( OperationContext context,
+ ModelNode operation,
+ ModelNode model ) throws OperationFailedException {
+
+ if (requiresRuntime(context)) {
+ ModelNode address = operation.require(ModelDescriptionConstants.OP_ADDR);
+ PathAddress pathAddress = PathAddress.pathAddress(address);
+ String webappName = pathAddress.getLastElement().getValue();
+
+ PathAddress deploymentAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.DEPLOYMENT, webappName));
+ ModelNode op = Util.createOperation(ModelDescriptionConstants.DEPLOYMENT, deploymentAddress);
+
+ ImmutableManagementResourceRegistration rootResourceRegistration = context.getRootResourceRegistration();
+ OperationStepHandler handler = rootResourceRegistration.getOperationHandler(deploymentAddress, ModelDescriptionConstants.REMOVE);
+ context.addStep(op, handler, OperationContext.Stage.MODEL);
+ }
+
+ super.performRemove(context, operation, model);
+ }
+}
View
38 ...modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/WebAppWriteAttributeHandler.java
@@ -0,0 +1,38 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.jboss.subsystem;
+
+/**
+ * {@link AbstractRepositoryConfigWriteAttributeHandler} implementation which exposes the <webapp/> attributes.
+ *
+ * @author Horia Chiorean (hchiorea@redhat.com)
+ */
+class WebAppWriteAttributeHandler extends AbstractRepositoryConfigWriteAttributeHandler {
+ static final WebAppWriteAttributeHandler INSTANCE = new WebAppWriteAttributeHandler();
+
+ private WebAppWriteAttributeHandler() {
+ super(ModelAttributes.WEBAPP_ATTRIBUTES);
+ }
+}
View
8 ...odeshape-jbossas-subsystem/src/main/resources/org/modeshape/jboss/subsystem/LocalDescriptions.properties
@@ -39,6 +39,14 @@ modeshape=The configuration of the ModeShape subsystem
modeshape.add = Add the ModeShape subsystem
modeshape.remove = Remove the ModeShape subsystem
+#Webapps
+modeshape.webapp = ModeShape web application
+modeshape.webapp.add = Deploy a ModeShape web application
+modeshape.webapp.remove = Undeploy a ModeShape web application
+modeshape.webapp.name = The name of the web application (as located under the modeshape main module /deployments)
+modeshape.webapp.exploded = Indicates if a web application is packaged exploded or nor
+modeshape.webapp.auto-deploy = Indicates if the web application should be auto deployed at subsystem startup or not
+
# Repository
modeshape.repository = ModeShape repository
modeshape.repository.add = Add ModeShape repositories
View
27 deploy/jbossas/modeshape-jbossas-subsystem/src/main/resources/schema/modeshape_1_0.xsd
@@ -15,14 +15,39 @@
<xs:complexType name="subsystem">
<xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="webapp" type="webapp">
+ <xs:annotation>
+ <xs:documentation>Defines an embedded web application.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="repository" type="repository">
<xs:annotation>
- <xs:documentation>Defines an embedded cache container.</xs:documentation>
+ <xs:documentation>Defines an embedded repository.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:complexType>
+ <xs:complexType name="webapp">
+ <xs:attribute name="name" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>The name of the web application that is located in the ModeShape's main module, under the deployments directory</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="exploded" type="xs:boolean" use="optional" default="true">
+ <xs:annotation>
+ <xs:documentation>Indicates if the web application is exploded or not</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="auto-deploy" type="xs:boolean" use="optional" default="true">
+ <xs:annotation>
+ <xs:documentation>Indicates if the web application should be auto deployed when the ModeShape subsystem starts up</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+
<xs:complexType name="repository">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
View
5 .../modeshape-jbossas-subsystem/src/test/java/org/modeshape/jboss/subsystem/ModeShapeConfigurationTest.java
@@ -120,6 +120,11 @@ public void testOutputPersistenceOfConfigurationWithCustomIndexRebuildOptions()
parse(readResource("modeshape-index-rebuilding-config.xml"));
}
+ @Test
+ public void testOutputPersistenceOfConfigurationWithWebapps() throws Exception {
+ parse(readResource("modeshape-webapp-config.xml"));
+ }
+
/* // todo replace with dmr format not json
@Test
public void testOutputPersistence() throws Exception {
View
9 ...modeshape-jbossas-subsystem/src/test/resources/org/modeshape/jboss/subsystem/modeshape-webapp-config.xml
@@ -0,0 +1,9 @@
+<subsystem xmlns="urn:jboss:domain:modeshape:1.0">
+ <webapp name="app1"/>
+ <webapp name="app2" exploded="true" auto-deploy="true"/>
+ <webapp name="app3" exploded="false" auto-deploy="false"/>
+ <repository name="sample" />
+</subsystem>
+
+
+
View
5 ...s-integration-tests/src/main/resources/kit/jboss-eap61/standalone/configuration/standalone-modeshape.xml
@@ -274,6 +274,11 @@
</cache-container>
</subsystem>
<subsystem xmlns="urn:jboss:domain:modeshape:1.0">
+ <!--The list of web applications that is packaged inside the kit and should be deployed when the subsystem starts up-->
+ <webapp name="modeshape-rest.war"/>
+ <webapp name="modeshape-cmis.war"/>
+ <webapp name="modeshape-webdav.war"/>
+
<!-- A sample repository that uses the "sample" cache in the "modeshape" container. All content, binary values,
and indexes are stored within the server's data directory. This is the simplest way to configure a repository
that uses defaults for everything; feel free to change and specify other configuration options. -->
View
3  integration/modeshape-jbossas-kit-tests/pom.xml
@@ -66,7 +66,8 @@
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
- <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
<scope>test</scope>
</dependency>
View
6 modeshape-assembly-descriptors/src/main/resources/assemblies/jbosseap-61-dist.xml
@@ -39,19 +39,19 @@
<!-- Deployment for the ModeShape RESTful service WAR (as an exploded directory) -->
<fileSet>
<directory>../deploy/jbossas/modeshape-jbossas-web-rest-war/target/modeshape-jbossas-web-rest-war-${project.version}</directory>
- <outputDirectory>standalone/deployments/modeshape-rest.war</outputDirectory>
+ <outputDirectory>modules/system/layers/base/org/modeshape/main/deployments/modeshape-rest.war</outputDirectory>
</fileSet>
<!-- Deployment for the ModeShape WebDAV service WAR (as an exploded directory) -->
<fileSet>
<directory>../deploy/jbossas/modeshape-jbossas-web-webdav-war/target/modeshape-jbossas-web-webdav-war-${project.version}</directory>
- <outputDirectory>standalone/deployments/modeshape-webdav.war</outputDirectory>
+ <outputDirectory>modules/system/layers/base/org/modeshape/main/deployments/modeshape-webdav.war</outputDirectory>
</fileSet>
<!-- Deployment for the ModeShape CMIS service WAR (as an exploded directory) -->
<fileSet>
<directory>../deploy/jbossas/modeshape-jbossas-cmis-war/target/modeshape-jbossas-cmis-war-${project.version}</directory>
- <outputDirectory>standalone/deployments/modeshape-cmis.war</outputDirectory>
+ <outputDirectory>modules/system/layers/base/org/modeshape/main/deployments/modeshape-cmis.war</outputDirectory>
</fileSet>
</fileSets>
Please sign in to comment.
Something went wrong with that request. Please try again.