Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B3CFA98EC for ; Thu, 12 Apr 2012 12:58:42 +0000 (UTC) Received: (qmail 68992 invoked by uid 500); 12 Apr 2012 12:58:42 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 68962 invoked by uid 500); 12 Apr 2012 12:58:42 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 68952 invoked by uid 99); 12 Apr 2012 12:58:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 12:58:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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, 12 Apr 2012 12:58:40 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F27F823889E7; Thu, 12 Apr 2012 12:58:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1325232 - /camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Date: Thu, 12 Apr 2012 12:58:18 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120412125818.F27F823889E7@eris.apache.org> Author: davsclaus Date: Thu Apr 12 12:58:18 2012 New Revision: 1325232 URL: http://svn.apache.org/viewvc?rev=1325232&view=rev Log: CAMEL-5168: Added Main class in camel-test-blueprint, to make it easier to run Camel Blueprint out of container. Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=1325232&r1=1325231&r2=1325232&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Thu Apr 12 12:58:18 2012 @@ -19,6 +19,7 @@ package org.apache.camel.util; import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; @@ -33,6 +34,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -863,6 +865,35 @@ public final class ObjectHelper { } /** + * Attempts to load the given resources from the given package name using the thread context + * class loader or the class loader used to load this class + * + * @param packageName the name of the package to load its resources + * @return the URLs for the resources or null if it could not be loaded + */ + public static Enumeration loadResourcesAsURL(String packageName) { + Enumeration url = null; + + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + if (contextClassLoader != null) { + try { + url = contextClassLoader.getResources(packageName); + } catch (IOException e) { + // ignore + } + } + if (url == null) { + try { + url = ObjectHelper.class.getClassLoader().getResources(packageName); + } catch (IOException e) { + // ignore + } + } + + return url; + } + + /** * A helper method to invoke a method via reflection and wrap any exceptions * as {@link RuntimeCamelException} instances *