diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-02 18:59:29 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-02 18:59:29 +0000 |
commit | 7dcd557051a188b97bcfbc998d2600f1c72fba0c (patch) | |
tree | 2dcb3d7f8944a3920a5af8921b9e3e59b194762a /sca-java-2.x/trunk/modules/host-webapp/src | |
parent | e421a202d29df1bbf3b4c5ab322ec31a5456f565 (diff) |
If WEB-INF/sca-contributions contains contributions then use it automatically without requireing users define it in the web.xml
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1041529 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/host-webapp/src')
-rw-r--r-- | sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java index 47fd852f57..0d905eb6eb 100644 --- a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java +++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java @@ -42,6 +42,7 @@ public class WebAppHelper { private static final String ROOT = "/"; // The prefix for the parameters in web.xml which configure the folders that contain SCA contributions private static final String CONTRIBUTIONS = "contributions"; + private static final String DEFAULT_CONTRIBUTIONS = "/WEB-INF/sca-contributions"; // The prefix for the parameters in web.xml which configure the individual SCA contributions private static final String CONTRIBUTION = "contribution"; private static final String NODE_CONFIGURATION = "node.configuration"; @@ -91,10 +92,14 @@ public class WebAppHelper { configuration = factory.loadConfiguration(url.openStream(), url); } else { configuration = factory.createNodeConfiguration(); + + + boolean explicitContributions = false; Enumeration<String> names = servletContext.getAttributeNames(); while (names.hasMoreElements()) { String name = names.nextElement(); if (name.equals(CONTRIBUTION) || name.startsWith(CONTRIBUTION + ".")) { + explicitContributions = true; // We need to have a way to select one or more folders within the webapp as the contributions String listOfValues = (String)servletContext.getAttribute(name); if (listOfValues != null) { @@ -107,6 +112,7 @@ public class WebAppHelper { } } } else if (name.equals(CONTRIBUTIONS) || name.startsWith(CONTRIBUTIONS + ".")) { + explicitContributions = true; String listOfValues = (String)servletContext.getAttribute(name); if (listOfValues != null) { for (String path : parse(listOfValues)) { @@ -126,14 +132,25 @@ public class WebAppHelper { } } - if (configuration.getContributions().isEmpty()) { + URL composite = getResource(servletContext, WEB_COMPOSITE); + if (configuration.getContributions().isEmpty() || (!explicitContributions && composite != null)) { // TODO: Which path should be the default root configuration.addContribution(getResource(servletContext, ROOT)); } - URL composite = getResource(servletContext, WEB_COMPOSITE); if (composite != null) { configuration.getContributions().get(0).addDeploymentComposite(composite); } + if (!explicitContributions) { + URL url = getResource(servletContext, DEFAULT_CONTRIBUTIONS); + if (url != null) { + File f = new File(url.toURI()); + if (f.isDirectory()) { + for (File n : f.listFiles()) { + configuration.addContribution(n.toURI().toURL()); + } + } + } + } String nodeURI = (String)servletContext.getAttribute(NODE_URI); if (nodeURI == null) { nodeURI = new File(servletContext.getRealPath(ROOT)).getName(); |