/* * Copyright 2002-2006 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.orm.jpa.vendor; import org.springframework.instrument.classloading.SimpleInstrumentableClassLoader; import org.springframework.instrument.classloading.SimpleLoadTimeWeaver; /** * OpenJPA-specific SimpleLoadTimeWeaver which excludes all the core * org.apache.openjpa packages from being instrumented. This * is important, since enhanced classes will wind up implementing * org.apache.openjpa.enhance.PersistenceCapable, so it there * is a mismatch between the PersistenceCapable that is loaded by the * system classloader and the one that is loaded by the * instrumenting ClassLoader, then OpenJPA will not function properly. * *
* * This loader can be specific by including the following in the * spring configuration XML as follows: * *
*
*
* <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&rt;
* ...
* <property name="loadTimeWeaver"&rt;
* <bean class="org.springframework.orm.jpa.vendor.OpenJpaLoadTimeWeaver"/&rt;
* </property&rt;
* </bean&rt;
*
*
* @author Marc Prud'hommeaux
* @since 2.0
*/
public class OpenJpaLoadTimeWeaver extends SimpleLoadTimeWeaver {
public OpenJpaLoadTimeWeaver() {
super();
((SimpleInstrumentableClassLoader) getInstrumentableClassLoader()).
excludePackage("org.apache.openjpa");
}
public OpenJpaLoadTimeWeaver(SimpleInstrumentableClassLoader loader) {
super(loader);
((SimpleInstrumentableClassLoader) getInstrumentableClassLoader()).
excludePackage("org.apache.openjpa");
}
}