You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2007/05/05 08:58:51 UTC

svn commit: r535465 [43/49] - in /jakarta/turbine/fulcrum/trunk: ./ bsf/ bsf/src/java/org/apache/fulcrum/bsf/ bsf/src/test/ bsf/xdocs/ cache/ cache/src/java/org/apache/fulcrum/cache/ cache/src/java/org/apache/fulcrum/cache/impl/ cache/src/test/ cache/s...

Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/baseservice/BaseInterceptorServiceImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/baseservice/BaseInterceptorServiceImpl.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/baseservice/BaseInterceptorServiceImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/baseservice/BaseInterceptorServiceImpl.java Fri May  4 23:58:06 2007
@@ -1,275 +1,277 @@
-package org.apache.fulcrum.yaafi.interceptor.baseservice;
-
-/*
- * Copyright 2004 Apache Software Foundation
- * 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.
- */
-
-import java.io.File;
-import java.util.HashSet;
-
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.Reconfigurable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext;
-import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
-import org.apache.fulcrum.yaafi.framework.util.StringUtils;
-
-/**
- * A base service providing common functionality for interceptors
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-
-public class BaseInterceptorServiceImpl
-    extends AbstractLogEnabled
-    implements AvalonInterceptorService, Contextualizable, Reconfigurable
-{
-    /** this matches all services */
-    private static final String WILDCARD = "*";
-    
-    /** contains the services being monitored by the interceptor */
-    private HashSet serviceSet;
-    
-    /** is the interceptor service enabled */
-    private boolean isEnabled;
-    
-    /** The name of the service as defined in the role configuration file */
-    private String serviceName;
-
-    /** The service manager supplied by the Avalon framework */
-    private ServiceManager serviceManager;
-
-    /** the Avalon application directory */
-    private File serviceApplicationDir;
-
-    /** the Avalon temp directory */
-    private File serviceTempDir;
-    
-    /** the supplied class loader */
-    private ClassLoader classLoader;
-    
-
-    /////////////////////////////////////////////////////////////////////////
-    // Avalon Service Lifecycle Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * Constructor
-     */
-    public BaseInterceptorServiceImpl()
-    {
-        this.serviceSet = new HashSet();
-    }
-
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException
-    {
-        this.serviceName = (String) context.get("urn:avalon:name");
-        this.serviceApplicationDir = (File) context.get("urn:avalon:home");
-        this.serviceTempDir = (File) context.get("urn:avalon:temp");
-        this.classLoader = (ClassLoader) context.get("urn:avalon:classloader");
-    }
-
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration configuration) throws ConfigurationException
-    {
-        // take care - the default is disabled which is helpful
-        // for the way we use the interceptors
-        
-        this.isEnabled = configuration.getChild("isEnabled").getValueAsBoolean(false);
-            
-        // parse the service to be monitored
-
-        Configuration[] serviceConfigList = configuration.getChild("services").getChildren("service");
-
-        if( serviceConfigList.length == 0 )
-        {
-            this.getServiceSet().add(WILDCARD);
-        }
-        else
-        {
-            for( int i=0; i<serviceConfigList.length; i++ )
-            {
-                String name = serviceConfigList[i].getAttribute("name", null);
-                String shorthand = serviceConfigList[i].getAttribute("shorthand", null);
-
-                if( !StringUtils.isEmpty(name) )
-                {
-                    this.getServiceSet().add(name);
-                }
-
-                if( !StringUtils.isEmpty(shorthand) )
-                {
-                    this.getServiceSet().add(shorthand);
-                }
-            }
-        }
-    }
-
-    /**
-     * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void reconfigure(Configuration configuration) throws ConfigurationException
-    {
-        this.getServiceSet().clear();
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service interface implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext)
-     */
-    public void onEntry(AvalonInterceptorContext avalonInterceptorContext)
-    {
-        // nothing to do
-    }
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Throwable)
-     */
-    public void onError(AvalonInterceptorContext avalonInterceptorContext,Throwable t)
-    {
-        // nothing to do
-    }
-    
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Object)
-     */
-    public void onExit(AvalonInterceptorContext avalonInterceptorContext, Object result)
-    {
-        // nothing to do
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @return Returns the isEnabled.
-     */
-    protected boolean isEnabled()
-    {
-        return isEnabled;
-    }
-    
-    /**
-     * Determine if the given service is monitored.
-     * 
-     * @param avalonInterceptorContext interceptor context 
-     * @return true if the service is monitored or false otherwise
-     */
-    protected boolean isServiceMonitored( AvalonInterceptorContext avalonInterceptorContext )
-    {
-        if( !this.isEnabled() )
-        {
-            return false;
-        }
-        else if( this.getServiceSet().contains(WILDCARD) )
-        {
-            return true;
-        }
-        else if( this.getServiceSet().contains(avalonInterceptorContext.getServiceName()) )
-        {
-            return true;
-        }
-        else if( this.getServiceSet().contains(avalonInterceptorContext.getServiceShorthand()) )
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-           
-    /**
-     * @return Returns the serviceApplicationDir.
-     */
-    protected File getServiceApplicationDir()
-    {
-        return serviceApplicationDir;
-    }
-    
-    /**
-     * @return Returns the serviceManager.
-     */
-    protected ServiceManager getServiceManager()
-    {
-        return serviceManager;
-    }
-    
-    /**
-     * @return Returns the serviceName.
-     */
-    protected String getServiceName()
-    {
-        return serviceName;
-    }
-    
-    /**
-     * @return Returns the serviceTempDir.
-     */
-    protected File getServiceTempDir()
-    {
-        return serviceTempDir;
-    }
-    
-    /**
-		 * @return Returns the classLoader.
-		 */
-		protected ClassLoader getClassLoader() {
-			return this.classLoader;
-		}
-
-		/**
-     * Determines the file location of the given name. If the name denotes
-     * a relative file location it will be resolved using the application
-     * home directory.
-     *
-     * @param name the filename
-     * @return the file
-     */
-    protected File makeAbsoluteFile( String name )
-    {
-        File result = new File(name);
-
-        if( result.isAbsolute() == false )
-        {
-            result = new File( this.getServiceApplicationDir(), name );
-        }
-
-        return result;
-    }
-
-    /**
-     * @return Returns the serviceMap.
-     */
-    private HashSet getServiceSet()
-    {
-        return serviceSet;
-    }      
-}
+package org.apache.fulcrum.yaafi.interceptor.baseservice;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.util.HashSet;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.Reconfigurable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext;
+import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
+import org.apache.fulcrum.yaafi.framework.util.StringUtils;
+
+/**
+ * A base service providing common functionality for interceptors
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+
+public class BaseInterceptorServiceImpl
+    extends AbstractLogEnabled
+    implements AvalonInterceptorService, Contextualizable, Reconfigurable
+{
+    /** this matches all services */
+    private static final String WILDCARD = "*";
+
+    /** contains the services being monitored by the interceptor */
+    private HashSet serviceSet;
+
+    /** is the interceptor service enabled */
+    private boolean isEnabled;
+
+    /** The name of the service as defined in the role configuration file */
+    private String serviceName;
+
+    /** The service manager supplied by the Avalon framework */
+    private ServiceManager serviceManager;
+
+    /** the Avalon application directory */
+    private File serviceApplicationDir;
+
+    /** the Avalon temp directory */
+    private File serviceTempDir;
+
+    /** the supplied class loader */
+    private ClassLoader classLoader;
+
+
+    /////////////////////////////////////////////////////////////////////////
+    // Avalon Service Lifecycle Implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Constructor
+     */
+    public BaseInterceptorServiceImpl()
+    {
+        this.serviceSet = new HashSet();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     */
+    public void contextualize(Context context) throws ContextException
+    {
+        this.serviceName = (String) context.get("urn:avalon:name");
+        this.serviceApplicationDir = (File) context.get("urn:avalon:home");
+        this.serviceTempDir = (File) context.get("urn:avalon:temp");
+        this.classLoader = (ClassLoader) context.get("urn:avalon:classloader");
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration configuration) throws ConfigurationException
+    {
+        // take care - the default is disabled which is helpful
+        // for the way we use the interceptors
+
+        this.isEnabled = configuration.getChild("isEnabled").getValueAsBoolean(false);
+
+        // parse the service to be monitored
+
+        Configuration[] serviceConfigList = configuration.getChild("services").getChildren("service");
+
+        if( serviceConfigList.length == 0 )
+        {
+            this.getServiceSet().add(WILDCARD);
+        }
+        else
+        {
+            for( int i=0; i<serviceConfigList.length; i++ )
+            {
+                String name = serviceConfigList[i].getAttribute("name", null);
+                String shorthand = serviceConfigList[i].getAttribute("shorthand", null);
+
+                if( !StringUtils.isEmpty(name) )
+                {
+                    this.getServiceSet().add(name);
+                }
+
+                if( !StringUtils.isEmpty(shorthand) )
+                {
+                    this.getServiceSet().add(shorthand);
+                }
+            }
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void reconfigure(Configuration configuration) throws ConfigurationException
+    {
+        this.getServiceSet().clear();
+    }
+
+    /////////////////////////////////////////////////////////////////////////
+    // Service interface implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext)
+     */
+    public void onEntry(AvalonInterceptorContext avalonInterceptorContext)
+    {
+        // nothing to do
+    }
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Throwable)
+     */
+    public void onError(AvalonInterceptorContext avalonInterceptorContext,Throwable t)
+    {
+        // nothing to do
+    }
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Object)
+     */
+    public void onExit(AvalonInterceptorContext avalonInterceptorContext, Object result)
+    {
+        // nothing to do
+    }
+
+    /////////////////////////////////////////////////////////////////////////
+    // Service Implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * @return Returns the isEnabled.
+     */
+    protected boolean isEnabled()
+    {
+        return isEnabled;
+    }
+
+    /**
+     * Determine if the given service is monitored.
+     *
+     * @param avalonInterceptorContext interceptor context
+     * @return true if the service is monitored or false otherwise
+     */
+    protected boolean isServiceMonitored( AvalonInterceptorContext avalonInterceptorContext )
+    {
+        if( !this.isEnabled() )
+        {
+            return false;
+        }
+        else if( this.getServiceSet().contains(WILDCARD) )
+        {
+            return true;
+        }
+        else if( this.getServiceSet().contains(avalonInterceptorContext.getServiceName()) )
+        {
+            return true;
+        }
+        else if( this.getServiceSet().contains(avalonInterceptorContext.getServiceShorthand()) )
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * @return Returns the serviceApplicationDir.
+     */
+    protected File getServiceApplicationDir()
+    {
+        return serviceApplicationDir;
+    }
+
+    /**
+     * @return Returns the serviceManager.
+     */
+    protected ServiceManager getServiceManager()
+    {
+        return serviceManager;
+    }
+
+    /**
+     * @return Returns the serviceName.
+     */
+    protected String getServiceName()
+    {
+        return serviceName;
+    }
+
+    /**
+     * @return Returns the serviceTempDir.
+     */
+    protected File getServiceTempDir()
+    {
+        return serviceTempDir;
+    }
+
+    /**
+		 * @return Returns the classLoader.
+		 */
+		protected ClassLoader getClassLoader() {
+			return this.classLoader;
+		}
+
+		/**
+     * Determines the file location of the given name. If the name denotes
+     * a relative file location it will be resolved using the application
+     * home directory.
+     *
+     * @param name the filename
+     * @return the file
+     */
+    protected File makeAbsoluteFile( String name )
+    {
+        File result = new File(name);
+
+        if( result.isAbsolute() == false )
+        {
+            result = new File( this.getServiceApplicationDir(), name );
+        }
+
+        return result;
+    }
+
+    /**
+     * @return Returns the serviceMap.
+     */
+    private HashSet getServiceSet()
+    {
+        return serviceSet;
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorService.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorService.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorService.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorService.java Fri May  4 23:58:06 2007
@@ -1,31 +1,33 @@
-package org.apache.fulcrum.yaafi.interceptor.jamon;
-
-/*
- * Copyright 2004 Apache Software Foundation
- * 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.
- */
-
-import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
-
-/**
- * A service using JAMON for performance monitoring
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-
-public interface JamonInterceptorService extends AvalonInterceptorService, Runnable
-{
-    // This interface doesn't exposes any other methods
-}
\ No newline at end of file
+package org.apache.fulcrum.yaafi.interceptor.jamon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
+
+/**
+ * A service using JAMON for performance monitoring
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+
+public interface JamonInterceptorService extends AvalonInterceptorService, Runnable
+{
+    // This interface doesn't exposes any other methods
+}

Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java Fri May  4 23:58:06 2007
@@ -1,382 +1,384 @@
-package org.apache.fulcrum.yaafi.interceptor.jamon;
-
-/*
- * Copyright 2004 Apache Software Foundation
- * 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.
- */
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-import java.lang.reflect.Method;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.Reconfigurable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext;
-import org.apache.fulcrum.yaafi.framework.reflection.Clazz;
-import org.apache.fulcrum.yaafi.interceptor.baseservice.BaseInterceptorServiceImpl;
-import org.apache.fulcrum.yaafi.interceptor.util.MethodToStringBuilderImpl;
-
-/**
- * A service using JAMon for performance monitoring. The implementation
- * relies on reflection to invoke JAMON to avoid compile-time coupling.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-
-public class JamonInterceptorServiceImpl
-    extends BaseInterceptorServiceImpl
-    implements JamonInterceptorService, Reconfigurable, ThreadSafe, Disposable, Initializable
-{
-	/** are the JAMon classes in the classpath */
-	private boolean isJamonAvailable;
-
-    /** the file to hold the report */
-    private File reportFile;
-
-    /** the time in ms between two reports */
-    private long reportTimeout;
-
-    /** do we create a report during disposal of the service */
-    private boolean reportOnExit;
-
-    /** the time when the next report is due */
-    private long nextReportTimestamp;
-
-    /** the class for JAMon MonitorFactory */
-    private Class monitorFactoryClass;
-
-    /** the class name of the JAMon MonitorFactory */
-    private static final String MONITORFACTOTY_CLASSNAME = "com.jamonapi.MonitorFactory";
-
-    /////////////////////////////////////////////////////////////////////////
-    // Avalon Service Lifecycle Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * Constructor
-     */
-    public JamonInterceptorServiceImpl()
-    {
-        super();
-    }
-
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration configuration) throws ConfigurationException
-    {
-        String reportFileName = null;
-
-        super.configure(configuration);
-        this.reportTimeout = configuration.getChild("reportTimeout").getValueAsLong(0);
-
-        // parse the report file name
-
-        reportFileName = configuration.getChild("reportFile").getValue("./jamon.html");
-        this.reportFile = this.makeAbsoluteFile( reportFileName );
-
-        // determine when to create the next report
-
-        this.nextReportTimestamp = System.currentTimeMillis() + this.reportTimeout;
-
-        // do we create a report on disposal
-
-        this.reportOnExit = configuration.getChild("reportOnExit").getValueAsBoolean(false);
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
-     */
-    public void initialize() throws Exception
-    {
-        ClassLoader classLoader = this.getClassLoader();
-
-        if (Clazz.hasClazz(classLoader, MONITORFACTOTY_CLASSNAME))
-        {
-            this.monitorFactoryClass = Clazz.getClazz(
-                classLoader,
-                MONITORFACTOTY_CLASSNAME
-                );
-
-            this.isJamonAvailable = true;
-        }
-        else
-        {
-            String msg = "The JamonInterceptorService is disabled since the JAMON classes are not found in the classpath";
-            this.getLogger().warn(msg);
-            this.isJamonAvailable = false;
-        }
-    }
-
-        /**
-     * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void reconfigure(Configuration configuration) throws ConfigurationException
-    {
-        super.reconfigure(configuration);
-        this.configure(configuration);
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Disposable#dispose()
-     */
-    public void dispose()
-    {
-        if( this.reportOnExit )
-        {
-            this.getLogger().debug( "Creating JAMOM report ..." );
-            this.run();
-        }
-
-        this.monitorFactoryClass = null;
-        this.reportFile = null;
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service interface implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext)
-     */
-    public void onEntry(AvalonInterceptorContext interceptorContext)
-    {
-        this.writeReport();
-
-        if( this.isJamonAvailable() && this.isServiceMonitored(interceptorContext ) )
-        {
-            this.createMonitor(interceptorContext);
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Throwable)
-     */
-    public void onError(AvalonInterceptorContext interceptorContext,Throwable t)
-    {
-        if( this.isJamonAvailable() && this.isServiceMonitored(interceptorContext) )
-        {
-            Object monitor = this.getMonitor(interceptorContext);
-            this.stopMonitor(monitor);
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Object)
-     */
-    public void onExit(AvalonInterceptorContext interceptorContext, Object result)
-    {
-        if( this.isJamonAvailable() && this.isServiceMonitored(interceptorContext) )
-        {
-            Object monitor = this.getMonitor(interceptorContext);
-            this.stopMonitor(monitor);
-        }
-    }
-    
-    /**
-     * Writes the JAMON report to the file system.
-     * 
-     * @see java.lang.Runnable#run()
-     */
-    public void run()
-    {
-        this.writeReport(this.reportFile);
-    }
-    
-    /////////////////////////////////////////////////////////////////////////
-    // Service Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @return Returns the isJamonAvailable.
-     */
-    protected boolean isJamonAvailable()
-    {
-        return this.isJamonAvailable;
-    }
-
-    /**
-     * Creates a JAMON monitor
-     *
-     * @param interceptorContext the current interceptor context
-     */
-    protected void createMonitor(
-        AvalonInterceptorContext interceptorContext )
-    {
-        Method method = interceptorContext.getMethod();
-        MethodToStringBuilderImpl methodToStringBuilder = new MethodToStringBuilderImpl(method,0);
-        String monitorCategory = methodToStringBuilder.toString();
-        Object monitor = this.createMonitor(monitorCategory);
-        interceptorContext.getRequestContext().put(this.getServiceName(),monitor);
-    }
-
-    /**
-     * Gets the JAMON Monitor
-     *
-     * @param interceptorContext the current interceptor context
-     * @return the monitor
-     */
-    protected Object getMonitor(
-        AvalonInterceptorContext interceptorContext )
-    {
-        return interceptorContext.getRequestContext().remove(
-            this.getServiceName()
-            );
-    }
-
-    /**
-     * Write a report file
-     */
-    protected void writeReport()
-    {
-        if( this.reportTimeout > 0 )
-        {
-            long currTimestamp = System.currentTimeMillis();
-
-            if( currTimestamp > this.nextReportTimestamp )
-            {
-                this.nextReportTimestamp = currTimestamp + this.reportTimeout;
-                this.writeReport(this.reportFile);
-            }
-        }
-    }
-
-    /**
-     * Write the HTML report to the given destination.
-     *
-     * @param reportFile the report destination
-     */
-    protected void writeReport( File reportFile )
-    {
-        if( this.isJamonAvailable() )
-        {
-            PrintWriter printWriter = null;
-            String report = null;
-
-            try
-            {
-                if( this.getLogger().isDebugEnabled() )
-                {
-                    this.getLogger().debug( "Writing JAMOM report to " + reportFile.getAbsolutePath() );
-                }
-
-                FileOutputStream fos = new FileOutputStream( reportFile );
-                printWriter = new PrintWriter( fos );
-                report = this.createReport();
-                printWriter.write( report );
-                printWriter.close();
-            }
-            catch( Throwable t )
-            {
-                String msg = "Generating the JAMON report failed for " + reportFile.getAbsolutePath();
-                this.getLogger().error(msg,t);
-            }
-            finally
-            {
-                if( printWriter != null )
-                {
-                    printWriter.close();
-                    printWriter = null;
-                }
-            }
-        }
-    }
-
-    /**
-     * Creates a JAMON monitor for the category name.
-     *
-     * @param category the category name
-     * @return the monitor
-     */
-    private Object createMonitor(String category)
-    {
-		Object result = null;
-		String methodName = "start";
-		Class[] signature = { String.class };
-		Object[] args = { category };
-		
-		// invoke MonitorFactory.start(String);
-
-        try
-        {
-            result = Clazz.invoke( this.monitorFactoryClass, methodName, signature, args );
-        }
-        catch (Exception e)
-        {
-            String msg = "Invoking com.jamonapi.MonitorFactory.start() failed";
-            this.getLogger().error( msg, e );
-        }
-
-        return result;
-    }
-
-    /**
-     * Stop the JAMON monitor.
-     *
-     * @param monitor the monitor to be stopped
-     */
-    private void stopMonitor( Object monitor )
-    {
-        String methodName = "stop";
-        Class[] signature = {};
-        Object[] args = {};
-
-        // invoke MonitorFactory.start(String);
-
-        try
-        {
-            Clazz.invoke(monitor, methodName, signature, args);
-        }
-        catch (Throwable t)
-        {
-            String msg = "Invoking com.jamonapi.MonitorFactory.start() failed";
-            this.getLogger().error(msg,t);
-        }
-    }
-
-    /**
-     * Create a JAMON report.
-     *
-     * @return the report
-     */
-    private String createReport()
-    {
-        String result = null;
-        Object rootMonitor = null;
-        Class[] signature = {};
-        Object[] args = {};
-
-        try
-        {
-            // invoke MonitorFactory.getRootMonitor().getReport()
-
-            rootMonitor = Clazz.invoke(this.monitorFactoryClass, "getRootMonitor", signature, args);
-            result = (String) Clazz.invoke(rootMonitor, "getReport", signature, args);
-        }
-        catch (Throwable t)
-        {
-            String msg = "Invoking com.jamonapi.MonitorFactory.getRootMonitor().getReport()() failed";
-            this.getLogger().error(msg,t);
-            result = "<" + t + ">";
-        }
-
-        return result;
-    }
-}
+package org.apache.fulcrum.yaafi.interceptor.jamon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.Reconfigurable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext;
+import org.apache.fulcrum.yaafi.framework.reflection.Clazz;
+import org.apache.fulcrum.yaafi.interceptor.baseservice.BaseInterceptorServiceImpl;
+import org.apache.fulcrum.yaafi.interceptor.util.MethodToStringBuilderImpl;
+
+/**
+ * A service using JAMon for performance monitoring. The implementation
+ * relies on reflection to invoke JAMON to avoid compile-time coupling.
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+
+public class JamonInterceptorServiceImpl
+    extends BaseInterceptorServiceImpl
+    implements JamonInterceptorService, Reconfigurable, ThreadSafe, Disposable, Initializable
+{
+	/** are the JAMon classes in the classpath */
+	private boolean isJamonAvailable;
+
+    /** the file to hold the report */
+    private File reportFile;
+
+    /** the time in ms between two reports */
+    private long reportTimeout;
+
+    /** do we create a report during disposal of the service */
+    private boolean reportOnExit;
+
+    /** the time when the next report is due */
+    private long nextReportTimestamp;
+
+    /** the class for JAMon MonitorFactory */
+    private Class monitorFactoryClass;
+
+    /** the class name of the JAMon MonitorFactory */
+    private static final String MONITORFACTOTY_CLASSNAME = "com.jamonapi.MonitorFactory";
+
+    /////////////////////////////////////////////////////////////////////////
+    // Avalon Service Lifecycle Implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Constructor
+     */
+    public JamonInterceptorServiceImpl()
+    {
+        super();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration configuration) throws ConfigurationException
+    {
+        String reportFileName = null;
+
+        super.configure(configuration);
+        this.reportTimeout = configuration.getChild("reportTimeout").getValueAsLong(0);
+
+        // parse the report file name
+
+        reportFileName = configuration.getChild("reportFile").getValue("./jamon.html");
+        this.reportFile = this.makeAbsoluteFile( reportFileName );
+
+        // determine when to create the next report
+
+        this.nextReportTimestamp = System.currentTimeMillis() + this.reportTimeout;
+
+        // do we create a report on disposal
+
+        this.reportOnExit = configuration.getChild("reportOnExit").getValueAsBoolean(false);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception
+    {
+        ClassLoader classLoader = this.getClassLoader();
+
+        if (Clazz.hasClazz(classLoader, MONITORFACTOTY_CLASSNAME))
+        {
+            this.monitorFactoryClass = Clazz.getClazz(
+                classLoader,
+                MONITORFACTOTY_CLASSNAME
+                );
+
+            this.isJamonAvailable = true;
+        }
+        else
+        {
+            String msg = "The JamonInterceptorService is disabled since the JAMON classes are not found in the classpath";
+            this.getLogger().warn(msg);
+            this.isJamonAvailable = false;
+        }
+    }
+
+        /**
+     * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void reconfigure(Configuration configuration) throws ConfigurationException
+    {
+        super.reconfigure(configuration);
+        this.configure(configuration);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose()
+    {
+        if( this.reportOnExit )
+        {
+            this.getLogger().debug( "Creating JAMOM report ..." );
+            this.run();
+        }
+
+        this.monitorFactoryClass = null;
+        this.reportFile = null;
+    }
+
+    /////////////////////////////////////////////////////////////////////////
+    // Service interface implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext)
+     */
+    public void onEntry(AvalonInterceptorContext interceptorContext)
+    {
+        this.writeReport();
+
+        if( this.isJamonAvailable() && this.isServiceMonitored(interceptorContext ) )
+        {
+            this.createMonitor(interceptorContext);
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Throwable)
+     */
+    public void onError(AvalonInterceptorContext interceptorContext,Throwable t)
+    {
+        if( this.isJamonAvailable() && this.isServiceMonitored(interceptorContext) )
+        {
+            Object monitor = this.getMonitor(interceptorContext);
+            this.stopMonitor(monitor);
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Object)
+     */
+    public void onExit(AvalonInterceptorContext interceptorContext, Object result)
+    {
+        if( this.isJamonAvailable() && this.isServiceMonitored(interceptorContext) )
+        {
+            Object monitor = this.getMonitor(interceptorContext);
+            this.stopMonitor(monitor);
+        }
+    }
+
+    /**
+     * Writes the JAMON report to the file system.
+     *
+     * @see java.lang.Runnable#run()
+     */
+    public void run()
+    {
+        this.writeReport(this.reportFile);
+    }
+
+    /////////////////////////////////////////////////////////////////////////
+    // Service Implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * @return Returns the isJamonAvailable.
+     */
+    protected boolean isJamonAvailable()
+    {
+        return this.isJamonAvailable;
+    }
+
+    /**
+     * Creates a JAMON monitor
+     *
+     * @param interceptorContext the current interceptor context
+     */
+    protected void createMonitor(
+        AvalonInterceptorContext interceptorContext )
+    {
+        Method method = interceptorContext.getMethod();
+        MethodToStringBuilderImpl methodToStringBuilder = new MethodToStringBuilderImpl(method,0);
+        String monitorCategory = methodToStringBuilder.toString();
+        Object monitor = this.createMonitor(monitorCategory);
+        interceptorContext.getRequestContext().put(this.getServiceName(),monitor);
+    }
+
+    /**
+     * Gets the JAMON Monitor
+     *
+     * @param interceptorContext the current interceptor context
+     * @return the monitor
+     */
+    protected Object getMonitor(
+        AvalonInterceptorContext interceptorContext )
+    {
+        return interceptorContext.getRequestContext().remove(
+            this.getServiceName()
+            );
+    }
+
+    /**
+     * Write a report file
+     */
+    protected void writeReport()
+    {
+        if( this.reportTimeout > 0 )
+        {
+            long currTimestamp = System.currentTimeMillis();
+
+            if( currTimestamp > this.nextReportTimestamp )
+            {
+                this.nextReportTimestamp = currTimestamp + this.reportTimeout;
+                this.writeReport(this.reportFile);
+            }
+        }
+    }
+
+    /**
+     * Write the HTML report to the given destination.
+     *
+     * @param reportFile the report destination
+     */
+    protected void writeReport( File reportFile )
+    {
+        if( this.isJamonAvailable() )
+        {
+            PrintWriter printWriter = null;
+            String report = null;
+
+            try
+            {
+                if( this.getLogger().isDebugEnabled() )
+                {
+                    this.getLogger().debug( "Writing JAMOM report to " + reportFile.getAbsolutePath() );
+                }
+
+                FileOutputStream fos = new FileOutputStream( reportFile );
+                printWriter = new PrintWriter( fos );
+                report = this.createReport();
+                printWriter.write( report );
+                printWriter.close();
+            }
+            catch( Throwable t )
+            {
+                String msg = "Generating the JAMON report failed for " + reportFile.getAbsolutePath();
+                this.getLogger().error(msg,t);
+            }
+            finally
+            {
+                if( printWriter != null )
+                {
+                    printWriter.close();
+                    printWriter = null;
+                }
+            }
+        }
+    }
+
+    /**
+     * Creates a JAMON monitor for the category name.
+     *
+     * @param category the category name
+     * @return the monitor
+     */
+    private Object createMonitor(String category)
+    {
+		Object result = null;
+		String methodName = "start";
+		Class[] signature = { String.class };
+		Object[] args = { category };
+
+		// invoke MonitorFactory.start(String);
+
+        try
+        {
+            result = Clazz.invoke( this.monitorFactoryClass, methodName, signature, args );
+        }
+        catch (Exception e)
+        {
+            String msg = "Invoking com.jamonapi.MonitorFactory.start() failed";
+            this.getLogger().error( msg, e );
+        }
+
+        return result;
+    }
+
+    /**
+     * Stop the JAMON monitor.
+     *
+     * @param monitor the monitor to be stopped
+     */
+    private void stopMonitor( Object monitor )
+    {
+        String methodName = "stop";
+        Class[] signature = {};
+        Object[] args = {};
+
+        // invoke MonitorFactory.start(String);
+
+        try
+        {
+            Clazz.invoke(monitor, methodName, signature, args);
+        }
+        catch (Throwable t)
+        {
+            String msg = "Invoking com.jamonapi.MonitorFactory.start() failed";
+            this.getLogger().error(msg,t);
+        }
+    }
+
+    /**
+     * Create a JAMON report.
+     *
+     * @return the report
+     */
+    private String createReport()
+    {
+        String result = null;
+        Object rootMonitor = null;
+        Class[] signature = {};
+        Object[] args = {};
+
+        try
+        {
+            // invoke MonitorFactory.getRootMonitor().getReport()
+
+            rootMonitor = Clazz.invoke(this.monitorFactoryClass, "getRootMonitor", signature, args);
+            result = (String) Clazz.invoke(rootMonitor, "getReport", signature, args);
+        }
+        catch (Throwable t)
+        {
+            String msg = "Invoking com.jamonapi.MonitorFactory.getRootMonitor().getReport()() failed";
+            this.getLogger().error(msg,t);
+            result = "<" + t + ">";
+        }
+
+        return result;
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorService.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorService.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorService.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorService.java Fri May  4 23:58:06 2007
@@ -1,31 +1,33 @@
-package org.apache.fulcrum.yaafi.interceptor.logging;
-
-/*
- * Copyright 2004 Apache Software Foundation
- * 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.
- */
-
-import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
-
-/**
- * A service logging of service invocations.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-
-public interface LoggingInterceptorService extends AvalonInterceptorService
-{
-    // This interface doesn't exposes any other methods
-}
\ No newline at end of file
+package org.apache.fulcrum.yaafi.interceptor.logging;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
+
+/**
+ * A service logging of service invocations.
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+
+public interface LoggingInterceptorService extends AvalonInterceptorService
+{
+    // This interface doesn't exposes any other methods
+}

Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java Fri May  4 23:58:06 2007
@@ -1,390 +1,392 @@
-package org.apache.fulcrum.yaafi.interceptor.logging;
-
-/*
- * Copyright 2004 Apache Software Foundation
- * 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.
- */
-
-import java.lang.reflect.Method;
-
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.Reconfigurable;
-import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext;
-import org.apache.fulcrum.yaafi.framework.reflection.Clazz;
-import org.apache.fulcrum.yaafi.interceptor.baseservice.BaseInterceptorServiceImpl;
-import org.apache.fulcrum.yaafi.interceptor.util.DefaultToStringBuilderImpl;
-import org.apache.fulcrum.yaafi.interceptor.util.InterceptorToStringBuilder;
-import org.apache.fulcrum.yaafi.interceptor.util.MethodToStringBuilderImpl;
-import org.apache.fulcrum.yaafi.interceptor.util.ArgumentToStringBuilderImpl;
-import org.apache.fulcrum.yaafi.interceptor.util.StopWatch;
-
-/**
- * A service logging of service invocations. The service allows to monitor
- * a list of services defined in the configuration.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-
-public class LoggingInterceptorServiceImpl
-    extends BaseInterceptorServiceImpl
-    implements LoggingInterceptorService, Reconfigurable, Initializable
-{
-    /** the maximum length of a dumped argument */
-    private static final int MAX_ARG_LENGTH = 2000;
-
-    /** seperator for the arguments in the logfile */
-    private static final String SEPERATOR = ";";
-
-    /** maximum argument length for dumping arguments */
-    private int maxArgLength;
-
-    /** the class name of the string builder to use */
-    private String toStringBuilderClassName;
-
-    /** monitor all excpetions independent from the monitored services */
-    private boolean monitorAllExceptions;
-
-    /** the ReflectionToStringBuilder class */
-    private Class toStringBuilderClass;
-
-    /////////////////////////////////////////////////////////////////////////
-    // Avalon Service Lifecycle Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * Constructor
-     */
-    public LoggingInterceptorServiceImpl()
-    {
-        super();
-        this.maxArgLength = MAX_ARG_LENGTH;
-    }
-
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration configuration) throws ConfigurationException
-    {
-        super.configure(configuration);
-        
-        this.maxArgLength = configuration.getChild("maxArgLength").getValueAsInteger(MAX_ARG_LENGTH);
-        this.toStringBuilderClassName = configuration.getChild("toStringBuilderClass").getValue(ArgumentToStringBuilderImpl.class.getName());
-        this.monitorAllExceptions = configuration.getChild("monitorAllExceptions").getValueAsBoolean(true);
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
-     */
-    public void initialize() throws Exception
-    {
-        // load the string builder class
-
-        ClassLoader classLoader = this.getClass().getClassLoader();
-
-        if( Clazz.hasClazz(classLoader, this.getToStringBuilderClassName()) )
-        {
-            this.toStringBuilderClass = Clazz.getClazz(
-                classLoader,
-                this.getToStringBuilderClassName()
-                );
-        }
-        
-        // create an instance of the StringBuilder to see if everything works
-        
-        InterceptorToStringBuilder interceptorToStringBuilder = this.createArgumentToStringBuilder(
-            this
-            );
-            
-        interceptorToStringBuilder.toString();        
-    }
-
-    /**
-     * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void reconfigure(Configuration configuration) throws ConfigurationException
-    {
-        super.reconfigure(configuration);
-        this.configure(configuration);
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service interface implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext)
-     */
-    public void onEntry(AvalonInterceptorContext interceptorContext)
-    {
-        if( this.isServiceMonitored(interceptorContext ) )
-        {
-            if( this.getLogger().isInfoEnabled() )
-            {                
-                String msg = this.toString(interceptorContext,null,ON_ENTRY);
-                this.getLogger().info(msg);
-                this.createStopWatch(interceptorContext);
-            }
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Throwable)
-     */
-    public void onError(AvalonInterceptorContext interceptorContext,Throwable t)
-    {
-        if( this.getLogger().isErrorEnabled() )
-        {
-	        if( this.isMonitorAllExceptions() || this.isServiceMonitored(interceptorContext) )
-	        {
-	            StopWatch stopWatch = this.getStopWatch(interceptorContext);
-	            stopWatch.stop();
-	            String msg = this.toString(interceptorContext, stopWatch, t);
-	            this.getLogger().error(msg);
-	        }
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Object)
-     */
-    public void onExit(AvalonInterceptorContext interceptorContext, Object result)
-    {
-        if( this.isServiceMonitored(interceptorContext) )
-        {
-            if( this.getLogger().isDebugEnabled() )
-            {
-                StopWatch stopWatch = this.getStopWatch(interceptorContext);
-                stopWatch.stop();
-                String msg = this.toString(interceptorContext, stopWatch, result);
-                this.getLogger().debug(msg);
-            }
-        }
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * Creates a stop watch
-     * 
-     * @param interceptorContext the current interceptor context
-     */
-    protected void createStopWatch(
-        AvalonInterceptorContext interceptorContext )
-    {
-        StopWatch stopWatch = new StopWatch();
-        stopWatch.start();
-        interceptorContext.getRequestContext().put(this.getServiceName(),stopWatch);        
-    }
-
-    /**
-     * Gets the stop watch. Even if none is defined we return one
-     * in a proper state.
-     * 
-     * @param interceptorContext the current interceptor context
-     * @return the stop watch
-     */
-    protected StopWatch getStopWatch( 
-        AvalonInterceptorContext interceptorContext )
-    {
-        StopWatch result = (StopWatch) interceptorContext.getRequestContext().remove(
-            this.getServiceName()
-            );
-        
-        if( result == null )
-        {
-            result = new StopWatch();
-            result.start();
-        }
-        
-        return result;
-    }
-
-    /**
-     * @return Returns the maxLineLength.
-     */
-    protected int getMaxArgLength()
-    {
-        return maxArgLength;
-    }
-
-    /**
-     * @return Returns the monitorAllExceptions.
-     */
-    protected boolean isMonitorAllExceptions()
-    {
-        return monitorAllExceptions;
-    }
-
-    /**
-     * @return Returns the toStringBuilderClass.
-     */
-    protected Class getToStringBuilderClass()
-    {
-        return toStringBuilderClass;
-    }
-    
-    /**
-     * @return Returns the toStringBuilderClassName.
-     */
-    protected String getToStringBuilderClassName()
-    {
-        return toStringBuilderClassName;
-    }
-    
-    /**
-     * Create an instance of an InterceptorToStringBuilder
-     * 
-     * @param target the object to stringify
-     * @return the string builder
-     */
-    protected InterceptorToStringBuilder createArgumentToStringBuilder(Object target)
-    {
-        InterceptorToStringBuilder result = null;
-        
-        try
-        {
-            result = (InterceptorToStringBuilder) 
-            	this.getToStringBuilderClass().newInstance();
-        }
-        catch (Exception e)
-        {
-            String msg = "Unable to create an instance for " + this.getToStringBuilderClassName();
-            this.getLogger().error(msg,e);
-            result = new DefaultToStringBuilderImpl();
-        }
-     
-        result.setTarget(target);
-        result.setMaxArgLength(this.getMaxArgLength());
-        result.setMode(1);
-        
-        return result;
-    }
-    
-    /**
-     * Create a string representation of a service invocation returning a result.
-     *
-     * @param avalonInterceptorContext the interceptor context
-     * @param stopWatch the stopwatch for the execution time
-     * @param result the result of the service invocation
-     * @return the string representation of the result
-     */
-    protected String toString( 
-        AvalonInterceptorContext avalonInterceptorContext, 
-        StopWatch stopWatch,
-        Object result )
-    {
-        StringBuffer methodSignature = new StringBuffer();
-        InterceptorToStringBuilder toStringBuilder = this.createArgumentToStringBuilder(result);
-
-        methodSignature.append( this.toString(avalonInterceptorContext, stopWatch, ON_EXIT) );
-        methodSignature.append(SEPERATOR);
-        methodSignature.append( "result={" );
-        methodSignature.append( toStringBuilder.toString() );
-        methodSignature.append( "}" );
-        
-        return methodSignature.toString();
-    }
-
-    /**
-     * Create a string representation of a service invocation throwing a Throwable
-     *
-     * @param avalonInterceptorContext the interceptor context
-     * @param stopWatch the stopwatch for the execution time
-     * @param throwable the result of the service invocation
-     * @return the string representation of the result
-     */
-    protected String toString( 
-        AvalonInterceptorContext avalonInterceptorContext, 
-        StopWatch stopWatch, 
-        Throwable throwable )
-    {
-        StringBuffer methodSignature = new StringBuffer();
-        InterceptorToStringBuilder toStringBuilder = this.createArgumentToStringBuilder(throwable);
-
-        methodSignature.append( this.toString(avalonInterceptorContext, stopWatch, ON_ERROR) );
-        methodSignature.append(SEPERATOR);
-        methodSignature.append( throwable.getClass().getName() );
-        methodSignature.append(SEPERATOR);
-        methodSignature.append( toStringBuilder.toString() );
-
-        return methodSignature.toString();
-    }
-
-    /**
-     * Create a method signature.
-     *
-     * @param interceptorContext the avalonInterceptorContext
-     * @param stopWatch the stopwatch for the execution time
-     * @param mode the mode (onEntry, onExit, onError)
-     * @return the debug output
-     */
-    protected String toString( 
-        AvalonInterceptorContext interceptorContext, StopWatch stopWatch, int mode )
-    {
-        StringBuffer result = new StringBuffer();
-        Method method = interceptorContext.getMethod();
-        Object[] args = interceptorContext.getArgs();
-        InterceptorToStringBuilder toStringBuilder = null;
-        MethodToStringBuilderImpl methodToStringBuilder = new MethodToStringBuilderImpl(method);
-
-        if( args == null )
-        {
-            args = new Object[0];
-        }
-
-        result.append(interceptorContext.getTransactionId());
-        result.append(SEPERATOR);
-        result.append(interceptorContext.getInvocationId());
-        result.append(SEPERATOR);
-        result.append(interceptorContext.getInvocationDepth());
-        result.append(SEPERATOR);        
-        result.append(mode);
-        result.append(SEPERATOR);        
-        result.append(interceptorContext.getServiceShorthand());
-        result.append(SEPERATOR);
-        result.append(method.getName());
-        result.append(SEPERATOR);
-        
-        if( stopWatch != null )
-        {
-            result.append(stopWatch.getTime());
-        }
-        else
-        {
-            result.append('0');
-        }
-        
-        result.append(SEPERATOR);
-        result.append(methodToStringBuilder.toString());
-        
-        if( (ON_ENTRY == mode) || (ON_ERROR == mode) )
-        {
-	        for( int i=0; i<args.length; i++ )
-	        {
-	            toStringBuilder = this.createArgumentToStringBuilder(args[i]);
-	            result.append(SEPERATOR);
-	            result.append("arg[" + i + "]:={");
-	            result.append( toStringBuilder.toString());
-	            result.append("}");
-	        }
-        }
-        
-        return result.toString();
-    }   
-}
+package org.apache.fulcrum.yaafi.interceptor.logging;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.lang.reflect.Method;
+
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.Reconfigurable;
+import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext;
+import org.apache.fulcrum.yaafi.framework.reflection.Clazz;
+import org.apache.fulcrum.yaafi.interceptor.baseservice.BaseInterceptorServiceImpl;
+import org.apache.fulcrum.yaafi.interceptor.util.DefaultToStringBuilderImpl;
+import org.apache.fulcrum.yaafi.interceptor.util.InterceptorToStringBuilder;
+import org.apache.fulcrum.yaafi.interceptor.util.MethodToStringBuilderImpl;
+import org.apache.fulcrum.yaafi.interceptor.util.ArgumentToStringBuilderImpl;
+import org.apache.fulcrum.yaafi.interceptor.util.StopWatch;
+
+/**
+ * A service logging of service invocations. The service allows to monitor
+ * a list of services defined in the configuration.
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+
+public class LoggingInterceptorServiceImpl
+    extends BaseInterceptorServiceImpl
+    implements LoggingInterceptorService, Reconfigurable, Initializable
+{
+    /** the maximum length of a dumped argument */
+    private static final int MAX_ARG_LENGTH = 2000;
+
+    /** seperator for the arguments in the logfile */
+    private static final String SEPERATOR = ";";
+
+    /** maximum argument length for dumping arguments */
+    private int maxArgLength;
+
+    /** the class name of the string builder to use */
+    private String toStringBuilderClassName;
+
+    /** monitor all excpetions independent from the monitored services */
+    private boolean monitorAllExceptions;
+
+    /** the ReflectionToStringBuilder class */
+    private Class toStringBuilderClass;
+
+    /////////////////////////////////////////////////////////////////////////
+    // Avalon Service Lifecycle Implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Constructor
+     */
+    public LoggingInterceptorServiceImpl()
+    {
+        super();
+        this.maxArgLength = MAX_ARG_LENGTH;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration configuration) throws ConfigurationException
+    {
+        super.configure(configuration);
+
+        this.maxArgLength = configuration.getChild("maxArgLength").getValueAsInteger(MAX_ARG_LENGTH);
+        this.toStringBuilderClassName = configuration.getChild("toStringBuilderClass").getValue(ArgumentToStringBuilderImpl.class.getName());
+        this.monitorAllExceptions = configuration.getChild("monitorAllExceptions").getValueAsBoolean(true);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception
+    {
+        // load the string builder class
+
+        ClassLoader classLoader = this.getClass().getClassLoader();
+
+        if( Clazz.hasClazz(classLoader, this.getToStringBuilderClassName()) )
+        {
+            this.toStringBuilderClass = Clazz.getClazz(
+                classLoader,
+                this.getToStringBuilderClassName()
+                );
+        }
+
+        // create an instance of the StringBuilder to see if everything works
+
+        InterceptorToStringBuilder interceptorToStringBuilder = this.createArgumentToStringBuilder(
+            this
+            );
+
+        interceptorToStringBuilder.toString();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void reconfigure(Configuration configuration) throws ConfigurationException
+    {
+        super.reconfigure(configuration);
+        this.configure(configuration);
+    }
+
+    /////////////////////////////////////////////////////////////////////////
+    // Service interface implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext)
+     */
+    public void onEntry(AvalonInterceptorContext interceptorContext)
+    {
+        if( this.isServiceMonitored(interceptorContext ) )
+        {
+            if( this.getLogger().isInfoEnabled() )
+            {
+                String msg = this.toString(interceptorContext,null,ON_ENTRY);
+                this.getLogger().info(msg);
+                this.createStopWatch(interceptorContext);
+            }
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Throwable)
+     */
+    public void onError(AvalonInterceptorContext interceptorContext,Throwable t)
+    {
+        if( this.getLogger().isErrorEnabled() )
+        {
+	        if( this.isMonitorAllExceptions() || this.isServiceMonitored(interceptorContext) )
+	        {
+	            StopWatch stopWatch = this.getStopWatch(interceptorContext);
+	            stopWatch.stop();
+	            String msg = this.toString(interceptorContext, stopWatch, t);
+	            this.getLogger().error(msg);
+	        }
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Object)
+     */
+    public void onExit(AvalonInterceptorContext interceptorContext, Object result)
+    {
+        if( this.isServiceMonitored(interceptorContext) )
+        {
+            if( this.getLogger().isDebugEnabled() )
+            {
+                StopWatch stopWatch = this.getStopWatch(interceptorContext);
+                stopWatch.stop();
+                String msg = this.toString(interceptorContext, stopWatch, result);
+                this.getLogger().debug(msg);
+            }
+        }
+    }
+
+    /////////////////////////////////////////////////////////////////////////
+    // Service Implementation
+    /////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Creates a stop watch
+     *
+     * @param interceptorContext the current interceptor context
+     */
+    protected void createStopWatch(
+        AvalonInterceptorContext interceptorContext )
+    {
+        StopWatch stopWatch = new StopWatch();
+        stopWatch.start();
+        interceptorContext.getRequestContext().put(this.getServiceName(),stopWatch);
+    }
+
+    /**
+     * Gets the stop watch. Even if none is defined we return one
+     * in a proper state.
+     *
+     * @param interceptorContext the current interceptor context
+     * @return the stop watch
+     */
+    protected StopWatch getStopWatch(
+        AvalonInterceptorContext interceptorContext )
+    {
+        StopWatch result = (StopWatch) interceptorContext.getRequestContext().remove(
+            this.getServiceName()
+            );
+
+        if( result == null )
+        {
+            result = new StopWatch();
+            result.start();
+        }
+
+        return result;
+    }
+
+    /**
+     * @return Returns the maxLineLength.
+     */
+    protected int getMaxArgLength()
+    {
+        return maxArgLength;
+    }
+
+    /**
+     * @return Returns the monitorAllExceptions.
+     */
+    protected boolean isMonitorAllExceptions()
+    {
+        return monitorAllExceptions;
+    }
+
+    /**
+     * @return Returns the toStringBuilderClass.
+     */
+    protected Class getToStringBuilderClass()
+    {
+        return toStringBuilderClass;
+    }
+
+    /**
+     * @return Returns the toStringBuilderClassName.
+     */
+    protected String getToStringBuilderClassName()
+    {
+        return toStringBuilderClassName;
+    }
+
+    /**
+     * Create an instance of an InterceptorToStringBuilder
+     *
+     * @param target the object to stringify
+     * @return the string builder
+     */
+    protected InterceptorToStringBuilder createArgumentToStringBuilder(Object target)
+    {
+        InterceptorToStringBuilder result = null;
+
+        try
+        {
+            result = (InterceptorToStringBuilder)
+            	this.getToStringBuilderClass().newInstance();
+        }
+        catch (Exception e)
+        {
+            String msg = "Unable to create an instance for " + this.getToStringBuilderClassName();
+            this.getLogger().error(msg,e);
+            result = new DefaultToStringBuilderImpl();
+        }
+
+        result.setTarget(target);
+        result.setMaxArgLength(this.getMaxArgLength());
+        result.setMode(1);
+
+        return result;
+    }
+
+    /**
+     * Create a string representation of a service invocation returning a result.
+     *
+     * @param avalonInterceptorContext the interceptor context
+     * @param stopWatch the stopwatch for the execution time
+     * @param result the result of the service invocation
+     * @return the string representation of the result
+     */
+    protected String toString(
+        AvalonInterceptorContext avalonInterceptorContext,
+        StopWatch stopWatch,
+        Object result )
+    {
+        StringBuffer methodSignature = new StringBuffer();
+        InterceptorToStringBuilder toStringBuilder = this.createArgumentToStringBuilder(result);
+
+        methodSignature.append( this.toString(avalonInterceptorContext, stopWatch, ON_EXIT) );
+        methodSignature.append(SEPERATOR);
+        methodSignature.append( "result={" );
+        methodSignature.append( toStringBuilder.toString() );
+        methodSignature.append( "}" );
+
+        return methodSignature.toString();
+    }
+
+    /**
+     * Create a string representation of a service invocation throwing a Throwable
+     *
+     * @param avalonInterceptorContext the interceptor context
+     * @param stopWatch the stopwatch for the execution time
+     * @param throwable the result of the service invocation
+     * @return the string representation of the result
+     */
+    protected String toString(
+        AvalonInterceptorContext avalonInterceptorContext,
+        StopWatch stopWatch,
+        Throwable throwable )
+    {
+        StringBuffer methodSignature = new StringBuffer();
+        InterceptorToStringBuilder toStringBuilder = this.createArgumentToStringBuilder(throwable);
+
+        methodSignature.append( this.toString(avalonInterceptorContext, stopWatch, ON_ERROR) );
+        methodSignature.append(SEPERATOR);
+        methodSignature.append( throwable.getClass().getName() );
+        methodSignature.append(SEPERATOR);
+        methodSignature.append( toStringBuilder.toString() );
+
+        return methodSignature.toString();
+    }
+
+    /**
+     * Create a method signature.
+     *
+     * @param interceptorContext the avalonInterceptorContext
+     * @param stopWatch the stopwatch for the execution time
+     * @param mode the mode (onEntry, onExit, onError)
+     * @return the debug output
+     */
+    protected String toString(
+        AvalonInterceptorContext interceptorContext, StopWatch stopWatch, int mode )
+    {
+        StringBuffer result = new StringBuffer();
+        Method method = interceptorContext.getMethod();
+        Object[] args = interceptorContext.getArgs();
+        InterceptorToStringBuilder toStringBuilder = null;
+        MethodToStringBuilderImpl methodToStringBuilder = new MethodToStringBuilderImpl(method);
+
+        if( args == null )
+        {
+            args = new Object[0];
+        }
+
+        result.append(interceptorContext.getTransactionId());
+        result.append(SEPERATOR);
+        result.append(interceptorContext.getInvocationId());
+        result.append(SEPERATOR);
+        result.append(interceptorContext.getInvocationDepth());
+        result.append(SEPERATOR);
+        result.append(mode);
+        result.append(SEPERATOR);
+        result.append(interceptorContext.getServiceShorthand());
+        result.append(SEPERATOR);
+        result.append(method.getName());
+        result.append(SEPERATOR);
+
+        if( stopWatch != null )
+        {
+            result.append(stopWatch.getTime());
+        }
+        else
+        {
+            result.append('0');
+        }
+
+        result.append(SEPERATOR);
+        result.append(methodToStringBuilder.toString());
+
+        if( (ON_ENTRY == mode) || (ON_ERROR == mode) )
+        {
+	        for( int i=0; i<args.length; i++ )
+	        {
+	            toStringBuilder = this.createArgumentToStringBuilder(args[i]);
+	            result.append(SEPERATOR);
+	            result.append("arg[" + i + "]:={");
+	            result.append( toStringBuilder.toString());
+	            result.append("}");
+	        }
+        }
+
+        return result.toString();
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/performance/PerformanceInterceptorService.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/performance/PerformanceInterceptorService.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/performance/PerformanceInterceptorService.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/performance/PerformanceInterceptorService.java Fri May  4 23:58:06 2007
@@ -1,31 +1,33 @@
-package org.apache.fulcrum.yaafi.interceptor.performance;
-
-/*
- * Copyright 2004 Apache Software Foundation
- * 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.
- */
-
-import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
-
-/**
- * A service logging the execution time of service invocations.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-
-public interface PerformanceInterceptorService extends AvalonInterceptorService
-{
-    // This interface doesn't exposes any other methods
-}
\ No newline at end of file
+package org.apache.fulcrum.yaafi.interceptor.performance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
+
+/**
+ * A service logging the execution time of service invocations.
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+
+public interface PerformanceInterceptorService extends AvalonInterceptorService
+{
+    // This interface doesn't exposes any other methods
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org