myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dennisby...@apache.org
Subject svn commit: r511552 - in /myfaces/core/branches/jsf12/impl/src: main/java/org/apache/myfaces/config/ main/java/org/apache/myfaces/config/annotation/ main/java/org/apache/myfaces/webapp/ test/java/org/apache/myfaces/config/annotation/
Date Sun, 25 Feb 2007 17:05:04 GMT
Author: dennisbyrne
Date: Sun Feb 25 09:05:03 2007
New Revision: 511552

URL: http://svn.apache.org/viewvc?view=rev&rev=511552
Log:
MYFACES-1246 implemented @PreDestroy

Added:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionAttributeListener.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletContextListener.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletRequestListener.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyfacesServletRequestAttributeListener.java
Modified:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandler.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedExceptionManagedBeanHandlerTestCase.java
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandlerTestCase.java
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedRuntimeExceptionManagedBeanHandlerTestCase.java

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java?view=diff&rev=511552&r1=511551&r2=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
Sun Feb 25 09:05:03 2007
@@ -65,7 +65,8 @@
     {
         final Object bean = ClassUtils.newInstance(beanConfiguration.getManagedBeanClassName());
 
-        final AnnotatedManagedBeanHandler handler = new AnnotatedManagedBeanHandler(bean,
beanConfiguration);
+        final AnnotatedManagedBeanHandler handler = new AnnotatedManagedBeanHandler(bean,

+        		beanConfiguration.getManagedBeanScope(), beanConfiguration.getManagedBeanName());
         
         final boolean threwUnchecked = handler.invokePostConstruct();
         

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandler.java?view=diff&rev=511552&r1=511551&r2=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandler.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandler.java
Sun Feb 25 09:05:03 2007
@@ -23,25 +23,31 @@
 
 	private Object managedBean;
 
-	private ManagedBean beanConfiguration;
-
+	private String scope;
+	
+	private String name;
+	
 	private static final String POST_CONSTRUCT = "javax.annotation.PostConstruct";
 	
 	private static final String PRE_DESTROY = "javax.annotation.PreDestroy";
 
-	public AnnotatedManagedBeanHandler(Object managedBean, ManagedBean beanConfiguration) {
+	public AnnotatedManagedBeanHandler(Object managedBean, String scope, String name) {
 
 		if (managedBean == null) {
 			throw new NullPointerException("Object managedBean");
 		}
 
-		if (beanConfiguration == null) {
-			throw new NullPointerException("ManagedBean beanConfiguration");
+		if (scope == null) {
+			throw new NullPointerException("scope");
 		}
 
+		if(name == null)
+			if(log.isWarnEnabled())
+				log.warn("managed bean " + managedBean.getClass() + "in " + scope + " scope has no name
");
+		
 		this.managedBean = managedBean;
-		this.beanConfiguration = beanConfiguration;
-
+		this.scope = scope;
+		this.name = name;
 	}
 
 	public boolean invokePreDestroy() {
@@ -56,10 +62,9 @@
 
 		boolean threwUnchecked = false;
 
-		if (ManagedBeanBuilder.NONE.equals(beanConfiguration.getManagedBeanScope())) {
+		if (ManagedBeanBuilder.NONE.equals(scope)) {
 			if(log.isDebugEnabled())
-				log.debug( annotationName + " not processed for managed bean " 
-						+ beanConfiguration.getManagedBeanName() 
+				log.debug( annotationName + " not processed for managed bean " + name 
 						+ " because it is not in request, session, or "
 						+ "application scope.  See section 5.4 of the JSF 1.3 spec"); 
 		} else {
@@ -132,14 +137,14 @@
 		if (e instanceof RuntimeException) // why did they make RE extend E ?
 		{
 			log.error(genericLoggingMessage + " MyFaces cannot " + " put the bean in "
-					+ beanConfiguration.getManagedBeanScope() + " scope " + " ... execution continues. ");
+					+ scope + " scope " + " ... execution continues. ");
 		} else {
 			throw new FacesException(genericLoggingMessage + " The spec is ambivalent on checked exceptions.");
 		}
 	}
 
 	private String getGenericLoggingMessage(Method method, Throwable e) {
-		return "When invoking " + method.getName() + " on a managed bean '" + beanConfiguration.getManagedBeanName()
+		return "When invoking " + method.getName() + " on a managed bean '" + name
 				+ "'," + " an exception " + e.getClass() + "{" + e.getMessage() + "} was thrown. "
 				+ " See section 5.4.1 of the JSF specification.";
 	}

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java?view=auto&rev=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java
Sun Feb 25 09:05:03 2007
@@ -0,0 +1,40 @@
+package org.apache.myfaces.webapp;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.apache.myfaces.config.annotation.AnnotatedManagedBeanHandler;
+
+/**
+ * @author Dennis Byrne
+ */
+
+public abstract class AbstractMyFacesListener {
+
+	protected void doPreDestroy(ServletRequestAttributeEvent event, String scope) {
+		doPreDestroy(event.getValue(), event.getName(), scope);
+	}
+
+	protected void doPreDestroy(HttpSessionBindingEvent event, String scope) {
+		doPreDestroy(event.getValue(), event.getName(), scope);
+	}
+
+	protected void doPreDestroy(ServletContextAttributeEvent event, String scope) {
+		doPreDestroy(event.getValue(), event.getName(), scope);
+	}
+	
+	protected void doPreDestroy(Object value, String name, String scope) {
+		
+		if(value != null)
+		{
+			AnnotatedManagedBeanHandler handler = 
+				new AnnotatedManagedBeanHandler(value, scope, name);
+
+			boolean threwUnChecked = handler.invokePreDestroy();
+			
+		}
+		
+	}
+	
+}

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionAttributeListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionAttributeListener.java?view=auto&rev=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionAttributeListener.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionAttributeListener.java
Sun Feb 25 09:05:03 2007
@@ -0,0 +1,26 @@
+package org.apache.myfaces.webapp;
+
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.apache.myfaces.config.ManagedBeanBuilder;
+
+/**
+ * @author Dennis Byrne
+ */
+
+public class MyFacesHttpSessionAttributeListener extends AbstractMyFacesListener
+		implements HttpSessionAttributeListener {
+
+	public void attributeAdded(HttpSessionBindingEvent event) { // noop
+	}
+
+	public void attributeRemoved(HttpSessionBindingEvent event) {
+		doPreDestroy(event, ManagedBeanBuilder.SESSION);
+	}
+
+	public void attributeReplaced(HttpSessionBindingEvent event) {
+		doPreDestroy(event, ManagedBeanBuilder.SESSION);
+	}
+
+}

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java?view=auto&rev=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
Sun Feb 25 09:05:03 2007
@@ -0,0 +1,34 @@
+package org.apache.myfaces.webapp;
+
+import java.util.Enumeration;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.myfaces.config.ManagedBeanBuilder;
+
+/**
+ * @author Dennis Byrne
+ */
+
+public class MyFacesHttpSessionListener extends AbstractMyFacesListener implements HttpSessionListener
{
+
+	public void sessionCreated(HttpSessionEvent event) { // noop
+	}
+
+	public void sessionDestroyed(HttpSessionEvent event) {
+		
+		HttpSession session = event.getSession();
+		Enumeration<String> attributes = session.getAttributeNames();
+		
+		while(attributes.hasMoreElements())
+		{
+			String name = attributes.nextElement();
+			Object value = session.getAttribute(name);
+			doPreDestroy(value, name, ManagedBeanBuilder.SESSION);
+		}
+		
+	}
+
+}

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletContextListener.java?view=auto&rev=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletContextListener.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletContextListener.java
Sun Feb 25 09:05:03 2007
@@ -0,0 +1,25 @@
+package org.apache.myfaces.webapp;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextAttributeListener;
+
+import org.apache.myfaces.config.ManagedBeanBuilder;
+
+/**
+ * @author Dennis Byrne
+ */
+
+public class MyFacesServletContextListener extends AbstractMyFacesListener implements ServletContextAttributeListener
{
+
+	public void attributeAdded(ServletContextAttributeEvent event) { // noop
+	}
+
+	public void attributeRemoved(ServletContextAttributeEvent event) {
+		doPreDestroy(event, ManagedBeanBuilder.APPLICATION);
+	}
+
+	public void attributeReplaced(ServletContextAttributeEvent event) {
+		doPreDestroy(event, ManagedBeanBuilder.APPLICATION);
+	}
+
+}

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletRequestListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletRequestListener.java?view=auto&rev=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletRequestListener.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyFacesServletRequestListener.java
Sun Feb 25 09:05:03 2007
@@ -0,0 +1,34 @@
+package org.apache.myfaces.webapp;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+
+import org.apache.myfaces.config.ManagedBeanBuilder;
+
+/**
+ * @author Dennis Byrne
+ */
+
+public class MyFacesServletRequestListener extends AbstractMyFacesListener implements ServletRequestListener
{
+
+	public void requestDestroyed(ServletRequestEvent event) {
+
+		ServletRequest request = event.getServletRequest();
+		Enumeration<String> attributes = request.getAttributeNames();
+		
+		while(attributes.hasMoreElements()) 
+		{
+			String name = attributes.nextElement();
+			Object attribute = request.getAttribute(name);
+			doPreDestroy(attribute, name, ManagedBeanBuilder.REQUEST);
+		}
+		
+	}
+		
+	public void requestInitialized(ServletRequestEvent event) { // noop
+	}
+
+}

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyfacesServletRequestAttributeListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyfacesServletRequestAttributeListener.java?view=auto&rev=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyfacesServletRequestAttributeListener.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/MyfacesServletRequestAttributeListener.java
Sun Feb 25 09:05:03 2007
@@ -0,0 +1,26 @@
+package org.apache.myfaces.webapp;
+
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestAttributeListener;
+
+import org.apache.myfaces.config.ManagedBeanBuilder;
+
+/**
+ * @author Dennis Byrne
+ */
+
+public class MyfacesServletRequestAttributeListener extends AbstractMyFacesListener
+		implements ServletRequestAttributeListener {
+	
+	public void attributeAdded(ServletRequestAttributeEvent event) { // noop
+	}
+
+	public void attributeRemoved(ServletRequestAttributeEvent event) { 
+		doPreDestroy(event, ManagedBeanBuilder.REQUEST);
+	}
+
+	public void attributeReplaced(ServletRequestAttributeEvent event) {
+		doPreDestroy(event, ManagedBeanBuilder.REQUEST);		
+	}
+
+}

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java?view=diff&rev=511552&r1=511551&r2=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
Sun Feb 25 09:05:03 2007
@@ -18,8 +18,11 @@
  */
 package org.apache.myfaces.webapp;
 
+import java.util.Enumeration;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.config.ManagedBeanBuilder;
 
 import javax.faces.FactoryFinder;
 import javax.servlet.ServletContext;
@@ -30,7 +33,8 @@
  * @author Manfred Geiler (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class StartupServletContextListener implements ServletContextListener
+public class StartupServletContextListener extends AbstractMyFacesListener
+	implements ServletContextListener
 {
     static final String FACES_INIT_DONE = StartupServletContextListener.class.getName() +
".FACES_INIT_DONE";
 
@@ -86,13 +90,28 @@
         }
     }
 
-    public void contextDestroyed(ServletContextEvent e)
+    public void contextDestroyed(ServletContextEvent event)
     {
+    	doPredestroy(event);
+    	
         if (_facesInitializer != null && _servletContext != null)
         {
             _facesInitializer.destroyFaces(_servletContext);
         }
         FactoryFinder.releaseFactories();
         _servletContext = null;
+    }
+    
+    private void doPredestroy(ServletContextEvent event) {
+    			
+    	ServletContext ctx = event.getServletContext();
+       	Enumeration<String> attributes = ctx.getAttributeNames();
+       	
+       	while(attributes.hasMoreElements()) 
+       	{
+       		String name = attributes.nextElement();
+       		Object value = ctx.getAttribute(name);
+       		doPreDestroy(value, name, ManagedBeanBuilder.APPLICATION);
+       	}
     }
 }

Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedExceptionManagedBeanHandlerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedExceptionManagedBeanHandlerTestCase.java?view=diff&rev=511552&r1=511551&r2=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedExceptionManagedBeanHandlerTestCase.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedExceptionManagedBeanHandlerTestCase.java
Sun Feb 25 09:05:03 2007
@@ -16,17 +16,16 @@
 
 	protected AnnotatedManagedBeanHandler handler;
 
-	protected ManagedBean managedBeanConf;
-
+	protected final String NAME = "sean_schofield";
+	
 	public void setUp() {
 		managedBean = new AnnotatedManagedBean(new Exception());
-		managedBeanConf = new ManagedBean();
-		handler = new AnnotatedManagedBeanHandler(managedBean, managedBeanConf);
 	}
 
 	public void testPostConstructShouldNotBlowUpForNoneScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.NONE);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.NONE, NAME);
 
 		boolean exceptionThrown = false;
 		
@@ -43,7 +42,8 @@
 
 	public void testPreDestroyShouldNotBlowUpForNoneScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.NONE);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.NONE, NAME);
 
 		boolean exceptionThrown = false;
 		
@@ -60,7 +60,8 @@
 	
 	public void testPostConstructShouldBlowUpForRequestScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.REQUEST);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.REQUEST, NAME);
 
 		boolean exceptionThrown = false;
 		
@@ -77,7 +78,8 @@
 
 	public void testPreDestroyShouldBlowUpForRequestScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.REQUEST);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.REQUEST, NAME);
 
 		boolean exceptionThrown = false;
 		
@@ -94,7 +96,8 @@
 	
 	public void testPostConstructShouldBlowUpForSessionScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.SESSION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.SESSION, NAME);
 
 		boolean exceptionThrown = false;
 		
@@ -111,7 +114,8 @@
 
 	public void testPreDestroyShouldBlowUpForSessionScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.SESSION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.SESSION, NAME);
 
 		boolean exceptionThrown = false;
 		
@@ -128,7 +132,8 @@
 	
 	public void testPostConstructShouldBlowUpForApplicationScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.APPLICATION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.APPLICATION, NAME);
 
 		boolean exceptionThrown = false;
 		
@@ -145,7 +150,8 @@
 
 	public void testPreDestroyShouldBlowUpForApplicationScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.APPLICATION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.APPLICATION, NAME);
 
 		boolean exceptionThrown = false;
 		

Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandlerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandlerTestCase.java?view=diff&rev=511552&r1=511551&r2=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandlerTestCase.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedManagedBeanHandlerTestCase.java
Sun Feb 25 09:05:03 2007
@@ -14,17 +14,17 @@
 	
 	protected AnnotatedManagedBean managedBean;
 	protected AnnotatedManagedBeanHandler handler;
-	protected ManagedBean managedBeanConf;
+	protected final String NAME = "volker weber";
 	
 	public void setUp() {
 		managedBean = new AnnotatedManagedBean(null);
-		managedBeanConf = new ManagedBean();
-		handler = new AnnotatedManagedBeanHandler(managedBean, managedBeanConf);
 	}
 
 	public void testPostConstructShouldNotInvokeForNoneScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.NONE);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.NONE, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertFalse(threwUnchecked);
@@ -34,7 +34,9 @@
 
 	public void testPreDestroyShouldNotInvokeForNoneScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.NONE);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.NONE, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertFalse(threwUnchecked);
@@ -44,7 +46,9 @@
 	
 	public void testPostConstructShouldInvokeForRequestScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.REQUEST);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.REQUEST, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertFalse(threwUnchecked);
@@ -54,7 +58,9 @@
 
 	public void testPreDestroyShouldInvokeForRequestScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.REQUEST);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.REQUEST, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertFalse(threwUnchecked);
@@ -64,7 +70,9 @@
 	
 	public void testPostConstructShouldInvokeForSessionScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.SESSION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.SESSION, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertFalse(threwUnchecked);
@@ -74,7 +82,9 @@
 
 	public void testPreDestroyShouldInvokeForSessionScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.SESSION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.SESSION, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertFalse(threwUnchecked);
@@ -84,7 +94,9 @@
 	
 	public void testPostConstructShouldInvokeForApplicationScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.APPLICATION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.APPLICATION, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertFalse(threwUnchecked);
@@ -94,7 +106,9 @@
 
 	public void testPreDestroyShouldInvokeForApplicationScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.APPLICATION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.APPLICATION, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertFalse(threwUnchecked);

Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedRuntimeExceptionManagedBeanHandlerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedRuntimeExceptionManagedBeanHandlerTestCase.java?view=diff&rev=511552&r1=511551&r2=511552
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedRuntimeExceptionManagedBeanHandlerTestCase.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedRuntimeExceptionManagedBeanHandlerTestCase.java
Sun Feb 25 09:05:03 2007
@@ -14,17 +14,17 @@
 
 	protected AnnotatedManagedBean managedBean;
 	protected AnnotatedManagedBeanHandler handler;
-	protected ManagedBean managedBeanConf;
+	protected final String NAME = "Thomas_Spiegl";
 	
 	public void setUp() {
 		managedBean = new AnnotatedManagedBean(new RuntimeException());
-		managedBeanConf = new ManagedBean();
-		handler = new AnnotatedManagedBeanHandler(managedBean, managedBeanConf);
 	}
 	
 	public void testPostConstructShouldNotInvokeForNoneScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.NONE);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.NONE, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertFalse(threwUnchecked);
@@ -34,7 +34,9 @@
 
 	public void testPreDestroyShouldNotInvokeForNoneScope() {
 
-		managedBeanConf.setScope(ManagedBeanBuilder.NONE);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.NONE, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertFalse(threwUnchecked);
@@ -44,7 +46,9 @@
 	
 	public void testPostConstructShouldInvokeForRequestScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.REQUEST);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.REQUEST, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertTrue(threwUnchecked);
@@ -54,7 +58,9 @@
 
 	public void testPreDestroyShouldInvokeForRequestScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.REQUEST);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.REQUEST, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertTrue(threwUnchecked);
@@ -64,7 +70,9 @@
 	
 	public void testPostConstructShouldInvokeForSessionScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.SESSION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.SESSION, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertTrue(threwUnchecked);
@@ -74,7 +82,9 @@
 
 	public void testPreDestroyShouldInvokeForSessionScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.SESSION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.SESSION, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertTrue(threwUnchecked);
@@ -84,7 +94,9 @@
 	
 	public void testPostConstructShouldInvokeForApplicationScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.APPLICATION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.APPLICATION, NAME);
+		
 		boolean threwUnchecked = handler.invokePostConstruct();
 		
 		assertTrue(threwUnchecked);
@@ -94,7 +106,9 @@
 
 	public void testPreDestroyShouldInvokeForApplicationScope() {
 		
-		managedBeanConf.setScope(ManagedBeanBuilder.APPLICATION);
+		handler = new AnnotatedManagedBeanHandler(managedBean, 
+				ManagedBeanBuilder.APPLICATION, NAME);
+		
 		boolean threwUnchecked = handler.invokePreDestroy();
 		
 		assertTrue(threwUnchecked);



Mime
View raw message