Author: struberg
Date: Thu Aug 5 22:04:44 2010
New Revision: 982801
URL: http://svn.apache.org/viewvc?rev=982801&view=rev
Log:
OWB-433 add a config to relax NoCheckedExceptions rule on lifecycle
interceptors
Added:
openwebbeans/trunk/readme/README_1_0_0-alpha-2.txt
- copied unchanged from r982766,
openwebbeans/trunk/readme/README_1_0_0-alpha-1.txt
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans-default.properties
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=982801&r1=982800&r2=982801&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
Thu Aug 5 22:04:44 2010
@@ -60,7 +60,15 @@ public class OpenWebBeansConfiguration
/**Conversation periodic delay in ms.*/
public static final String CONVERSATION_PERIODIC_DELAY =
"org.apache.webbeans.conversation.Conversation.periodicDelay";
-
+
+ /**
+ * Lifycycle methods like {...@link javax.annotation.PostConstruct} and
+ * {...@link javax.annotation.PreDestroy} must not define a checked
Exception
+ * regarding to the spec. But this is often unnecessary restrictive so we
+ * allow to disable this check application wide.
+ */
+ public static final String INTERCEPTOR_FORCE_NO_CHECKED_EXCEPTIONS =
"org.apache.webbeans.forceNoCheckedExceptions";
+
/**Use OWB Specific XML Configuration or Strict Spec XML*/
@Deprecated //Not use any more
public static final String USE_OWB_SPECIFIC_XML_CONFIGURATION =
"org.apache.webbeans.useOwbSpecificXmlConfig";
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=982801&r1=982800&r2=982801&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Thu Aug 5 22:04:44 2010
@@ -128,6 +128,7 @@ import org.apache.webbeans.config.Defini
import org.apache.webbeans.config.EJBWebBeansConfigurator;
import org.apache.webbeans.config.ManagedBeanConfigurator;
import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.config.OpenWebBeansConfiguration;
import org.apache.webbeans.container.BeanManagerImpl;
import org.apache.webbeans.container.ExternalScope;
import org.apache.webbeans.container.InjectionResolver;
@@ -183,7 +184,7 @@ public final class WebBeansUtil
* Enforcing that interceptor callbacks should not be
* able to throw checked exceptions is configurable
*/
- public static boolean enforceCheckedException = true;
+ private static Boolean enforceCheckedException;
// No instantiate
private WebBeansUtil()
@@ -192,6 +193,25 @@ public final class WebBeansUtil
}
/**
+ * Lifycycle methods like {...@link javax.annotation.PostConstruct} and
+ * {...@link javax.annotation.PreDestroy} must not define a checked
Exception
+ * regarding to the spec. But this is often unnecessary restrictive so we
+ * allow to disable this check application wide.
+ *
+ * @return <code>true</code> if the spec rule of having no checked
exception should be enforced
+ */
+ private static boolean isNoCheckedExceptionEnforced()
+ {
+ if (enforceCheckedException == null)
+ {
+ enforceCheckedException =
Boolean.parseBoolean(OpenWebBeansConfiguration.getInstance().
+
getProperty(OpenWebBeansConfiguration.INTERCEPTOR_FORCE_NO_CHECKED_EXCEPTIONS,
"true"));
+ }
+
+ return enforceCheckedException.booleanValue();
+ }
+
+ /**
* Gets current classloader with current thread.
*
* @return Current class loader instance
@@ -916,7 +936,7 @@ public final class WebBeansUtil
+ " must return void type");
}
- if (enforceCheckedException &&
ClassUtil.isMethodHasCheckedException(method))
+ if (isNoCheckedExceptionEnforced() &&
ClassUtil.isMethodHasCheckedException(method))
{
throw new WebBeansConfigurationException("@" +
commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in
class : " + clazz.getName()
@@ -1002,7 +1022,7 @@ public final class WebBeansUtil
+ " must return void type");
}
- if (enforceCheckedException &&
ClassUtil.isMethodHasCheckedException(method))
+ if (isNoCheckedExceptionEnforced() &&
ClassUtil.isMethodHasCheckedException(method))
{
throw new WebBeansConfigurationException("@" +
commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in
class : " + clazz.getName()
Modified:
openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans-default.properties
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans-default.properties?rev=982801&r1=982800&r2=982801&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans-default.properties
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans-default.properties
Thu Aug 5 22:04:44 2010
@@ -65,6 +65,15 @@ org.apache.webbeans.spi.deployer.useEjbM
org.apache.webbeans.application.useEJBInterceptorInjection=true
################################################################################################
+################# Force not having Checked Exceptions in lifecycle methods
####################
+# If it is true, OWB forces that lifecycle methods like @PreDestroy and
@PostConstruct must not
+# throw any checked exceptions. This is the behaviour which is defined in the
EE interceptor
+# spec. Since this is sometimes way too restrictive, we allow to relax this
rule by configuration
+# The default value is 'true' internally.
+# ATTENTION: this property works container wide!
+# org.apache.webbeans.forceNoCheckedExceptions=true
+################################################################################################
+
################################### Use OWB Specific XML Configuration
#########################
#Use OWB Specific XML configuration. Not recommended to use as true.
#It will be removed in future development.