patterntesting.check.runtime.DeprecatedAspect.aj Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of patterntesting-check-rt Show documentation
Show all versions of patterntesting-check-rt Show documentation
PatternTesting Check.RT (patterntesting-check-rt) provides different runtime
checks of known anti patterns (like using null values as arguments or
return values) but provides also a test framework for better testing.
/*
* $Id: DeprecatedAspect.aj,v 1.1 2011/12/22 17:15:11 oboehm Exp $
*
* Copyright (c) 2008 by Oliver Boehm
*
* 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 orimplied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* (c)reated 17.02.2009 by oliver ([email protected])
*/
package patterntesting.check.runtime;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.LogFactoryImpl;
/**
* Do you have developers who are resistent against deprecated methods?
* Now you can see it in the log as warning which "@Deprecated" methods
* were executed.
*
* And if assertions are enabled ('java -ea ...') a DeprecatedCodeException
* will be thrown to force the use of *not* deprecated methods.
*
* @author oliver
* @since 17.02.2009
* @version $Revision: 1.1 $
*/
public aspect DeprecatedAspect extends AbstractDeprecatedAspect {
private static final Log log = LogFactoryImpl.getLog(DeprecatedAspect.class);
/**
* To return the aspect specific logger to the super aspect.
* @return the aspect specific logger
*/
public final Log getLog() {
return log;
}
/**
* These are the methods which are marked as "@Deprecated"
* (unfortunately the methods marked as "deprecated" in a Javadoc
* comment cannot be recognized).
*/
pointcut deprecatedMethods() :
execution((@Deprecated *..*).new(..))
|| execution(* @Deprecated *..*.*(..))
|| @withincode(Deprecated)
;
/**
* "@Deprecated" attributes should eiter be set nor read.a
*/
pointcut deprecatedAttributes() :
(set(@Deprecated * *..*.*)
&& withincode(* *..*.*(..)))
|| get(@Deprecated * *..*.*)
;
/**
* Deprecated code.
*/
public pointcut deprecatedCode() :
deprecatedMethods()
|| deprecatedAttributes()
;
}
/**
* $Log: DeprecatedAspect.aj,v $
* Revision 1.1 2011/12/22 17:15:11 oboehm
* directory structure adapted to preferences of maven-aspectj-plugin
*
* Revision 1.2 2010/01/11 09:40:33 oboehm
* bug 2926501 fixed
*
* Revision 1.1 2010/01/05 16:54:19 oboehm
* begin with 1.0
*
* Revision 1.3 2009/12/20 17:30:03 oboehm
* trailing spaces removed
*
* Revision 1.2 2009/09/26 10:04:15 oboehm
* javadocs completed with the help of JAutodoc
*
* Revision 1.1 2009/03/24 20:31:41 oboehm
* extracted from patterntesting-check
*
* $Source: /cvsroot/patterntesting/PatternTesting10/patterntesting-check-rt/src/main/aspect/patterntesting/check/runtime/DeprecatedAspect.aj,v $
*/