You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2012/02/21 15:48:55 UTC
[2/2] git commit: DELTASPIKE-92 and DELTASPIKE-102
DELTASPIKE-92 and DELTASPIKE-102
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/4fe5dbc0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/4fe5dbc0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/4fe5dbc0
Branch: refs/heads/master
Commit: 4fe5dbc0339bd3982b3ef107cffe5611c9d110a9
Parents: 13bcf10
Author: gpetracek <gp...@apache.org>
Authored: Tue Feb 21 14:49:05 2012 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Tue Feb 21 14:49:05 2012 +0100
----------------------------------------------------------------------
.../deltaspike/cdise/api/CdiContainerLoader.java | 24 +++++++++++++-
1 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/4fe5dbc0/deltaspike/cdise/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdise/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java b/deltaspike/cdise/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java
index e060cb0..743a1a1 100644
--- a/deltaspike/cdise/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java
+++ b/deltaspike/cdise/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java
@@ -47,14 +47,34 @@ public final class CdiContainerLoader
}
else
{
- throw new RuntimeException("Could not find a CdiContainer available in the classpath!");
+ throw new IllegalStateException("Could not find an implementation of " + CdiContainer.class.getName() +
+ " available in the classpath!");
}
if (cdiIt.hasNext())
{
- throw new RuntimeException("Too many CdiContainer found in the classpath!");
+ String foundContainers = getContainerDetails();
+ throw new IllegalStateException("Too many implementations of " + CdiContainer.class.getName() +
+ " found in the classpath! Details: " + foundContainers);
}
return testContainer;
}
+
+ private static String getContainerDetails()
+ {
+ StringBuilder result = new StringBuilder();
+
+ Class containerClass;
+ for (CdiContainer cdiContainer : ServiceLoader.load(CdiContainer.class))
+ {
+ containerClass = cdiContainer.getClass();
+ result.append(containerClass.getProtectionDomain().getCodeSource().getLocation().toExternalForm());
+ result.append(containerClass.getName());
+
+ result.append(System.getProperty("line.separator"));
+ }
+
+ return result.toString();
+ }
}