Return-Path: Delivered-To: apmail-tuscany-commits-archive@www.apache.org Received: (qmail 38170 invoked from network); 2 Dec 2010 19:01:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Dec 2010 19:01:05 -0000 Received: (qmail 4156 invoked by uid 500); 2 Dec 2010 19:01:05 -0000 Delivered-To: apmail-tuscany-commits-archive@tuscany.apache.org Received: (qmail 4092 invoked by uid 500); 2 Dec 2010 19:01:04 -0000 Mailing-List: contact commits-help@tuscany.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tuscany.apache.org Delivered-To: mailing list commits@tuscany.apache.org Received: (qmail 4085 invoked by uid 99); 2 Dec 2010 19:01:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Dec 2010 19:01:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Dec 2010 19:01:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6D29123888E4; Thu, 2 Dec 2010 18:59:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1041529 - /tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java Date: Thu, 02 Dec 2010 18:59:29 -0000 To: commits@tuscany.apache.org From: antelder@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101202185929.6D29123888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: antelder Date: Thu Dec 2 18:59:29 2010 New Revision: 1041529 URL: http://svn.apache.org/viewvc?rev=1041529&view=rev Log: If WEB-INF/sca-contributions contains contributions then use it automatically without requireing users define it in the web.xml Modified: tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java Modified: tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java?rev=1041529&r1=1041528&r2=1041529&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java (original) +++ tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java Thu Dec 2 18:59:29 2010 @@ -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 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();