KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > test > jpa > AbstractAspectjJpaTests


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc DEFAULT_AOP_XML_LOCATION = "META-INF/aop.xml";
39
40
41     @Override JavaDoc
42     protected void customizeResourceOverridingShadowingClassLoader(ClassLoader JavaDoc shadowingClassLoader) {
43         ResourceOverridingShadowingClassLoader orxl = (ResourceOverridingShadowingClassLoader) shadowingClassLoader;
44         orxl.override(DEFAULT_AOP_XML_LOCATION, getActualAopXmlLocation());
45         orxl.addTransformer(new ClassPreProcessorAgentAdapter());
46     }
47
48     /**
49      * Return the actual location of the <code>aop.xml</code> file
50      * in the class path. The default is "META-INF/aop.xml".
51      * <p>Override this method to point to a specific <code>aop.xml</code>
52      * file within your test suite, allowing for different config files
53      * to co-exist within the same class path.
54      */

55     protected String JavaDoc getActualAopXmlLocation() {
56         return DEFAULT_AOP_XML_LOCATION;
57     }
58
59 }
60
Popular Tags