You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2011/01/12 08:36:49 UTC

svn commit: r1058009 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/conversation/ webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/ webbeans-impl/src/main...

Author: gerdogdu
Date: Wed Jan 12 07:36:49 2011
New Revision: 1058009

URL: http://svn.apache.org/viewvc?rev=1058009&view=rev
Log:
[OWB-517] Conversation Log Improvement and some minor improvements

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java?rev=1058009&r1=1058008&r2=1058009&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java Wed Jan 12 07:36:49 2011
@@ -41,6 +41,7 @@ public class OWBLogConst
     public final static String INFO_0008 = "INFO_0008"; // Stopping OpenWebBeans Container...
     public final static String INFO_0009 = "INFO_0009"; // OpenWebBeans Container has stopped.
     public final static String INFO_0010 = "INFO_0010"; // Cannot send event to bean in non-active context \: [{0}]
+    public final static String INFO_0011 = "INFO_0011"; // Conversation with id {0} has been destroyed because of inactive time period.
 
 
     public final static String WARN_0001 = "WARN_0001"; // No plugins to shutDown.

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=1058009&r1=1058008&r2=1058009&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 Wed Jan 12 07:36:49 2011
@@ -48,6 +48,9 @@ public class OpenWebBeansConfiguration
         
     /**Conversation periodic delay in ms.*/
     public static final String CONVERSATION_PERIODIC_DELAY = "org.apache.webbeans.conversation.Conversation.periodicDelay";
+    
+    /**Timeout interval in ms*/
+    public static final String CONVERSATION_TIMEOUT_INTERVAL = "org.apache.webbeans.conversation.Conversation.timeoutInterval";
 
     /**
      * Lifycycle methods like {@link javax.annotation.PostConstruct} and

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java?rev=1058009&r1=1058008&r2=1058009&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java Wed Jan 12 07:36:49 2011
@@ -26,6 +26,7 @@ import javax.enterprise.context.Conversa
 import javax.enterprise.context.ConversationScoped;
 
 import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.ConversationContext;
 import org.apache.webbeans.logger.WebBeansLogger;
@@ -53,7 +54,7 @@ public class ConversationImpl implements
     private boolean isTransient = true;
 
     /**Default timeout is 30mins*/
-    private long timeout = 30 * 60 * 1000 ;
+    private long timeout;
 
     /**Id of the session that this conversation is created*/
     private String sessionId;
@@ -72,7 +73,15 @@ public class ConversationImpl implements
      */
     public ConversationImpl()
     {
-        
+        try
+        {
+            this.timeout = Long.parseLong(WebBeansContext.getInstance().getOpenWebBeansConfiguration().
+                    getProperty(OpenWebBeansConfiguration.CONVERSATION_TIMEOUT_INTERVAL, "1800000"));   
+        }
+        catch(NumberFormatException e)
+        {
+            this.timeout = 30 * 60 * 1000;
+        }
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java?rev=1058009&r1=1058008&r2=1058009&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java Wed Jan 12 07:36:49 2011
@@ -30,8 +30,10 @@ import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 
 import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.ConversationContext;
+import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.util.Asserts;
 
 /**
@@ -46,6 +48,7 @@ public class ConversationManager
     /**Current conversations*/
     private final ConcurrentHashMap<Conversation, ConversationContext> conversations = new ConcurrentHashMap<Conversation, ConversationContext>();
     private final WebBeansContext webBeansContext;
+    private final WebBeansLogger logger = WebBeansLogger.getLogger(ConversationManager.class);
 
     /**
      * Creates new conversation manager
@@ -226,6 +229,10 @@ public class ConversationManager
                     ConversationContext ctx = getConversationContext(conv);
                     if (ctx != null) 
                     {
+                        if(logger.wblWillLogInfo())
+                        {
+                            logger.info(logger.getTokenString(OWBLogConst.INFO_0011),new Object[]{conv.getId()});
+                        }
                         ctx.destroy();
                     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java?rev=1058009&r1=1058008&r2=1058009&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java Wed Jan 12 07:36:49 2011
@@ -37,7 +37,7 @@ import org.apache.webbeans.util.ClassUti
 public abstract class AbstractMetaDataDiscovery implements ScannerService
 {
     /** Location of the beans.xml files. */
-    private Set<URL> webBeansXmlLocations = new HashSet<URL>();
+    private final Set<URL> webBeansXmlLocations = new HashSet<URL>();
 
     //private Map<String, InputStream> EJB_XML_LOCATIONS = new HashMap<String, InputStream>();
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties?rev=1058009&r1=1058008&r2=1058009&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties Wed Jan 12 07:36:49 2011
@@ -33,6 +33,7 @@ INFO_0006 = Initializing OpenWebBeans Co
 INFO_0008 = Stopping OpenWebBeans Container...
 INFO_0009 = OpenWebBeans Container has stopped.
 INFO_0010 = Cannot send event to bean in non-active context \: [{0}]
+INFO_0011 = Conversation with id {0} has been destroyed because it is not active for the period of configured time out interval.
 
 
 #warning messages:

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java?rev=1058009&r1=1058008&r2=1058009&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java Wed Jan 12 07:36:49 2011
@@ -77,8 +77,11 @@ public class WebBeansConfigurationListen
 
         try
         {
-                this.lifeCycle.startApplication(event);  
-                event.getServletContext().setAttribute(OpenWebBeansConfiguration.PROPERTY_OWB_APPLICATION, "true");
+                this.lifeCycle.startApplication(event);
+                
+                //If there is no beans.xml, not an owb application
+                boolean isOwbApplication = !webBeansContext.getScannerService().getBeanXmls().isEmpty();
+                event.getServletContext().setAttribute(OpenWebBeansConfiguration.PROPERTY_OWB_APPLICATION, Boolean.toString(isOwbApplication));
         }
         catch (Exception e)
         {

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java?rev=1058009&r1=1058008&r2=1058009&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java Wed Jan 12 07:36:49 2011
@@ -36,6 +36,7 @@ import javax.servlet.jsp.JspApplicationC
 import javax.servlet.jsp.JspFactory;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -89,12 +90,21 @@ public final class WebContainerLifecycle
     /**
      * {@inheritDoc}
      */
-    protected void afterStartApplication(Object startupObject) throws Exception
+    protected void afterStartApplication(final Object startupObject) throws Exception
     {
-        String strDelay = WebBeansContext.getInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.CONVERSATION_PERIODIC_DELAY,"150000");
+        String strDelay = getWebBeansContext().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.CONVERSATION_PERIODIC_DELAY,"150000");
         long delay = Long.parseLong(strDelay);
 
-        service = Executors.newScheduledThreadPool(1);
+        service = Executors.newScheduledThreadPool(1, new ThreadFactory()
+        {            
+            @Override
+            public Thread newThread(Runnable runable)
+            {
+                Thread t = new Thread(runable, "OwbConversationCleaner-" + ((ServletContext)(startupObject)).getContextPath());
+                t.setDaemon(true);
+                return t;                
+            }
+        });
         service.scheduleWithFixedDelay(new ConversationCleaner(), delay, delay, TimeUnit.MILLISECONDS);
 
         ELAdaptor elAdaptor = getWebBeansContext().getService(ELAdaptor.class);