deprecated JdoTemplate and co in favor of native PersistenceManager usage
This commit is contained in:
parent
feed594ba4
commit
ba2c8fc592
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2010 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -91,7 +91,7 @@ public class DefaultJdoDialect implements JdoDialect, PersistenceExceptionTransl
|
||||||
* @see javax.jdo.PersistenceManagerFactory#getConnectionFactory()
|
* @see javax.jdo.PersistenceManagerFactory#getConnectionFactory()
|
||||||
* @see PersistenceManagerFactoryUtils#newJdbcExceptionTranslator(Object)
|
* @see PersistenceManagerFactoryUtils#newJdbcExceptionTranslator(Object)
|
||||||
*/
|
*/
|
||||||
DefaultJdoDialect(Object connectionFactory) {
|
public DefaultJdoDialect(Object connectionFactory) {
|
||||||
this.jdbcExceptionTranslator = PersistenceManagerFactoryUtils.newJdbcExceptionTranslator(connectionFactory);
|
this.jdbcExceptionTranslator = PersistenceManagerFactoryUtils.newJdbcExceptionTranslator(connectionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -47,7 +47,11 @@ import org.springframework.dao.DataAccessException;
|
||||||
* @see JdoTemplate
|
* @see JdoTemplate
|
||||||
* @see JdoInterceptor
|
* @see JdoInterceptor
|
||||||
* @see #setFlushEager
|
* @see #setFlushEager
|
||||||
|
* @deprecated as of Spring 3.1, in favor of native PersistenceManager usage
|
||||||
|
* (see {@link TransactionAwarePersistenceManagerFactoryProxy} and
|
||||||
|
* {@link org.springframework.orm.jdo.support.SpringPersistenceManagerProxyBean})
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public abstract class JdoAccessor implements InitializingBean {
|
public abstract class JdoAccessor implements InitializingBean {
|
||||||
|
|
||||||
/** Logger available to subclasses */
|
/** Logger available to subclasses */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -40,7 +40,11 @@ import javax.jdo.PersistenceManager;
|
||||||
* @since 03.06.2003
|
* @since 03.06.2003
|
||||||
* @see JdoTemplate
|
* @see JdoTemplate
|
||||||
* @see JdoTransactionManager
|
* @see JdoTransactionManager
|
||||||
|
* @deprecated as of Spring 3.1, in favor of native PersistenceManager usage
|
||||||
|
* (see {@link TransactionAwarePersistenceManagerFactoryProxy} and
|
||||||
|
* {@link org.springframework.orm.jdo.support.SpringPersistenceManagerProxyBean})
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface JdoCallback<T> {
|
public interface JdoCallback<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2006 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -68,7 +68,11 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||||
* @see PersistenceManagerFactoryUtils#getPersistenceManager
|
* @see PersistenceManagerFactoryUtils#getPersistenceManager
|
||||||
* @see JdoTransactionManager
|
* @see JdoTransactionManager
|
||||||
* @see JdoTemplate
|
* @see JdoTemplate
|
||||||
|
* @deprecated as of Spring 3.1, in favor of native PersistenceManager usage
|
||||||
|
* and AOP-driven exception translation through
|
||||||
|
* {@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class JdoInterceptor extends JdoAccessor implements MethodInterceptor {
|
public class JdoInterceptor extends JdoAccessor implements MethodInterceptor {
|
||||||
|
|
||||||
private boolean exceptionConversionEnabled = true;
|
private boolean exceptionConversionEnabled = true;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -48,7 +48,11 @@ import org.springframework.dao.DataAccessException;
|
||||||
* @see JdoDialect
|
* @see JdoDialect
|
||||||
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter
|
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter
|
||||||
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor
|
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor
|
||||||
|
* @deprecated as of Spring 3.1, in favor of native PersistenceManager usage
|
||||||
|
* (see {@link TransactionAwarePersistenceManagerFactoryProxy} and
|
||||||
|
* {@link org.springframework.orm.jdo.support.SpringPersistenceManagerProxyBean})
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface JdoOperations {
|
public interface JdoOperations {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -89,7 +89,11 @@ import org.springframework.util.ClassUtils;
|
||||||
* @see org.springframework.transaction.jta.JtaTransactionManager
|
* @see org.springframework.transaction.jta.JtaTransactionManager
|
||||||
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter
|
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter
|
||||||
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor
|
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor
|
||||||
|
* @deprecated as of Spring 3.1, in favor of native PersistenceManager usage
|
||||||
|
* (see {@link TransactionAwarePersistenceManagerFactoryProxy} and
|
||||||
|
* {@link org.springframework.orm.jdo.support.SpringPersistenceManagerProxyBean})
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class JdoTemplate extends JdoAccessor implements JdoOperations {
|
public class JdoTemplate extends JdoAccessor implements JdoOperations {
|
||||||
|
|
||||||
private boolean allowCreate = true;
|
private boolean allowCreate = true;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -53,7 +53,11 @@ import org.springframework.orm.jdo.PersistenceManagerFactoryUtils;
|
||||||
* @see #releasePersistenceManager
|
* @see #releasePersistenceManager
|
||||||
* @see org.springframework.orm.jdo.JdoTemplate
|
* @see org.springframework.orm.jdo.JdoTemplate
|
||||||
* @see org.springframework.orm.jdo.JdoInterceptor
|
* @see org.springframework.orm.jdo.JdoInterceptor
|
||||||
|
* @deprecated as of Spring 3.1, in favor of native PersistenceManager usage
|
||||||
|
* (see {@link org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy}
|
||||||
|
* and {@link SpringPersistenceManagerProxyBean})
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public abstract class JdoDaoSupport extends DaoSupport {
|
public abstract class JdoDaoSupport extends DaoSupport {
|
||||||
|
|
||||||
private JdoTemplate jdoTemplate;
|
private JdoTemplate jdoTemplate;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,10 +21,13 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import javax.jdo.PersistenceManager;
|
import javax.jdo.PersistenceManager;
|
||||||
|
import javax.jdo.PersistenceManagerFactory;
|
||||||
import javax.jdo.Query;
|
import javax.jdo.Query;
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.orm.jdo.JdoAccessor;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.orm.jdo.DefaultJdoDialect;
|
||||||
|
import org.springframework.orm.jdo.JdoDialect;
|
||||||
import org.springframework.orm.jdo.PersistenceManagerFactoryUtils;
|
import org.springframework.orm.jdo.PersistenceManagerFactoryUtils;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
|
@ -56,7 +59,11 @@ import org.springframework.util.Assert;
|
||||||
* @see org.springframework.orm.jdo.PersistenceManagerFactoryUtils#getPersistenceManager
|
* @see org.springframework.orm.jdo.PersistenceManagerFactoryUtils#getPersistenceManager
|
||||||
* @see org.springframework.orm.jdo.PersistenceManagerFactoryUtils#releasePersistenceManager
|
* @see org.springframework.orm.jdo.PersistenceManagerFactoryUtils#releasePersistenceManager
|
||||||
*/
|
*/
|
||||||
public class SpringPersistenceManagerProxyBean extends JdoAccessor implements FactoryBean<PersistenceManager> {
|
public class SpringPersistenceManagerProxyBean implements FactoryBean<PersistenceManager>, InitializingBean {
|
||||||
|
|
||||||
|
private PersistenceManagerFactory persistenceManagerFactory;
|
||||||
|
|
||||||
|
private JdoDialect jdoDialect;
|
||||||
|
|
||||||
private Class<? extends PersistenceManager> persistenceManagerInterface = PersistenceManager.class;
|
private Class<? extends PersistenceManager> persistenceManagerInterface = PersistenceManager.class;
|
||||||
|
|
||||||
|
|
@ -65,6 +72,36 @@ public class SpringPersistenceManagerProxyBean extends JdoAccessor implements Fa
|
||||||
private PersistenceManager proxy;
|
private PersistenceManager proxy;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the target PersistenceManagerFactory for this proxy.
|
||||||
|
*/
|
||||||
|
public void setPersistenceManagerFactory(PersistenceManagerFactory persistenceManagerFactory) {
|
||||||
|
this.persistenceManagerFactory = persistenceManagerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the target PersistenceManagerFactory for this proxy.
|
||||||
|
*/
|
||||||
|
protected PersistenceManagerFactory getPersistenceManagerFactory() {
|
||||||
|
return this.persistenceManagerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the JDO dialect to use for this proxy.
|
||||||
|
* <p>Default is a DefaultJdoDialect based on the PersistenceManagerFactory's
|
||||||
|
* underlying DataSource, if any.
|
||||||
|
*/
|
||||||
|
public void setJdoDialect(JdoDialect jdoDialect) {
|
||||||
|
this.jdoDialect = jdoDialect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the JDO dialect to use for this proxy.
|
||||||
|
*/
|
||||||
|
protected JdoDialect getJdoDialect() {
|
||||||
|
return this.jdoDialect;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the PersistenceManager interface to expose,
|
* Specify the PersistenceManager interface to expose,
|
||||||
* possibly including vendor extensions.
|
* possibly including vendor extensions.
|
||||||
|
|
@ -107,9 +144,14 @@ public class SpringPersistenceManagerProxyBean extends JdoAccessor implements Fa
|
||||||
return this.allowCreate;
|
return this.allowCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
super.afterPropertiesSet();
|
if (getPersistenceManagerFactory() == null) {
|
||||||
|
throw new IllegalArgumentException("Property 'persistenceManagerFactory' is required");
|
||||||
|
}
|
||||||
|
// Build default JdoDialect if none explicitly specified.
|
||||||
|
if (this.jdoDialect == null) {
|
||||||
|
this.jdoDialect = new DefaultJdoDialect(getPersistenceManagerFactory().getConnectionFactory());
|
||||||
|
}
|
||||||
this.proxy = (PersistenceManager) Proxy.newProxyInstance(
|
this.proxy = (PersistenceManager) Proxy.newProxyInstance(
|
||||||
getPersistenceManagerFactory().getClass().getClassLoader(),
|
getPersistenceManagerFactory().getClass().getClassLoader(),
|
||||||
new Class[] {getPersistenceManagerInterface()}, new PersistenceManagerInvocationHandler());
|
new Class[] {getPersistenceManagerInterface()}, new PersistenceManagerInvocationHandler());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue