Removing deprecations.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/proxy/branches/version-2.0-work@645231 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java
deleted file mode 100644
index c448f96..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.commons.proxy.interceptor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-import org.apache.commons.proxy.ProxyUtils;
-
-/**
- * An interceptor which logs each method invocation.
- * <b>Note</b>: The implementation of this class was borrowed from
- * HiveMind's logging interceptor.
- * <p/>
- * <p>
- * <b>Dependencies</b>:
- * <ul>
- * <li>Apache Commons Logging version 1.0.4 or greater</li>
- * </ul>
- * </p>
- *
- * @author James Carman
- * @since 1.0
- * @deprecated please use {@link org.apache.commons.proxy.interceptor.logging.CommonsLoggingInterceptor} instead
- */
-public class LoggingInterceptor implements Interceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static final int BUFFER_SIZE = 100;
- private Log log;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public LoggingInterceptor( Log log )
- {
- this.log = log;
- }
-
-//**********************************************************************************************************************
-// Interceptor Implementation
-//**********************************************************************************************************************
-
- public Object intercept( Invocation invocation ) throws Throwable
- {
- if( log.isDebugEnabled() )
- {
- final String methodName = invocation.getMethod().getName();
- entry(methodName, invocation.getArguments());
- try
- {
- Object result = invocation.proceed();
- if( Void.TYPE.equals(invocation.getMethod().getReturnType()) )
- {
- voidExit(methodName);
- }
- else
- {
- exit(methodName, result);
- }
- return result;
- }
- catch( Throwable t )
- {
- exception(methodName, t);
- throw t;
- }
- }
- else
- {
- return invocation.proceed();
- }
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private void convert( StringBuffer buffer, Object input )
- {
- if( input == null )
- {
- buffer.append("<null>");
- return;
- }
-
- // Primitive types, and non-object arrays
- // use toString(). Less than ideal for int[], etc., but
- // that's a lot of work for a rare case.
- if( !( input instanceof Object[] ) )
- {
- buffer.append(input.toString());
- return;
- }
- buffer.append("(");
- buffer.append(ProxyUtils.getJavaClassName(input.getClass()));
- buffer.append("){");
- Object[] array = ( Object[] ) input;
- int count = array.length;
- for( int i = 0; i < count; i++ )
- {
- if( i > 0 )
- {
- buffer.append(", ");
- }
-
- // We use convert() again, because it could be a multi-dimensional array
- // (god help us) where each element must be converted.
- convert(buffer, array[i]);
- }
- buffer.append("}");
- }
-
- private void entry( String methodName, Object[] args )
- {
- StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
- buffer.append("BEGIN ");
- buffer.append(methodName);
- buffer.append("(");
- int count = args.length;
- for( int i = 0; i < count; i++ )
- {
- Object arg = args[i];
- if( i > 0 )
- {
- buffer.append(", ");
- }
- convert(buffer, arg);
- }
- buffer.append(")");
- log.debug(buffer.toString());
- }
-
- private void exception( String methodName, Throwable t )
- {
- StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
- buffer.append("EXCEPTION ");
- buffer.append(methodName);
- buffer.append("() -- ");
- buffer.append(t.getClass().getName());
- log.debug(buffer.toString(), t);
- }
-
- private void exit( String methodName, Object result )
- {
- StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
- buffer.append("END ");
- buffer.append(methodName);
- buffer.append("() [");
- convert(buffer, result);
- buffer.append("]");
- log.debug(buffer.toString());
- }
-
- private void voidExit( String methodName )
- {
- StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
- buffer.append("END ");
- buffer.append(methodName);
- buffer.append("()");
- log.debug(buffer.toString());
- }
-}
-
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java b/src/test/java/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java
deleted file mode 100644
index 8b3feda..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.commons.proxy.interceptor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.proxy.factory.cglib.CglibProxyFactory;
-import org.apache.commons.proxy.util.Echo;
-import org.apache.commons.proxy.util.EchoImpl;
-import org.jmock.Mock;
-import org.jmock.MockObjectTestCase;
-
-import java.io.IOException;
-
-public class TestLoggingInterceptor extends MockObjectTestCase
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private Mock logMock;
- private Echo echo;
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- protected void setUp() throws Exception
- {
- logMock = mock(Log.class);
- echo = ( Echo ) new CglibProxyFactory()
- .createInterceptorProxy(new EchoImpl(), new LoggingInterceptor(( Log ) logMock.proxy()),
- new Class[] {Echo.class});
- }
-
- public void testException()
- {
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(true));
- logMock.expects(once()).method("debug").with(eq("BEGIN ioException()"));
- logMock.expects(once()).method("debug").with(eq("EXCEPTION ioException() -- java.io.IOException"), isA(IOException.class));
- try
- {
- echo.ioException();
- fail();
- }
- catch( IOException e )
- {
- }
- }
-
- public void testMultipleParameters()
- {
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(true));
- logMock.expects(once()).method("debug").with(eq("BEGIN echoBack(Hello, World)"));
- logMock.expects(once()).method("debug").with(eq("END echoBack() [HelloWorld]"));
- echo.echoBack("Hello", "World");
- }
-
- public void testNonVoidMethod()
- {
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(true));
- logMock.expects(once()).method("debug").with(eq("BEGIN echoBack(Hello)"));
- logMock.expects(once()).method("debug").with(eq("END echoBack() [Hello]"));
- echo.echoBack("Hello");
- }
-
- public void testNullReturnValue()
- {
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(true));
- logMock.expects(once()).method("debug").with(eq("BEGIN echoBack(<null>)"));
- logMock.expects(once()).method("debug").with(eq("END echoBack() [<null>]"));
- echo.echoBack(( String ) null);
- }
-
- public void testRuntimeException()
- {
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(true));
- logMock.expects(once()).method("debug").with(eq("BEGIN illegalArgument()"));
- logMock.expects(once()).method("debug").with(eq("EXCEPTION illegalArgument() -- java.lang.IllegalArgumentException"), isA(IllegalArgumentException.class));
- try
- {
- echo.illegalArgument();
- fail();
- }
- catch( IllegalArgumentException e )
- {
- }
- }
-
- public void testVoidMethod()
- {
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(true));
- logMock.expects(once()).method("debug").with(eq("BEGIN echo()"));
- logMock.expects(once()).method("debug").with(eq("END echo()"));
- echo.echo();
- }
-
- public void testWhenLoggingDisabled()
- {
- logMock = mock(Log.class);
- echo = ( Echo ) new CglibProxyFactory()
- .createInterceptorProxy(new EchoImpl(), new LoggingInterceptor(( Log ) logMock.proxy()),
- new Class[] {Echo.class});
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(false));
- echo.echoBack("Hello");
- }
-
- public void testWithArrayParameter()
- {
- logMock.expects(once()).method("isDebugEnabled").will(returnValue(true));
- logMock.expects(once()).method("debug").with(eq("BEGIN echoBack((java.lang.String[]){Hello, World})"));
- logMock.expects(once()).method("debug").with(eq("END echoBack() [HelloWorld]"));
- echo.echoBack(new String[] {"Hello", "World"});
- }
-}
\ No newline at end of file