01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.test.jpa;
18:
19: import org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter;
20:
21: import org.springframework.instrument.classloading.ResourceOverridingShadowingClassLoader;
22:
23: /**
24: * Subclass of AbstractJpaTests that activates AspectJ load-time weaving
25: * and allows the ability to specify a custom location for AspectJ's
26: * <code>aop.xml</code> file.
27: *
28: * @author Rod Johnson
29: * @author Juergen Hoeller
30: * @since 2.0
31: */
32: public abstract class AbstractAspectjJpaTests extends AbstractJpaTests {
33:
34: /**
35: * Default location of the <code>aop.xml</code> file in the class path:
36: * "META-INF/aop.xml"
37: */
38: public static final String DEFAULT_AOP_XML_LOCATION = "META-INF/aop.xml";
39:
40: @Override
41: protected void customizeResourceOverridingShadowingClassLoader(
42: ClassLoader shadowingClassLoader) {
43: ResourceOverridingShadowingClassLoader orxl = (ResourceOverridingShadowingClassLoader) shadowingClassLoader;
44: orxl.override(DEFAULT_AOP_XML_LOCATION,
45: getActualAopXmlLocation());
46: orxl.addTransformer(new ClassPreProcessorAgentAdapter());
47: }
48:
49: /**
50: * Return the actual location of the <code>aop.xml</code> file
51: * in the class path. The default is "META-INF/aop.xml".
52: * <p>Override this method to point to a specific <code>aop.xml</code>
53: * file within your test suite, allowing for different config files
54: * to co-exist within the same class path.
55: */
56: protected String getActualAopXmlLocation() {
57: return DEFAULT_AOP_XML_LOCATION;
58: }
59:
60: }
|