Browse Source

deprecated JdoTemplate and co in favor of native PersistenceManager usage

pull/7/head
Juergen Hoeller 13 years ago
parent
commit
ba2c8fc592
  1. 4
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/DefaultJdoDialect.java
  2. 6
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoAccessor.java
  3. 6
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoCallback.java
  4. 6
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoInterceptor.java
  5. 6
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoOperations.java
  6. 6
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoTemplate.java
  7. 8
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/support/JdoDaoSupport.java
  8. 52
      org.springframework.orm/src/main/java/org/springframework/orm/jdo/support/SpringPersistenceManagerProxyBean.java

4
org.springframework.orm/src/main/java/org/springframework/orm/jdo/DefaultJdoDialect.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -91,7 +91,7 @@ public class DefaultJdoDialect implements JdoDialect, PersistenceExceptionTransl @@ -91,7 +91,7 @@ public class DefaultJdoDialect implements JdoDialect, PersistenceExceptionTransl
* @see javax.jdo.PersistenceManagerFactory#getConnectionFactory()
* @see PersistenceManagerFactoryUtils#newJdbcExceptionTranslator(Object)
*/
DefaultJdoDialect(Object connectionFactory) {
public DefaultJdoDialect(Object connectionFactory) {
this.jdbcExceptionTranslator = PersistenceManagerFactoryUtils.newJdbcExceptionTranslator(connectionFactory);
}

6
org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoAccessor.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -47,7 +47,11 @@ import org.springframework.dao.DataAccessException; @@ -47,7 +47,11 @@ import org.springframework.dao.DataAccessException;
* @see JdoTemplate
* @see JdoInterceptor
* @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 {
/** Logger available to subclasses */

6
org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoCallback.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -40,7 +40,11 @@ import javax.jdo.PersistenceManager; @@ -40,7 +40,11 @@ import javax.jdo.PersistenceManager;
* @since 03.06.2003
* @see JdoTemplate
* @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> {
/**

6
org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoInterceptor.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -68,7 +68,11 @@ import org.springframework.transaction.support.TransactionSynchronizationManager @@ -68,7 +68,11 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* @see PersistenceManagerFactoryUtils#getPersistenceManager
* @see JdoTransactionManager
* @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 {
private boolean exceptionConversionEnabled = true;

6
org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoOperations.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -48,7 +48,11 @@ import org.springframework.dao.DataAccessException; @@ -48,7 +48,11 @@ import org.springframework.dao.DataAccessException;
* @see JdoDialect
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter
* @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 {
/**

6
org.springframework.orm/src/main/java/org/springframework/orm/jdo/JdoTemplate.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -89,7 +89,11 @@ import org.springframework.util.ClassUtils; @@ -89,7 +89,11 @@ import org.springframework.util.ClassUtils;
* @see org.springframework.transaction.jta.JtaTransactionManager
* @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter
* @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 {
private boolean allowCreate = true;

8
org.springframework.orm/src/main/java/org/springframework/orm/jdo/support/JdoDaoSupport.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -53,7 +53,11 @@ import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; @@ -53,7 +53,11 @@ import org.springframework.orm.jdo.PersistenceManagerFactoryUtils;
* @see #releasePersistenceManager
* @see org.springframework.orm.jdo.JdoTemplate
* @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 {
private JdoTemplate jdoTemplate;
@ -67,7 +71,7 @@ public abstract class JdoDaoSupport extends DaoSupport { @@ -67,7 +71,7 @@ public abstract class JdoDaoSupport extends DaoSupport {
*/
public final void setPersistenceManagerFactory(PersistenceManagerFactory persistenceManagerFactory) {
if (this.jdoTemplate == null || persistenceManagerFactory != this.jdoTemplate.getPersistenceManagerFactory()) {
this.jdoTemplate = createJdoTemplate(persistenceManagerFactory);
this.jdoTemplate = createJdoTemplate(persistenceManagerFactory);
}
}

52
org.springframework.orm/src/main/java/org/springframework/orm/jdo/support/SpringPersistenceManagerProxyBean.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -21,10 +21,13 @@ import java.lang.reflect.InvocationTargetException; @@ -21,10 +21,13 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
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.util.Assert;
@ -56,7 +59,11 @@ 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#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;
@ -65,6 +72,36 @@ public class SpringPersistenceManagerProxyBean extends JdoAccessor implements Fa @@ -65,6 +72,36 @@ public class SpringPersistenceManagerProxyBean extends JdoAccessor implements Fa
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,
* possibly including vendor extensions.
@ -107,9 +144,14 @@ public class SpringPersistenceManagerProxyBean extends JdoAccessor implements Fa @@ -107,9 +144,14 @@ public class SpringPersistenceManagerProxyBean extends JdoAccessor implements Fa
return this.allowCreate;
}
@Override
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(
getPersistenceManagerFactory().getClass().getClassLoader(),
new Class[] {getPersistenceManagerInterface()}, new PersistenceManagerInvocationHandler());

Loading…
Cancel
Save