[webbeans-commits] Webbeans SVN: r380 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: transaction and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Nov 28 06:26:27 EST 2008


Author: nickarls
Date: 2008-11-28 06:26:26 -0500 (Fri, 28 Nov 2008)
New Revision: 380

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
Log:
javadocs/comments/toStrings

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.servlet;
 
 import java.lang.reflect.Constructor;
@@ -17,15 +34,27 @@
 import org.jboss.webbeans.util.JNDI;
 import org.jboss.webbeans.util.Reflections;
 
+/**
+ * Reacts to phases of the servlet life cycles
+ * 
+ * @author Pete Muir
+ * @author Nicklas Karlsson
+ */
 public class ServletLifecycle
 {
-   
    private static LogProvider log = Logging.getLogProvider(ServletLifecycle.class);
-   
+   // Where to find the manager in JNDI
    private static final String MANAGER_JNDI_KEY = "java:comp/Manager";
-   
+   // The servlet context
    private static ServletContext servletContext;
    
+   /**
+    * Starts the application
+    * 
+    * Runs the bootstrapper for bean discover and initialization
+    * 
+    * @param context The servlet context
+    */
    public static void beginApplication(ServletContext context)
    {
       servletContext = context;
@@ -33,31 +62,66 @@
       bootstrap.boot(getWebBeanDiscovery());
    }
    
+   /**
+    * Ends the application
+    */
    public static void endApplication() {
       servletContext = null;
    }
    
+   /**
+    * Begins a session
+    * 
+    * @param session The HTTP session
+    */
    public static void beginSession(HttpSession session)
    {
    }
    
+   /**
+    * Ends a session
+    * 
+    * @param session The HTTP session
+    */
    public static void endSession(HttpSession session) {
    }   
    
+   /**
+    * Begins a HTTP request 
+    * 
+    * Sets the session into the session context
+    * 
+    * @param request The request
+    */
    public static void beginRequest(HttpServletRequest request) {
       ManagerImpl manager = (ManagerImpl) JNDI.lookup(MANAGER_JNDI_KEY);
       SessionContext sessionContext = (SessionContext) manager.getContext(SessionScoped.class);
       sessionContext.setSession(request.getSession(true));
    }
    
+   /**
+    * Ends a HTTP request
+    * 
+    * @param request The request
+    */
    public static void endRequest(HttpServletRequest request) {
    }
    
+   /**
+    * Gets the servlet context
+    * 
+    * @return The servlet context
+    */
    public static ServletContext getServletContext() 
    {
       return servletContext;
    }
    
+   /**
+    * Gets the Web Beans discovery class
+    * 
+    * @return The discoverer
+    */
    // TODO move some of this bootstrap for reuse outside Servlet
    private static WebBeanDiscovery getWebBeanDiscovery()
    {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java	2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java	2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.servlet;
 
 import java.io.IOException;
@@ -11,17 +28,35 @@
 import javax.servlet.http.HttpServletRequest;
 
 /**
+ * Filter for handling request-level events
  * 
- * @author Shane Bryzak
+ * Delegates work to the ServletLifecycle
  * 
+ * @author Pete Muir
+ * @author Nicklas Karlsson
  */
 public class WebBeansFilter implements Filter
 {
+   /**
+    * Called when the filter is initializes
+    * 
+    * @param filterConfig The filter configuration
+    * @throws ServletException When things go Wrong(tm)
+    */
    public void init(FilterConfig filterConfig) throws ServletException
    {
-
    }
 
+   /**
+    * Executes the filter
+    * 
+    * @param request The request
+    * @param response The response
+    * @param chain The filter chain
+    * 
+    * @throws IOException When things go Wrong(tm)
+    * @throws ServletException When things go Wrong(tm)
+    */
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
    {
       try
@@ -35,6 +70,9 @@
       }
    }
 
+   /**
+    * Called when the filter is destroyed
+    */
    public void destroy()
    {
    }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java	2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java	2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.servlet;
 
 import javax.servlet.ServletContextEvent;
@@ -5,24 +22,54 @@
 import javax.servlet.http.HttpSessionEvent;
 import javax.servlet.http.HttpSessionListener;
 
+/**
+ * The Web Beans listener
+ * 
+ * Listens for context/session creation/destruction.
+ * 
+ * Delegates work to the ServletLifeCycle.
+ * 
+ * @author Nicklas Karlsson
+ *
+ */
 public class WebBeansListener implements ServletContextListener, HttpSessionListener
 {
 
+   /**
+    * Called when the context is initialized (application started)
+    * 
+    * @param event The context event
+    */
    public void contextInitialized(ServletContextEvent event) 
    {
       ServletLifecycle.beginApplication(event.getServletContext());
    }
 
+   /**
+    * Called when the session is created
+    * 
+    * @param event The session event
+    */
    public void sessionCreated(HttpSessionEvent event) 
    {
       ServletLifecycle.beginSession(event.getSession());
    }
 
+   /**
+    * Called when the session is destroyed
+    * 
+    * @param event The session event
+    */
    public void sessionDestroyed(HttpSessionEvent event) 
    {
       ServletLifecycle.endSession(event.getSession());
    }
 
+   /**
+    * Called when the context is destroyed (application sopped)
+    * 
+    * @param event The context event
+    */
    public void contextDestroyed(ServletContextEvent event) 
    {
       ServletLifecycle.endApplication();

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java	2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java	2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.transaction;
 
 import javax.ejb.Local;
@@ -2,5 +19,14 @@
 
+/**
+ * The local EJB interface for the TransactionListener
+ * 
+ * @author Nicklas Karlsson
+ * 
+ */
 @Local
-public interface LocalTransactionListener 
+public interface LocalTransactionListener
 {
+   /**
+    * The destroy method
+    */
    public void destroy();

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java	2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java	2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.transaction;
 
 import java.rmi.RemoteException;
@@ -14,18 +31,38 @@
 import javax.transaction.Synchronization;
 import javax.webbeans.RequestScoped;
 
+/**
+ * An EJB used for transaction synchronization (e.g. transactional observers)
+ * 
+ * @author Nicklas Karlsson
+ * 
+ */
 @Stateful
 @RequestScoped
 @TransactionAttribute(TransactionAttributeType.SUPPORTS)
 public class TransactionListener implements LocalTransactionListener, SessionSynchronization
 {
-
+   // The registered synchronizations
    private List<Synchronization> synchronizations = new CopyOnWriteArrayList<Synchronization>();
 
+   /**
+    * Fired after the current transaction have begun
+    * 
+    * @see javax.ejb.SessionSynchronization
+    */
    public void afterBegin() throws EJBException, RemoteException
    {
    }
 
+   /**
+    * Fired after the transaction has completed
+    *
+    * Notifies any registered synchronizations 
+    *
+    * @param success Did the transaction succeed?
+    * 
+    * @see javax.ejb.SessionSynchronization
+    */
    public void afterCompletion(boolean success) throws EJBException, RemoteException
    {
       for (Synchronization synchronization : synchronizations)
@@ -35,6 +72,13 @@
       synchronizations.clear();
    }
 
+   /**
+    * Fired before the transaction completed
+    *
+    * Notifies any registered synchronizations 
+    *
+    * @see javax.ejb.SessionSynchronization
+    */   
    public void beforeCompletion() throws EJBException, RemoteException
    {
       for (Synchronization synchronization : synchronizations)
@@ -43,13 +87,23 @@
       }
    }
 
+   /**
+    * Registers a synchronization
+    * 
+    * @param synchronization The synchronization to register
+    */
    public void registerSynhronization(Synchronization synchronization)
    {
       synchronizations.add(synchronization);
    }
 
+   /**
+    * The remove method
+    */
    @Remove
    public void destroy()
-   {      
+   {
+      synchronizations.clear();
+      synchronizations = null;
    }
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java	2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java	2008-11-28 11:26:26 UTC (rev 380)
@@ -1,15 +1,12 @@
 package org.jboss.webbeans.util;
 
 import java.beans.Introspector;
-import java.lang.annotation.Annotation;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.Map.Entry;
 
-import org.jboss.webbeans.introspector.AnnotatedField;
-
 public class Strings
 {
 
@@ -40,24 +37,37 @@
    public static String mapToString(String header, Map<?, ?> map)
    {
       StringBuffer buffer = new StringBuffer();
-      buffer.append(header + map.size() + "\n");
+      buffer.append(header + "[" + map.size() + " entries]\n");
       int i = 0;
       for (Object key : map.keySet())
       {
          Object value = map.get(key);
+         buffer.append("  #" + ++i + ": " + key.toString() + "->");
          if (value instanceof Iterable)
          {
+            buffer.append("\n");
             for (Object subValue : (Iterable<?>) value)
             {
-               buffer.append(++i + " - " + key.toString() + ": " + subValue.toString() + "\n");
+                buffer.append("    " + subValue.toString() + "\n");
             }
          }
          else
          {
-            buffer.append(++i + " - " + key.toString() + ": " + value.toString() + "\n");
+            buffer.append(value.toString() + "\n");
          }
       }
       return buffer.toString();
    }
 
+   public static void main(String[] args) {
+     Map map = new HashMap<String, Collection<?>>();
+     Collection a = new ArrayList<String>();
+     a.add("1"); a.add("2");
+     map.put("foo", a);
+     Collection b = new ArrayList<String>();
+     b.add("3"); b.add("4");
+     map.put("bar", b);
+     System.out.println(mapToString("Header: ", map));
+   }
+   
 }




More information about the weld-commits mailing list