Author: nfilotto
Date: 2011-02-28 07:30:08 -0500 (Mon, 28 Feb 2011)
New Revision: 4024
Added:
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/util/
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestContainerUtil.java
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
Log:
EXOJCR-1089: Now the ContainerUtil get rid of any resources found into the WEB-INF
directory
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2011-02-28
09:25:46 UTC (rev 4023)
+++
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2011-02-28
12:30:08 UTC (rev 4024)
@@ -86,10 +86,17 @@
Map<String, URL> map = new HashMap<String, URL>();
Iterator i = c.iterator();
+ String forbiddenSuffix = "WEB-INF/" + configuration;
while (i.hasNext())
{
URL url = (URL)i.next();
String key = url.toString();
+ // The content of the WEB-INF folder is part of the CL in JBoss AS 6 so
+ // we have to get rid of it in order to prevent any boot issues
+ if (key.endsWith(forbiddenSuffix))
+ {
+ continue;
+ }
// jboss bug, jboss has a very weird behavior. It copy all the jar files
// and
// deploy them to a temp dir and include both jars, the one in sar and tmp
Added:
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestContainerUtil.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestContainerUtil.java
(rev 0)
+++
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestContainerUtil.java 2011-02-28
12:30:08 UTC (rev 4024)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software 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.exoplatform.container.util;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas
Filotto</a>
+ * @version $Id$
+ */
+public class TestContainerUtil extends TestCase
+{
+
+ public void testJBossAS6CL() throws Exception
+ {
+ ClassLoader oldCLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(new JBossAS6MockClassLoader());
+ Collection<URL> urls =
ContainerUtil.getConfigurationURL("conf/configuration.xml");
+ assertNotNull(urls);
+ assertEquals(3, urls.size());
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldCLoader);
+ }
+ }
+
+ private static class JBossAS6MockClassLoader extends ClassLoader
+ {
+
+ @Override
+ public Enumeration<URL> getResources(String name) throws IOException
+ {
+ List<URL> urls = new ArrayList<URL>();
+ urls.add(new
URL("file:///GateIn-JBoss6/server/default/deploy/gatein.ear/lib/exo.portal.webui.portal.jar/conf/configuration.xml"));
+ urls.add(new
URL("file:///GateIn-JBoss6/server/default/deploy/gatein.ear/lib/exo.core.component.xml-processing/conf/configuration.xml"));
+ urls.add(new
URL("file:///GateIn-JBoss6/server/default/deploy/gatein-sample-extension.ear/sample-ext.war/WEB-INF/conf/configuration.xml"));
+ urls.add(new
URL("file:///GateIn-JBoss6/server/default/deploy/gatein.ear/lib/exo.kernel.commons.jar/conf/configuration.xml"));
+ return Collections.enumeration(urls);
+ }
+
+ }
+}