openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1075432 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/decorator/ webbeans-impl/src/...
Date Mon, 28 Feb 2011 17:15:23 GMT
Author: struberg
Date: Mon Feb 28 17:15:22 2011
New Revision: 1075432

URL: http://svn.apache.org/viewvc?rev=1075432&view=rev
Log:
OWB-536 revisit logger usage in our ManagedBeans


Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java?rev=1075432&r1=1075431&r2=1075432&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
Mon Feb 28 17:15:22 2011
@@ -147,7 +147,6 @@ public abstract class BaseEjbBean<T> ext
      * @param proxyInstance The contextual reference 
      * @param ejbInstance The underlying EJB instance to be removed
      */
-    
     protected void destroyStatefulSessionBeanInstance(T proxyInstance, Object ejbInstance)
     {
         Method removeMeth = null;
@@ -164,10 +163,8 @@ public abstract class BaseEjbBean<T> ext
             }
             catch (NoSuchMethodException e) 
             {
-                if (logger.wblWillLogDebug())
-                {
-                    logger.debug("Error calling remove method: ", e);
-                }
+                getLogger().error("Error calling Stateful Session Bean remove method: ",
e);
+                throw new RuntimeException(e);
             }
         }
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=1075432&r1=1075431&r2=1075432&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
Mon Feb 28 17:15:22 2011
@@ -51,7 +51,6 @@ import org.apache.webbeans.intercept.Int
 import org.apache.webbeans.intercept.InterceptorUtil;
 import org.apache.webbeans.intercept.InvocationContextImpl;
 import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
-import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.util.ClassUtil;
@@ -262,7 +261,7 @@ public abstract class AbstractInjectionT
 
                 catch (Exception e)
                 {
-                    logger.error(OWBLogConst.ERROR_0008, e, "@PostConstruct.");
+                    getLogger().error(OWBLogConst.ERROR_0008, e, "@PostConstruct.");
                     throw new WebBeansException(e);
                 }
             }            
@@ -300,7 +299,7 @@ public abstract class AbstractInjectionT
                 }
                 catch (Exception e)
                 {
-                    logger.error(OWBLogConst.ERROR_0008, e, "@PreDestroy.");
+                    getLogger().error(OWBLogConst.ERROR_0008, e, "@PreDestroy.");
                     throw new WebBeansException(e);
                 }
             }            
@@ -417,9 +416,9 @@ public abstract class AbstractInjectionT
             }
             catch (Exception e)
             {
-                logger.error(OWBLogConst.ERROR_0023, instance);
+                getLogger().error(OWBLogConst.ERROR_0023, instance);
                 throw new WebBeansException(MessageFormat.format(
-                        logger.getTokenString(OWBLogConst.ERROR_0023), instance), e);
+                        getLogger().getTokenString(OWBLogConst.ERROR_0023), instance), e);
             }
         }
     }
@@ -549,17 +548,6 @@ public abstract class AbstractInjectionT
     {
         this.inheritedMetaData = new BeanInheritedMetaData<T>(this);
     }
-    
-    
-    /**
-     * Returns bean logger instance.
-     * 
-     * @return logger
-     */
-    protected WebBeansLogger getLogger()
-    {
-        return this.logger;
-    }
 
     /**
      * {@inheritDoc}
@@ -603,7 +591,7 @@ public abstract class AbstractInjectionT
             if(!decorator.isPassivationCapable())
             {
                 throw new WebBeansConfigurationException(MessageFormat.format(
-                        logger.getTokenString(OWBLogConst.EXCEPT_0015), toString()));
+                        getLogger().getTokenString(OWBLogConst.EXCEPT_0015), toString()));
             }
             else
             {
@@ -619,7 +607,7 @@ public abstract class AbstractInjectionT
                 if(!interceptor.isPassivationCapable())
                 {
                     throw new WebBeansConfigurationException(MessageFormat.format(
-                            logger.getTokenString(OWBLogConst.EXCEPT_0016), toString()));
+                            getLogger().getTokenString(OWBLogConst.EXCEPT_0016), toString()));
                 }
                 else
                 {
@@ -634,14 +622,14 @@ public abstract class AbstractInjectionT
                     if(!Serializable.class.isAssignableFrom(interceptorClass))
                     {
                         throw new WebBeansConfigurationException(MessageFormat.format(
-                                logger.getTokenString(OWBLogConst.EXCEPT_0016), toString()));
+                                getLogger().getTokenString(OWBLogConst.EXCEPT_0016), toString()));
                     }               
                     else
                     {
                         if(!AnnotationManager.checkInjectionPointForInterceptorPassivation(interceptorClass))
                         {
                             throw new WebBeansConfigurationException(MessageFormat.format(
-                                    logger.getTokenString(OWBLogConst.EXCEPT_0017), toString(),
interceptorClass));
+                                    getLogger().getTokenString(OWBLogConst.EXCEPT_0017),
toString(), interceptorClass));
                         }
                     }
                 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=1075432&r1=1075431&r2=1075432&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
Mon Feb 28 17:15:22 2011
@@ -51,7 +51,7 @@ import org.apache.webbeans.util.ClassUti
 public abstract class AbstractOwbBean<T> implements OwbBean<T>
 {
     /**Logger instance*/
-    protected final WebBeansLogger logger = WebBeansLogger.getLogger(getClass());
+    private WebBeansLogger logger = null;
     
     /** Name of the bean */
     protected String name;
@@ -119,7 +119,7 @@ public abstract class AbstractOwbBean<T>
         this.returnType = returnType;
         this.webBeansContext = webBeansContext;
     }
-    
+
     /**
      * Creates a new instance.
      * 
@@ -224,11 +224,6 @@ public abstract class AbstractOwbBean<T>
     {
         try
         {
-            if (logger.wblWillLogDebug())
-            {
-                logger.debug("Destroying instance : [{0}]", this);
-            }
-            
             InjectionTargetWrapper<T> wrapper = getManager().getInjectionTargetWrapper(this);
             if(wrapper != null)
             {
@@ -250,7 +245,7 @@ public abstract class AbstractOwbBean<T>
         }
         catch(Exception e)
         {
-            logger.fatal(e, OWBLogConst.FATAL_0001, this);
+            getLogger().fatal(e, OWBLogConst.FATAL_0001, this);
         }
         finally
         {
@@ -660,10 +655,17 @@ public abstract class AbstractOwbBean<T>
         
         return builder.toString();
     }
-    
-    protected WebBeansLogger getLogger()
+
+    /**
+     * The Logger should really only be used to log errors!
+     */
+    protected synchronized WebBeansLogger getLogger()
     {
-        return this.logger;
+        if (logger == null)
+        {
+            logger = WebBeansLogger.getLogger(getClass());
+        }
+        return logger;
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java?rev=1075432&r1=1075431&r2=1075432&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
Mon Feb 28 17:15:22 2011
@@ -32,9 +32,7 @@ import javax.enterprise.context.spi.Crea
 import javassist.util.proxy.MethodHandler;
 import javassist.util.proxy.ProxyObject;
 
-import org.apache.webbeans.config.BeansDeployer;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 
 /**
@@ -58,10 +56,6 @@ import org.apache.webbeans.proxy.Javassi
 public abstract class BuildInOwbBean<T> extends AbstractOwbBean<T>
 {
 
-    //Logger instance
-    private final WebBeansLogger logger = WebBeansLogger.getLogger(BeansDeployer.class);
-
-    
     private final HashMap<WebBeansType, String> proxyHandlerMap = new HashMap<WebBeansType,
String>();
 
     
@@ -184,15 +178,15 @@ public abstract class BuildInOwbBean<T> 
                 } 
                 catch (ClassNotFoundException e) 
                 {
-                    logger.error(e);
+                    getLogger().error(e);
                 } 
                 catch (SecurityException e) 
                 {
-                    logger.error(e);
+                    getLogger().error(e);
                 } 
                 catch (NoSuchMethodException e) 
                 {
-                    logger.error(e);
+                    getLogger().error(e);
                 }
                 buildinBean.handlerClass = null;
                 buildinBean.handlerContructor = null;
@@ -237,7 +231,8 @@ public abstract class BuildInOwbBean<T> 
             } 
             catch (Exception e) 
             {
-                logger.error(e);
+                getLogger().error(e);
+                //X TODO don't we rethrow this Exception?
             }
         }
         return null;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=1075432&r1=1075431&r2=1075432&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
Mon Feb 28 17:15:22 2011
@@ -83,7 +83,7 @@ public class WebBeansDecorator<T> extend
     
     /**
      * Creates a new decorator bean instance with the given wrapped bean.
-     * @param delegateComponent delegate bean instance
+     * @param wrappedBean wrapped bean instance
      */
     public WebBeansDecorator(AbstractInjectionTargetBean<T> wrappedBean, Decorator<T>
customDecorator)
     {
@@ -96,7 +96,7 @@ public class WebBeansDecorator<T> extend
     
     /**
      * Creates a new decorator bean instance with the given wrapped bean.
-     * @param delegateComponent delegate bean instance
+     * @param wrappedBean wrapped bean instance
      */
     public WebBeansDecorator(AbstractInjectionTargetBean<T> wrappedBean)
     {
@@ -322,13 +322,13 @@ public class WebBeansDecorator<T> extend
         }
         catch (IllegalArgumentException e)
         {
-            logger.error(OWBLogConst.ERROR_0007, e, instance.getClass().getName());
+            getLogger().error(OWBLogConst.ERROR_0007, e, instance.getClass().getName());
             throw new WebBeansException(e);
 
         }
         catch (IllegalAccessException e)
         {
-            logger.error(OWBLogConst.ERROR_0015, e, delegateField.getName(), instance.getClass().getName());
+            getLogger().error(OWBLogConst.ERROR_0015, e, delegateField.getName(), instance.getClass().getName());
         }
 
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1075432&r1=1075431&r2=1075432&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
Mon Feb 28 17:15:22 2011
@@ -322,7 +322,7 @@ public class ObserverMethodImpl<T> imple
 
         //Define annotated parameter
         AnnotatedType<T> annotatedType = (AnnotatedType<T>) annotatedElementFactory.newAnnotatedType(this.bean.getReturnType());
-        AnnotatedMethod<T> annotatedMethod = (AnnotatedMethod<T>)annotatedElementFactory.newAnnotatedMethod(this.observerMethod,
annotatedType);
+        AnnotatedMethod<T> annotatedMethod = annotatedElementFactory.newAnnotatedMethod(this.observerMethod,
annotatedType);
         
         Type[] types = this.observerMethod.getGenericParameterTypes();
         Annotation[][] annots = this.observerMethod.getParameterAnnotations();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=1075432&r1=1075431&r2=1075432&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Mon Feb 28 17:15:22 2011
@@ -413,7 +413,7 @@ public class WebBeansInterceptor<T> exte
         }
         catch (Exception e)
         {
-            logger.error(e);
+            getLogger().error(e);
             throw new WebBeansException(e);
         }
 



Mime
View raw message