Chris Beams
16 years ago
35 changed files with 166 additions and 232 deletions
@ -1,34 +0,0 @@
@@ -1,34 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 the original author or authors. |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.springframework.aop.framework; |
||||
|
||||
import java.lang.reflect.Method; |
||||
|
||||
import org.springframework.aop.MethodBeforeAdvice; |
||||
|
||||
/** |
||||
* Simple before advice example that we can use for counting checks. |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
public class CountingBeforeAdvice extends MethodCounter implements MethodBeforeAdvice { |
||||
|
||||
public void before(Method m, Object[] args, Object target) throws Throwable { |
||||
count(m); |
||||
} |
||||
|
||||
} |
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 the original author or authors. |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.springframework.aop.framework; |
||||
|
||||
import org.aopalliance.intercept.MethodInvocation; |
||||
import org.springframework.aop.interceptor.ExposeInvocationInterceptor; |
||||
import org.springframework.beans.TestBean; |
||||
|
||||
|
||||
/** |
||||
* Used to test ExposeInvocationInterceptor. |
||||
* @author Rod Johnson |
||||
*/ |
||||
public abstract class ExposedInvocationTestBean extends TestBean { |
||||
|
||||
public String getName() { |
||||
MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); |
||||
assertions(invocation); |
||||
return super.getName(); |
||||
} |
||||
|
||||
public void absquatulate() { |
||||
MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); |
||||
assertions(invocation); |
||||
super.absquatulate(); |
||||
} |
||||
|
||||
protected abstract void assertions(MethodInvocation invocation); |
||||
} |
@ -1,31 +0,0 @@
@@ -1,31 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 the original author or authors. |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.springframework.aop.framework; |
||||
|
||||
import junit.framework.TestCase; |
||||
|
||||
import org.aopalliance.intercept.MethodInvocation; |
||||
import org.springframework.beans.ITestBean; |
||||
|
||||
|
||||
public class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean { |
||||
protected void assertions(MethodInvocation invocation) { |
||||
TestCase.assertTrue(invocation.getThis() == this); |
||||
TestCase.assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(), |
||||
ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass())); |
||||
} |
||||
} |
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 the original author or authors. |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.springframework.aop.framework; |
||||
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor; |
||||
|
||||
public class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor |
||||
implements TimeStamped { |
||||
|
||||
private long ts; |
||||
|
||||
public TimestampIntroductionInterceptor() { |
||||
} |
||||
|
||||
public TimestampIntroductionInterceptor(long ts) { |
||||
this.ts = ts; |
||||
} |
||||
|
||||
public void setTime(long ts) { |
||||
this.ts = ts; |
||||
} |
||||
|
||||
public long getTimeStamp() { |
||||
return ts; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue