BATCH-1786: Added type to AbstractJobExplorerFactoryBean so that a cast isn't required on getObject()
This commit is contained in:
@@ -34,8 +34,7 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract class AbstractJobExplorerFactoryBean implements FactoryBean {
|
||||
public abstract class AbstractJobExplorerFactoryBean implements FactoryBean<JobExplorer> {
|
||||
|
||||
/**
|
||||
* @return fully configured {@link JobInstanceDao} implementation.
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.batch.core.explore.support;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.repository.ExecutionContextSerializer;
|
||||
import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao;
|
||||
import org.springframework.batch.core.repository.dao.ExecutionContextDao;
|
||||
@@ -39,6 +38,8 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer
|
||||
import org.springframework.jdbc.support.lob.LobHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* A {@link FactoryBean} that automates the creation of a
|
||||
* {@link SimpleJobExplorer} using JDBC DAO implementations. Requires the user
|
||||
@@ -71,7 +72,7 @@ implements InitializingBean {
|
||||
* A custom implementation of the {@link ExecutionContextSerializer}.
|
||||
* The default, if not injected, is the {@link XStreamExecutionContextStringSerializer}.
|
||||
*
|
||||
* @param serializer
|
||||
* @param serializer used to serialize/deserialize an {@link org.springframework.batch.item.ExecutionContext}
|
||||
* @see ExecutionContextSerializer
|
||||
*/
|
||||
public void setSerializer(ExecutionContextSerializer serializer) {
|
||||
@@ -91,7 +92,7 @@ implements InitializingBean {
|
||||
/**
|
||||
* Sets the table prefix for all the batch meta-data tables.
|
||||
*
|
||||
* @param tablePrefix
|
||||
* @param tablePrefix prefix for the batch meta-data tables
|
||||
*/
|
||||
public void setTablePrefix(String tablePrefix) {
|
||||
this.tablePrefix = tablePrefix;
|
||||
@@ -101,7 +102,7 @@ implements InitializingBean {
|
||||
* The lob handler to use when saving {@link ExecutionContext} instances.
|
||||
* Defaults to null which works for most databases.
|
||||
*
|
||||
* @param lobHandler
|
||||
* @param lobHandler Large object handler for saving {@link org.springframework.batch.item.ExecutionContext}
|
||||
*/
|
||||
public void setLobHandler(LobHandler lobHandler) {
|
||||
this.lobHandler = lobHandler;
|
||||
@@ -122,7 +123,7 @@ implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
private Object getTarget() throws Exception {
|
||||
private JobExplorer getTarget() throws Exception {
|
||||
return new SimpleJobExplorer(createJobInstanceDao(),
|
||||
createJobExecutionDao(), createStepExecutionDao(),
|
||||
createExecutionContextDao());
|
||||
@@ -170,7 +171,7 @@ implements InitializingBean {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() throws Exception {
|
||||
public JobExplorer getObject() throws Exception {
|
||||
return getTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.batch.core.explore.support;
|
||||
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.repository.dao.ExecutionContextDao;
|
||||
import org.springframework.batch.core.repository.dao.JobExecutionDao;
|
||||
import org.springframework.batch.core.repository.dao.JobInstanceDao;
|
||||
@@ -39,7 +40,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im
|
||||
/**
|
||||
* Create an instance with the provided {@link MapJobRepositoryFactoryBean}
|
||||
* as a source of Dao instances.
|
||||
* @param repositoryFactory
|
||||
* @param repositoryFactory provides the used {@link org.springframework.batch.core.repository.JobRepository}
|
||||
*/
|
||||
public MapJobExplorerFactoryBean(MapJobRepositoryFactoryBean repositoryFactory) {
|
||||
this.repositoryFactory = repositoryFactory;
|
||||
@@ -92,7 +93,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() throws Exception {
|
||||
public JobExplorer getObject() throws Exception {
|
||||
return new SimpleJobExplorer(createJobInstanceDao(), createJobExecutionDao(), createStepExecutionDao(),
|
||||
createExecutionContextDao());
|
||||
}
|
||||
|
||||
@@ -15,17 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.core.explore.support;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.explore.support.JobExplorerFactoryBean;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -70,7 +69,7 @@ public class JobExplorerFactoryBeanTests {
|
||||
public void testCreateExplorer() throws Exception {
|
||||
|
||||
factory.afterPropertiesSet();
|
||||
JobExplorer explorer = (JobExplorer) factory.getObject();
|
||||
JobExplorer explorer = factory.getObject();
|
||||
assertNotNull(explorer);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user