You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by m1k0 <m1...@gmail.com> on 2012/01/12 11:05:27 UTC

patch: spend time in bussines method

Hi,
I propose some patch to ejb-core 3.1.2


# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to:
/home/m1k0/Projekty/opensource/repos/asf/openejb/tags/openejb-3.1.2/container/openejb-core/src/main/java/org/apache/openejb/core/ivm
# This patch can be applied using context Tools: Patch action on respective
folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: EjbObjectProxyHandler.java
--- EjbObjectProxyHandler.java Base (BASE)
+++ EjbObjectProxyHandler.java Locally Modified (Based On LOCAL)
@@ -58,9 +58,10 @@
     public Object _invoke(Object p, Class interfce, Method m, Object[] a)
throws Throwable {
         java.lang.Object retValue = null;
         java.lang.Throwable exc = null;
-
+        long startInMilis = 0;
         try {
             if (logger.isDebugEnabled()) {
+                startInMilis = System.currentTimeMillis();
                 logger.debug("invoking method " + m.getName() + " on " +
deploymentID + " with identity " + primaryKey);
             }
             Integer operation = (Integer) dispatchTable.get(m.getName());
@@ -145,10 +146,11 @@
             throw new RemoteException("Unknown Container Exception",
oe.getRootCause());
         } finally {
             if (logger.isDebugEnabled()) {
+                long duration = System.currentTimeMillis() - startInMilis;
                 if (exc == null) {
-                    logger.debug("finished invoking method " + m.getName()
+ ". Return value:" + retValue);
+                    logger.debug("finished invoking method " + m.getName()
+ "[Spent time: "+duration+"ms]. Return value:" + retValue);
                 } else {
-                    logger.debug("finished invoking method " + m.getName()
+ " with exception " + exc);
+                    logger.debug("finished invoking method " + m.getName()
+ "[Spent time: "+duration+"ms] with exception " + exc);
                 }
             }
         }


--
View this message in context: http://openejb.979440.n4.nabble.com/patch-spend-time-in-bussines-method-tp4288464p4288464.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: patch: spend time in bussines method

Posted by David Blevins <da...@gmail.com>.
First, thank you so much for the patch!

We actually added something very similar to that in 3.1.3.  Check out:

  https://issues.apache.org/jira/browse/OPENEJB-1275

Open to any changes to that that might make it a better fit for your needs.  We could also use some help documenting it.


-David

On Jan 12, 2012, at 2:05 AM, m1k0 wrote:

> Hi,
> I propose some patch to ejb-core 3.1.2
> 
> 
> # This patch file was generated by NetBeans IDE
> # Following Index: paths are relative to:
> /home/m1k0/Projekty/opensource/repos/asf/openejb/tags/openejb-3.1.2/container/openejb-core/src/main/java/org/apache/openejb/core/ivm
> # This patch can be applied using context Tools: Patch action on respective
> folder.
> # It uses platform neutral UTF-8 encoding and \n newlines.
> # Above lines and this line are ignored by the patching process.
> Index: EjbObjectProxyHandler.java
> --- EjbObjectProxyHandler.java Base (BASE)
> +++ EjbObjectProxyHandler.java Locally Modified (Based On LOCAL)
> @@ -58,9 +58,10 @@
>     public Object _invoke(Object p, Class interfce, Method m, Object[] a)
> throws Throwable {
>         java.lang.Object retValue = null;
>         java.lang.Throwable exc = null;
> -
> +        long startInMilis = 0;
>         try {
>             if (logger.isDebugEnabled()) {
> +                startInMilis = System.currentTimeMillis();
>                 logger.debug("invoking method " + m.getName() + " on " +
> deploymentID + " with identity " + primaryKey);
>             }
>             Integer operation = (Integer) dispatchTable.get(m.getName());
> @@ -145,10 +146,11 @@
>             throw new RemoteException("Unknown Container Exception",
> oe.getRootCause());
>         } finally {
>             if (logger.isDebugEnabled()) {
> +                long duration = System.currentTimeMillis() - startInMilis;
>                 if (exc == null) {
> -                    logger.debug("finished invoking method " + m.getName()
> + ". Return value:" + retValue);
> +                    logger.debug("finished invoking method " + m.getName()
> + "[Spent time: "+duration+"ms]. Return value:" + retValue);
>                 } else {
> -                    logger.debug("finished invoking method " + m.getName()
> + " with exception " + exc);
> +                    logger.debug("finished invoking method " + m.getName()
> + "[Spent time: "+duration+"ms] with exception " + exc);
>                 }
>             }
>         }
> 
> 
> --
> View this message in context: http://openejb.979440.n4.nabble.com/patch-spend-time-in-bussines-method-tp4288464p4288464.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: patch: spend time in bussines method

Posted by Thiago Veronezi <th...@veronezi.org>.
Hi,

It seems the log call for the _invoke method is there since 2007. I think
it could be removed to save some "if" calls in production.
If you want to log the execution of your business methods
without polluting your code, you can use interceptors. Check the use of
"@AroundInvoke".

http://openejb.apache.org/callbacks.html
http://docs.oracle.com/javaee/6/tutorial/doc/gkedm.html#gkecy

[]s,
Thiago.



On Thu, Jan 12, 2012 at 5:05 AM, m1k0 <m1...@gmail.com> wrote:

> Hi,
> I propose some patch to ejb-core 3.1.2
>
>
> # This patch file was generated by NetBeans IDE
> # Following Index: paths are relative to:
>
> /home/m1k0/Projekty/opensource/repos/asf/openejb/tags/openejb-3.1.2/container/openejb-core/src/main/java/org/apache/openejb/core/ivm
> # This patch can be applied using context Tools: Patch action on respective
> folder.
> # It uses platform neutral UTF-8 encoding and \n newlines.
> # Above lines and this line are ignored by the patching process.
> Index: EjbObjectProxyHandler.java
> --- EjbObjectProxyHandler.java Base (BASE)
> +++ EjbObjectProxyHandler.java Locally Modified (Based On LOCAL)
> @@ -58,9 +58,10 @@
>     public Object _invoke(Object p, Class interfce, Method m, Object[] a)
> throws Throwable {
>         java.lang.Object retValue = null;
>         java.lang.Throwable exc = null;
> -
> +        long startInMilis = 0;
>         try {
>             if (logger.isDebugEnabled()) {
> +                startInMilis = System.currentTimeMillis();
>                 logger.debug("invoking method " + m.getName() + " on " +
> deploymentID + " with identity " + primaryKey);
>             }
>             Integer operation = (Integer) dispatchTable.get(m.getName());
> @@ -145,10 +146,11 @@
>             throw new RemoteException("Unknown Container Exception",
> oe.getRootCause());
>         } finally {
>             if (logger.isDebugEnabled()) {
> +                long duration = System.currentTimeMillis() - startInMilis;
>                 if (exc == null) {
> -                    logger.debug("finished invoking method " + m.getName()
> + ". Return value:" + retValue);
> +                    logger.debug("finished invoking method " + m.getName()
> + "[Spent time: "+duration+"ms]. Return value:" + retValue);
>                 } else {
> -                    logger.debug("finished invoking method " + m.getName()
> + " with exception " + exc);
> +                    logger.debug("finished invoking method " + m.getName()
> + "[Spent time: "+duration+"ms] with exception " + exc);
>                 }
>             }
>         }
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/patch-spend-time-in-bussines-method-tp4288464p4288464.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>