You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2009/01/21 19:10:57 UTC
svn commit: r736357 -
/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
Author: struberg
Date: Wed Jan 21 10:10:57 2009
New Revision: 736357
URL: http://svn.apache.org/viewvc?rev=736357&view=rev
Log:
OWB-57 add missing break and also add default cases with InvalidArgumentExceptions
Modified:
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java?rev=736357&r1=736356&r2=736357&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java Wed Jan 21 10:10:57 2009
@@ -226,6 +226,7 @@
*
* @return the current context
* @throws ContextNotActiveException if context is not active
+ * @throws IllegalArgumentException if the type is not a standard context
*/
public static WebBeansContext getStandartContext(ContextTypes type) throws ContextNotActiveException
{
@@ -233,24 +234,28 @@
switch (type.getName())
{
- case 0:
- context = getRequestContext();
- break;
-
- case 1:
- context = getSessionContext();
- break;
-
- case 2:
- context = getApplicationContext();
- break;
-
- case 3:
- context = getConversationContext();
-
- case 4:
- context = getDependentContext();
-
+ case 0:
+ context = getRequestContext();
+ break;
+
+ case 1:
+ context = getSessionContext();
+ break;
+
+ case 2:
+ context = getApplicationContext();
+ break;
+
+ case 3:
+ context = getConversationContext();
+ break;
+
+ case 4:
+ context = getDependentContext();
+ break;
+
+ default:
+ throw new IllegalArgumentException("There is no such a standard context with name id=" + type.getName());
}
return context;
@@ -261,6 +266,7 @@
*
* @return the current context
* @throws ContextNotActiveException if context is not active
+ * @throws IllegalArgumentException if the type is not a standard context
*/
public static WebBeansContext getStandartContext(Class<? extends Annotation> scopeType) throws ContextNotActiveException
{
@@ -287,7 +293,11 @@
{
context = getDependentContext();
}
-
+ else
+ {
+ throw new IllegalArgumentException("There is no such a standard context with name id=" + scopeType.getName());
+ }
+
return context;
}